commonOeeReport.js
14.1 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/* eslint-disable */
import { routerRedux } from 'dva/router';
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 oeeStyle from './oee.less';
import OeeSearchComponent from './oeeSearchComponent';
import * as commonBusiness from '../../components/Common/commonBusiness';
import * as commonFunc from '../../components/Common/commonFunc';
import * as commonUtils from '../../utils/utils';
// import * as commonConfig from '../../utils/config';
import '../../index.less';
import CommonBase from '../../components/Common/CommonBase';
import CommonListEvent from '../../components/Common/CommonListEvent';
import AntdDraggableModal from '../../components/Common/AntdDraggableModal';
import CommonListSelect from '../../components/Common/CommonListSelect';
import AffixOeeMenu from './AffixOeeMenu';
const { Content } = Layout;
class CommonOeeReport extends Component {
constructor(props) {
super(props);
this.state = {
bool: true,
};
}
componentWillMount() {
if(this.props && this.props.app) {
const { app } = this.props;
const { token } = app;
commonBusiness.clearSocketData({ token, value: { optName: '' }, sModelsId: 100 });
commonUtils.clearStoreDropDownData();
}
}
componentWillReceiveProps(nextProps) {
const { oeeBtnStatus } = nextProps;
if (oeeBtnStatus !== undefined) { /* 此作用是 按钮点击后置灰色,调用接口返回数据后 按钮状态回到初始可点击状态 */
this.setState({ bool: oeeBtnStatus });
}
}
shouldComponentUpdate(nextProps) {
const { slaveColumn } = nextProps;
return commonUtils.isNotEmptyArr(slaveColumn);
}
componentDidUpdate() {
// 设置table中的ant-table-body的高度,使滚动条至底
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`;
}
// ----------------------------数据修改回带end ---------------------------- //
handleEject = () => {
const { currentPane, panes } = this.props.app;
if (commonUtils.isNotEmptyArr(panes) && commonUtils.isNotEmptyObject(currentPane)) {
// const index = panes.indexOf(currentPane);
const index = panes.findIndex(item => item.formId === currentPane.formId && item.key === currentPane.key && item.notCurrentPane === currentPane.notCurrentPane && item.route === currentPane.route && item.title === currentPane.title && item.sModelsType === currentPane.sModelsType && item.sProcName === currentPane.sProcName);
/* 当前页签 */
let currentTab = document.getElementById('navTabWrap').children[index];
if (commonUtils.isEmpty(currentTab)) {
const oChildren = document.getElementById('navTabWrap').getElementsByClassName('ant-tabs-content')[0].children;
for (const child of oChildren) {
if (child.nodeName === 'DIV' && index !== undefined && child.getAttribute('id') === `navTabWrap-panel-${panes[index].key}`) {
currentTab = child;
}
}
}
// const currentTab = document.getElementById('tabs').getElementsByClassName('ant-tabs-content-no-animated')[0].children[index];
if (!commonUtils.isEmpty(currentTab)) {
const filterTreeArr = currentTab.getElementsByClassName('xly-filter-tree');/* 获取当前页签下的树组件 */
if (commonUtils.isNotEmptyArr(filterTreeArr)) {
const filterTree = filterTreeArr[0];
if (filterTree.style.display === 'block') {
filterTree.style.display = 'none';
} else {
filterTree.style.display = 'block';
}
}
}
}
};
/** 树节点选中 */
handleTreeSelect = (name, checkedKeys, e) => {
this.props.onSelect(name, checkedKeys, e); /* 调用CommonListEvent通用处理 */
};
handleBtnClick = async (btnConfig) => {
const { app, slaveSelectedRowKeys, slaveSelectedData, slaveData } = this.props;
if (btnConfig.sControlName === 'BtnCopyTo.productionReport') {
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
message.warn('请选择数据!');
return;
} else if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
if (slaveSelectedData[0].sState === '3') {
message.warn('该任务已暂停,不能开工!');
return;
}
/* 若设置了禁止跳单 选择数据不是第一条时进行提示 */
const iIndex = app.systemData.findIndex(item => item.sName === 'CkxNoSkip');
if (iIndex > -1) {
const sValue = app.systemData[iIndex].sValue;
if ( sValue === "1" ) { /* 如果设置了进制跳单 */
const indexFirst = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
if (indexFirst > 0) {
message.warn('禁止跳单!');
return;
}
}
}
}
if (this.state.bool) {
this.setState({
bool: false,
});
// this.props.onOeeCopyTo(btnConfig.sControlName, btnConfig.sActiveId);
await this.props.onOeeCopyTo(btnConfig.sControlName, btnConfig.sActiveId);
this.setState({
bool: true,
});
} else {
message.warning(commonFunc.showMessage(app.commonConst, 'donotRepeat'));
return;
}
// setTimeout(() => { // 防止多次点击
// this.setState({
// bool: true,
// });
// }, 1000);
} 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 (btnConfig.sControlName === 'BtnEnterLabel') { // 标签打印
const { slaveSelectedRowKeys, getSlaveSelectedRowKeys } = this.props;
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
message.warn('请选择数据!');
return;
}
const { slaveData, onSaveCurrentState } = this.props;
onSaveCurrentState(slaveData, undefined, undefined, slaveSelectedRowKeys);
this.props.onOeeLabelCopyTo(btnConfig.sControlName, btnConfig.sActiveId);
this.props.dispatch(routerRedux.push('/indexOee/labelPrint'));
if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { // 向父组件中存slaveSelectedRowKeys
getSlaveSelectedRowKeys(slaveSelectedRowKeys);
}
} else if (btnConfig.sControlName.includes('OeeCopyTo')) { /* OEE单据 */
const { slaveSelectedRowKeys, getSlaveSelectedRowKeys } = this.props;
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
message.warn('请选择数据!');
return;
}
const { slaveData, onSaveCurrentState } = this.props;
onSaveCurrentState(slaveData, undefined, undefined, btnConfig, undefined, true);
this.props.onOeeBillCopyTo(btnConfig.sControlName, btnConfig.sActiveId, btnConfig);
// this.props.dispatch(routerRedux.push('/indexOee/commonBillOee'));
if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { // 向父组件中存slaveSelectedRowKeys
getSlaveSelectedRowKeys(slaveSelectedRowKeys);
}
} else if (btnConfig.sControlName === 'BtnDetailProcess') { // 详细进度
const { slaveSelectedRowKeys, slaveData } = this.props;
if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && commonUtils.isNotEmptyArr(slaveData)) {
const iIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
if (iIndex > -1) {
const slaveDataRow = slaveData[iIndex];
this.props.onPartNameClick('BtnDetailProcess', btnConfig, slaveDataRow);
}
} else {
message.error('请选择数据!');
}
} else if (commonUtils.isNotEmptyObject(btnConfig.sControlName) && btnConfig.sControlName.indexOf('BtnConvert') > -1) { /* 自定义按钮 */
this.setState({
bool: false,
});
this.props.onOeeBtnEent(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,
sModelsId,
} = props;
// isSmall将分页变小,以及去掉跳转页面和总条数记录
/* 回带表单 */
if (commonUtils.isNotEmptyObject(slavePagination)) {
if (isSmall) {
slavePagination.showTotal = null;
}
}
onReturnForm(form);
// const pagination = {
// pageSize: commonConfig.pageSize,
// ...slavePagination,
// size: isSmall ? 'small' : 'large',
// pageSizeOptions: commonConfig.pageSizeOptions,
// showSizeChanger: !isSmall,
// showQuickJumper: !isSmall,
// };
const pagination = false;
const tableProps = {
...commonBusiness.getTableTypes('slave', props),
tableProps: { rowKey: 'sSlaveId', pagination, onChange: props.onTitleChange },
onSaveState: props.onSaveState,
clearArray: props.clearArray,
readOnly: true,
isSmall,
sGroupByList: props.sGroupByList,
};
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: 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,
};
}
const bCanClick = props.bool; /* 按钮是否可点击,true:可点击,false:禁用 */
// 取得配置中的按钮
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" disabled={!bCanClick} style={{ background: bCanClick ? `${item.sColorTerms}` : '#ABAAAB', position: 'relative' }} onClick={() => (bCanClick ? onBtnClick(item) : null)}>
{item.showName}<AffixOeeMenu{...props}/>
</a>
);
} else {
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid,react/no-array-index-key
<a key={index} disabled={!bCanClick} style={{ background: bCanClick ? `${item.sColorTerms}` : '#ABAAAB' }} onClick={() => (bCanClick ? onBtnClick(item) : null)}>
{item.showName}
</a>
);
}
}) : ''
}
</div>
<div className={oeeStyle.searchComponent}>
<OeeSearchComponent {...props} />
</div>
</div>
{
props.workScheduleVisible ?
<AntdDraggableModal
className="workScheduleModal"
width={1300}
title={commonUtils.isEmptyObject(searchWorkSchedule) ? searchWorkTitle : searchWorkSchedule.app.currentPane.title}
visible={props.workScheduleVisible}
onCancel={props.onCloseModel.bind(this, 'workScheduleVisible')}
onSaveState={props.onSaveState}
footer={null}
>
<CommonListSelect {...searchWorkSchedule} />
</AntdDraggableModal> : null
}
</Layout>
</Form>
</div>
);
});
export default CommonBase(CommonListEvent(CommonOeeReport));