PagePropEdit.vue 4.7 KB

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