|
@@ -6,17 +6,35 @@
|
|
|
<el-button type="primary" size="mini" @click="downloadExcel">导出xlsx</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <excel-view ref="excelView" v-if="!loading" :plan="plan" :classTypeList="classTypeList" :schStuList="schStuList"
|
|
|
- :schoolList="schoolList" :placeList="placeList" :vacation="vacation" :year="plan.year"
|
|
|
- @planUpdate="planUpdate" :schPlan="schPlan"></excel-view>
|
|
|
- <div v-else v-loading="loading" style="height:85vh;width:100%" element-loading-text="加载中,请稍后..."
|
|
|
- element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)"></div>
|
|
|
+ <excel-view
|
|
|
+ ref="excelView"
|
|
|
+ v-if="!loading"
|
|
|
+ :plan="plan"
|
|
|
+ :classTypeList="classTypeList"
|
|
|
+ :schStuList="schStuList"
|
|
|
+ :schoolList="schoolList"
|
|
|
+ :placeList="placeList"
|
|
|
+ :vacation="vacation"
|
|
|
+ :year="plan.year"
|
|
|
+ @planUpdate="planUpdate"
|
|
|
+ :schPlan="schPlan"
|
|
|
+ :template="template"
|
|
|
+ @saveArrange="saveArrange"
|
|
|
+ ></excel-view>
|
|
|
+ <div
|
|
|
+ v-else
|
|
|
+ v-loading="loading"
|
|
|
+ style="height:85vh;width:100%"
|
|
|
+ element-loading-text="加载中,请稍后..."
|
|
|
+ element-loading-spinner="el-icon-loading"
|
|
|
+ element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
|
+ ></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import _ from 'lodash'
|
|
|
-import excelView from './school-arrange/excel-view.vue'
|
|
|
+import _ from 'lodash';
|
|
|
+import excelView from './school-arrange/excel-view.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
|
|
|
const { mapActions: classtype } = createNamespacedHelpers('classtype');
|
|
@@ -29,7 +47,7 @@ export default {
|
|
|
name: 'school-arrange',
|
|
|
props: {},
|
|
|
components: { excelView },
|
|
|
- data: function () {
|
|
|
+ data: function() {
|
|
|
return {
|
|
|
loading: true,
|
|
|
// 当前默认设置
|
|
@@ -49,7 +67,7 @@ export default {
|
|
|
/**假期列表(计划中的festivals整理出来的) */
|
|
|
vacation: [],
|
|
|
/**培训计划安排 */
|
|
|
- schPlan: []
|
|
|
+ schPlan: [],
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -74,52 +92,73 @@ export default {
|
|
|
async planUpdate({ data }) {
|
|
|
// 使用期数 查询是否有数据
|
|
|
const { term, ...others } = data;
|
|
|
- const plan = _.cloneDeep(this.plan)
|
|
|
- const termData = plan.termnum.find(f => f.term === term)
|
|
|
+ const plan = _.cloneDeep(this.plan);
|
|
|
+ const termData = plan.termnum.find(f => f.term === term);
|
|
|
if (termData) {
|
|
|
// 有期数
|
|
|
- const batchnum = _.get(termData, 'batchnum', [])
|
|
|
- const classnum = _.get(termData, 'classnum', 0)
|
|
|
- const batchData = batchnum.find(f => f.batch === others.batch)
|
|
|
+ const batchnum = _.get(termData, 'batchnum', []);
|
|
|
+ const classnum = _.get(termData, 'classnum', 0);
|
|
|
+ const batchData = batchnum.find(f => f.batch === others.batch);
|
|
|
if (batchData) {
|
|
|
// 有批次,修改
|
|
|
for (const key in others) {
|
|
|
- const val = others[key]
|
|
|
+ const val = others[key];
|
|
|
batchData[key] = val;
|
|
|
}
|
|
|
} else {
|
|
|
// 没有批次
|
|
|
- batchnum.push(others)
|
|
|
+ batchnum.push(others);
|
|
|
}
|
|
|
// 计算班级数
|
|
|
- termData.classnum = batchnum.reduce((p, n) => p + _.get(n, 'class', []).length, 0)
|
|
|
+ termData.classnum = batchnum.reduce((p, n) => p + _.get(n, 'class', []).length, 0);
|
|
|
} else {
|
|
|
// 没有该期数
|
|
|
const object = {
|
|
|
term,
|
|
|
classnum: _.get(others, 'class', []).length,
|
|
|
- batchnum: [others]
|
|
|
- }
|
|
|
+ batchnum: [others],
|
|
|
+ };
|
|
|
plan.termnum.push(object);
|
|
|
}
|
|
|
- const res = await this.tranPlanUpdate(plan)
|
|
|
+ const res = await this.tranPlanUpdate(plan);
|
|
|
if (this.$checkRes(res, '计划修改成功', res.errmsg)) {
|
|
|
this.loadData();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ async saveArrange({ data, schid }) {
|
|
|
+ const schPlanData = this.schPlan.find(f => f.schid === schid);
|
|
|
+ if (!schPlanData) {
|
|
|
+ this.$message.error('未找到学校安排数据');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_.get(data, '_id')) {
|
|
|
+ const index = schPlanData.arrange.findIndex(f => f._id === data._id);
|
|
|
+ if (index >= 0) schPlanData.arrange[index] = data;
|
|
|
+ } else {
|
|
|
+ const arrange = _.get(schPlanData, 'arrange', []);
|
|
|
+ arrange.push(data);
|
|
|
+ }
|
|
|
+ const schPlanDataIndex = this.schPlan.findIndex(f => f.schid === schid);
|
|
|
+ const cd = _.cloneDeep(this.schPlan);
|
|
|
+ cd[schPlanDataIndex] = schPlanData;
|
|
|
+ const res = await this.setSchPlan(cd);
|
|
|
+ if (this.$checkRes(res, '保存成功', res.errmsg)) {
|
|
|
+ this.loadData();
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
/**查询需要根据默认值重新加载的数据 */
|
|
|
async needResearchData() {
|
|
|
let planyearid = _.get(this.defaultOption, 'planyearid');
|
|
|
let planid = _.get(this.defaultOption, 'planid');
|
|
|
- // #region查询上传学生名单的学校
|
|
|
+ // #region查询上传学生名单的学校
|
|
|
let res = await this.getSchoolStudent({ planid });
|
|
|
if (this.$checkRes(res)) {
|
|
|
const { data } = res;
|
|
|
- console.group('schStuList')
|
|
|
- console.log(data)
|
|
|
- console.groupEnd()
|
|
|
+ console.group('schStuList');
|
|
|
+ console.log(data);
|
|
|
+ console.groupEnd();
|
|
|
this.$set(this, `schStuList`, data);
|
|
|
}
|
|
|
// #endregion
|
|
@@ -128,13 +167,13 @@ export default {
|
|
|
if (this.$checkRes(res)) {
|
|
|
const data = _.get(res, 'data');
|
|
|
if (data) {
|
|
|
- let termnum = _.get(data, 'termnum', [])
|
|
|
+ let termnum = _.get(data, 'termnum', []);
|
|
|
termnum = _.orderBy(termnum, ['term'], ['asc']);
|
|
|
data.termnum = termnum;
|
|
|
- console.group('plan')
|
|
|
- console.log(data)
|
|
|
+ console.group('plan');
|
|
|
+ console.log(data);
|
|
|
console.groupEnd();
|
|
|
- this.$set(this, 'plan', data)
|
|
|
+ this.$set(this, 'plan', data);
|
|
|
// 假期
|
|
|
let fest = _.get(res.data, 'festivals', []);
|
|
|
let vac = fest.map(i => {
|
|
@@ -151,28 +190,28 @@ export default {
|
|
|
this.$set(this, `vacation`, vac);
|
|
|
// TODO:原逻辑需要处理批次列表
|
|
|
// 可以处理学校,分配人数的学校也在年度计划中存着,可以拿出来换学校名称
|
|
|
- const needStudentSchool = _.get(data, 'school', [])
|
|
|
+ const needStudentSchool = _.get(data, 'school', []);
|
|
|
let schoolList = [];
|
|
|
if (needStudentSchool.length > 0) {
|
|
|
- const schoolCodes = needStudentSchool.map(i => i.code)
|
|
|
- const schoolListResult = await this.findByCodes({ code: schoolCodes })
|
|
|
+ const schoolCodes = needStudentSchool.map(i => i.code);
|
|
|
+ const schoolListResult = await this.findByCodes({ code: schoolCodes });
|
|
|
if (this.$checkRes(schoolListResult)) {
|
|
|
// 组成数据,将查询出来的学校 和 需要学校各类型班级的人数带上
|
|
|
- schoolList = _.get(schoolListResult, 'data', [])
|
|
|
+ schoolList = _.get(schoolListResult, 'data', []);
|
|
|
schoolList = schoolList.map(i => {
|
|
|
- const r = needStudentSchool.find(f => f.code === i.code)
|
|
|
+ const r = needStudentSchool.find(f => f.code === i.code);
|
|
|
if (r) {
|
|
|
- i.classnum = _.get(r, 'classnum', [])
|
|
|
+ i.classnum = _.get(r, 'classnum', []);
|
|
|
}
|
|
|
return i;
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
// TODO:查询出学校不能参培的时间,要禁止该时间段的操作
|
|
|
|
|
|
- console.group('schoolList')
|
|
|
- console.log(schoolList)
|
|
|
- console.groupEnd()
|
|
|
- this.$set(this, 'schoolList', schoolList)
|
|
|
+ console.group('schoolList');
|
|
|
+ console.log(schoolList);
|
|
|
+ console.groupEnd();
|
|
|
+ this.$set(this, 'schoolList', schoolList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -180,31 +219,30 @@ export default {
|
|
|
// #region 获取计划模板
|
|
|
res = await this.modelFetch({ model: 'trainmodel', planyearid, planid });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- console.group('template')
|
|
|
- console.log(res.data)
|
|
|
- console.groupEnd()
|
|
|
+ console.group('template');
|
|
|
+ console.log(res.data);
|
|
|
+ console.groupEnd();
|
|
|
this.$set(this, `template`, _.get(res, 'data', {}));
|
|
|
}
|
|
|
// #endregion
|
|
|
res = await this.schPlanQuery({ planid });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- console.group('arrange')
|
|
|
- console.log(res.data)
|
|
|
- console.groupEnd()
|
|
|
- this.$set(this, 'schPlan', res.data)
|
|
|
+ console.group('arrange');
|
|
|
+ console.log(res.data);
|
|
|
+ console.groupEnd();
|
|
|
+ this.$set(this, 'schPlan', res.data);
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
/**查询不需要重载的字典数据 */
|
|
|
async getOtherList() {
|
|
|
let res = await this.getClassType();
|
|
|
if (this.$checkRes(res)) {
|
|
|
- console.group('classTypeList')
|
|
|
- console.log(res.data)
|
|
|
- console.groupEnd()
|
|
|
+ console.group('classTypeList');
|
|
|
+ console.log(res.data);
|
|
|
+ console.groupEnd();
|
|
|
this.$set(this, `classTypeList`, res.data);
|
|
|
}
|
|
|
- res = await this.getLocation({ type: '4' })
|
|
|
+ res = await this.getLocation({ type: '4' });
|
|
|
if (this.$checkRes(res)) {
|
|
|
// 为每个地点随机生成颜色
|
|
|
let list = res.data;
|
|
@@ -219,10 +257,10 @@ export default {
|
|
|
},
|
|
|
async loadData() {
|
|
|
try {
|
|
|
- this.loading = true
|
|
|
- await this.needResearchData()
|
|
|
+ this.loading = true;
|
|
|
+ await this.needResearchData();
|
|
|
} catch (error) {
|
|
|
- console.error(error)
|
|
|
+ console.error(error);
|
|
|
} finally {
|
|
|
this.loading = false;
|
|
|
}
|