|
@@ -21,7 +21,7 @@
|
|
|
</el-form>
|
|
|
<el-row style="margin: 20px 0 5px 0" type="flex" align="middle" justify="end">
|
|
|
<el-col :span="2">
|
|
|
- <el-button type="primary" size="mini" @click="toExportStudent">导出学生</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="eDialog = true">导出学生</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="2">
|
|
|
<el-button type="danger" size="mini" :disabled="batchdet.length <= 0" @click="batchdelete">批量删除</el-button>
|
|
@@ -41,25 +41,42 @@
|
|
|
</template>
|
|
|
</data-form>
|
|
|
</el-dialog>
|
|
|
- <el-dialog title="选择导出学生的范围" :visible.sync="exportDialog" @close="toClose" width="30%">
|
|
|
- <data-form :data="exportInfo" :fields="exportFields" :rules="{}" @save="toExportExcel" submitText="导出">
|
|
|
- <template #custom="{ item, form }">
|
|
|
- <template v-if="item.model === 'termid'">
|
|
|
- {{ getTerm(form[item.model]) }}
|
|
|
+ <el-dialog title="导出" center :visible.sync="eDialog">
|
|
|
+ <export-range :usestudent="false" @close="eDialog = false" @toExport="toExportExcel">
|
|
|
+ <el-card>
|
|
|
+ <template #header>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">选择导出的字段-学生表(点击字段可以更换顺序)</el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <span v-for="(i, index) in selectModel" :key="`select-${index}`" style="padding-right:15px;zoom:1.1">
|
|
|
+ <el-link type="primary" v-if="index === selectIndex && index !== 0" icon="el-icon-back" @click="toChangePos(i, -1)"></el-link>
|
|
|
+ <el-link @click="toDisplayPos(index)">{{ i }}</el-link>
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ v-if="index === selectIndex && index !== selectModel.length - 1"
|
|
|
+ icon="el-icon-right"
|
|
|
+ @click="toChangePos(i, 1)"
|
|
|
+ ></el-link>
|
|
|
+ </span>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</template>
|
|
|
- </template>
|
|
|
- <template #options="{item,form}">
|
|
|
- <template v-if="item.model === 'batchid'">
|
|
|
- <el-option v-for="(i, index) in batchList" :key="index" :label="`第${i.batch}批`" :value="i._id"></el-option>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </data-form>
|
|
|
+ <el-checkbox-group v-model="selectModel">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="4" v-for="(i, index) in models.student" :key="`model-${index}`">
|
|
|
+ <el-checkbox :label="i.zh">{{ i.zh }}</el-checkbox>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </el-card>
|
|
|
+ </export-range>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import _ from 'lodash';
|
|
|
+import exportRange from '@frame/components/export-range';
|
|
|
import listFrame from '@frame/layout/admin/list-frame';
|
|
|
import dataForm from '@frame/components/form';
|
|
|
import dataTable from '@frame/components/data-table';
|
|
@@ -67,6 +84,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions } = createNamespacedHelpers('student');
|
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
|
|
|
+const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
|
|
|
export default {
|
|
|
metaInfo: { title: '学生管理' },
|
|
@@ -76,9 +94,11 @@ export default {
|
|
|
listFrame,
|
|
|
dataTable,
|
|
|
dataForm,
|
|
|
+ exportRange,
|
|
|
},
|
|
|
data: () => ({
|
|
|
dialog: false,
|
|
|
+ eDialog: false,
|
|
|
exportDialog: false,
|
|
|
opera: [
|
|
|
{
|
|
@@ -126,18 +146,22 @@ export default {
|
|
|
total: 0,
|
|
|
selectClassList: [],
|
|
|
batchdet: [],
|
|
|
- exportInfo: {},
|
|
|
exportFields: [
|
|
|
{ label: '导出期', model: 'termid', custom: true },
|
|
|
{ label: '导出批次', model: 'batchid', type: 'select' },
|
|
|
],
|
|
|
allClassList: [],
|
|
|
+ models: {},
|
|
|
+ selectModel: [],
|
|
|
+ selectIndex: '',
|
|
|
}),
|
|
|
created() {
|
|
|
this.getPlan();
|
|
|
+ this.toFindModel();
|
|
|
},
|
|
|
computed: { ...mapState(['user', 'defaultOption']) },
|
|
|
methods: {
|
|
|
+ ...util(['findModel', 'exportExcel']),
|
|
|
...trainplan({ planfetch: 'fetch' }),
|
|
|
...mapActions(['query', 'delete', 'update', 'removeAll', 'computedIsFine', 'toExport']),
|
|
|
...classes({ classesquery: 'query' }),
|
|
@@ -216,14 +240,6 @@ export default {
|
|
|
toClose() {
|
|
|
this.exportDialog = false;
|
|
|
this.dialog = false;
|
|
|
- this.exportInfo = {};
|
|
|
- },
|
|
|
- // 导出学生弹框
|
|
|
- toExportStudent() {
|
|
|
- const { termid } = this.defaultOption;
|
|
|
- this.$set(this.exportInfo, `termid`, termid);
|
|
|
- this.toBatchList(termid);
|
|
|
- this.exportDialog = true;
|
|
|
},
|
|
|
// 批次列表更改
|
|
|
async toBatchList(termid) {
|
|
@@ -233,21 +249,70 @@ export default {
|
|
|
if (batchnum) this.$set(this, `batchList`, batchnum);
|
|
|
}
|
|
|
},
|
|
|
- async toExportExcel() {
|
|
|
+ async toExportExcel(data) {
|
|
|
+ // 重新整理model
|
|
|
+ let model = this.selectModel.map(i => {
|
|
|
+ const om = this.models.student.find(f => f.zh == i);
|
|
|
+ if (om) return om;
|
|
|
+ });
|
|
|
+ model = _.compact(model);
|
|
|
+ // 将查询条件和model整理在一起
|
|
|
+ const obj = { ...data, model };
|
|
|
const msg = this.$message({ duration: 0, message: '正在导出,请稍后...' });
|
|
|
- let duplicate = _.cloneDeep(this.exportInfo);
|
|
|
- const res = await this.toExport(duplicate);
|
|
|
- msg.close();
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- const { data } = res;
|
|
|
- window.open(data);
|
|
|
- }
|
|
|
+ const res = await this.toExport(obj);
|
|
|
+ // msg.close();
|
|
|
+ // if (this.$checkRes(res)) {
|
|
|
+ // const { data } = res;
|
|
|
+ // window.open(data);
|
|
|
+ // }
|
|
|
},
|
|
|
getTerm(termid) {
|
|
|
console.log(termid);
|
|
|
const r = this.termList.find(f => f._id === termid);
|
|
|
if (r) return `第${r.term}期`;
|
|
|
},
|
|
|
+
|
|
|
+ async toFindModel() {
|
|
|
+ const res = await this.findModel('student');
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ const { data } = res;
|
|
|
+ if (!(data && _.isObject(data))) return;
|
|
|
+ const keys = Object.keys(data);
|
|
|
+ let obj = {};
|
|
|
+ const arr = [];
|
|
|
+ for (const key of keys) {
|
|
|
+ const o = data[key];
|
|
|
+ const { zh } = o;
|
|
|
+ if (zh) {
|
|
|
+ const ao = { zh };
|
|
|
+ ao['model'] = key;
|
|
|
+ arr.push(ao);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ obj['student'] = arr;
|
|
|
+ this.$set(this, `models`, obj);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 显示已经选择的字段的移动位置按钮
|
|
|
+ toDisplayPos(index) {
|
|
|
+ this.selectIndex = index;
|
|
|
+ },
|
|
|
+ // 移动位置,
|
|
|
+ toChangePos(data, num) {
|
|
|
+ const dup = _.cloneDeep(this.selectModel);
|
|
|
+ // 当前元素位置
|
|
|
+ const di = dup.findIndex(f => f == data);
|
|
|
+ // 要交换的元素位置及数据
|
|
|
+ const ci = di + num;
|
|
|
+ const c = dup[ci];
|
|
|
+ // 交换
|
|
|
+ dup[ci] = data;
|
|
|
+ dup[di] = c;
|
|
|
+ this.$set(this, `selectModel`, dup);
|
|
|
+ // 将目标也跟随过去
|
|
|
+ this.toDisplayPos(ci);
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
defaultOption: {
|