|
@@ -0,0 +1,171 @@
|
|
|
+<template>
|
|
|
+ <div id="index">
|
|
|
+ <list-frame title="学生参培名单导入" :needPag="false" :needFilter="false" :needAdd="false">
|
|
|
+ <el-row style="margin: 0 0 10px 0" type="flex" align="middle" justify="end">
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" size="mini" @click="downloadTemplate">下载导入学生模板</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" size="mini" @click="eDialog = true">导入学生</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <data-table :fields="fields" :usePage="false" :data="list" :opera="[]"></data-table>
|
|
|
+ </list-frame>
|
|
|
+ <el-dialog title="学生参培名单导入" center :visible.sync="eDialog" @close="toClose">
|
|
|
+ <el-col :span="24" class="title">温馨提示:该计划该期该批次学生有班级会导入失败,学生参培名单导入将会把以前的学生全部清空!!!</el-col>
|
|
|
+ <el-form :model="form" :rules="rules" ref="form" size="small" label-width="80px">
|
|
|
+ <el-form-item label="年度计划">
|
|
|
+ <el-select clearable v-model="form.planid">
|
|
|
+ <el-option disabled v-for="(i, index) in planList" :key="index" :label="i.title" :value="i._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="期(可选)" prop="termid">
|
|
|
+ <el-select clearable v-model="form.termid" @change="selectTerm">
|
|
|
+ <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="批(可选)" prop="batchid">
|
|
|
+ <el-select clearable v-model="form.batchid">
|
|
|
+ <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="上传名单" prop="file">
|
|
|
+ <el-upload v-model="form.file" :limit="1" class="upload-demo" :action="`/files/train/studentImport/upload`" :on-success="handleSuccess">
|
|
|
+ <el-button size="small" type="primary">点击上传</el-button>
|
|
|
+ <div slot="tip" class="el-upload__tip">不超过500kb</div>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-row type="flex" justify="space-around" class="btn_bar">
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" size="small" @click="toExport('form')">导入</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import _ from 'lodash';
|
|
|
+import listFrame from '@frame/layout/admin/list-frame';
|
|
|
+import dataTable from '@frame/components/filter-page-table';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
|
|
|
+const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'index',
|
|
|
+ props: {},
|
|
|
+ components: {
|
|
|
+ listFrame,
|
|
|
+ dataTable,
|
|
|
+ },
|
|
|
+ data: () => ({
|
|
|
+ fields: [
|
|
|
+ { label: '姓名', prop: 'name' },
|
|
|
+ { label: '错误信息', prop: 'msg' },
|
|
|
+ ],
|
|
|
+ form: {},
|
|
|
+ rules: {
|
|
|
+ termid: [{ required: true, message: '请选择期', trigger: 'change' }],
|
|
|
+ batchid: [{ required: true, message: '请选择批', trigger: 'change' }],
|
|
|
+ file: [{ required: true, message: '请选择上传名单', trigger: 'change' }],
|
|
|
+ },
|
|
|
+ list: [],
|
|
|
+ planList: [],
|
|
|
+ batchList: [],
|
|
|
+ termList: [],
|
|
|
+ eDialog: false,
|
|
|
+ }),
|
|
|
+ async created() {
|
|
|
+ await this.planSearch();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...util(['stuImport']),
|
|
|
+ ...trainplan({ planfetch: 'fetch' }),
|
|
|
+ // 查询计划
|
|
|
+ async planSearch() {
|
|
|
+ let res;
|
|
|
+ this.form.planid = this.defaultOption.planid;
|
|
|
+ res = await this.planfetch(this.defaultOption.planid);
|
|
|
+ let terms = res.data.termnum;
|
|
|
+ this.$set(this, `planList`, [res.data]);
|
|
|
+ this.$set(this, `termList`, terms);
|
|
|
+ if (this.defaultOption.termid) {
|
|
|
+ this.form.termid = this.defaultOption.termid;
|
|
|
+ await this.selectTerm(this.defaultOption.termid);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 找到批次列表,查询班级列表
|
|
|
+ async selectTerm(termid) {
|
|
|
+ this.$set(this.form, `batchid`, undefined);
|
|
|
+ // 正常找期下的批次,班级
|
|
|
+ const r = this.termList.find(f => f._id === termid);
|
|
|
+ if (!r) return;
|
|
|
+ const { batchnum } = r;
|
|
|
+ const nbn = batchnum.map(i => {
|
|
|
+ i.name = `第${r.term}期-第${i.batch}批`;
|
|
|
+ return i;
|
|
|
+ });
|
|
|
+ this.$set(this, `batchList`, nbn);
|
|
|
+ },
|
|
|
+ // 下载导入模板
|
|
|
+ downloadTemplate() {
|
|
|
+ window.open('/files/名单模板.xlsx');
|
|
|
+ },
|
|
|
+ // 上传文件
|
|
|
+ async handleSuccess(file, fileList) {
|
|
|
+ this.$set(this.form, `file`, file.uri);
|
|
|
+ },
|
|
|
+ // 导入
|
|
|
+ async toExport(formName) {
|
|
|
+ this.$refs[formName].validate(async valid => {
|
|
|
+ if (valid) {
|
|
|
+ let res = await this.stuImport({
|
|
|
+ filepath: this.form.file,
|
|
|
+ planid: this.form.planid,
|
|
|
+ batchid: this.form.batchid,
|
|
|
+ termid: this.form.termid,
|
|
|
+ });
|
|
|
+ if (this.$checkRes(res, null, res.errmsg || '上传失败')) {
|
|
|
+ if (res.data.errorcode == '1') {
|
|
|
+ this.$message.error('数据错误,请按错误信息提示修改数据');
|
|
|
+ let { errormsg } = res.data;
|
|
|
+ let r = [];
|
|
|
+ errormsg.map(e => {
|
|
|
+ let { msg } = e;
|
|
|
+ if (msg) r.push(e);
|
|
|
+ });
|
|
|
+ this.$set(this, `list`, r);
|
|
|
+ } else this.$message.success('上传成功');
|
|
|
+ this.toClose();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ toClose() {
|
|
|
+ this.eDialog = false;
|
|
|
+ this.$set(this.form, `file`, '');
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: { ...mapState(['user', 'defaultOption']) },
|
|
|
+ watch: {
|
|
|
+ defaultOption: {
|
|
|
+ handler(val) {
|
|
|
+ this.planSearch();
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.title {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ color: red;
|
|
|
+}
|
|
|
+</style>
|