PagePropEdit.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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
  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. <el-checkbox v-model="form.aOrB" @change="configChange"
  41. >启用AB卷</el-checkbox
  42. >
  43. </el-form-item>
  44. <el-form-item label="大题顺序">
  45. <ul class="topicno-list" v-if="topicNoSeries.length">
  46. <li v-for="item in topicNoSeries" :key="item.id">
  47. {{ item.topicNo }}
  48. </li>
  49. </ul>
  50. <el-button type="text" class="btn-primary" @click="toViewStruct"
  51. >查看题卡结构<i class="el-icon-arrow-right"></i
  52. ></el-button>
  53. </el-form-item>
  54. </el-form>
  55. <!-- PageStructDialog -->
  56. <page-struct-dialog ref="PageStructDialog"></page-struct-dialog>
  57. </div>
  58. </template>
  59. <script>
  60. import { mapState, mapMutations, mapActions } from "vuex";
  61. import { objAssign } from "../plugins/utils";
  62. import PageStructDialog from "./PageStructDialog.vue";
  63. import { CARD_SIZE_TYPE } from "@/constants/enumerate";
  64. const COLUMN_OPTIONS = [
  65. {
  66. value: 1,
  67. title: "一栏",
  68. label: "one",
  69. sizeValid: ["A4"],
  70. disabled: false,
  71. },
  72. {
  73. value: 2,
  74. title: "二栏",
  75. label: "two",
  76. sizeValid: ["A3", "A4", "8K"],
  77. disabled: false,
  78. },
  79. {
  80. value: 3,
  81. title: "三栏",
  82. label: "three",
  83. sizeValid: ["A3", "8K"],
  84. disabled: false,
  85. },
  86. {
  87. value: 4,
  88. title: "四栏",
  89. label: "four",
  90. sizeValid: ["A3", "8K"],
  91. disabled: false,
  92. },
  93. ];
  94. export default {
  95. name: "page-prop-edit",
  96. components: { PageStructDialog },
  97. data() {
  98. return {
  99. columnOptions: [],
  100. pageSizeOptions: CARD_SIZE_TYPE,
  101. form: {
  102. pageSize: "A3",
  103. columnNumber: 2,
  104. columnGap: 4,
  105. aOrB: false,
  106. showForbidArea: false,
  107. },
  108. prePageSize: "A3",
  109. };
  110. },
  111. computed: {
  112. ...mapState("card", ["cardConfig", "topicNoSeries"]),
  113. },
  114. watch: {
  115. cardConfig: {
  116. immediate: true,
  117. handler(val) {
  118. this.form = objAssign(this.form, val);
  119. this.prePageSize = this.form.pageSize;
  120. this.columnOptions = COLUMN_OPTIONS.filter((item) =>
  121. item.sizeValid.includes(this.form.pageSize)
  122. );
  123. if (this.form.pageSize === "A3" || this.form.pageSize === "8K") {
  124. this.columnOptions[2].disabled = val.examNumberStyle === "fill";
  125. }
  126. },
  127. },
  128. },
  129. methods: {
  130. ...mapMutations("card", [
  131. "setPages",
  132. "setTopics",
  133. "setCurElement",
  134. "setCardConfig",
  135. "setTopicSeries",
  136. "setTopicNoSeries",
  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.setTopicSeries([]);
  158. this.setTopicNoSeries([]);
  159. this.$emit("init-page");
  160. },
  161. cardConfigChange() {
  162. this.setCardConfig(this.form);
  163. },
  164. configChange() {
  165. this.setCardConfig(this.form);
  166. this.$nextTick(() => {
  167. this.rebuildPages();
  168. this.setCurElement({});
  169. this.$nextTick(() => {
  170. this.resetElementProp(true);
  171. });
  172. });
  173. },
  174. modifyPageSize() {
  175. this.$confirm("此操作将会重置当前页面所有元素信息, 是否继续?", "提示", {
  176. type: "warning",
  177. })
  178. .then(() => {
  179. this.columnOptions = COLUMN_OPTIONS.filter((item) =>
  180. item.sizeValid.includes(this.form.pageSize)
  181. );
  182. this.form.columnNumber = this.columnOptions[0].value;
  183. this.configChange();
  184. })
  185. .catch(() => {
  186. this.form.pageSize = this.prePageSize;
  187. });
  188. },
  189. toViewStruct() {
  190. this.$refs.PageStructDialog.open();
  191. },
  192. },
  193. };
  194. </script>