|
@@ -1,7 +1,15 @@
|
|
<template>
|
|
<template>
|
|
<div id="detail">
|
|
<div id="detail">
|
|
- <detail-frame :title="mainTitle" returns="/student/index">
|
|
|
|
|
|
+ <detail-frame :title="mainTitle" :returns="toReturns">
|
|
<data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
|
|
<data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
|
|
|
|
+ <template #options="{item}">
|
|
|
|
+ <template v-if="item.model === 'school_name'">
|
|
|
|
+ <el-option v-for="(item, index) in schcoolList" :key="index" :label="item.name" :value="item.name"></el-option>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-if="item.model === 'nation'">
|
|
|
|
+ <el-option v-for="(item, index) in nationList" :key="index" :label="item.name" :value="item.name"></el-option>
|
|
|
|
+ </template>
|
|
|
|
+ </template>
|
|
<template #radios="{item}">
|
|
<template #radios="{item}">
|
|
<template v-if="item.model === 'gender'">
|
|
<template v-if="item.model === 'gender'">
|
|
<el-radio label="男">男</el-radio>
|
|
<el-radio label="男">男</el-radio>
|
|
@@ -25,6 +33,8 @@ import detailFrame from '@frame/layout/admin/detail-frame';
|
|
import dataForm from '@frame/components/form';
|
|
import dataForm from '@frame/components/form';
|
|
import { createNamespacedHelpers } from 'vuex';
|
|
import { createNamespacedHelpers } from 'vuex';
|
|
const { mapActions } = createNamespacedHelpers('student');
|
|
const { mapActions } = createNamespacedHelpers('student');
|
|
|
|
+const { mapActions: mapNation } = createNamespacedHelpers('nation');
|
|
|
|
+const { mapActions: mapschool } = createNamespacedHelpers('school');
|
|
//缺少字典表:学校表,民族表,院系表,专业表
|
|
//缺少字典表:学校表,民族表,院系表,专业表
|
|
export default {
|
|
export default {
|
|
metaInfo: { title: '学生信息' },
|
|
metaInfo: { title: '学生信息' },
|
|
@@ -35,13 +45,15 @@ export default {
|
|
dataForm,
|
|
dataForm,
|
|
},
|
|
},
|
|
data: () => ({
|
|
data: () => ({
|
|
|
|
+ schcoolList: [],
|
|
|
|
+ nationList: [],
|
|
info: {},
|
|
info: {},
|
|
fields: [
|
|
fields: [
|
|
{ label: '姓名', required: true, model: 'name' },
|
|
{ label: '姓名', required: true, model: 'name' },
|
|
{ label: '性别', required: true, model: 'gender', type: 'radio' },
|
|
{ label: '性别', required: true, model: 'gender', type: 'radio' },
|
|
- // { label: '民族', required: true, model: 'nation', type: 'select' },
|
|
|
|
|
|
+ { label: '民族', required: true, model: 'nation', type: 'select' },
|
|
{ label: '身份证号', required: true, model: 'id_number', options: { maxlength: 18 } },
|
|
{ label: '身份证号', required: true, model: 'id_number', options: { maxlength: 18 } },
|
|
- // { label: '学校', required: true, model: 'school_name', type: 'select' },
|
|
|
|
|
|
+ { label: '学校', required: true, model: 'school_name', type: 'select' },
|
|
// { label: '院系', required: true, model: 'yard', type: 'select' },
|
|
// { label: '院系', required: true, model: 'yard', type: 'select' },
|
|
// { label: '专业', required: true, model: 'major', type: 'select' },
|
|
// { label: '专业', required: true, model: 'major', type: 'select' },
|
|
{ label: '入学年份', required: true, model: 'entry_year', type: 'year' },
|
|
{ label: '入学年份', required: true, model: 'entry_year', type: 'year' },
|
|
@@ -54,10 +66,9 @@ export default {
|
|
{ label: '家庭是否困难', required: true, model: 'family_is_hard', type: 'radio' },
|
|
{ label: '家庭是否困难', required: true, model: 'family_is_hard', type: 'radio' },
|
|
{ label: '是否获得过助学金', required: true, model: 'have_grant', type: 'radio' },
|
|
{ label: '是否获得过助学金', required: true, model: 'have_grant', type: 'radio' },
|
|
{ label: '职务', model: 'job' },
|
|
{ label: '职务', model: 'job' },
|
|
- //可以根据上个页面带过来,不需要添加
|
|
|
|
- // { label: '期', required: true, model: 'term' },
|
|
|
|
- // { label: '批次', required: true, model: 'batch' },
|
|
|
|
- // { label: '班级', required: true, model: 'class' },
|
|
|
|
|
|
+ { label: '期', required: true, model: 'term' },
|
|
|
|
+ { label: '批次', required: true, model: 'batch' },
|
|
|
|
+ { label: '班级', required: true, model: 'class' },
|
|
{ label: '是否优秀', model: 'is_fine', type: 'radio' },
|
|
{ label: '是否优秀', model: 'is_fine', type: 'radio' },
|
|
],
|
|
],
|
|
rules: {
|
|
rules: {
|
|
@@ -88,32 +99,9 @@ export default {
|
|
is_fine: [{ required: true, message: '请选择是否优秀' }],
|
|
is_fine: [{ required: true, message: '请选择是否优秀' }],
|
|
},
|
|
},
|
|
}),
|
|
}),
|
|
- created() {},
|
|
|
|
-
|
|
|
|
- methods: {
|
|
|
|
- ...mapActions(['fetch', 'create', 'update']),
|
|
|
|
- async search() {
|
|
|
|
- const res = await this.fetch(this.id);
|
|
|
|
- if (this.$checkRes(res)) this.$set(this, `info`, res.data);
|
|
|
|
- this.loading = false;
|
|
|
|
- },
|
|
|
|
- async handleSave({ isNew, data }) {
|
|
|
|
- let res;
|
|
|
|
- let msg;
|
|
|
|
- if (isNew) {
|
|
|
|
- data.openid = new Date().getTime();
|
|
|
|
- data.nation = `汉族`;
|
|
|
|
- data.yard = `测试学院`;
|
|
|
|
- data.major = `测试专业`;
|
|
|
|
- data.school_name = `测试学校`;
|
|
|
|
- res = await this.create(data);
|
|
|
|
- msg = `${this.keyWord}添加成功`;
|
|
|
|
- } else {
|
|
|
|
- res = await this.update(data);
|
|
|
|
- msg = `${this.keyWord}修改成功`;
|
|
|
|
- }
|
|
|
|
- if (this.$checkRes(res, msg)) window.history.back(-1);
|
|
|
|
- },
|
|
|
|
|
|
+ created() {
|
|
|
|
+ this.otherList();
|
|
|
|
+ this.schoolname();
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
id() {
|
|
id() {
|
|
@@ -133,16 +121,6 @@ export default {
|
|
let main = meta.title || '';
|
|
let main = meta.title || '';
|
|
return main;
|
|
return main;
|
|
},
|
|
},
|
|
- //添加必传
|
|
|
|
- classes() {
|
|
|
|
- return this.$route.query.class;
|
|
|
|
- },
|
|
|
|
- term() {
|
|
|
|
- return this.$route.query.term;
|
|
|
|
- },
|
|
|
|
- batch() {
|
|
|
|
- return this.$route.query.batch;
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
isNew: {
|
|
isNew: {
|
|
@@ -153,6 +131,46 @@ export default {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ methods: {
|
|
|
|
+ ...mapActions(['fetch', 'create', 'update']),
|
|
|
|
+ ...mapNation({ nation: 'query' }),
|
|
|
|
+ ...mapschool({ zschool: 'query' }),
|
|
|
|
+ async otherList() {
|
|
|
|
+ const res = await this.nation();
|
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `nationList`, res.data);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ async schoolname() {
|
|
|
|
+ const res = await this.zschool();
|
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `schcoolList`, res.data);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ async search() {
|
|
|
|
+ const res = await this.fetch(this.id);
|
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `info`, res.data);
|
|
|
|
+ this.loading = false;
|
|
|
|
+ },
|
|
|
|
+ async handleSave({ isNew, data }) {
|
|
|
|
+ let res;
|
|
|
|
+ let msg;
|
|
|
|
+ if (isNew) {
|
|
|
|
+ data.openid = new Date().getTime();
|
|
|
|
+ // data.nation = `汉族`;
|
|
|
|
+ // data.yard = `测试学院`;
|
|
|
|
+ // data.major = `测试专业`;
|
|
|
|
+ // data.school_name = `测试学校`;
|
|
|
|
+ res = await this.create(data);
|
|
|
|
+ msg = `${this.keyWord}添加成功`;
|
|
|
|
+ } else {
|
|
|
|
+ res = await this.update(data);
|
|
|
|
+ msg = `${this.keyWord}修改成功`;
|
|
|
|
+ }
|
|
|
|
+ if (this.$checkRes(res, msg)) this.toReturns();
|
|
|
|
+ },
|
|
|
|
+ toReturns() {
|
|
|
|
+ window.history.go(-1);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|