PagePropEdit.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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-button
  22. v-for="(item, index) in columnOptions"
  23. :key="index"
  24. class="column-btn"
  25. :title="item.title"
  26. :disabled="item.disabled"
  27. @click="modifyColumnNum(item)"
  28. >
  29. <i
  30. :class="[
  31. 'icon',
  32. form.columnNumber == item.value
  33. ? `icon-column-${item.label}-act`
  34. : `icon-column-${item.label}`,
  35. ]"
  36. ></i>
  37. </el-button>
  38. </el-form-item>
  39. <el-form-item label="大题顺序">
  40. <ul class="topicno-list" v-if="topicNoSeries.length">
  41. <li v-for="item in topicNoSeries" :key="item.id">
  42. {{ item.topicNo }}
  43. </li>
  44. </ul>
  45. <el-button type="text" class="btn-primary" @click="toViewStruct"
  46. >查看题卡结构<i class="el-icon-arrow-right"></i
  47. ></el-button>
  48. </el-form-item>
  49. </el-form>
  50. <!-- PageStructDialog -->
  51. <page-struct-dialog ref="PageStructDialog"></page-struct-dialog>
  52. </div>
  53. </template>
  54. <script>
  55. import { mapState, mapMutations, mapActions } from "vuex";
  56. import { objAssign } from "../plugins/utils";
  57. import PageStructDialog from "./PageStructDialog.vue";
  58. const COLUMN_OPTIONS = [
  59. {
  60. value: 1,
  61. title: "一栏",
  62. label: "one",
  63. sizeValid: ["A4"],
  64. disabled: false,
  65. },
  66. {
  67. value: 2,
  68. title: "二栏",
  69. label: "two",
  70. sizeValid: ["A3", "A4"],
  71. disabled: false,
  72. },
  73. {
  74. value: 3,
  75. title: "三栏",
  76. label: "three",
  77. sizeValid: ["A3"],
  78. disabled: false,
  79. },
  80. {
  81. value: 4,
  82. title: "四栏",
  83. label: "four",
  84. sizeValid: ["A3"],
  85. disabled: false,
  86. },
  87. ];
  88. export default {
  89. name: "page-prop-edit",
  90. components: { PageStructDialog },
  91. data() {
  92. return {
  93. columnOptions: [],
  94. pageSizeOptions: ["A3"],
  95. // pageSizeOptions: ["A3", "A4"],
  96. form: {
  97. pageSize: "A3",
  98. columnNumber: 2,
  99. columnGap: 4,
  100. aOrB: false,
  101. showForbidArea: false,
  102. },
  103. prePageSize: "A3",
  104. };
  105. },
  106. computed: {
  107. ...mapState("card", ["cardConfig", "topicNoSeries"]),
  108. },
  109. watch: {
  110. cardConfig: {
  111. immediate: true,
  112. handler(val) {
  113. this.form = objAssign(this.form, val);
  114. this.prePageSize = this.form.pageSize;
  115. this.columnOptions = COLUMN_OPTIONS.filter((item) =>
  116. item.sizeValid.includes(this.form.pageSize)
  117. );
  118. if (this.form.pageSize === "A3") {
  119. this.columnOptions[2].disabled = val.examNumberStyle === "fill";
  120. }
  121. },
  122. },
  123. },
  124. methods: {
  125. ...mapMutations("card", [
  126. "setPages",
  127. "setTopics",
  128. "setCurElement",
  129. "setCardConfig",
  130. "setTopicSeries",
  131. ]),
  132. ...mapActions("card", ["rebuildPages", "resetElementProp"]),
  133. modifyColumnNum(item) {
  134. this.$confirm(
  135. "此操作会导致当前题卡编辑的所有元素清空, 是否继续?",
  136. "提示",
  137. {
  138. type: "warning",
  139. }
  140. )
  141. .then(() => {
  142. this.columnNumChange(item.value);
  143. })
  144. .catch(() => {});
  145. },
  146. columnNumChange(val) {
  147. this.form.columnNumber = val;
  148. this.setCardConfig(this.form);
  149. this.setPages([]);
  150. this.setTopics([]);
  151. this.setTopicSeries([]);
  152. this.$emit("init-page");
  153. },
  154. cardConfigChange() {
  155. this.setCardConfig(this.form);
  156. },
  157. configChange() {
  158. this.setCardConfig(this.form);
  159. this.$nextTick(() => {
  160. this.rebuildPages();
  161. this.setCurElement({});
  162. this.$nextTick(() => {
  163. this.resetElementProp(true);
  164. });
  165. });
  166. },
  167. modifyPageSize() {
  168. this.$confirm("此操作将会重置当前页面所有元素信息, 是否继续?", "提示", {
  169. type: "warning",
  170. })
  171. .then(() => {
  172. this.columnOptions = COLUMN_OPTIONS.filter((item) =>
  173. item.sizeValid.includes(this.form.pageSize)
  174. );
  175. this.form.columnNumber = this.columnOptions[0].value;
  176. this.configChange();
  177. })
  178. .catch(() => {
  179. this.form.pageSize = this.prePageSize;
  180. });
  181. },
  182. toViewStruct() {
  183. this.$refs.PageStructDialog.open();
  184. },
  185. },
  186. };
  187. </script>