CommobileViewMaster.js
4.94 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
/**
* Created by mar105 on 2019-02-27.
*/
/* eslint-disable object-curly-newline,prefer-destructuring */
import React, { Component } from 'react';
import { List, Flex } from 'antd-mobile-v2';
import ShowType from './CommobileComponent';
import * as commonUtils from '../../utils/utils';
import styles from '../mobile.less'; /* 通用方法 */
export default class CommobileViewMaster extends Component {
handleMasterFieldScan = (fieldConfig, tbName, record, newValue, cancelValue) => {
this.props.onMasterFieldScan(fieldConfig, tbName, record, newValue, cancelValue);
}
handleMobileScan = (fieldConfig, tbName, record, newValue, cancelValue) => {
this.props.onMobileScan(fieldConfig, tbName, record, newValue, cancelValue);
}
handleFocus = (fieldConfig) => {
this.props.onFocus(fieldConfig);
}
handleBlur = (fieldConfig) => {
this.props.onBlur(fieldConfig);
}
render() {
const { masterConfig, masterData, sModelsId, enabled, sUseInfo, app, iTag, bOpenKeyboard } = this.props;
let masterShowConfig;
if (iTag === 1) {
masterShowConfig = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1) : [];
} else {
masterShowConfig = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.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 : ''} style={{ overflow: 'hidden', padding: '5px' }}>
{
// 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 bNotViewTitle = child.bNotViewTitle; /* 不显示标题 */
const iRowNum = child.iColValue === 1 ? 24 : 1; /* 每个字段占的网格个数 ,网格总个数是24 */
const iColValue = sMemo ? 24 : child.iColValue * iRowNum; /* 跨度 */
// eslint-disable-next-line no-unused-vars
const iRowValue = commonUtils.isEmptyNumber(child.iRowValue) || child.iRowValue === 0 ? 1 : child.iRowValue; /* 行高 */
const showTypeProps = {
app,
record: masterData,
sId: masterData.sId, /* 修改当前编号(数据格式:字符串) */
name: 'master',
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.onChange,
onFocus: this.handleFocus,
onBlur: this.handleBlur,
showConfig: child,
formItemLayout: sMemo ? formItemLayout : {},
textArea: sMemo,
enabled: enabledNew,
dataValue: masterData[child.sName],
bTable: false,
onFilterDropDownData: this.props.onFilterDropDownData,
onSaveState: this.props.onSaveState,
onFieldScan: this.handleMasterFieldScan,
onMobileScan: this.handleMobileScan,
bOpenKeyboard,
};
if (child.iTag === 1) {
if (index > -1) {
return (
<div className={iColValue === 24 ? 'singleItem' : (iColValue === 12 ? 'doubleItem' : 'treeItem')} style={{ marginBottom: '12px' }}>
<Flex style={{ background: '#f37d3d', color: '#f5f5f5', padding: '0 15px 5px 15px', fontSize: '16px', alignItems: 'center' }} wrap="wrap" align="start">
{
bNotViewTitle ?
<><Flex.Item style={{ fontWeight: 'bold', paddingLeft: '0.5px' }}> {masterData[child.sName]}</Flex.Item></>
:
<><div className="flexTitle">{child.showName}</div><div style={{ fontWeight: 'bold' }}>:</div><Flex.Item style={{ paddingLeft: '0.5px' }}> {masterData[child.sName]}</Flex.Item></>
}
</Flex>
</div>
);
}
} else {
return (
<List>
<ShowType {...showTypeProps} />
</List>
);
}
})
}
</div>
);
}
}