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. const COLUMN_OPTIONS = [
  35. {
  36. value: 1,
  37. title: "一栏",
  38. label: "one",
  39. sizeValid: ["A3", "A4"]
  40. },
  41. {
  42. value: 2,
  43. title: "二栏",
  44. label: "two",
  45. sizeValid: ["A3", "A4"]
  46. },
  47. {
  48. value: 3,
  49. title: "三栏",
  50. label: "three",
  51. sizeValid: ["A3"]
  52. },
  53. {
  54. value: 4,
  55. title: "四栏",
  56. label: "four",
  57. sizeValid: ["A3"]
  58. }
  59. ];
  60. export default {
  61. name: "page-prop-edit",
  62. data() {
  63. return {
  64. columnOptions: [],
  65. pageSizeOptions: ["A3"],
  66. // pageSizeOptions: ["A3", "A4"],
  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>