|
@@ -0,0 +1,131 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="field-manage part-box part-box-pad">
|
|
|
|
+ <h4 class="part-box-tips">考生字段管理</h4>
|
|
|
|
+ <el-form ref="modalFormComp" label-width="100px">
|
|
|
|
+ <el-form-item label="基础字段:" required>
|
|
|
|
+ <el-checkbox
|
|
|
|
+ v-for="field in modalForm.requiredFields"
|
|
|
|
+ :key="field.code"
|
|
|
|
+ v-model="field.enable"
|
|
|
|
+ :disabled="field.disabled"
|
|
|
|
+ >{{ field.name }}</el-checkbox
|
|
|
|
+ >
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="扩展字段:">
|
|
|
|
+ <div class="part-box part-box-pad part-box-border">
|
|
|
|
+ <div class="label-edit">
|
|
|
|
+ <div
|
|
|
|
+ v-for="field in modalForm.extendFields"
|
|
|
|
+ :key="field.code"
|
|
|
|
+ class="label-item"
|
|
|
|
+ >
|
|
|
|
+ <el-checkbox
|
|
|
|
+ v-model="field.enable"
|
|
|
|
+ class="label-item-content"
|
|
|
|
+ @change="checkRuleChange"
|
|
|
|
+ >{{ field.name }}</el-checkbox
|
|
|
|
+ >
|
|
|
|
+ <i
|
|
|
|
+ class="label-item-delete el-icon-error"
|
|
|
|
+ @click="deleteField(field)"
|
|
|
|
+ ></i>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="label-add" @click="toAddField">
|
|
|
|
+ <i class="el-icon-plus"></i><i>添加</i>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ :disabled="isSubmit"
|
|
|
|
+ style="width: 140px"
|
|
|
|
+ @click="submit"
|
|
|
|
+ >保存</el-button
|
|
|
|
+ >
|
|
|
|
+ <span v-if="ruleChanged" class="tips-info tips-error">(有修改)</span>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+
|
|
|
|
+ <!-- ModifyField -->
|
|
|
|
+ <modify-field ref="ModifyField" @confirm="addField"></modify-field>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import ModifyField from "../components/ModifyField";
|
|
|
|
+import { fieldListQuery, saveFieldList } from "../api";
|
|
|
|
+
|
|
|
|
+const initModalForm = {
|
|
|
|
+ id: null,
|
|
|
|
+ requiredFields: [],
|
|
|
|
+ extendFields: [],
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+export default {
|
|
|
|
+ name: "field-manage",
|
|
|
|
+ components: { ModifyField },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ modalForm: { ...initModalForm },
|
|
|
|
+ isSubmit: false,
|
|
|
|
+ examRule: {},
|
|
|
|
+ ruleChanged: false,
|
|
|
|
+ prevModalFrom: "",
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.getData();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ async getData() {
|
|
|
|
+ const res = await fieldListQuery();
|
|
|
|
+ const field = res || { ...initModalForm };
|
|
|
|
+ this.modalForm.requiredFields = JSON.parse(field.requiredFields);
|
|
|
|
+ if (this.modalForm.extendFields)
|
|
|
|
+ this.modalForm.extendFields = JSON.parse(field.extendFields);
|
|
|
|
+ this.modalForm.id = field.id;
|
|
|
|
+
|
|
|
|
+ this.prevModalFrom = JSON.stringify(this.modalForm);
|
|
|
|
+ },
|
|
|
|
+ checkRuleChange() {
|
|
|
|
+ this.ruleChanged = this.prevModalFrom !== JSON.stringify(this.modalForm);
|
|
|
|
+ },
|
|
|
|
+ toAddField() {
|
|
|
|
+ this.$refs.ModifyField.open();
|
|
|
|
+ },
|
|
|
|
+ addField(field) {
|
|
|
|
+ this.modalForm.extendFields.push({ ...field });
|
|
|
|
+ this.checkRuleChange();
|
|
|
|
+ },
|
|
|
|
+ deleteField(field) {
|
|
|
|
+ const index = this.modalForm.extendFields.findIndex(
|
|
|
|
+ (item) => item.code === field.code
|
|
|
|
+ );
|
|
|
|
+ if (index !== -1) this.modalForm.extendFields.splice(index, 1);
|
|
|
|
+ this.checkRuleChange();
|
|
|
|
+ },
|
|
|
|
+ async submit() {
|
|
|
|
+ const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
|
|
+ if (!valid) return;
|
|
|
|
+
|
|
|
|
+ if (this.isSubmit) return;
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+ let datas = {
|
|
|
|
+ id: this.modalForm.id,
|
|
|
|
+ requiredFields: JSON.stringify(datas.requiredFields),
|
|
|
|
+ extendFields: JSON.stringify(datas.extendFields),
|
|
|
|
+ };
|
|
|
|
+ const data = await saveFieldList(datas).catch(() => {});
|
|
|
|
+ this.isSubmit = false;
|
|
|
|
+ if (!data) return;
|
|
|
|
+
|
|
|
|
+ this.modalForm.id = data;
|
|
|
|
+ this.prevModalFrom = JSON.stringify(this.modalForm);
|
|
|
|
+ this.checkRuleChange();
|
|
|
|
+ this.$message.success("保存成功!");
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|