123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <div class="card-config-prop-edit">
- <el-button @click="open" type="primary"> 配置题卡规则 </el-button>
- <el-drawer
- :visible.sync="drawer"
- :with-header="false"
- append-to-body
- :close-on-press-escape="false"
- :size="820"
- class="card-config-drawer"
- >
- <div class="card-config-edit">
- <div class="card-config-header">
- <h2>配置题卡规则</h2>
- </div>
- <div class="card-config-body">
- <el-form
- ref="modalFormComp"
- label-width="130px"
- :rules="rules"
- :model="modalForm"
- >
- <el-form-item
- prop="examNumberStyle"
- label="考号版式:"
- class="inline-block"
- >
- <el-select
- v-model="modalForm.examNumberStyle"
- style="width: 142px"
- placeholder="请选择"
- @change="numStyleChange"
- >
- <el-option
- v-for="(val, key) in EXAM_NUMBER_STYLE"
- :key="key"
- :value="key"
- :label="val"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- prop="fillNumber"
- label="考号位数:"
- class="inline-block"
- >
- <el-input-number
- v-if="modalForm.examNumberStyle === 'FILL'"
- v-model="modalForm.fillNumber"
- :min="5"
- :max="15"
- :step="1"
- step-strictly
- :controls="false"
- style="width: 100px"
- ></el-input-number>
- <span v-else>
- {{ modalForm.fillNumber }}
- </span>
- </el-form-item>
- <el-form-item>
- <el-checkbox v-model="modalForm.examAbsent"
- >启用“缺考填涂”</el-checkbox
- >
- <el-checkbox v-model="modalForm.discipline"
- >启用“违纪填涂”</el-checkbox
- >
- <el-checkbox
- v-model="modalForm.writeSign"
- :disabled="modalForm.examNumberStyle === 'FILL'"
- >启用“手写签名”</el-checkbox
- >
- </el-form-item>
- <div class="part-box part-box-pad part-box-border">
- <h4 class="part-box-tips">题卡版头变量印刷字段配置:</h4>
- <el-form-item label="必选字段:" label-width="115px" required>
- <el-checkbox
- v-for="column in modalForm.requiredFields"
- :key="column.code"
- v-model="column.enable"
- disabled
- >{{ column.name }}</el-checkbox
- >
- </el-form-item>
- <el-form-item label="扩展字段:" label-width="115px">
- <el-checkbox
- v-for="column in modalForm.extendFields"
- :key="column.code"
- v-model="column.enable"
- >{{ column.name }}</el-checkbox
- >
- </el-form-item>
- </div>
- <el-form-item prop="attention" label="注意事项:">
- <el-input
- type="textarea"
- :rows="4"
- v-model="modalForm.attention"
- ></el-input>
- <p class="tips-info">
- 提示:换行之后,题卡注意事项会展示为多条内容,内容序号会被自动添加。
- </p>
- </el-form-item>
- <el-form-item prop="objectiveAttention" label="客观题注意事项:">
- <el-input v-model="modalForm.objectiveAttention"></el-input>
- </el-form-item>
- <el-form-item prop="subjectiveAttention" label="主观题注意事项:">
- <el-input v-model="modalForm.subjectiveAttention"></el-input>
- </el-form-item>
- </el-form>
- </div>
- <div class="card-config-footer">
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="submit">确认</el-button>
- </div>
- </div>
- </el-drawer>
- </div>
- </template>
- <script>
- import { mapState, mapMutations, mapActions } from "vuex";
- import { objAssign } from "../plugins/utils";
- import { EXAM_NUMBER_STYLE, PAPER_TYPE } from "@/constants/enumerate";
- const initModalForm = {
- examNumberStyle: "",
- fillNumber: 10,
- paperType: "PRINT",
- examAbsent: true,
- discipline: true,
- writeSign: true,
- requiredFields: [],
- extendFields: [],
- attention: "",
- objectiveAttention: "",
- subjectiveAttention: "",
- };
- export default {
- name: "card-config-prop-edit",
- data() {
- return {
- modalForm: { ...initModalForm },
- EXAM_NUMBER_STYLE,
- PAPER_TYPE,
- drawer: false,
- rules: {
- examNumberStyle: [
- {
- required: true,
- message: "请选择考号版式",
- trigger: "change",
- },
- ],
- fillNumber: [
- {
- required: true,
- message: "请输入考号位数",
- trigger: "change",
- },
- ],
- paperType: [
- {
- required: true,
- message: "请选择AB卷版式",
- trigger: "change",
- },
- ],
- attention: [
- {
- required: true,
- message: "请输入注意事项",
- trigger: "change",
- },
- {
- validator: (rule, value, callback) => {
- const val = value.replace(/\n/g, "");
- if (val.length > 200) {
- callback(new Error("注意事项最多只能输入200个字符"));
- } else {
- callback();
- }
- },
- trigger: "change",
- },
- ],
- objectiveAttention: [
- {
- required: false,
- message: "请输入客观题注意事项",
- trigger: "change",
- },
- {
- max: 26,
- message: "客观题注意事项最多只能输入26个汉字",
- trigger: "change",
- },
- ],
- subjectiveAttention: [
- {
- required: false,
- message: "请输入主观题注意事项",
- trigger: "change",
- },
- {
- max: 26,
- message: "主观题注意事项最多只能输入26个汉字",
- trigger: "change",
- },
- ],
- },
- };
- },
- computed: {
- ...mapState("card", ["cardConfig"]),
- },
- watch: {
- cardConfig: {
- immediate: true,
- handler(val) {
- this.modalForm = objAssign(initModalForm, val);
- },
- },
- },
- methods: {
- ...mapMutations("card", ["setCardConfig"]),
- ...mapActions("card", ["rebuildPages"]),
- open() {
- this.drawer = true;
- },
- cancel() {
- this.drawer = false;
- },
- numStyleChange() {
- this.modalForm.writeSign = this.modalForm.examNumberStyle !== "FILL";
- if (this.modalForm.examNumberStyle !== "FILL") {
- this.modalForm.examNumberDigit = 10;
- }
- },
- async submit() {
- const valid = await this.$refs.modalFormComp.validate().catch(() => {});
- if (!valid) return;
- this.setCardConfig({ ...this.modalForm });
- this.cancel();
- this.$nextTick(() => {
- this.rebuildPages();
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .card-config-edit {
- display: flex;
- flex-direction: column;
- height: 100%;
- }
- .card-config-header {
- padding: 15px 20px;
- line-height: 20px;
- border-bottom: 1px solid #f0f0f0;
- }
- .card-config-body {
- flex: 1;
- padding: 15px 20px;
- }
- .card-config-footer {
- padding: 15px 20px;
- text-align: right;
- }
- </style>
|