|
@@ -0,0 +1,136 @@
|
|
|
+<template>
|
|
|
+ <div id="default-select">
|
|
|
+ <el-row type="flex" align="middle" justify="start" class="user-menu">
|
|
|
+ <el-col :span="12">
|
|
|
+ 当前默认:
|
|
|
+ <span>
|
|
|
+ <el-tooltip :disabled="this.user.type != 0" content="点击更改默认批次" effect="dark" placement="bottom">
|
|
|
+ <el-select
|
|
|
+ v-model="options.planyearid"
|
|
|
+ :disabled="this.user.type != 0"
|
|
|
+ placeholder="未设置培训批次"
|
|
|
+ size="mini"
|
|
|
+ @change="data => changeList('plan', data)"
|
|
|
+ >
|
|
|
+ <el-option v-for="(i, index) in planYearList" :key="index" :label="i.title" :value="i._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-tooltip>
|
|
|
+ </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-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-tooltip>
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <el-button type="text" size="mini" @click="settingSave">保存默认值</el-button>
|
|
|
+ </span>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import _ from 'lodash';
|
|
|
+import { mapState, mapMutations, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: trainBatch } = createNamespacedHelpers('trainBatch');
|
|
|
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
|
|
|
+const { mapActions: setting } = createNamespacedHelpers('setting');
|
|
|
+export default {
|
|
|
+ name: 'default-select',
|
|
|
+ props: {},
|
|
|
+ components: {},
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ options: {},
|
|
|
+ planYearList: [],
|
|
|
+ planList: [],
|
|
|
+ termList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.$set(this, `options`, _.cloneDeep(this.defaultOption));
|
|
|
+ this.checkOption();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapMutations(['deleteUser', 'changeOpt']),
|
|
|
+ ...trainBatch({ getplanYear: 'query' }),
|
|
|
+ ...trainplan({ getplan: 'query' }),
|
|
|
+ ...setting({ sFetch: 'fetch', sUpdate: 'update' }),
|
|
|
+ async search({ type, ...info }) {
|
|
|
+ let res = await _.get(this, `get${type}`)({ ...info });
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkOption() {
|
|
|
+ if (_.get(this.options, 'planyearid')) {
|
|
|
+ this.search({ type: 'planYear' });
|
|
|
+ if (_.get(this.options, 'planid')) {
|
|
|
+ this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async changeList(type, data) {
|
|
|
+ let obj = { type };
|
|
|
+ let res;
|
|
|
+ if (type == 'plan') {
|
|
|
+ obj[`planyearid`] = data;
|
|
|
+ await this.search(obj);
|
|
|
+ }
|
|
|
+ this.toClear();
|
|
|
+ this.setVuexOpt();
|
|
|
+ },
|
|
|
+ setVuexOpt() {
|
|
|
+ this.changeOpt(this.options);
|
|
|
+ },
|
|
|
+ toClear() {
|
|
|
+ let planid = _.get(this.options, 'planid');
|
|
|
+ if (planid) {
|
|
|
+ let res = this.planList.find(f => f.id == planid);
|
|
|
+ if (!res) this.$set(this.options, 'planid', undefined);
|
|
|
+ }
|
|
|
+ let termid = _.get(this.options, 'termid');
|
|
|
+ if (termid) {
|
|
|
+ let res = this.planList.find(f => f.id == planid);
|
|
|
+ if (!res) this.$set(this.options, 'termid', undefined);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async settingSave() {
|
|
|
+ let res = await this.sUpdate(this.options);
|
|
|
+ this.$checkRes(res, '设置成功', res.errmsg);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user', 'defaultOption']),
|
|
|
+ pageTitle() {
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.user-menu {
|
|
|
+ height: 4rem;
|
|
|
+ .el-col {
|
|
|
+ margin-left: 10px;
|
|
|
+ span {
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|