Commit 7ad9ce4f authored by tianhongyang's avatar tianhongyang

merge

parent 66510cec
......@@ -230,6 +230,9 @@ export default {
console.log(error);
}
},
getNowMonth() {
return dayjs(new Date().valueOf()).format("YYYYMM");
},
createRequestConditions() {
const { projectId, cbStage } = this.comProjectDetailInfo;
const params = {
......@@ -238,7 +241,7 @@ export default {
};
params["cbSubjectName"] = this.currentNodeName;
// 判断当月是否存在于server返回month集合中
const _now = dayjs(new Date().valueOf()).format("YYYYMM");
const _now = this.getNowMonth();
if (this.includeNowMonth(_now)) {
params["recordDate"] = _now;
}
......@@ -264,7 +267,7 @@ export default {
if (list.code == 200 && list.data instanceof Array) {
const _temp = list.data;
// 计算总和
if (this.hasTarget) {
if (this.hasTarget && _temp.length) {
const row = this.countRowParams(_temp, statisticsPropNames);
_temp.unshift(row);
}
......@@ -324,7 +327,7 @@ export default {
if (monthList.code == 200 && monthList.data instanceof Array) {
const data = monthList.data;
this.originMonthList = cloneDeep(data);
const _now = dayjs(new Date().valueOf()).format("YYYYMM");
const _now = this.getNowMonth();
this.recordDate = _now;
this.oldRecordDate = _now;
// 默认以当前月数据为准 若不包含当前月 需要手动push数据
......@@ -332,9 +335,7 @@ export default {
data.push(_now);
}
// 年月排序
let _tempMonthList = data.sort((before, after) => {
return parseInt(after) - parseInt(before);
});
let _tempMonthList = this.monthsSort(data);
_tempMonthList = _tempMonthList.map(item => {
return {
label: dayjs(item).format("YYYY年MM月"),
......@@ -347,23 +348,31 @@ export default {
}
},
monthsSort(monthList) {
const sortResult = monthList.sort((before, after) => {
const _before = Object.prototype.toString.call(before) == "[object Object]" ? before["value"] : before;
const _after = Object.prototype.toString.call(before) == "[object Object]" ? after["value"] : after;
return parseInt(_after) - parseInt(_before);
});
return sortResult;
},
monthChange(month) {
this.resetEditStatus();
// 当前月
const _now = dayjs(new Date().valueOf()).format("YYYYMM");
const _now = this.getNowMonth();
// 请求列表参数
const params = this.createRequestConditions();
// 清空了年月默认选中当前月
if (!month) {
this.recordDate = _now;
// 如果命中的旧月份 等于当前月 说明清空的是当前月 不调用接口
if (this.oldRecordDate == _now) return;
// 如果命中的旧月份 等于当前月 且 不处于编辑状态 说明清空的是当前月 不调用接口
if (this.oldRecordDate == _now && !this.addActualCostEditStatus) return;
} else {
// 正常选择
params["recordDate"] = month;
// 记录历史切换年月
this.oldRecordDate = month;
}
this.resetEditStatus();
// 获取列表数据
this.getFeedSummaryList(params);
},
......@@ -396,27 +405,46 @@ export default {
fillActualCost() {
this.showAddActualCost = true;
},
// 编辑状态下 进行了其它操作
resetEditStatus() {
// 当前需要编辑或者新增的成本年份
const _selectActualCostTime = this.selectActualCostTime;
this.addActualCostEditStatus = false;
this.selectActualCostTime = "";
/**
* 判断 当前需要编辑 或者新增的成本年份是否存在于server返回的month数组中
* 默认本月
*/
if (!this.originMonthList.includes(_selectActualCostTime) && _selectActualCostTime != this.getNowMonth()) {
const index = this.monthList.findIndex(item => item.value == _selectActualCostTime);
if (index != -1) {
this.monthList.splice(index, 1);
}
}
},
async timeSelect(selectTime) {
// 编辑状态
this.addActualCostEditStatus = true;
this.selectActualCostTime = selectTime;
// 判断是否包含 选择的年月 包含则修改 未包含则新增
const findReslut = this.originMonthList.includes(selectTime);
// 包含所选月
if (findReslut) {
this.recordDate = selectTime;
const params = this.createRequestConditions();
params["recordDate"] = selectTime;
// 获取选中月数据
await this.getFeedSummaryList(params);
} else {
const findReslut = this.originMonthList.includes(selectTime) || this.monthList.find(item => item.value == selectTime);
const params = this.createRequestConditions();
if (!findReslut) {
// 不包含当前所选月 新增数据
let _temp = JSON.parse(JSON.stringify(this.monthList));
_temp.push({
label: dayjs(selectTime).format("YYYY年MM月"),
value: selectTime
});
_temp = this.monthsSort(_temp);
console.log(_temp);
this.monthList = _temp;
}
this.recordDate = selectTime;
this.oldRecordDate = selectTime;
params["recordDate"] = selectTime;
// 获取选中月数据
await this.getFeedSummaryList(params);
}
},
}
......
......@@ -6,7 +6,8 @@
<div class="project-detail-header-name">{{comDetailInfo.projectName ? comDetailInfo.projectName : "-"}}</div>
<!-- 项目信息 -->
<div class="project-detail-plate">
<div class="detail-plate-item project-code" v-if="isShowProjectCode.includes(current)">
<div class="detail-plate-item project-code">
<!-- <div class="detail-plate-item project-code" v-if="isShowProjectCode.includes(current)"> -->
<span class="plate-item-name">项目编码:</span>
<span>{{comDetailInfo.ipmProjectNo ? comDetailInfo.ipmProjectNo : "-"}}</span>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment