Commit 346801f5 authored by tyn's avatar tyn

成本汇总 工料汇总 滚动逻辑优化,节流

parent 2e8bda49
...@@ -219,6 +219,8 @@ export default { ...@@ -219,6 +219,8 @@ export default {
{ trigger: ["change"], validator: amountCheckValidator } { trigger: ["change"], validator: amountCheckValidator }
] ]
}, },
// 竖向滚动条最后的位置
lastScrollTop: 0
}; };
}, },
//可访问data属性 //可访问data属性
...@@ -251,7 +253,7 @@ export default { ...@@ -251,7 +253,7 @@ export default {
}, },
// 返回当前月是否在server month集合中 // 返回当前月是否在server month集合中
includeNowMonth(time) { includeNowMonth(time) {
return this.originMonthList.includes(time); return this.originMonthList.find(item => item.expenseDate == time);
}, },
// 按项目汇总 按成本科目汇总 // 按项目汇总 按成本科目汇总
currentCategoryChange(category) { currentCategoryChange(category) {
...@@ -261,9 +263,9 @@ export default { ...@@ -261,9 +263,9 @@ export default {
this.tableLoading = true; this.tableLoading = true;
this.init(this.comProjectDetailInfo); this.init(this.comProjectDetailInfo);
}, },
async init(detail = {}, resetDate = "") { async init(detail = {}, resetDate = "", saveReset = false) {
try { try {
this.resetEditStatus(); this.resetEditStatus(saveReset);
const { projectId, cbStage } = detail; const { projectId, cbStage } = detail;
if (!projectId) return; if (!projectId) return;
const params = { const params = {
...@@ -272,22 +274,22 @@ export default { ...@@ -272,22 +274,22 @@ export default {
cbType: this.currentCategory cbType: this.currentCategory
}; };
await this.getCostSummaryMenuTree(params); await this.getCostSummaryMenuTree(params);
await this.getCostSummaryMonthList(params); await this.getCostSummaryMonthList(params, saveReset);
await this.getLockMonthList(params); await this.getLockMonthList(params);
await this.initDefaultSetting(resetDate); await this.initDefaultSetting(resetDate, saveReset);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally { } finally {
this.tableLoading = false; this.tableLoading = false;
} }
}, },
async initDefaultSetting(resetDate = "") { async initDefaultSetting(resetDate = "", saveReset = false) {
try { try {
await this.$nextTick(); await this.$nextTick();
const first = this.$refs["projectSideMenu"].getFirstLevelWithDeepId(); const first = saveReset ? this.currentNodeValue : this.$refs["projectSideMenu"].getFirstLevelWithDeepId();
const menus = this.$refs["projectSideMenu"].getResultMenuList(); const menus = this.$refs["projectSideMenu"].getResultMenuList();
const defaultCurrent = this.findMenuNode(menus, first); const defaultCurrent = this.findMenuNode(menus, first);
// 默认选中结构劳务分包 // 默认选中第一层级 第一个子菜单
if (defaultCurrent) { if (defaultCurrent) {
this.currentNodeValue = defaultCurrent.nodeValue; this.currentNodeValue = defaultCurrent.nodeValue;
const parentId = defaultCurrent.parent ? this.getCurrentType(defaultCurrent.parent) : defaultCurrent.nodeName; const parentId = defaultCurrent.parent ? this.getCurrentType(defaultCurrent.parent) : defaultCurrent.nodeName;
...@@ -350,14 +352,14 @@ export default { ...@@ -350,14 +352,14 @@ export default {
} }
}, },
async getCostSummaryMonthList(params) { async getCostSummaryMonthList(params, saveReset = false) {
try { try {
const monthList = await getCostSummaryMonthListApi(params); const monthList = await getCostSummaryMonthListApi(params);
if (monthList.code == 200 && monthList.data instanceof Array) { if (monthList.code == 200 && monthList.data instanceof Array) {
const data = monthList.data; const data = monthList.data;
this.originMonthList = cloneDeep(data); this.originMonthList = cloneDeep(data);
const _now = this.getNowMonth(); const _now = this.getNowMonth();
this.expenseDate = _now; this.expenseDate = saveReset ? this.expenseDate : _now;
// 默认以当前月数据为准 若不包含当前月 需要手动push数据 // 默认以当前月数据为准 若不包含当前月 需要手动push数据
if (!data.includes(_now)) { if (!data.includes(_now)) {
data.push({ data.push({
...@@ -543,7 +545,7 @@ export default { ...@@ -543,7 +545,7 @@ export default {
} }
}, },
// 编辑状态下 进行了其它操作 // 编辑状态下 进行了其它操作
resetEditStatus() { resetEditStatus(saveReset = false) {
// 当前需要编辑或者新增的成本年份 // 当前需要编辑或者新增的成本年份
const _selectActualCostTime = this.selectActualCostTime; const _selectActualCostTime = this.selectActualCostTime;
this.editCostMonthSelectDialog = false; this.editCostMonthSelectDialog = false;
...@@ -554,9 +556,9 @@ export default { ...@@ -554,9 +556,9 @@ export default {
* 默认本月 * 默认本月
*/ */
if (!_selectActualCostTime) return; if (!_selectActualCostTime) return;
if (!this.originMonthList.includes(_selectActualCostTime) && _selectActualCostTime != this.getNowMonth()) { if (!this.originMonthList.find(item => item.expenseDate == _selectActualCostTime) && _selectActualCostTime != this.getNowMonth()) {
const index = this.monthList.findIndex(item => item.expenseDate == _selectActualCostTime); const index = this.monthList.findIndex(item => item.expenseDate == _selectActualCostTime);
if (index != -1) { if (index != -1 && !saveReset) {
this.monthList.splice(index, 1); this.monthList.splice(index, 1);
this.expenseDate = this.getNowMonth(); this.expenseDate = this.getNowMonth();
} }
...@@ -651,7 +653,7 @@ export default { ...@@ -651,7 +653,7 @@ export default {
this.addActualCostEditStatus = true; this.addActualCostEditStatus = true;
this.selectActualCostTime = selectTime; this.selectActualCostTime = selectTime;
// 判断是否包含 选择的年月 包含则修改 未包含则新增 // 判断是否包含 选择的年月 包含则修改 未包含则新增
const findReslut = this.originMonthList.includes(selectTime) || this.monthList.find(item => item.value == selectTime); const findReslut = this.originMonthList.includes(selectTime) || this.monthList.find(item => item.expenseDate == selectTime);
const params = this.createRequestConditions(); const params = this.createRequestConditions();
if (!findReslut) { if (!findReslut) {
// 不包含当前所选月 新增数据 // 不包含当前所选月 新增数据
...@@ -686,8 +688,9 @@ export default { ...@@ -686,8 +688,9 @@ export default {
container.scrollTo({ container.scrollTo({
behavior: "smooth", behavior: "smooth",
left, left,
top: 0 top: this.lastScrollTop
}); });
this.lastScrollTop = 0;
} }
}, },
// 成本输入数据限制 // 成本输入数据限制
...@@ -703,14 +706,32 @@ export default { ...@@ -703,14 +706,32 @@ export default {
if (flag) { if (flag) {
// 进行差异化对比 // 进行差异化对比
let resultData = this.differentCompare(); let resultData = this.differentCompare();
console.log(resultData);
// 没有差异 // 没有差异
if (!resultData.length) { if (!resultData.length) {
this.resetEditStatus();
const params = this.createRequestConditions(this.expenseDate);
await this.getCostSummaryList(params);
return;
}
// 有差异数据 记录滚动条滚动位置
await this.getLastScrollTop();
const result = await saveCostModifyApi(resultData);
if (result.code == 200) {
this.$message.success("保存成功");
await this.init(this.comProjectDetailInfo, this.expenseDate, true);
await this.$nextTick();
await this.editRegionToViewPort();
} }
} }
}); });
}, },
//获取竖向滚动条最后的位置
async getLastScrollTop() {
const table = document.querySelector(".custom-table .el-table__body-wrapper");
if (table) {
this.lastScrollTop = table.scrollTop;
}
},
// 差异化比对 // 差异化比对
differentCompare() { differentCompare() {
const originData = this.originTableDataList; const originData = this.originTableDataList;
......
...@@ -258,6 +258,7 @@ export default { ...@@ -258,6 +258,7 @@ export default {
addActualCostEditStatus: false, addActualCostEditStatus: false,
// 当前选择的成本年份 // 当前选择的成本年份
selectActualCostTime: "", selectActualCostTime: "",
lastScrollTop: 0,
// 推送工程量弹窗 // 推送工程量弹窗
pushProjectUseDialog: false, pushProjectUseDialog: false,
// 推送工程量数据缓存 // 推送工程量数据缓存
...@@ -302,9 +303,9 @@ export default { ...@@ -302,9 +303,9 @@ export default {
}, },
//方法集 //方法集
methods: { methods: {
async init(detail = {}, resetDate = "") { async init(detail = {}, resetDate = "", saveReset = false) {
try { try {
this.resetEditStatus(); this.resetEditStatus(saveReset);
const { projectId, cbStage } = detail; const { projectId, cbStage } = detail;
if (!projectId) return; if (!projectId) return;
const params = { const params = {
...@@ -312,19 +313,19 @@ export default { ...@@ -312,19 +313,19 @@ export default {
cbStage cbStage
}; };
await this.getFeedSummaryMenuTree(params); await this.getFeedSummaryMenuTree(params);
await this.getFeedSummaryMonthList(params); await this.getFeedSummaryMonthList(params, saveReset);
await this.initDefaultSetting(resetDate); await this.initDefaultSetting(resetDate, saveReset);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally { } finally {
this.tableLoading = false; this.tableLoading = false;
} }
}, },
async initDefaultSetting(resetDate = "") { async initDefaultSetting(resetDate = "", saveReset = false) {
try { try {
await this.$nextTick(); await this.$nextTick();
const menus = this.$refs["projectSideMenu"].getResultMenuList(); const menus = this.$refs["projectSideMenu"].getResultMenuList();
const defaultCurrent = this.findMenuNode(menus, "结构劳务分包"); const defaultCurrent = this.findMenuNode(menus, saveReset ? this.currentNodeName : "结构劳务分包");
// 默认选中结构劳务分包 // 默认选中结构劳务分包
if (defaultCurrent) { if (defaultCurrent) {
this.currentNodeName = defaultCurrent.nodeName; this.currentNodeName = defaultCurrent.nodeName;
...@@ -427,14 +428,14 @@ export default { ...@@ -427,14 +428,14 @@ export default {
} }
}, },
async getFeedSummaryMonthList(params) { async getFeedSummaryMonthList(params, saveReset = false) {
try { try {
const monthList = await getFeedSummaryMonthListApi(params); const monthList = await getFeedSummaryMonthListApi(params);
if (monthList.code == 200 && monthList.data instanceof Array) { if (monthList.code == 200 && monthList.data instanceof Array) {
const data = monthList.data; const data = monthList.data;
this.originMonthList = cloneDeep(data); this.originMonthList = cloneDeep(data);
const _now = this.getNowMonth(); const _now = this.getNowMonth();
this.recordDate = _now; this.recordDate = saveReset ? this.recordDate : _now;
// this.oldRecordDate = _now; // this.oldRecordDate = _now;
// 默认以当前月数据为准 若不包含当前月 需要手动push数据 // 默认以当前月数据为准 若不包含当前月 需要手动push数据
if (!data.includes(_now)) { if (!data.includes(_now)) {
...@@ -652,16 +653,25 @@ export default { ...@@ -652,16 +653,25 @@ export default {
recordDate: this.recordDate recordDate: this.recordDate
}; };
}); });
// 有差异数据 记录滚动条滚动位置
await this.getLastScrollTop();
const result = await updateFeedSummaryRowsApi(resultData); const result = await updateFeedSummaryRowsApi(resultData);
if (result.code == 200) { if (result.code == 200) {
this.$message.success("保存成功"); this.$message.success("保存成功");
await this.init(this.comProjectDetailInfo, this.selectActualCostTime); await this.init(this.comProjectDetailInfo, this.recordDate, true);
await this.$nextTick(); await this.$nextTick();
await this.editRegionToViewPort(); await this.editRegionToViewPort();
} }
} }
}); });
}, },
//获取竖向滚动条最后的位置
async getLastScrollTop() {
const table = document.querySelector(".custom-table .el-table__body-wrapper");
if (table) {
this.lastScrollTop = table.scrollTop;
}
},
// 推送工程用量 // 推送工程用量
pushProjectUse(row) { pushProjectUse(row) {
if (!row.id) return; if (!row.id) return;
...@@ -702,7 +712,7 @@ export default { ...@@ -702,7 +712,7 @@ export default {
return cloneDeep(different); return cloneDeep(different);
}, },
// 编辑状态下 进行了其它操作 // 编辑状态下 进行了其它操作
resetEditStatus() { resetEditStatus(saveReset = false) {
// 当前需要编辑或者新增的成本年份 // 当前需要编辑或者新增的成本年份
const _selectActualCostTime = this.selectActualCostTime; const _selectActualCostTime = this.selectActualCostTime;
this.addActualCostEditStatus = false; this.addActualCostEditStatus = false;
...@@ -714,7 +724,7 @@ export default { ...@@ -714,7 +724,7 @@ export default {
if (!_selectActualCostTime) return; if (!_selectActualCostTime) return;
if (!this.originMonthList.includes(_selectActualCostTime) && _selectActualCostTime != this.getNowMonth()) { if (!this.originMonthList.includes(_selectActualCostTime) && _selectActualCostTime != this.getNowMonth()) {
const index = this.monthList.findIndex(item => item.value == _selectActualCostTime); const index = this.monthList.findIndex(item => item.value == _selectActualCostTime);
if (index != -1) { if (index != -1 && !saveReset) {
this.monthList.splice(index, 1); this.monthList.splice(index, 1);
this.recordDate = this.getNowMonth(); this.recordDate = this.getNowMonth();
} }
...@@ -764,8 +774,9 @@ export default { ...@@ -764,8 +774,9 @@ export default {
container.scrollTo({ container.scrollTo({
behavior: "smooth", behavior: "smooth",
left, left,
top: 0 top: this.lastScrollTop
}); });
this.lastScrollTop = 0;
} }
}, },
cellClassName({ row, column, rowIndex, columnIndex }) { cellClassName({ row, column, rowIndex, columnIndex }) {
......
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