Commit cd59ff1268d51f959a39fae3fa07c5de842ac4ad

Authored by Min
1 parent 3d008fd4

1.排程超能力要先对数据进行移动

src/components/Common/CommonProductionPlanTreeEvent.js
@@ -10,7 +10,8 @@ import * as commonUtils from '../../utils/utils'; /* 通用方法 */ @@ -10,7 +10,8 @@ import * as commonUtils from '../../utils/utils'; /* 通用方法 */
10 import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */ 10 import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
11 import * as commonServices from '../../services/services'; /* 服务类 */ 11 import * as commonServices from '../../services/services'; /* 服务类 */
12 import commonConfig from '../../utils/config'; 12 import commonConfig from '../../utils/config';
13 -import * as commonFunc from './commonFunc'; /* 通用单据方法 */ 13 +import * as commonFunc from './commonFunc';
  14 +import moment from "moment/moment"; /* 通用单据方法 */
14 15
15 export default (ChildComponent) => { 16 export default (ChildComponent) => {
16 return class extends Component { 17 return class extends Component {
@@ -516,7 +517,7 @@ export default (ChildComponent) => { @@ -516,7 +517,7 @@ export default (ChildComponent) => {
516 }; 517 };
517 518
518 /** 保存校验 */ 519 /** 保存校验 */
519 - handleValidateSave = (bFresh) => { 520 + handleValidateSave = (bFresh, slaveNewData) => {
520 this.form.validateFields((err) => { 521 this.form.validateFields((err) => {
521 /* 验证通过与不通过走不同的流程 */ 522 /* 验证通过与不通过走不同的流程 */
522 if (err) { /* 验证失败 */ 523 if (err) { /* 验证失败 */
@@ -526,8 +527,13 @@ export default (ChildComponent) => { @@ -526,8 +527,13 @@ export default (ChildComponent) => {
526 } 527 }
527 } else { /* 验证成功 */ 528 } else { /* 验证成功 */
528 const { 529 const {
529 - slaveConfig, slaveData, slaveDelData, app, productionPlanDelData, tableBtnEnabled, charGanttData, bGantt, 530 + slaveConfig, slaveDelData, app, productionPlanDelData, tableBtnEnabled, charGanttData, bGantt,
530 } = this.props; 531 } = this.props;
  532 + let { slaveData = [] } = this.props;
  533 + if(commonUtils.isNotEmptyArr(slaveNewData) && Array.isArray(slaveNewData)) {
  534 + slaveData = slaveNewData;
  535 + }
  536 +
531 const data = []; 537 const data = [];
532 if (commonUtils.isEmptyArr(slaveData)) { 538 if (commonUtils.isEmptyArr(slaveData)) {
533 message.error(commonFunc.showMessage(app.commonConst, 'slaveNotNull')); // 从表不能为空! 539 message.error(commonFunc.showMessage(app.commonConst, 'slaveNotNull')); // 从表不能为空!
@@ -573,7 +579,7 @@ export default (ChildComponent) => { @@ -573,7 +579,7 @@ export default (ChildComponent) => {
573 for (const item of slaveData) { 579 for (const item of slaveData) {
574 const { 580 const {
575 sSlaveId, handleType, iOrder, tStartDate, sMemo, dAdjustHour, sDivRowNew, sDivRow,bEmploy, sDivRowTmp, sDivRowGroupBy, sAPSCodeDirection, dQty2, 581 sSlaveId, handleType, iOrder, tStartDate, sMemo, dAdjustHour, sDivRowNew, sDivRow,bEmploy, sDivRowTmp, sDivRowGroupBy, sAPSCodeDirection, dQty2,
576 - dProcessfeesendQty, sMachineId, dCalcHourTz1, dTxHour, tCutDate, dFirstQty, 582 + dProcessfeesendQty, sMachineId, dCalcHourTz1, dTxHour, tCutDate, dFirstQty, sSrcNo,
577 } = item; 583 } = item;
578 if (commonUtils.isEmptyObject(sDivRowNew)) { 584 if (commonUtils.isEmptyObject(sDivRowNew)) {
579 const sIds = sSlaveId.split('-'); 585 const sIds = sSlaveId.split('-');
@@ -598,6 +604,7 @@ export default (ChildComponent) => { @@ -598,6 +604,7 @@ export default (ChildComponent) => {
598 // addState.dAdjustHour = dAdjustHour; 604 // addState.dAdjustHour = dAdjustHour;
599 // } 605 // }
600 addState.sMemo = sMemo; 606 addState.sMemo = sMemo;
  607 + addState.sSrcNo = sSrcNo;
601 addState.dAdjustHour = dAdjustHour; 608 addState.dAdjustHour = dAdjustHour;
602 addState.dCalcHourTz1 = dCalcHourTz1; 609 addState.dCalcHourTz1 = dCalcHourTz1;
603 addState.handleType = handleType; 610 addState.handleType = handleType;
@@ -1294,31 +1301,197 @@ export default (ChildComponent) => { @@ -1294,31 +1301,197 @@ export default (ChildComponent) => {
1294 } 1301 }
1295 }; 1302 };
1296 1303
  1304 + /* 自定义排序号 */
  1305 + orderNum = (tableData) => {
  1306 + const {slaveColumn} = this.props;
  1307 + tableData.forEach((item, index) => {
  1308 + item.iOrder = index + 1;
  1309 + item.handleType = 'update';
  1310 + });
  1311 + /* 移动后 重新计算分割间隔条数及用时逻辑 */
  1312 + const returnFilterData = tableData.filter(item => commonUtils.isNotEmptyObject(item.sDivRowNew) && item.sDivRowNew !=='');
  1313 + if (commonUtils.isNotEmptyArr(returnFilterData)) {
  1314 + returnFilterData.forEach((tableDataRow, index) => {
  1315 + /* 找到白班与晚班区间的汇总条数与工时 */
  1316 + let startIndex = 0; /* 找到开始下标 */
  1317 + let endindex = 0; /* 找到结束下标 */
  1318 + let sliceData =[];
  1319 + startIndex = tableData.findIndex(item => item.sId === returnFilterData[index].sId);
  1320 + if(index +1 < returnFilterData.length) {
  1321 + endindex = tableData.findIndex(item => item.sId === returnFilterData[index + 1].sId);
  1322 + }
  1323 + if(index === returnFilterData.length -1) {
  1324 + endindex = tableData.length;
  1325 + }
  1326 + if(startIndex < endindex) {
  1327 + sliceData= tableData.slice(startIndex + 1, endindex);
  1328 + }
  1329 + let num = 0;
  1330 + let dTime = 0;
  1331 + let dPlateQty = 0; /* 付版 */
  1332 + let dProcessQty = 0;
  1333 + let endTime;
  1334 + /* 找到第二个字段 */
  1335 + const scheduleShow = ['16508090850002295893127095467000'].includes(this.props?.sModelsId);
  1336 + let timeSName = 'dHour1';
  1337 + if (scheduleShow) timeSName = 'dSumHour';
  1338 + if(commonUtils.isNotEmptyArr(sliceData)) {
  1339 + num = sliceData.length;
  1340 + sliceData.forEach((item) => {
  1341 + if (commonUtils.isNotEmptyNumber(item[timeSName])) {
  1342 + dTime += item[timeSName];
  1343 + dPlateQty += item.dPlateQty;
  1344 + dProcessQty += item.dProcessQty;
  1345 + if (item?.tEndDate) {
  1346 + let value = item.tEndDate;
  1347 + if (endTime) {
  1348 + value = moment.max(moment(endTime), moment(item.tEndDate));
  1349 + }
  1350 + endTime = value;
  1351 + }
  1352 + const iSrcIndex = tableData.findIndex(itemReturn => itemReturn.sSlaveId === item.sSlaveId); /* 汇总的每行上都加newRow的sSlaveId作为父级Id */
  1353 + if(iSrcIndex > -1) {
  1354 + tableData[iSrcIndex] = {...tableData[iSrcIndex], sDivRowParentId : tableDataRow.sSlaveId, sDivRowTmp : tableDataRow.sDivRowNew}
  1355 + }
  1356 + }
  1357 + });
  1358 + let sCount = '';
  1359 + if(num > 0) {
  1360 + sCount += 'F'+ num + '单';
  1361 + }
  1362 + if(dProcessQty > 0) {
  1363 + sCount += ' - '+ dProcessQty;
  1364 + }
  1365 + if(sliceData[0].sType === "1" && !scheduleShow) {
  1366 + sCount += ' - ' + dPlateQty +'付版';
  1367 + }
  1368 + if(dTime > 0) {
  1369 + if (scheduleShow) {
  1370 + sCount += ' - ' + Math.floor(dTime / 24) + "d" + (dTime % 24).toFixed(2) + 'h';
  1371 + } else {
  1372 + sCount += ' - ' + (dTime/60).toFixed(2) + 'h';
  1373 + };
  1374 +
  1375 + }
  1376 + if (endTime) {
  1377 + sCount += ' - ' + moment(endTime).format('MM月DD日');
  1378 + }
  1379 + const sFileName = commonUtils.isNotEmptyArr(slaveColumn) && slaveColumn.length > 2 ? slaveColumn[1].dataIndex : '';
  1380 + if(sCount && sFileName) {
  1381 + const addState ={};
  1382 + addState[sFileName] = tableDataRow.sDivRowNew + sCount;
  1383 + tableData[startIndex] = {...tableData[startIndex] , ...addState}
  1384 + }
  1385 + }
  1386 + });
  1387 + }
  1388 + return tableData;
  1389 + };
  1390 +
  1391 + getOrderData = (name, type) => {
  1392 + const { [`${name}SelectedRowKeys`]: tableselectedRowKeys, app, slavePagination: slavePaginationOld } = this.props;
  1393 + let { [`${name}Data`]: currentData } = this.props;
  1394 + if (name === 'slave') {
  1395 + const tempData = [];
  1396 +
  1397 + for (const sId of tableselectedRowKeys) {
  1398 + let index = 0;
  1399 + const tableDataIndex = currentData.findIndex(item => item.sId === sId);
  1400 + if (tableDataIndex > -1) {
  1401 + const tableDataRow = JSON.parse(JSON.stringify(currentData[tableDataIndex]));
  1402 + if(commonUtils.isNotEmptyObject(tableDataRow)) {
  1403 + const iSelectedOrder = tableDataRow.iOrder + index + 100;
  1404 + const row = {...tableDataRow, iSelectedOrder : iSelectedOrder }
  1405 + tempData.push(row);
  1406 + }
  1407 + }
  1408 + index +=1;
  1409 + }
  1410 +
  1411 + const tempNew = commonUtils.isNotEmptyArr(tempData) ? JSON.parse(JSON.stringify(tempData)) : [];
  1412 + if (commonUtils.isEmptyArr(tempNew)) {
  1413 + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请选择要移动数据 */
  1414 + return;
  1415 + }
  1416 + const len = currentData.length;
  1417 + currentData = this.orderNum(currentData);
  1418 + const newLen = tempNew.length;
  1419 + let num = 0.01;/* 循环增加体 */
  1420 + let targetiOrder = -1;
  1421 + if (type === 1) { /* 上移 */
  1422 + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[0].sSlaveId);/* 选中第一个节点的下标 */
  1423 + if (iIndex === 0) {
  1424 + if (newLen === 1) {
  1425 + message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */
  1426 + return;
  1427 + } else {
  1428 + targetiOrder = 0;
  1429 + }
  1430 + } else if (iIndex === 1 && currentData[0].sDivRowNew) {
  1431 + message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */
  1432 + return;
  1433 + } else {
  1434 + targetiOrder = currentData[iIndex - 1].iOrder - 1; /* 目标排序号 */
  1435 + }
  1436 + }
  1437 + tempNew.forEach((item) => {
  1438 + const index1 = currentData.findIndex(item1 => item1.sSlaveId === item.sSlaveId);
  1439 + currentData[index1] = { ...item, iOrder: targetiOrder + num, handleType: 'update' };
  1440 + num += 0.01;
  1441 + });
  1442 + currentData = this.sortData(currentData);
  1443 + currentData = this.orderNum(currentData);
  1444 + return currentData;
  1445 + }
  1446 + };
  1447 +
  1448 + sortData = (tempData) => {
  1449 + tempData.sort((g1, g2) => {
  1450 + return g1.iOrder - g2.iOrder;
  1451 + });
  1452 + return tempData;
  1453 + };
1297 1454
1298 /* 超期计算 */ 1455 /* 超期计算 */
1299 handleOverExec= async (other) => { 1456 handleOverExec= async (other) => {
1300 const { 1457 const {
1301 - app, sModelsId, slaveFilterCondition, slaveSelectedRowKeys, slaveData, masterData, 1458 + app, sModelsId, slaveFilterCondition, slaveSelectedRowKeys, slaveData = [], masterData,
1302 } = this.props; 1459 } = this.props;
  1460 + if(commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
  1461 + message.error('请选择数据');
  1462 + }
  1463 +
1303 let value = {}; 1464 let value = {};
1304 this.props.onSaveState({ 1465 this.props.onSaveState({
1305 pageLoading: true 1466 pageLoading: true
1306 }); 1467 });
  1468 +
  1469 + // 创建新的slaveData数组,保持未选中记录顺序不变,只对选中记录重新排序
  1470 + let newSlaveData = [];
1307 let sRowData = []; 1471 let sRowData = [];
1308 if (commonUtils.isNotEmptyObject(this.treeChild) && commonUtils.isNotEmptyObject(this.treeChild.sMachineId)) { 1472 if (commonUtils.isNotEmptyObject(this.treeChild) && commonUtils.isNotEmptyObject(this.treeChild.sMachineId)) {
1309 const sMachineId = this.treeChild.sMachineId; 1473 const sMachineId = this.treeChild.sMachineId;
1310 const slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sSlaveId) && commonUtils.isEmptyObject(item.sDivRowNew)); 1474 const slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sSlaveId) && commonUtils.isEmptyObject(item.sDivRowNew));
1311 const minSelectedData = this.arrayMin(slaveSelectedData); /* iOrder最小的 */ 1475 const minSelectedData = this.arrayMin(slaveSelectedData); /* iOrder最小的 */
1312 - if(commonUtils.isNotEmptyArr(slaveSelectedData)) {  
1313 - slaveSelectedData.forEach((item, index) => {  
1314 - const tableRow = {};  
1315 - tableRow.sId =item.sSlaveId;  
1316 - sRowData.push(tableRow); 1476 + if(commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
  1477 +
  1478 + newSlaveData = this.getOrderData('slave', 1);
  1479 +
  1480 + slaveSelectedRowKeys.forEach(slaveId => {
  1481 + const item = slaveData.find(item => item.sSlaveId === slaveId && commonUtils.isEmptyObject(item.sDivRowNew));
  1482 + if (item) {
  1483 + const tableRow = {
  1484 + sId: item.sSlaveId,
  1485 + iOrder: item.iOrder,
  1486 + sSrcNo: item.sSrcNo
  1487 + };
  1488 + sRowData.push(tableRow);
  1489 + }
1317 }); 1490 });
1318 } 1491 }
1319 1492
1320 /* 先走保存 */ 1493 /* 先走保存 */
1321 - await this.handleValidateSave(true); 1494 + await this.handleValidateSave(true, newSlaveData);
1322 value = { 1495 value = {
1323 sProName: 'Sp_productionPlan_BtnEventCnl', 1496 sProName: 'Sp_productionPlan_BtnEventCnl',
1324 sProInParam: JSON.stringify({ 1497 sProInParam: JSON.stringify({