CommobileViewSlave.js
3.39 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
/**
* Created by mar105 on 2019-02-27.
*/
/* eslint-disable object-curly-newline,prefer-destructuring */
import React, { Component } from 'react';
import { List } from 'antd-mobile-v2';
import ShowType from './CommobileComponent';
import * as commonUtils from '../../utils/utils';
import styles from '../mobile.less'; /* 通用方法 */
export default class CommobileView extends Component {
// shouldComponentUpdate(nextProps) {
// const { slaveData, enabled } = this.props;
// return JSON.stringify(slaveData) !== JSON.stringify(nextProps.slaveData) || enabled !== nextProps.enabled;
// }
render() {
const { slaveConfig, slaveData, sModelsId, enabled, sUseInfo, app, iTag } = this.props;
const slaveDataRow = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
let masterShowConfig;
if (iTag === 1) {
masterShowConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1) : [];
} else {
masterShowConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag !== 1) : [];
}
const formItemLayout = { labelCol: { span: 2 }, wrapperCol: { span: 18 } };
return (
<div className={iTag === 1 ? styles.onlyWordBg : ''}>
{
// eslint-disable-next-line array-callback-return
masterShowConfig.map((child, index) => {
const sMemo = child.sName.toLowerCase().endsWith('memo');
// sUseInfo是指被其他单据调用,或者被审核
let enabledNew = (enabled && !child.bReadonly && !child.specialControl && commonUtils.isEmpty(sUseInfo));
if (child.iTag === 1) {
enabledNew = false;
} else if (child.iTag === 3) {
enabledNew = true;
}
const showTypeProps = {
app,
record: slaveDataRow,
sId: slaveDataRow.sId, /* 修改当前编号(数据格式:字符串) */
name: 'slave',
form: this.props.form,
formId: sModelsId,
getSqlDropDownData: this.props.getSqlDropDownData,
getSqlCondition: this.props.getSqlCondition,
handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord,
getFloatNum: this.props.getFloatNum,
getDateFormat: this.props.getDateFormat,
onChange: this.props.onDataChange,
showConfig: child,
formItemLayout: sMemo ? formItemLayout : {},
textArea: sMemo,
enabled: enabledNew,
dataValue: slaveDataRow[child.sName],
bTable: false,
onFilterDropDownData: this.props.onFilterDropDownData,
onSaveState: this.props.onSaveState,
};
if (child.iTag === 1) {
if (index > 9) {
return (
<div className={styles.onlyWordBg}>
<div style={{ padding: '0 0 5px 15px', fontSize: '17px' }}>{child.showName} : {showTypeProps.dataValue}</div>
</div>
);
}
} else {
return (
<List>
<ShowType {...showTypeProps} />
</List>
);
}
})
}
</div>
);
}
}