|
@@ -0,0 +1,121 @@
|
|
|
+<template>
|
|
|
+ <div id="detail">
|
|
|
+ <detail-frame :title="mainTitle" returns="/certificaate/index">
|
|
|
+ <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
|
|
|
+ <template #options="{item}">
|
|
|
+ <template v-if="item.model === 'batch'">
|
|
|
+ <el-option label="第一批次" value="0"></el-option>
|
|
|
+ <el-option label="第二批次" value="1"></el-option>
|
|
|
+ <el-option label="第三批次" value="2"></el-option>
|
|
|
+ <el-option label="特殊批次" value="3"></el-option>
|
|
|
+ </template>
|
|
|
+ <template v-if="item.model === 'class'">
|
|
|
+ <el-option label="一班" value="0"></el-option>
|
|
|
+ <el-option label="二班" value="1"></el-option>
|
|
|
+ <el-option label="三班" value="2"></el-option>
|
|
|
+ <el-option label="四班" value="3"></el-option>
|
|
|
+ <el-option label="五班" value="4"></el-option>
|
|
|
+ <el-option label="六班" value="5"></el-option>
|
|
|
+ <el-option label="七班" value="6"></el-option>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </data-form>
|
|
|
+ </detail-frame>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
+import dataForm from '@frame/components/form';
|
|
|
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: mapClass } = createNamespacedHelpers('dept');
|
|
|
+
|
|
|
+export default {
|
|
|
+ metaInfo: { title: '部门信息' },
|
|
|
+ name: 'detail',
|
|
|
+ props: {},
|
|
|
+ components: {
|
|
|
+ detailFrame,
|
|
|
+ dataForm,
|
|
|
+ },
|
|
|
+ data: () => ({
|
|
|
+ info: {},
|
|
|
+ fields: [
|
|
|
+ { label: '学校(院)', required: true, model: 'school_name' },
|
|
|
+ { label: '姓名', required: true, model: 'name' },
|
|
|
+ { label: '参加训练日期', required: true, model: 'data' },
|
|
|
+ { label: '专业', required: true, model: 'major' },
|
|
|
+ { label: '期数', required: true, model: 'term' },
|
|
|
+ { label: '批次', required: true, model: 'batch', type: `select` },
|
|
|
+ { label: '班级', required: true, model: 'class', type: `select` },
|
|
|
+ { label: '证书编号', required: true, model: 'bianhao' },
|
|
|
+ { label: '发证日期', required: true, model: 'zsdate' },
|
|
|
+ { label: '成绩', required: true, model: 'grade' },
|
|
|
+ ],
|
|
|
+ rules: {
|
|
|
+ name: [{ required: true, message: '请输入学生姓名' }],
|
|
|
+ school_name: [{ required: true, message: '请输入学校名称' }],
|
|
|
+ data: [{ required: true, message: '请输入参加训练日期' }],
|
|
|
+ major: [{ required: true, message: '请输入专业名称' }],
|
|
|
+ term: [{ required: true, message: '请输入期数' }],
|
|
|
+ bianhao: [{ required: true, message: '请输入证书编号' }],
|
|
|
+ zsdate: [{ required: true, message: '请输入发证日期' }],
|
|
|
+ grade: [{ required: true, message: '请输入成绩' }],
|
|
|
+ batch: [{ required: true, message: '请选择批次' }],
|
|
|
+ class: [{ required: true, message: '请选择班级' }],
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ created() {},
|
|
|
+ computed: {
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
+ isNew() {
|
|
|
+ return this.$route.query.id ? false : true;
|
|
|
+ },
|
|
|
+ mainTitle() {
|
|
|
+ let meta = this.$route.meta;
|
|
|
+ let main = meta.title || '';
|
|
|
+ let sub = meta.sub || '';
|
|
|
+ return `${main}${sub}`;
|
|
|
+ },
|
|
|
+ keyWord() {
|
|
|
+ let meta = this.$route.meta;
|
|
|
+ let main = meta.title || '';
|
|
|
+ return main;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ isNew: {
|
|
|
+ immediate: true,
|
|
|
+ handler(val) {
|
|
|
+ if (val) this.loading = false;
|
|
|
+ else this.search();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapClass(['fetch', 'create', 'update']),
|
|
|
+ async search() {
|
|
|
+ const res = await this.fetch(this.id);
|
|
|
+ console.log(res);
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `info`, res.data);
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ async handleSave({ isNew, data }) {
|
|
|
+ let res;
|
|
|
+ let msg;
|
|
|
+ if (isNew) {
|
|
|
+ res = await this.create(data);
|
|
|
+ msg = `${this.keyWord}添加成功`;
|
|
|
+ } else {
|
|
|
+ res = await this.update(data);
|
|
|
+ msg = `${this.keyWord}修改成功`;
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, msg)) this.$router.push({ path: '/dept/index' });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|