|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="default-select">
|
|
|
- <el-row type="flex" align="middle" justify="start" class="user-menu">
|
|
|
- <el-col :span="12">
|
|
|
+ <el-row type="flex" align="middle" justify="start" class="user-menu" v-loading="loading">
|
|
|
+ <el-col :span="12" v-if="options">
|
|
|
当前默认:
|
|
|
<span>
|
|
|
<el-tooltip :disabled="this.user.type != 0" content="点击更改默认批次" effect="dark" placement="bottom">
|
|
@@ -18,14 +18,16 @@
|
|
|
</span>
|
|
|
<span>
|
|
|
<el-tooltip :disabled="this.user.type != 0" content="点击更改默认年度计划" effect="dark" placement="bottom">
|
|
|
- <el-select v-model="options.planid" :disabled="this.user.type != 0" placeholder="未设置年度计划" size="mini">
|
|
|
+ <el-select v-model="options.planid" :disabled="this.user.type != 0" placeholder="未设置年度计划" size="mini" @change="getTermList">
|
|
|
<el-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i._id"></el-option>
|
|
|
</el-select>
|
|
|
</el-tooltip>
|
|
|
</span>
|
|
|
<span>
|
|
|
<el-tooltip content="点击更改默认期" effect="dark" placement="bottom">
|
|
|
- <el-select v-model="options.termid" placeholder="未设置默认期" size="mini"></el-select>
|
|
|
+ <el-select v-model="options.termid" placeholder="未设置默认期" size="mini">
|
|
|
+ <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
|
|
|
+ </el-select>
|
|
|
</el-tooltip>
|
|
|
</span>
|
|
|
<span>
|
|
@@ -48,15 +50,18 @@ export default {
|
|
|
components: {},
|
|
|
data: function() {
|
|
|
return {
|
|
|
- options: {},
|
|
|
+ loading: true,
|
|
|
+ options: undefined,
|
|
|
planYearList: [],
|
|
|
planList: [],
|
|
|
termList: [],
|
|
|
};
|
|
|
},
|
|
|
- created() {
|
|
|
- this.$set(this, `options`, _.cloneDeep(this.defaultOption));
|
|
|
+ async created() {
|
|
|
+ // this.$set(this, `options`, _.cloneDeep(this.defaultOption));
|
|
|
+ this.search({ type: 'planYear' });
|
|
|
this.checkOption();
|
|
|
+ this.loading = false;
|
|
|
},
|
|
|
methods: {
|
|
|
...mapMutations(['deleteUser', 'changeOpt']),
|
|
@@ -68,28 +73,32 @@ export default {
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$set(this, `${type}List`, res.data);
|
|
|
if (type == 'plan') {
|
|
|
- let term = _.get(res.data, 'termnum', []);
|
|
|
- this.$set(this, `termList`, term);
|
|
|
+ let planid = _.get(this.options, 'planid');
|
|
|
+ this.getTermList(planid);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
checkOption() {
|
|
|
- if (_.get(this.options, 'planyearid')) {
|
|
|
- this.search({ type: 'planYear' });
|
|
|
- if (_.get(this.options, 'planid')) {
|
|
|
- this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
|
|
|
- }
|
|
|
+ if (_.get(this.options, 'planid')) {
|
|
|
+ this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
|
|
|
}
|
|
|
},
|
|
|
async changeList(type, data) {
|
|
|
let obj = { type };
|
|
|
let res;
|
|
|
+ this.toClear();
|
|
|
+ this.setVuexOpt();
|
|
|
if (type == 'plan') {
|
|
|
obj[`planyearid`] = data;
|
|
|
await this.search(obj);
|
|
|
}
|
|
|
- this.toClear();
|
|
|
- this.setVuexOpt();
|
|
|
+ },
|
|
|
+ getTermList(planid) {
|
|
|
+ let r = this.planList.find(f => f.id == planid);
|
|
|
+ if (r) {
|
|
|
+ let term = _.get(r, 'termnum', []);
|
|
|
+ this.$set(this, `termList`, term);
|
|
|
+ }
|
|
|
},
|
|
|
setVuexOpt() {
|
|
|
this.changeOpt(this.options);
|
|
@@ -111,6 +120,18 @@ export default {
|
|
|
this.$checkRes(res, '设置成功', res.errmsg);
|
|
|
},
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ defaultOption: {
|
|
|
+ handler(val) {
|
|
|
+ if (val) {
|
|
|
+ let opt = _.get(this, `options`);
|
|
|
+ if (!opt) this.$set(this, `options`, _.cloneDeep(val));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
computed: {
|
|
|
...mapState(['user', 'defaultOption']),
|
|
|
pageTitle() {
|