Commit 549cd80dfcb226e544cae5fb3cf1331d1417b046

Authored by 陈鑫涛
2 parents 74147346 52991fcc

Merge branch 'main' of http://git.xlyprint.cn/zhangz/xlyUmi into main

src/components/Common/CommonProductionPlanTreeEvent.js
... ... @@ -657,32 +657,58 @@ export default (ChildComponent) => {
657 657 this.props.onRemovePane(panes, currentPane);
658 658 };
659 659  
  660 + handleEndDate = (dateStr, hoursToAdd = 0) => {
  661 + const date = moment(dateStr, "YYYY-MM-DD HH:mm:ss");
  662 + if (hoursToAdd) {
  663 + date.add(hoursToAdd, 'hours');
  664 + }
  665 + return date.format("YYYY-MM-DD HH:mm");
  666 + }
  667 +
660 668 /** 表格数据更改 */
661 669 // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
662 670 handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
663   - const { sModelsId } = this.props;
664   - this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, false);
665   - if (name === 'slave') {
666   - commonUtils.setStoreDropDownData(sModelsId, 'master', 'sTeamId', []);
667   - if (sFieldName === 'iOrder') {
668   - /* 修改汇总表数据后,slaveInfo表iOrder同步更改 */
669   - const { slaveInfoData, slaveData } = this.props;
670   - const iIndex = slaveData.findIndex(item => item.sId === sId);
671   - if (iIndex > -1) {
672   - const tableDataRow = slaveData[iIndex];
673   - let childrenData = [];
674   - childrenData = tableDataRow.childrenData;
675   - if (commonUtils.isNotEmptyArr(childrenData)) {
676   - childrenData.forEach((child) => {
677   - const index = slaveInfoData.findIndex(item => item.sId === child.sId);
678   - const addState = {};
679   - addState.handleType = 'update';
680   - addState.iOrder = tableDataRow.iOrder;
681   - if (index > -1) {
682   - slaveInfoData[index] = { ...slaveInfoData[index], ...addState }
683   - }
684   - });
685   - this.props.onSaveState({ slaveData, slaveInfoData });
  671 + const { sModelsId , [`${name}Data`]: tableData, } = this.props;
  672 + if(sFieldName === 'dCalcHourTz1') {
  673 + let tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
  674 +
  675 + // 计算总小时数 = (dCalcHourTz1 或 dCalcHour1) + dHour(四舍五入到分钟)
  676 + const dHourInMinutes = Math.round((tableDataRow.dHour || 0) * 60); // 将小时转换为分钟并四舍五入
  677 + const dHourInHours = dHourInMinutes / 60; // 转换回小时,保留两位小数
  678 + const hoursToAdd = (tableDataRow.dCalcHourTz1 !== undefined ? tableDataRow.dCalcHourTz1 : tableDataRow.dCalcHour1) + dHourInHours;
  679 +
  680 + const tEndDate = this.handleEndDate(tableDataRow.tStartDate, hoursToAdd);
  681 +
  682 + console.log('总小时数:', hoursToAdd);
  683 + console.log('结束时间:', tEndDate);
  684 + tableDataRow.tEndDate = tEndDate;
  685 + const iIndex = tableData.findIndex(item => item.sId === sId);
  686 + tableData[iIndex] = tableDataRow;
  687 + this.props.onSaveState({ slaveData: tableData });
  688 + } else {
  689 + this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, false);
  690 + if (name === 'slave') {
  691 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sTeamId', []);
  692 + if (sFieldName === 'iOrder') {
  693 + /* 修改汇总表数据后,slaveInfo表iOrder同步更改 */
  694 + const { slaveInfoData, slaveData } = this.props;
  695 + const iIndex = slaveData.findIndex(item => item.sId === sId);
  696 + if (iIndex > -1) {
  697 + const tableDataRow = slaveData[iIndex];
  698 + let childrenData = [];
  699 + childrenData = tableDataRow.childrenData;
  700 + if (commonUtils.isNotEmptyArr(childrenData)) {
  701 + childrenData.forEach((child) => {
  702 + const index = slaveInfoData.findIndex(item => item.sId === child.sId);
  703 + const addState = {};
  704 + addState.handleType = 'update';
  705 + addState.iOrder = tableDataRow.iOrder;
  706 + if (index > -1) {
  707 + slaveInfoData[index] = { ...slaveInfoData[index], ...addState }
  708 + }
  709 + });
  710 + this.props.onSaveState({ slaveData, slaveInfoData });
  711 + }
686 712 }
687 713 }
688 714 }
... ...