PagePropEdit.vue 5.2 KB

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