PagePropEdit.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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", ["curPageNo", "pages", "cardConfig", "topicNoSeries"]),
  118. curPage() {
  119. return this.pages[this.curPageNo];
  120. }
  121. // aOrBDisabled() {
  122. // return this.cardConfig.hasOwnProperty("aOrBSystem");
  123. // }
  124. },
  125. watch: {
  126. cardConfig: {
  127. immediate: true,
  128. handler(val) {
  129. this.form = objAssign(this.form, val);
  130. this.prePageSize = this.form.pageSize;
  131. this.columnOptions = COLUMN_OPTIONS.filter(item =>
  132. item.sizeValid.includes(this.form.pageSize)
  133. );
  134. if (this.form.pageSize === "A3") {
  135. this.columnOptions[2].disabled = val.examNumberStyle === "fill";
  136. }
  137. }
  138. }
  139. },
  140. methods: {
  141. ...mapMutations("card", [
  142. "setPages",
  143. "setTopics",
  144. "setCurElement",
  145. "setCardConfig",
  146. "setTopicSeries"
  147. ]),
  148. ...mapActions("card", ["rebuildPages", "resetElementProp"]),
  149. modifyColumnNum(item) {
  150. this.$confirm(
  151. "此操作会导致当前题卡编辑的所有元素清空, 是否继续?",
  152. "提示",
  153. {
  154. type: "warning"
  155. }
  156. )
  157. .then(() => {
  158. this.columnNumChange(item.value);
  159. })
  160. .catch(() => {});
  161. },
  162. columnNumChange(val) {
  163. this.form.columnNumber = val;
  164. this.setCardConfig(this.form);
  165. this.setPages([]);
  166. this.setTopics([]);
  167. this.setTopicSeries([]);
  168. this.$emit("init-page");
  169. },
  170. showForbidAreaChange() {
  171. this.setCardConfig(this.form);
  172. },
  173. configChange() {
  174. this.setCardConfig(this.form);
  175. this.$nextTick(() => {
  176. this.rebuildPages();
  177. this.setCurElement({});
  178. this.$nextTick(() => {
  179. this.resetElementProp(true);
  180. });
  181. });
  182. },
  183. modifyPageSize() {
  184. this.$confirm("此操作将会重置当前页面所有元素信息, 是否继续?", "提示", {
  185. type: "warning"
  186. })
  187. .then(() => {
  188. this.columnOptions = COLUMN_OPTIONS.filter(item =>
  189. item.sizeValid.includes(this.form.pageSize)
  190. );
  191. this.form.columnNumber = this.columnOptions[0].value;
  192. this.configChange();
  193. })
  194. .catch(() => {
  195. this.form.pageSize = this.prePageSize;
  196. });
  197. },
  198. toViewStruct() {
  199. this.$refs.PageStructDialog.open();
  200. }
  201. }
  202. };
  203. </script>