oeeCommonList.js
10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/* eslint-disable */
import React, { Component } from 'react';
import { Layout, message } from 'antd';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import StaticEditTable from '@/components/Common/CommonTable';
import * as commonBusiness from '@/components/Common/commonBusiness';
import * as commonFunc from '@/components/Common/commonFunc';
import * as commonUtils from '@/utils/utils';
import '@/index.less';
import CommonBase from '@/components/Common/CommonBase';
import CommonListEvent from '@/components/Common/CommonListEvent';
import * as commonConfig from '@/utils/config';
import * as commonServices from '@/services/services';
import oeeStyle from './oee.less';
import OeeSearchComponent from './oeeSearchComponent';
import OeeToolBar from './oeeToolBarNew';
import AffixOeeMenu from './AffixOeeMenu';
// import { timeMillisecond } from 'd3-time';
const { Content } = Layout;
class OeeCommonList extends Component {
constructor(props) {
super(props);
this.state = {
prevSlaveColumn: null // 添加状态记录上一次的slaveColumn
};
}
shouldComponentUpdate(nextProps, nextState) {
const { slaveColumn } = nextProps;
return commonUtils.isNotEmptyArr(slaveColumn);
}
componentDidUpdate() {
// 设置table中的ant-table-body的高度,使滚动条至底
if (document.getElementsByClassName('xly-normal-list') && commonUtils.isNotEmptyArr(document.getElementsByClassName('table')) &&
document.getElementsByClassName('table')[0].getElementsByClassName('xly-normal-list')) {
const antTable = document.getElementsByClassName('table')[0].getElementsByClassName('xly-normal-list')[0].offsetHeight;
const antTableHeader = document.getElementsByClassName('table')[0].getElementsByClassName('ant-table-header')[0].offsetHeight;
document.getElementsByClassName('table')[0].getElementsByClassName('ant-table-body')[0].style.height = `${antTable - antTableHeader}px`;
}
}
// 存储过程按钮调用存储过程
handleProcedureCall = async (btnConfig, proName, proInParam) => {
const { app, sModelsId } = this.props;
const value = {
sProName: proName,
paramsMap: {
sMachineId: app.sMachineNameSId,
sProInParam: proInParam,
},
};
const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(app.token, value, url)).data;
if (returnData.code === 1) {
message.success(returnData.msg);
this.props.onButtonClick('BtnRefresh');
} else {
this.props.onSaveState({ loading: false });
this.props.getServiceError(returnData);
}
}
// 根据配置解析拼接具体参数
handleProParams = (sKey, arr) => {
const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props;
const keyData = commonUtils.isNotEmptyArr(tableData) ? tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId)) : [];
if (commonUtils.isNotEmptyArr(keyData)) {
const addState = {};
addState.key = sKey;
const val = [];
keyData.forEach((currData) => {
const currVal = {};
arr.forEach((filed) => {
currVal[`${filed}`] = currData[`${filed}`];
});
val.push(currVal);
});
addState.value = val;
return addState;
} else {
return undefined;
}
};
// 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析,配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"}
handleBtnEent = (btnConfig) => {
const { masterData } = this.props;
const { sButtonParam } = btnConfig;
const btn = JSON.parse(sButtonParam);
const sProName = btn.sproName;
const inParams = [];
const { inMap } = btn;
const inlist = inMap.split(',');
const masterArr = [];
const slaveArr = [];
if (inlist.length > 0) {
inlist.forEach((item) => {
const itemArr = item.split('.');
if (itemArr.length > 0) {
const sname = itemArr[0];
const stype = itemArr[1];
if (commonUtils.isNotEmptyStr(sname) && sname === 'master') {
masterArr.push(stype);
}
if (commonUtils.isNotEmptyStr(sname) && sname === 'slave') {
slaveArr.push(stype);
}
}
});
if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
const addState = {};
addState.key = 'master';
const val = [];
const currVal = {};
masterArr.forEach((filed) => {
currVal[`${filed}`] = masterData[`${filed}`];
});
val.push(currVal);
addState.value = val;
inParams.push({ ...addState });
}
if (commonUtils.isNotEmptyArr(slaveArr)) {
const addState = this.handleProParams('slave', slaveArr);
if (commonUtils.isNotEmptyObject(addState)) {
inParams.push({ ...addState });
}
}
}
this.handleProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParams }));
};
handleBtnClick = (btnConfig) => {
if (btnConfig.sControlName === 'BtnCopyTo.productionReport') {
this.props.onOeeCopyTo(btnConfig.sControlName, btnConfig.sActiveId);
} else if (btnConfig.sControlName === 'BtnClose') {
// eslint-disable-next-line prefer-destructuring
const userAgent = navigator.userAgent;
if (userAgent.indexOf('Firefox') !== -1 || userAgent.indexOf('Chrome') !== -1) {
window.location.href = 'about:blank';
} else {
window.opener = null;
window.open(' ', '_self', ' ');
window.close();
}
} else if (commonUtils.isNotEmptyObject(btnConfig.sControlName) && btnConfig.sControlName.indexOf('BtnConvert') > -1) {
this.handleBtnEent(btnConfig);
}
}
render() {
return (
<CommonOeeReportComponent
{...this.props}
{...this.state}
onEject={this.handleEject}
onSelectTree={this.handleTreeSelect}
// handleColsePage={this.handleColsePage}
// onstartWork={this.handleonStartWork}
onBtnClick={this.handleBtnClick}
/>
);
}
}
const CommonOeeReportComponent = Form.create({
mapPropsToFields(props) {
const { masterData } = props;
const obj = commonFunc.mapPropsToFields(masterData, Form);
return obj;
},
})((props) => {
const {
form,
onReturnForm,
slavePagination,
slaveConfig,
isSmall,
onBtnClick,
} = props;
// isSmall将分页变小,以及去掉跳转页面和总条数记录
/* 回带表单 */
if (commonUtils.isNotEmptyObject(slavePagination)) {
if (isSmall) {
slavePagination.showTotal = null;
}
}
onReturnForm(form);
const pagination = false;
const tableProps = {
...commonBusiness.getTableTypes('slave', props),
onSaveState: props.onSaveState,
clearArray: props.clearArray,
readOnly: true,
isSmall,
sGroupByList: props.sGroupByList,
tableProps: {
rowKey: 'sSlaveId', pagination, onChange: props.onTitleChange,
},
};
// console.log('============tableProps\r\n', tableProps);
// if (tableProps?.config?.gdsconfigformslave) {
// tableProps.config.gdsconfigformslave.forEach(item => {
// if (item.sName === 'sPicturePath') {
// item.bVisible = true;
// item.sName = 'sDownload';
// item.showName = '附件';
// }
// });
// }
// if (tableProps?.data) {
// tableProps.data.forEach((item, index) => {
// if (item.sPicturePath) {
// item.sDownload = item.sPicturePath;
// }
// if (index === 2) {
// item.sDownload = 'D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520852730_test.pdf,D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520852730_全能印厂部分流程.jpg,D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520938420_包装ERP流程.vsd,D:/xlyweberp/xlyerpfiles/tempPath/202111/12012615914116379057124180_1637905703379.jpg'
// }
// if (index === 3) {
// item.sDownload = 'D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520852730_test.pdf';
// }
// });
// }
// 取得配置中的按钮
const buttonConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName !== '' && item.bVisible && item.sControlName.indexOf('Btn') > -1) : [];
return (
<div>
<Form style={{ height: '100%' }}>
<Layout style={{ height: '100%' }} className="xly-list">
<Layout className="table">
<Content className="xly-normal-list" >
<StaticEditTable {...tableProps} footer="hidden" tableBelone="list" />
</Content>
</Layout>
<div className={oeeStyle.bottomBtns}>
<div className={oeeStyle.btnBrints}>
{
commonUtils.isNotEmptyArr(buttonConfig) ?
buttonConfig.map((item, index) => {
if (item.sControlName === 'BtnSet') {
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid,react/no-array-index-key
<a key={index} className="oeeAffixBtnContainer" style={{ background: `${item.sColorTerms}` }} onClick={() => onBtnClick(item)}>
{item.showName}<AffixOeeMenu{...props}/>
</a>
);
} else {
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid,react/no-array-index-key
<a key={index} style={{ background: `${item.sColorTerms}` }} onClick={() => onBtnClick(item)}>
{item.showName}
</a>
);
}
}) : ''
}
</div>
<OeeToolBar {...props} />
<div className={oeeStyle.searchComponent}>
<OeeSearchComponent {...props} />
</div>
</div>
</Layout>
</Form>
</div>
);
});
export default CommonBase(CommonListEvent(OeeCommonList));