PagePropEdit.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="page-prop-edit">
  3. <el-form ref="form" :model="form" label-width="70px">
  4. <el-form-item label="纸张规格">
  5. <el-select
  6. v-model="form.pageSize"
  7. placeholder="请选择"
  8. :disabled="pageSizeOptions.length < 2"
  9. @change="modifyPageSize"
  10. >
  11. <el-option
  12. v-for="item in pageSizeOptions"
  13. :key="item"
  14. :label="item"
  15. :value="item"
  16. >
  17. </el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="禁答区域">
  21. <el-checkbox
  22. v-model="form.showForbidArea"
  23. @change="showForbidAreaChange"
  24. >启用</el-checkbox
  25. >
  26. </el-form-item>
  27. </el-form>
  28. </div>
  29. </template>
  30. <script>
  31. import { mapState, mapMutations, mapActions } from "vuex";
  32. import { objAssign } from "../../../plugins/utils";
  33. import { getModel as getPageModel } from "../../../elements/page/model";
  34. import { CARD_SIZE_TYPE } from "@/constants/enumerate";
  35. const COLUMN_OPTIONS = [
  36. {
  37. value: 1,
  38. title: "一栏",
  39. label: "one",
  40. sizeValid: ["A3", "A4", "8K"],
  41. },
  42. {
  43. value: 2,
  44. title: "二栏",
  45. label: "two",
  46. sizeValid: ["A3", "A4", "8K"],
  47. },
  48. {
  49. value: 3,
  50. title: "三栏",
  51. label: "three",
  52. sizeValid: ["A3", "8K"],
  53. },
  54. {
  55. value: 4,
  56. title: "四栏",
  57. label: "four",
  58. sizeValid: ["A3", "8K"],
  59. },
  60. ];
  61. export default {
  62. name: "page-prop-edit",
  63. data() {
  64. return {
  65. columnOptions: [],
  66. pageSizeOptions: CARD_SIZE_TYPE,
  67. form: {
  68. pageSize: "A3",
  69. columnNumber: 2,
  70. showForbidArea: false,
  71. },
  72. prePageSize: "A3",
  73. };
  74. },
  75. computed: {
  76. ...mapState("free", ["curPageNo", "pages", "cardConfig"]),
  77. curPage() {
  78. return this.pages[this.curPageNo];
  79. },
  80. },
  81. watch: {
  82. cardConfig: {
  83. immediate: true,
  84. handler(val) {
  85. this.form = objAssign(this.form, val);
  86. this.prePageSize = this.form.pageSize;
  87. this.columnOptions = COLUMN_OPTIONS.filter((item) =>
  88. item.sizeValid.includes(this.form.pageSize)
  89. );
  90. },
  91. },
  92. },
  93. methods: {
  94. ...mapMutations("free", [
  95. "setPages",
  96. "setCurElement",
  97. "setCardConfig",
  98. "setCurPageNo",
  99. ]),
  100. ...mapActions("free", ["modifyAllPageShowForbidArea"]),
  101. showForbidAreaChange() {
  102. this.setCardConfig(this.form);
  103. this.modifyAllPageShowForbidArea(this.form.showForbidArea);
  104. },
  105. configChange() {
  106. this.setCardConfig(this.form);
  107. const page = getPageModel(this.form);
  108. this.setPages([page]);
  109. this.setCurPageNo(0);
  110. this.setCurElement({});
  111. },
  112. modifyPageSize() {
  113. this.$confirm("此操作将会重置所有页面, 是否继续?", "提示", {
  114. type: "warning",
  115. })
  116. .then(() => {
  117. this.columnOptions = COLUMN_OPTIONS.filter((item) =>
  118. item.sizeValid.includes(this.form.pageSize)
  119. );
  120. this.form.columnNumber = this.columnOptions[0].value;
  121. this.configChange();
  122. })
  123. .catch(() => {
  124. this.form.pageSize = this.prePageSize;
  125. });
  126. },
  127. },
  128. };
  129. </script>