PagePropEdit.vue 4.5 KB

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