PagePropEdit.vue 4.8 KB

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