|
@@ -117,6 +117,23 @@
|
|
:disabled="editDisabled"
|
|
:disabled="editDisabled"
|
|
></el-input>
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+
|
|
|
|
+ <!-- 自定义字段 -->
|
|
|
|
+ <template v-if="extendFields.length">
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-for="field in extendFields"
|
|
|
|
+ :key="field.code"
|
|
|
|
+ :label="`${field.name}:`"
|
|
|
|
+ >
|
|
|
|
+ <el-input
|
|
|
|
+ v-model.trim="modalForm[field.code]"
|
|
|
|
+ :placeholder="`请输入${field.name}`"
|
|
|
|
+ clearable
|
|
|
|
+ :max-length="100"
|
|
|
|
+ :disabled="editDisabled"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
</el-form>
|
|
</el-form>
|
|
<div slot="footer">
|
|
<div slot="footer">
|
|
<el-button type="primary" :disabled="!canSubmit" @click="submit"
|
|
<el-button type="primary" :disabled="!canSubmit" @click="submit"
|
|
@@ -128,7 +145,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { getStudentInfo, updateStudent } from "../api";
|
|
|
|
|
|
+import { getStudentInfo, updateStudent, fieldListQuery } from "../api";
|
|
|
|
|
|
const initModalForm = {
|
|
const initModalForm = {
|
|
id: null,
|
|
id: null,
|
|
@@ -146,6 +163,7 @@ const initModalForm = {
|
|
examRoom: "",
|
|
examRoom: "",
|
|
score: undefined,
|
|
score: undefined,
|
|
remark: "",
|
|
remark: "",
|
|
|
|
+ extendFields: "",
|
|
};
|
|
};
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -268,6 +286,7 @@ export default {
|
|
},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
},
|
|
|
|
+ extendFields: [],
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -280,27 +299,56 @@ export default {
|
|
this.releaseStudent.studentCode === this.modalForm.studentCode
|
|
this.releaseStudent.studentCode === this.modalForm.studentCode
|
|
);
|
|
);
|
|
},
|
|
},
|
|
|
|
+ taskBaseInfo() {
|
|
|
|
+ return {
|
|
|
|
+ semesterId: this.task.semesterId,
|
|
|
|
+ examId: this.task.examId,
|
|
|
|
+ courseCode: this.task.courseCode,
|
|
|
|
+ courseName: this.task.courseName,
|
|
|
|
+ };
|
|
|
|
+ },
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- visibleChange() {
|
|
|
|
|
|
+ async getExtendFields() {
|
|
|
|
+ const res = await fieldListQuery();
|
|
|
|
+ const fields = res || [];
|
|
|
|
+
|
|
|
|
+ this.extendFields = fields.filter(
|
|
|
|
+ (item) => !item.basicField && item.enable
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ async visibleChange() {
|
|
|
|
+ await this.getExtendFields();
|
|
|
|
+ let modalForm = {};
|
|
if (this.datas.length === 1) {
|
|
if (this.datas.length === 1) {
|
|
- this.modalForm = this.$objAssign(initModalForm, this.datas[0]);
|
|
|
|
|
|
+ modalForm = this.$objAssign(initModalForm, this.datas[0]);
|
|
if (this.datas[0].studentName) {
|
|
if (this.datas[0].studentName) {
|
|
- this.releaseStudent = { ...this.modalForm };
|
|
|
|
|
|
+ this.releaseStudent = { ...modalForm };
|
|
} else {
|
|
} else {
|
|
|
|
+ modalForm.id = null;
|
|
this.releaseStudent = null;
|
|
this.releaseStudent = null;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- this.modalForm = { ...initModalForm };
|
|
|
|
this.releaseStudent = null;
|
|
this.releaseStudent = null;
|
|
|
|
+ modalForm = { ...initModalForm };
|
|
}
|
|
}
|
|
|
|
|
|
- if (!this.modalForm.studentName) this.modalForm.id = null;
|
|
|
|
|
|
+ modalForm = this.$objAssign(modalForm, this.taskBaseInfo);
|
|
|
|
|
|
- this.modalForm.semesterId = this.task.semesterId;
|
|
|
|
- this.modalForm.examId = this.task.examId;
|
|
|
|
- this.modalForm.courseCode = this.task.courseCode;
|
|
|
|
- this.modalForm.courseName = this.task.courseName;
|
|
|
|
|
|
+ if (this.extendFields.length) {
|
|
|
|
+ const extendFieldsData = this.releaseStudent?.extendFields
|
|
|
|
+ ? JSON.parse(this.releaseStudent?.extendFields)
|
|
|
|
+ : [];
|
|
|
|
+ const extendFieldDict = {};
|
|
|
|
+ extendFieldsData.forEach((field) => {
|
|
|
|
+ extendFieldDict[field.code] = field.value;
|
|
|
|
+ });
|
|
|
|
+ this.extendFields.forEach((field) => {
|
|
|
|
+ modalForm[field.code] = extendFieldDict[field.code] || "";
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.modalForm = modalForm;
|
|
|
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.$refs.modalFormComp.clearValidate();
|
|
this.$refs.modalFormComp.clearValidate();
|
|
@@ -332,21 +380,31 @@ export default {
|
|
courseCode: this.task.courseCode,
|
|
courseCode: this.task.courseCode,
|
|
studentCode: this.modalForm.studentCode,
|
|
studentCode: this.modalForm.studentCode,
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
|
|
+ let modalForm = {};
|
|
if (res) {
|
|
if (res) {
|
|
this.releaseStudent = res;
|
|
this.releaseStudent = res;
|
|
- this.modalForm = this.$objAssign(this.modalForm, res);
|
|
|
|
|
|
+ modalForm = this.$objAssign(initModalForm, res);
|
|
} else {
|
|
} else {
|
|
this.releaseStudent = null;
|
|
this.releaseStudent = null;
|
|
- this.modalForm = {
|
|
|
|
- ...initModalForm,
|
|
|
|
- studentCode: this.modalForm.studentCode,
|
|
|
|
- };
|
|
|
|
- this.modalForm.semesterId = this.task.semesterId;
|
|
|
|
- this.modalForm.examId = this.task.examId;
|
|
|
|
- this.modalForm.courseCode = this.task.courseCode;
|
|
|
|
- this.modalForm.courseName = this.task.courseName;
|
|
|
|
|
|
+ modalForm = this.$objAssign(initModalForm, this.taskBaseInfo);
|
|
|
|
+ modalForm.studentCode = this.modalForm.studentCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.extendFields.length) {
|
|
|
|
+ const extendFieldsData = this.releaseStudent?.extendFields
|
|
|
|
+ ? JSON.parse(this.releaseStudent?.extendFields)
|
|
|
|
+ : [];
|
|
|
|
+ const extendFieldDict = {};
|
|
|
|
+ extendFieldsData.forEach((field) => {
|
|
|
|
+ extendFieldDict[field.code] = field.value;
|
|
|
|
+ });
|
|
|
|
+ this.extendFields.forEach((field) => {
|
|
|
|
+ modalForm[field.code] = extendFieldDict[field.code] || "";
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.modalForm = modalForm;
|
|
|
|
+
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.$refs.modalFormComp.clearValidate();
|
|
this.$refs.modalFormComp.clearValidate();
|
|
});
|
|
});
|
|
@@ -355,14 +413,21 @@ export default {
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
if (!valid) return;
|
|
if (!valid) return;
|
|
|
|
|
|
|
|
+ const datas = this.$objAssign(initModalForm, this.modalForm);
|
|
if (!this.editDisabled) {
|
|
if (!this.editDisabled) {
|
|
// 新创建的考生,先保存
|
|
// 新创建的考生,先保存
|
|
- const res = await updateStudent(this.modalForm).catch(() => {});
|
|
|
|
|
|
+ if (this.extendFields.length) {
|
|
|
|
+ const extendFieldsData = this.extendFields.map((field) => {
|
|
|
|
+ return { ...field, value: this.modalForm[field.code] };
|
|
|
|
+ });
|
|
|
|
+ datas.extendFields = JSON.stringify(extendFieldsData);
|
|
|
|
+ }
|
|
|
|
+ const res = await updateStudent(datas).catch(() => {});
|
|
if (!res) return;
|
|
if (!res) return;
|
|
- this.modalForm.id = res;
|
|
|
|
|
|
+ datas.id = res.id;
|
|
}
|
|
}
|
|
|
|
|
|
- this.$emit("confirm", this.modalForm);
|
|
|
|
|
|
+ this.$emit("confirm", datas);
|
|
this.cancel();
|
|
this.cancel();
|
|
},
|
|
},
|
|
},
|
|
},
|