PagePropEdit.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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-width="0px">
  40. <el-checkbox v-model="form.aOrB" disabled>启用A/B卷</el-checkbox>
  41. </el-form-item> -->
  42. <el-form-item label="禁答区域">
  43. <el-checkbox
  44. v-model="form.showForbidArea"
  45. @change="showForbidAreaChange"
  46. >启用</el-checkbox
  47. >
  48. </el-form-item>
  49. <el-form-item label="大题数">
  50. <ul class="topicno-list" v-if="topicSeries.length">
  51. <li>{{ topicSeries.length }}</li>
  52. </ul>
  53. </el-form-item>
  54. </el-form>
  55. </div>
  56. </template>
  57. <script>
  58. import { mapState, mapMutations, mapActions } from "vuex";
  59. import { objAssign } from "../plugins/utils";
  60. const COLUMN_OPTIONS = [
  61. {
  62. value: 1,
  63. title: "一栏",
  64. label: "one",
  65. sizeValid: ["A4"],
  66. disabled: false
  67. },
  68. {
  69. value: 2,
  70. title: "二栏",
  71. label: "two",
  72. sizeValid: ["A3", "A4"],
  73. disabled: false
  74. },
  75. {
  76. value: 3,
  77. title: "三栏",
  78. label: "three",
  79. sizeValid: ["A3"],
  80. disabled: false
  81. },
  82. {
  83. value: 4,
  84. title: "四栏",
  85. label: "four",
  86. sizeValid: ["A3"],
  87. disabled: false
  88. }
  89. ];
  90. export default {
  91. name: "page-prop-edit",
  92. data() {
  93. return {
  94. columnOptions: [],
  95. pageSizeOptions: ["A3"],
  96. // pageSizeOptions: ["A3", "A4"],
  97. form: {
  98. pageSize: "A3",
  99. columnNumber: 2,
  100. columnGap: 4,
  101. aOrB: false,
  102. showForbidArea: false
  103. },
  104. prePageSize: "A3"
  105. };
  106. },
  107. computed: {
  108. ...mapState("card", ["curPageNo", "pages", "cardConfig", "topicSeries"]),
  109. curPage() {
  110. return this.pages[this.curPageNo];
  111. }
  112. // aOrBDisabled() {
  113. // return this.cardConfig.hasOwnProperty("aOrBSystem");
  114. // }
  115. },
  116. watch: {
  117. cardConfig: {
  118. immediate: true,
  119. handler(val) {
  120. this.form = objAssign(this.form, val);
  121. this.prePageSize = this.form.pageSize;
  122. this.columnOptions = COLUMN_OPTIONS.filter(item =>
  123. item.sizeValid.includes(this.form.pageSize)
  124. );
  125. if (this.form.pageSize === "A3") {
  126. this.columnOptions[2].disabled = val.examNumberStyle === "fill";
  127. }
  128. }
  129. }
  130. },
  131. methods: {
  132. ...mapMutations("card", [
  133. "setPages",
  134. "setTopics",
  135. "setCurElement",
  136. "setCardConfig"
  137. ]),
  138. ...mapActions("card", ["rebuildPages", "resetElementProp"]),
  139. modifyColumnNum(item) {
  140. this.$confirm(
  141. "此操作会导致当前题卡编辑的所有元素清空, 是否继续?",
  142. "提示",
  143. {
  144. type: "warning"
  145. }
  146. )
  147. .then(() => {
  148. this.columnNumChange(item.value);
  149. })
  150. .catch(() => {});
  151. },
  152. columnNumChange(val) {
  153. this.form.columnNumber = val;
  154. this.setCardConfig(this.form);
  155. this.setPages([]);
  156. this.setTopics([]);
  157. this.$emit("init-page");
  158. },
  159. showForbidAreaChange() {
  160. this.setCardConfig(this.form);
  161. },
  162. configChange() {
  163. this.setCardConfig(this.form);
  164. this.$nextTick(() => {
  165. this.rebuildPages();
  166. this.setCurElement({});
  167. this.$nextTick(() => {
  168. this.resetElementProp(true);
  169. });
  170. });
  171. },
  172. modifyPageSize() {
  173. this.$confirm("此操作将会重置当前页面所有元素信息, 是否继续?", "提示", {
  174. type: "warning"
  175. })
  176. .then(() => {
  177. this.columnOptions = COLUMN_OPTIONS.filter(item =>
  178. item.sizeValid.includes(this.form.pageSize)
  179. );
  180. this.form.columnNumber = this.columnOptions[0].value;
  181. this.configChange();
  182. })
  183. .catch(() => {
  184. this.form.pageSize = this.prePageSize;
  185. });
  186. }
  187. }
  188. };
  189. </script>