|
@@ -0,0 +1,141 @@
|
|
|
+<template>
|
|
|
+ <div id="experience-export">
|
|
|
+ <el-row class="btn_bar" type="flex" justify="end">
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" size="small" @click="dialog = true">导出培训心得</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-dialog title="请选择要导出培训心得的范围" width="30%" :visible.sync="dialog" center @close="toClose">
|
|
|
+ <el-form size="small">
|
|
|
+ <el-form-item label="年度计划">
|
|
|
+ <el-select clearable v-model="form.planid" @change="toGetTerm">
|
|
|
+ <el-option 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="期(可选)">
|
|
|
+ <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="批(可选)">
|
|
|
+ <el-select clearable v-model="form.batchid">
|
|
|
+ <el-option v-for="(i, index) in batchList" :key="index" :label="`第${i.batch}批`" :value="i._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="班(可选)">
|
|
|
+ <el-select clearable v-model="form.classid" @change="selectClass">
|
|
|
+ <el-option v-for="(c, index) in classList" :key="index" :label="`${c.name.includes('班') ? c.name : `${c.name}班`}`" :value="c._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="人(可选)">
|
|
|
+ <el-select clearable v-model="form.studentid">
|
|
|
+ <el-option v-for="(i, index) in studentList" :key="index" :label="`${i.name}(${i.job})`" :value="i._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-row type="flex" justify="space-around">
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" size="small" @click="toExport">导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const _ = require('lodash');
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: experience } = createNamespacedHelpers('experience');
|
|
|
+const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
|
|
|
+const { mapActions: student } = createNamespacedHelpers('student');
|
|
|
+export default {
|
|
|
+ name: 'experience-export',
|
|
|
+ props: {},
|
|
|
+ components: {},
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ dialog: false,
|
|
|
+ form: {},
|
|
|
+ planList: [],
|
|
|
+ termList: [],
|
|
|
+ batchList: [],
|
|
|
+ classList: [],
|
|
|
+ studentList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ await this.toGetPlan();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...experience(['export']),
|
|
|
+ ...student({ getStudent: 'query' }),
|
|
|
+ ...trainplan({ getPlan: 'query' }),
|
|
|
+ ...classes({ getClass: 'query' }),
|
|
|
+ // 查询年度计划
|
|
|
+ async toGetPlan() {
|
|
|
+ const res = await this.getPlan();
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `planList`, res.data);
|
|
|
+ },
|
|
|
+ // 找到期列表
|
|
|
+ async toGetTerm(planid) {
|
|
|
+ const res = await this.planList.find(f => f._id === planid);
|
|
|
+ if (!res) return;
|
|
|
+ const { termnum } = res;
|
|
|
+ this.$set(this, `termList`, termnum);
|
|
|
+ },
|
|
|
+ // 找到批次列表,查询班级列表
|
|
|
+ async selectTerm(termid) {
|
|
|
+ const r = this.termList.find(f => f._id === termid);
|
|
|
+ if (!r) return;
|
|
|
+ const { batchnum } = r;
|
|
|
+ this.$set(this, `batchList`, batchnum);
|
|
|
+ const stures = await this.getClass({ termid });
|
|
|
+ if (this.$checkRes(stures)) {
|
|
|
+ let duplicate = _.cloneDeep(stures.data);
|
|
|
+ duplicate = duplicate.map(i => {
|
|
|
+ if (parseInt(i.name)) {
|
|
|
+ i.order = parseInt(i.name);
|
|
|
+ } else {
|
|
|
+ // i.order = i.name;
|
|
|
+ }
|
|
|
+ return i;
|
|
|
+ });
|
|
|
+ duplicate = _.orderBy(duplicate, ['order'], ['asc']);
|
|
|
+ this.$set(this, `classList`, duplicate);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 找到班级的班长,学委
|
|
|
+ async selectClass(classid) {
|
|
|
+ const bzres = await this.getStudent({ classid, job: '班长' });
|
|
|
+ const xwres = await this.getStudent({ classid, job: '学委' });
|
|
|
+ let arr = [];
|
|
|
+ if (this.$checkRes(bzres)) arr = [...arr, ...bzres.data];
|
|
|
+ if (this.$checkRes(xwres)) arr = [...arr, ...xwres.data];
|
|
|
+ this.$set(this, `studentList`, arr);
|
|
|
+ },
|
|
|
+ //导出
|
|
|
+ async toExport() {
|
|
|
+ const res = await this.export(this.form);
|
|
|
+ if (this.$checkRes(res, '导出成功', res.errmsg || '导出失败')) {
|
|
|
+ window.open(res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toClose() {
|
|
|
+ this.dialog = false;
|
|
|
+ this.$set(this, `form`, {});
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ pageTitle() {
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|