/* eslint-disable array-callback-return,no-undef */
import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
// import '@ant-design/compatible/assets/index.css';
import { Layout, Spin, Avatar, Tabs, Card, Row, Col, message } from 'antd-v4'; // Switch, Modal, Card, Row, Col
import styles from '@/index.less';
import * as commonFunc from '@/components/Common/commonFunc';
import CommonBase from '@/components/Common/CommonBase';
import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */
import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */
import SearchComponent from '@/components/Common/SearchComponent';/* 搜索组件 */
import CommonProductionMainPlanEvent from '@/components/Common/CommonProductionmMainPlanEvent';
import CommonListSelect from '@/components/Common/CommonListSelect';/* 选择界面 */
import Toolbar from '@/components/Common/ToolBar/ToolBarNew';
import * as commonUtils from '@/utils/utils';/* 通用方法 */
import Gantt from '@/components/Charts/Gantt';
import ProductionUnifiedPlanning from '@/components/productionMainPlan/productionUnifiedPlanning';
import CustomizedChar from '@/components/Common/ShowChar/CustomizedChar';
import MoveUp from '@/assets/processUp.svg';
import MoveDown from '@/assets/processDown.svg';
import DisableMoveUp from '@/assets/disableprocessUp.svg';
import DisableMoveDown from '@/assets/disableprocessDown.svg';
import MoveTop from '@/assets/processTop.svg';
import DisableMoveTop from '@/assets/disableprocessTop.svg';
import MoveBottom from '@/assets/processBottom.svg';
import DisableMoveBottom from '@/assets/disableprocessBottom.svg';
import ShowList from '@/assets/list.svg';
import DisableShowList from '@/assets/disablelist.svg';
import ShowGantt from '@/assets/gantt.svg';
import DisableShowGantt from '@/assets/disablegantt.svg';
import commonConfig from '@/utils/config';
import AntdDraggableModal from '@/components/Common/AntdDraggableModal';
import ShowCheckModel from '@/assets/checkModel.svg';
import DisableShowCheckModel from '@/assets/disablecheckModel.svg';
import selfstyles from './index.less';
import GanttStyles from '../productionScheduleTree/index.less';
const { TabPane } = Tabs;
const { Header, Content, Sider } = Layout;
class ProductionMainPlanComponent extends Component {
constructor(props) {
super(props);
this.state = {};
this.form = {}; /* 表单对象 */
}
// onRowMouseEnter = (name, record) => {
// // if (this.props.enabled && name === 'control') {
// // this.props.onTableSelectRowChange(name, [record.sId]);
// // }
// }
onDoubleClick = (name, record) => {
if (this.props.onDoubleClick !== undefined) {
this.props.onDoubleClick(record);
}
};
onRowClick1 = (name, record, bRowClick) => {
let selectedRowKeys = [...this.props.slaveSelectedRowKeys];
if (commonUtils.isEmptyArr(selectedRowKeys)) {
const keys = [];
keys.push(record.sId);
selectedRowKeys = keys;
} else {
const indexKey = selectedRowKeys.indexOf(record.sId);
if (indexKey === -1) {
selectedRowKeys.push(record.sId);
} else if (indexKey !== -1) {
if (!bRowClick) { /* 可输入行,行内点击时 不去除selectedRowKeys */
selectedRowKeys.splice(indexKey, 1);
}
}
}
this.props.onTableSelectRowChange(name, selectedRowKeys);
};
// eslint-disable-next-line no-unused-vars
onRowClick = (name, record, bRowClick) => {
// let selectedRowKeys = [...this.props.slaveSelectedRowKeys];
// if (commonUtils.isEmptyArr(selectedRowKeys)) {
// const keys = [];
// keys.push(record.sId);
// selectedRowKeys = keys;
// } else {
// const indexKey = selectedRowKeys.indexOf(record.sId);
// if (indexKey === -1) {
// selectedRowKeys.push(record.sId);
// } else if (indexKey !== -1) {
// if (!bRowClick) { /* 可输入行,行内点击时 不去除selectedRowKeys */
// selectedRowKeys.splice(indexKey, 1);
// }
// }
// }
// this.props.onTableSelectRowChange(name, selectedRowKeys);
/* 子表选中 */
if (name === 'slaveInfo') {
const { slaveInfoSelectedRowKeys } = this.props;
let selectedRowKeys = slaveInfoSelectedRowKeys;
if (commonUtils.isEmptyArr(selectedRowKeys)) {
const keys = [];
keys.push(record.sId);
selectedRowKeys = keys;
} else {
const indexKey = selectedRowKeys.indexOf(record.sId);
if (indexKey === -1) {
selectedRowKeys.push(record.sId);
} else if (indexKey !== -1) {
if (!bRowClick) { /* 可输入行,行内点击时 不去除selectedRowKeys */
selectedRowKeys.splice(indexKey, 1);
}
}
}
this.props.onTableSelectRowChange(name, selectedRowKeys);
}
};
/** 处理选择行发生改变 */
handleTableFilterData = (name, data, record) => {
/* 外置处理业务 */
if (name === 'slave') {
let slaveInfoDataNew = [];
if (commonUtils.isNotEmptyArr(data)) {
slaveInfoDataNew = data.filter(item => item.sProductionPlanId === record.sId);
}
return slaveInfoDataNew;
}
};
handleCancelUnifiedPlanningChooseModal = () => {
this.props.onGetProdData('workCenter', 'Sp_Productionplan_Pie_Char', {});
const { workCenterSelectedRowKeys, workCenterData } = this.props;
if (commonUtils.isNotEmptyArr(workCenterData)) {
const addFilter = {};
addFilter.bFilterName = 'sWorkCenterId';
addFilter.bFilterCondition = '=';
addFilter.bFilterValue = commonUtils.isEmpty(workCenterSelectedRowKeys) ? workCenterData[0].sWorkCenterId : workCenterSelectedRowKeys;
const filterArr = [addFilter];
this.props.onGetProdData('machine', 'Sp_Productionplan_sColumnarStack_Char', { bFilter: JSON.stringify(filterArr) });
}
this.props.onSaveState({ unifiedPlanningChooseVisible: false });
this.props.onRefresh();
};
handlePieCard = async (sWorkCenterId) => {
const addFilter = {};
addFilter.bFilterName = 'sWorkCenterId';
addFilter.bFilterCondition = '=';
addFilter.bFilterValue = sWorkCenterId;
let bProductionPlanOutside = false;
if (sWorkCenterId === '0000000000') {
bProductionPlanOutside = true; /* 跳转到发外排程 */
}
const filterArr = [addFilter];
this.props.onGetProdData('machine', 'Sp_Productionplan_sColumnarStack_Char', { bFilter: JSON.stringify(filterArr) });
this.props.onSaveState({ workCenterSelectedRowKeys: [sWorkCenterId], bProductionPlanOutside });
};
handleWorkCenterData = () => {
const { workCenterData, workCenterCharData } = this.props;
return commonUtils.isNotEmptyArr(workCenterData) && commonUtils.isNotEmptyObject(workCenterCharData) && commonUtils.isNotEmptyArr(workCenterCharData.data) ? workCenterData.map((child) => {
const charConfigArr = [];
const charConfigAndDataArr = [];
const charConfig = commonBusiness.getCharConfig('', 'sPieGroup', child.sWorkCenterId, 1, 20, 65);
charConfigArr.push({ ...charConfig });
// charConfigAndData.percent = 3;
const charConfigAndData = workCenterCharData.data.filter(item => item.sWorkCenterId === child.sWorkCenterId)[0];
charConfigAndDataArr.push({ ...charConfig, child: { data: [{ ...charConfigAndData }], height: 90 } });
const charProps = commonBusiness.getCharTypes(child.sWorkCenterName, charConfigArr, charConfigAndDataArr, this.props, { bordered: false });
const gridStyle = {
width: '99%',
padding: '5px 10px',
height: '80px',
};
return (
{child.sWorkCenterName}
工时:{child.dHourSum}{commonUtils.isNotEmptyNumber(child.dHourSum) ? 'h' : ''}
数量:{child.iPlanSum}
{child.dStdWorkCenterHour}h
最晚:{child.sLimitDate}
);
}) : '';
}
sortData = (tempData) => {
tempData.sort((g1, g2) => {
return g1.iOrder - g2.iOrder;
});
return tempData;
};
/* 控制排序 */
orderData = (e, name, type) => {
// 埋入数据修监听点
this.props.onSaveState({
dataChanged: true,
});
const { [`${name}SelectedRowKeys`]: tableselectedRowKeys, app, slavePagination: slavePaginationOld } = this.props;
let { [`${name}Data`]: currentData } = this.props;
if (name === 'slave') {
if (commonUtils.isEmptyArr(tableselectedRowKeys)) {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请勾选要移动数据 */
return;
}
if (commonUtils.isEmptyArr(currentData)) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoProcessData'));/* 请填写工序表数据 */
return;
}
const tempNew = currentData.filter((item) => { /* 获取勾选数据集 */
return tableselectedRowKeys.indexOf(item.sId) > -1;
});
if (commonUtils.isEmptyArr(tempNew)) {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请选择要移动数据 */
return;
}
const len = currentData.length;
const newLen = tempNew.length;
let num = 0.01;/* 循环增加体 */
let targetiOrder = -1;
if (type === 1) { /* 上移 */
const iIndex = currentData.findIndex(item => item.sId === tempNew[0].sId);/* 选中第一个节点的下标 */
if (iIndex === 0) {
if (newLen === 1) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */
return;
} else {
targetiOrder = 0;
}
} else {
targetiOrder = currentData[iIndex - 1].iOrder - 1; /* 目标排序号 */
}
} else if (type === 2) { /* 下移 */
const iIndex = currentData.findIndex(item => item.sId === tempNew[newLen - 1].sId);/* 选中最后一个节点的下标 */
if (iIndex === len - 1) {
if (newLen === 1) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoDown')); /* 无需下移 */
return;
} else {
targetiOrder = currentData[iIndex].iOrder;
}
} else {
targetiOrder = currentData[iIndex + 1].iOrder;
}
} else if (type === 0) { /* 置顶 */
const iIndex = currentData.findIndex(item => item.sId === tempNew[0].sId);/* 选中第一个节点的下标 */
if (iIndex === 0) {
if (newLen === 1) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoTop')); /* 无需置顶 */
return;
} else {
targetiOrder = currentData[iIndex].iOrder;
}
} else {
targetiOrder = currentData[0].iOrder - 1;
}
} else if (type === 3) { /* 置底 */
const iIndex = currentData.findIndex(item => item.sId === tempNew[newLen - 1].sId);/* 选中最后一个节点的下标 */
if (iIndex === len - 1) {
if (newLen === 1) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoBottom')); /* 无需置底 */
return;
} else {
targetiOrder = currentData[iIndex].iOrder;
}
} else {
targetiOrder = currentData[len - 1].iOrder + 1;
}
}
tempNew.forEach((item) => {
const index1 = currentData.findIndex(item1 => item1.sId === item.sId);
currentData[index1] = { ...item, iOrder: targetiOrder + num, handleType: 'update' };
num += 0.01;
});
currentData = this.sortData(currentData);
currentData = this.orderNum(currentData);
const iIndex = currentData.findIndex(item => item.sSlaveId === tableselectedRowKeys[0]);
const slavePagination = { ...slavePaginationOld };
slavePagination.current = Math.ceil((iIndex + 1) / commonConfig.pageSize);
this.props.onSaveState({ [`${name}Data`]: currentData, slavePagination });
}
};
/* 自定义排序号 */
orderNum = (tableData) => {
tableData.forEach((item, index) => {
item.iOrder = index + 1;
item.handleType = 'update';
});
return tableData;
};
/* 切换稽查列表 */
changeCheckModel= (e, type) => {
if (type === 'checkModel') {
const { slaveFilterCondition } = this.props;
/* 调用获取甘特图数据 */
const chart = {};
chart.sProcedureName = 'Sp_Manufacture_GetPlanAPSstate';
chart.paramsMap = {
};
this.props.onCheckModel(chart, slaveFilterCondition).catch(() => {
this.props.onSaveState({ pageLoading: false });
});
}
};
/* 切换甘特图/列表视图 */
changeGantt = (e, type) => {
let bGantt = false;
if (type === 'gantt') {
const { slaveFilterCondition } = this.props;
bGantt = true;
/* 调用获取甘特图数据 */
const chart = {};
chart.sProcedureName = 'Sp_WorkOrder_GtCharAll';
chart.paramsMap = {
};
this.props.onGanttChar(chart, slaveFilterCondition).finally(() => {
this.props.onSaveState({ pageLoading: false });
});
} else if (type === 'list') {
bGantt = false;
}
this.props.onSaveState({ bGantt });
};
render() {
const { pageLoading } = this.props;
return (
);
}
}
const ProductionPlanComponent = Form.create({
mapPropsToFields(props) {
const { masterData } = props;
const obj = commonFunc.mapPropsToFields(masterData, Form);
return obj;
},
})((props) => {
const {
form, onReturnForm, app, onGetChartClick, slavePagination, planLoadingSate, iPageSize, bGantt, charGanttData,
} = props;
/* 回带表单 */
onReturnForm(form);
const pagination = {
pageSize: commonUtils.isNotEmptyNumber(iPageSize) && iPageSize !== 0 ? iPageSize : commonConfig.pageSize,
...slavePagination,
size: 'large',
pageSizeOptions: commonConfig.pageSizeOptions,
// showQuickJumper: true,
hideOnSinglePage: false,
showSizeChanger: true,
current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current,
// size: 'large',
};
const width = '18px';
const height = '18px';
const moveUp = {
title: '上移',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const moveDown = {
title: '下移',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const moveTop = {
title: '置顶',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const moveBottom = {
title: '置底',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const showGantt = {
title: '查看Gantt',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const showList = {
title: '查看列表',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const showCheckModel = {
title: '齐套稽查',
width: { width },
height: { height },
img:
,
disableimg:
,
};
let zoom = {};
zoom.scale = 'Minutes';
zoom.step = '10'; /* 间隔 */
if (commonUtils.isNotEmptyObject(charGanttData)) {
// eslint-disable-next-line prefer-destructuring
zoom = charGanttData.zoom;
}
const ganttProps = {
// ...commonBusiness.getGanttTypes('slave', props),
tasks: commonUtils.isNotEmptyObject(charGanttData) ? charGanttData : {}, /* 甘特图数据源 */
zoom: commonUtils.isNotEmptyObject(zoom) ? zoom : {},
onDataUpdated: props.onDataUpdated,
};
// onChange: props.onTitleChange.bind(this, 'slave'),, 表头没有点击排序事件可以不添加onChange事件
const tableProps = {
...commonBusiness.getTableTypes('slave', props),
onTableFilterData: props.onTableFilterData,
// tableBelone: 'list',
tableProps: {
rowKey: 'sId',
pagination,
onRow: (record) => {
return {
onClick: () => { props.onRowClick('slave', record, true); },
onDoubleClick: () => { props.onDoubleClick('slave', record); },
// onMouseEnter: () => { props.onRowMouseEnter('slave', record); },
};
},
onChange: props.onTitleChange.bind(this, 'slave'),
},
clearArray: props.clearArray,
};
const tableInfoProps = {
...commonBusiness.getTableTypes('slaveInfo', props),
tableProps: {
rowKey: 'sId',
pagination,
// rowSelection: null,
planLoadingSate,
onRow: (record) => {
return {
onClick: () => { props.onRowClick('slaveInfo', record, true); },
onDoubleClick: () => { props.onDoubleClick('slaveInfo', record); },
// onMouseEnter: () => { props.onRowMouseEnter('slaveInfo', record); },
};
},
onChange: props.onTitleChange.bind(this, 'slaveInfo'),
},
// data: commonUtils.isNotEmptyObject(props.slaveInfoDataNew) ? props.slaveInfoDataNew : props.slaveInfoData,
};
let unifiedPlanningType = {};
if (commonUtils.isNotEmptyObject(props.unifiedPlanningChooseData)) {
unifiedPlanningType = {
app: {
...props.app,
currentPane: {
name: 'unifiedPlanning',
config: props.unifiedPlanningConfig,
conditonValues: props.getSqlCondition(props.unifiedPlanningConfig),
title: props.unifiedPlanningChooseData.sMenuName,
route: props.unifiedPlanningChooseData.sName,
formId: props.unifiedPlanningChooseData.sId,
key: props.sModelsId + props.unifiedPlanningChooseData.sId,
sModelsType: props.unifiedPlanningChooseData.sModelType,
select: props.onSelect,
selectCancel: props.onCancelUnifiedPlanningChooseModal,
},
},
dispatch: props.dispatch,
content: props.content,
id: new Date().getTime().toString(),
};
}
const addProps = {};
const charConfigArr = [];
const charConfigAndDataArr = [];
const charConfig = commonBusiness.getCharConfig('机台排程', 'sEqualColumnarStack', '1324324', 1, 24, 280);
charConfigArr.push({ ...charConfig });
if (commonUtils.isNotEmptyArr(props.machineCharData)) {
charConfigAndDataArr.push({
...charConfig,
child: {
...props.machineCharData, height: 300, chartName: 'chartMachine', onChartClick: onGetChartClick,
},
});
}
/* 生产进度详情 */
let searchWorkSchedule = {};
let workScheduleConfig = {};
let searchWorkTitle = '';
if (commonUtils.isNotEmptyObject(props.workScheduleConfig)) {
// eslint-disable-next-line prefer-destructuring
workScheduleConfig = props.workScheduleConfig;
searchWorkTitle = workScheduleConfig.sActiveName;
const sWorkOrderId = commonUtils.isNotEmptyObject(props.workScheduleRecord) ? props.workScheduleRecord.sWorkOrderId : '';
searchWorkSchedule = {
app: {
...props.app,
currentPane: {
name: 'workSchedule',
config: workScheduleConfig,
conditonValues: props.getSqlCondition(workScheduleConfig),
title: workScheduleConfig.sActiveName,
route: '/indexPage/commonList',
formRoute: '/indexPage/commonList',
formId: workScheduleConfig.sActiveId,
key: props.sModelsId + workScheduleConfig.sId,
sModelsType: 'search/workSchedule',
bFilterProName: 'p_sWorkOrderId_pro',
bFilterProValue: sWorkOrderId,
// select: props.onSelect,
// selectCancel: props.onSelectCancel,
},
},
dispatch: props.dispatch,
content: props.content,
id: new Date().getTime().toString(),
realizeHeight: props.realizeHeight, /* 拖动偏移高度 */
bNotShowBtn: true,
rowSelection: null,
};
}
const machineCharProps = commonBusiness.getCharTypes('machineChar', charConfigArr, charConfigAndDataArr, props);
const setUp = commonFunc.showMessage(app.commonConst, 'setUp');/* 上移 */
const setDown = commonFunc.showMessage(app.commonConst, 'setDown');/* 下移 */
const setTop = commonFunc.showMessage(app.commonConst, 'setTop');/* 置顶 */
const setBottom = commonFunc.showMessage(app.commonConst, 'setBottom');/* 置底 */
const bSetList = true; /* 显示列表 */
const bSetGantt = true; /* 显示甘特图 */
return (
);
});
export default CommonBase(CommonProductionMainPlanEvent(ProductionMainPlanComponent));