CardConfigPropEdit.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div class="card-config-prop-edit">
  3. <el-button @click="open" type="primary"> 配置题卡规则 </el-button>
  4. <el-drawer
  5. :visible.sync="drawer"
  6. :with-header="false"
  7. append-to-body
  8. :close-on-press-escape="false"
  9. :size="820"
  10. class="card-config-drawer"
  11. >
  12. <div class="card-config-edit">
  13. <div class="card-config-header">
  14. <h2>配置题卡规则</h2>
  15. </div>
  16. <div class="card-config-body">
  17. <el-form
  18. ref="modalFormComp"
  19. label-width="130px"
  20. :rules="rules"
  21. :model="modalForm"
  22. >
  23. <el-form-item
  24. prop="examNumberStyle"
  25. label="考号版式:"
  26. class="inline-block"
  27. >
  28. <el-select
  29. v-model="modalForm.examNumberStyle"
  30. style="width: 142px"
  31. placeholder="请选择"
  32. @change="numStyleChange"
  33. >
  34. <el-option
  35. v-for="(val, key) in EXAM_NUMBER_STYLE"
  36. :key="key"
  37. :value="key"
  38. :label="val"
  39. ></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item
  43. prop="fillNumber"
  44. label="考号位数:"
  45. class="inline-block"
  46. >
  47. <el-input-number
  48. v-if="modalForm.examNumberStyle === 'FILL'"
  49. v-model="modalForm.fillNumber"
  50. :min="5"
  51. :max="15"
  52. :step="1"
  53. step-strictly
  54. :controls="false"
  55. style="width: 100px"
  56. ></el-input-number>
  57. <span v-else>
  58. {{ modalForm.fillNumber }}
  59. </span>
  60. </el-form-item>
  61. <el-form-item>
  62. <el-checkbox v-model="modalForm.examAbsent"
  63. >启用“缺考填涂”</el-checkbox
  64. >
  65. <el-checkbox v-model="modalForm.discipline"
  66. >启用“违纪填涂”</el-checkbox
  67. >
  68. <el-checkbox
  69. v-model="modalForm.writeSign"
  70. :disabled="modalForm.examNumberStyle === 'FILL'"
  71. >启用“手写签名”</el-checkbox
  72. >
  73. </el-form-item>
  74. <div class="part-box part-box-pad part-box-border">
  75. <h4 class="part-box-tips">题卡版头变量印刷字段配置:</h4>
  76. <el-form-item label="必选字段:" label-width="115px" required>
  77. <el-checkbox
  78. v-for="column in modalForm.requiredFields"
  79. :key="column.code"
  80. v-model="column.enable"
  81. disabled
  82. >{{ column.name }}</el-checkbox
  83. >
  84. </el-form-item>
  85. <el-form-item label="扩展字段:" label-width="115px">
  86. <el-checkbox
  87. v-for="column in modalForm.extendFields"
  88. :key="column.code"
  89. v-model="column.enable"
  90. >{{ column.name }}</el-checkbox
  91. >
  92. </el-form-item>
  93. </div>
  94. <el-form-item prop="attention" label="注意事项:">
  95. <el-input
  96. type="textarea"
  97. :rows="4"
  98. v-model="modalForm.attention"
  99. ></el-input>
  100. <p class="tips-info">
  101. 提示:换行之后,题卡注意事项会展示为多条内容,内容序号会被自动添加。
  102. </p>
  103. </el-form-item>
  104. <el-form-item prop="objectiveAttention" label="客观题注意事项:">
  105. <el-input v-model="modalForm.objectiveAttention"></el-input>
  106. </el-form-item>
  107. <el-form-item prop="subjectiveAttention" label="主观题注意事项:">
  108. <el-input v-model="modalForm.subjectiveAttention"></el-input>
  109. </el-form-item>
  110. </el-form>
  111. </div>
  112. <div class="card-config-footer">
  113. <el-button @click="cancel">取消</el-button>
  114. <el-button type="primary" @click="submit">确认</el-button>
  115. </div>
  116. </div>
  117. </el-drawer>
  118. </div>
  119. </template>
  120. <script>
  121. import { mapState, mapMutations, mapActions } from "vuex";
  122. import { objAssign } from "../plugins/utils";
  123. import { EXAM_NUMBER_STYLE, PAPER_TYPE } from "@/constants/enumerate";
  124. const initModalForm = {
  125. examNumberStyle: "",
  126. fillNumber: 10,
  127. paperType: "PRINT",
  128. examAbsent: true,
  129. discipline: true,
  130. writeSign: true,
  131. requiredFields: [],
  132. extendFields: [],
  133. attention: "",
  134. objectiveAttention: "",
  135. subjectiveAttention: "",
  136. };
  137. export default {
  138. name: "card-config-prop-edit",
  139. data() {
  140. return {
  141. modalForm: { ...initModalForm },
  142. EXAM_NUMBER_STYLE,
  143. PAPER_TYPE,
  144. drawer: false,
  145. rules: {
  146. examNumberStyle: [
  147. {
  148. required: true,
  149. message: "请选择考号版式",
  150. trigger: "change",
  151. },
  152. ],
  153. fillNumber: [
  154. {
  155. required: true,
  156. message: "请输入考号位数",
  157. trigger: "change",
  158. },
  159. ],
  160. paperType: [
  161. {
  162. required: true,
  163. message: "请选择AB卷版式",
  164. trigger: "change",
  165. },
  166. ],
  167. attention: [
  168. {
  169. required: true,
  170. message: "请输入注意事项",
  171. trigger: "change",
  172. },
  173. {
  174. validator: (rule, value, callback) => {
  175. const val = value.replace(/\n/g, "");
  176. if (val.length > 200) {
  177. callback(new Error("注意事项最多只能输入200个字符"));
  178. } else {
  179. callback();
  180. }
  181. },
  182. trigger: "change",
  183. },
  184. ],
  185. objectiveAttention: [
  186. {
  187. required: false,
  188. message: "请输入客观题注意事项",
  189. trigger: "change",
  190. },
  191. {
  192. max: 26,
  193. message: "客观题注意事项最多只能输入26个汉字",
  194. trigger: "change",
  195. },
  196. ],
  197. subjectiveAttention: [
  198. {
  199. required: false,
  200. message: "请输入主观题注意事项",
  201. trigger: "change",
  202. },
  203. {
  204. max: 26,
  205. message: "主观题注意事项最多只能输入26个汉字",
  206. trigger: "change",
  207. },
  208. ],
  209. },
  210. };
  211. },
  212. computed: {
  213. ...mapState("card", ["cardConfig"]),
  214. },
  215. watch: {
  216. cardConfig: {
  217. immediate: true,
  218. handler(val) {
  219. this.modalForm = objAssign(initModalForm, val);
  220. },
  221. },
  222. },
  223. methods: {
  224. ...mapMutations("card", ["setCardConfig"]),
  225. ...mapActions("card", ["rebuildPages"]),
  226. open() {
  227. this.drawer = true;
  228. },
  229. cancel() {
  230. this.drawer = false;
  231. },
  232. numStyleChange() {
  233. this.modalForm.writeSign = this.modalForm.examNumberStyle !== "FILL";
  234. if (this.modalForm.examNumberStyle !== "FILL") {
  235. this.modalForm.examNumberDigit = 10;
  236. }
  237. },
  238. async submit() {
  239. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  240. if (!valid) return;
  241. this.setCardConfig({ ...this.modalForm });
  242. this.cancel();
  243. this.$nextTick(() => {
  244. this.rebuildPages();
  245. });
  246. },
  247. },
  248. };
  249. </script>
  250. <style lang="scss" scoped>
  251. .card-config-edit {
  252. display: flex;
  253. flex-direction: column;
  254. height: 100%;
  255. }
  256. .card-config-header {
  257. padding: 15px 20px;
  258. line-height: 20px;
  259. border-bottom: 1px solid #f0f0f0;
  260. }
  261. .card-config-body {
  262. flex: 1;
  263. padding: 15px 20px;
  264. }
  265. .card-config-footer {
  266. padding: 15px 20px;
  267. text-align: right;
  268. }
  269. </style>