|
@@ -1,16 +1,28 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
<list-frame title="新人才报" @query="search" :total="total" :needFilter="false" :needAdd="false">
|
|
|
- <data-table :fields="fields" :data="list" :opera="opera" @download="download" @delete="toDelete"></data-table>
|
|
|
+ <el-form size="small" :inline="true">
|
|
|
+ <el-form-item label="班级">
|
|
|
+ <el-select v-model="searchInfo.classid" placeholder="请选择班级">
|
|
|
+ <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>
|
|
|
+ <export-range @getStudent="toGetStudent" :studentList="studentList" @toExport="toExport"></export-range>
|
|
|
+ <data-table :fields="fields" :data="list" :opera="opera" @download="download"></data-table>
|
|
|
</list-frame>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import _ from 'lodash';
|
|
|
+import exportRange from '@/components/export-range.vue';
|
|
|
import listFrame from '@frame/layout/admin/list-frame';
|
|
|
import dataTable from '@frame/components/data-table';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: talented } = createNamespacedHelpers('talented');
|
|
|
+const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
+const { mapActions: student } = createNamespacedHelpers('student');
|
|
|
|
|
|
export default {
|
|
|
metaInfo: { title: '新人才报' },
|
|
@@ -19,6 +31,7 @@ export default {
|
|
|
components: {
|
|
|
listFrame,
|
|
|
dataTable,
|
|
|
+ exportRange,
|
|
|
},
|
|
|
data: () => ({
|
|
|
opera: [
|
|
@@ -27,27 +40,82 @@ export default {
|
|
|
icon: 'el-icon-download',
|
|
|
method: 'download',
|
|
|
},
|
|
|
- {
|
|
|
- label: '删除',
|
|
|
- icon: 'el-icon-delete',
|
|
|
- method: 'delete',
|
|
|
- },
|
|
|
],
|
|
|
- fields: [{ label: '姓名', prop: 'name' }],
|
|
|
+ fields: [{ label: '姓名', prop: 'stuname' }],
|
|
|
list: [],
|
|
|
-
|
|
|
+ classList: [],
|
|
|
+ searchInfo: {},
|
|
|
+ studentList: [],
|
|
|
total: 0,
|
|
|
}),
|
|
|
- created() {},
|
|
|
+ async created() {
|
|
|
+ await this.getOtherList();
|
|
|
+ },
|
|
|
computed: { ...mapState(['user', 'defaultOption']) },
|
|
|
methods: {
|
|
|
+ ...classes({ getClass: 'query' }),
|
|
|
+ ...student({ getStudent: 'query' }),
|
|
|
+ ...talented(['query', 'export']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ this.$set(this, `total`, 0);
|
|
|
+ const res = await this.query({ ...this.searchInfo, skip, limit });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getOtherList() {
|
|
|
+ const { termid } = this.defaultOption;
|
|
|
+ if (!termid) return;
|
|
|
+ const res = await this.getClass({ termid });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ let duplicate = _.cloneDeep(res.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);
|
|
|
+ }
|
|
|
+ },
|
|
|
// 下载
|
|
|
- download({ data }) {
|
|
|
- console.log(data);
|
|
|
+ async download({ data }) {
|
|
|
+ const { id } = data;
|
|
|
+ const r = await this.export({ id });
|
|
|
+ if (this.$checkRes(r)) {
|
|
|
+ window.open(r.data);
|
|
|
+ }
|
|
|
},
|
|
|
- // 删除
|
|
|
- toDelete({ data }) {
|
|
|
- console.log(data);
|
|
|
+ async toGetStudent(classid) {
|
|
|
+ const res = await this.getStudent({ classid, job: '宣传委员' });
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `studentList`, res.data);
|
|
|
+ },
|
|
|
+ async toExport(data) {
|
|
|
+ const r = await this.export(data);
|
|
|
+ if (this.$checkRes(r)) {
|
|
|
+ window.open(r.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ defaultOption: {
|
|
|
+ deep: true,
|
|
|
+ handler(val, oval) {
|
|
|
+ this.getOtherList();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ searchInfo: {
|
|
|
+ deep: true,
|
|
|
+ handler(val) {
|
|
|
+ if (val) {
|
|
|
+ const keys = Object.keys(val);
|
|
|
+ if (keys.length > 0) this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
};
|