ContextMenuModal.js
4.95 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
/**
* Created by mar105 on 2019-02-13.
*/
/* eslint-disable no-undef,import/first,prefer-destructuring,jsx-a11y/alt-text */
import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Row, Col } from 'antd';
import * as commonUtils from '../../utils/utils';
import ShowType from './CommonComponent';/* 通用方法 */
import AntdDraggableModal from '../Common/AntdDraggableModal';
const FormItem = Form.Item;
export default class ContextMenuModal extends Component {
/** 构造函数 */
constructor(props) {
super(props);
this.state = {
};
this.form = {};
/* 表单对象 */
}
handleViewClick = (name, sName, sId) => {
this.props.onViewClick(name, sName, sId);
};
/* 右击弹出窗确定 取表单值 */
handleContextMenuOk= () => {
const { masterData, contextMenuConfig } = this.props;
if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyArr(contextMenuConfig)) {
const showConfig = contextMenuConfig[0];
if (commonUtils.isNotEmptyObject(showConfig.sName)) {
const contextMenuValue = masterData[showConfig.sName]; /* 取弹窗框的值 */
if (!commonUtils.isEmpty(contextMenuValue)) {
this.props.onContextMenuOk(contextMenuValue);
}
}
}
}
handleModalCancel = (modelVisible) => {
this.props.onSaveState({
[modelVisible]: false,
});
};
/** 渲染 */
render() {
const {
contextMenuModalVisible,
contextMenuTbName,
contextMenuConfig,
contextMenuName,
app,
form,
sTabId,
[`${contextMenuTbName}Data`]: tableData, [`${contextMenuTbName}SelectedRowKeys`]: selectedRowKeys,
} = this.props;
let tableDataRow = {};
if (commonUtils.isNotEmptyArr(tableData)) {
const tableFilterData = tableData.filter(item => selectedRowKeys.includes(item.sId));
if (commonUtils.isNotEmptyArr(tableFilterData)) {
tableDataRow = tableFilterData[0];
}
}
const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0];
return (
<div>
{
(pane.notCurrentPane ? false : contextMenuModalVisible) ?
<AntdDraggableModal
title={`全部更新:${contextMenuName}`}
visible={contextMenuModalVisible}
onOk={this.handleContextMenuOk}
onCancel={this.handleModalCancel.bind(this, 'contextMenuModalVisible')}
width={380}
okButtonProps={{ style: { marginRight: '5px' } }}
// cancelButtonProps={{ style: { marginRight: '10px' } }}
bodyStyle={{ paddingLeft: '3px', paddingRight: '3px' }}
>
<div className="contextMenuStyle" >
<FormItem className="searchMainForm">
<Row type="flex" style={{ height: 'auto', overflow: 'hidden' }}>
{ commonUtils.isNotEmptyArr(contextMenuConfig) ?
contextMenuConfig.map((child) => {
const sMemo = child.sName.toLowerCase().endsWith('memo');
let enabledNew = !child.bReadonly;
if (child.iTag === 1) {
enabledNew = false;
} else if (child.iTag === 3) {
enabledNew = true;
}
const showTypeProps = {
name: 'slave',
form,
record: tableDataRow,
sId: commonUtils.createSid(),
getSqlDropDownData: this.props.getSqlDropDownData,
getSqlCondition: this.props.getSqlCondition,
handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord,
getFloatNum: this.props.getFloatNum,
onChange: this.props.onChange,
onViewClick: this.handleViewClick,
getDateFormat: this.props.getDateFormat,
showConfig: child,
textArea: sMemo,
enabled: enabledNew,
dataValue: commonUtils.isNotEmptyObject(tableDataRow) ? tableDataRow[child.sName] : '',
bTable: true,
formRoute: this.props.formRoute,
formItemLayout: {},
};
return (
<Col key={child.sId} span={24} order={child.iOrder} className="ContextMenuCol" style={{ border: '1px solid #d3d3d3' }}>
<ShowType {...showTypeProps} />
</Col>
);
}) : ''
}
</Row>
</FormItem>
</div>
</AntdDraggableModal>
: ''
}
</div>
);
}
}