AssignmentField.js
4.45 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
/**
* 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 { Modal } from 'antd-v4';
import styles from '@/index.less';
import * as commonUtils from '@/utils/utils';
import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */
import * as commonBusiness from '@/components/Common/commonBusiness';
/* 单据业务功能 */
export default class AssignmentField extends Component {
/** 构造函数 */
constructor(props) {
super(props);
this.state = {};
}
/* 获取数字格式化规范 */
getFloatNum = (sName, decimals) => {
if (sName.toLowerCase().endsWith('price')) { /* 价格 */
return decimals.dNetPrice;
} else if (sName.toLowerCase().endsWith('money')) { /* 金额 */
return decimals.dNetMoney;
} else { /* 其它 */
return 0;
}
};
handleOk = () => {
/* 选中之后 */
const { sAssignFieldData } = this.props;
this.props.onGetsAssignField(sAssignFieldData, 'sAssignField');
this.props.onSaveState({
visibleAssignmentField: false,
// enabled: false,
});
};
handleCancel = () => {
this.props.onSaveState({
visibleAssignmentField: false,
// enabled: false,
});
};
handleSelectRowChange = (name, selectedRowKeys) => {
this.props.onSaveState({
selectedRowKeys,
sAssignFieldSelectedRowKeys: selectedRowKeys,
});
};
handleChange = (name, sFieldName, changeValue, sId) => {
const { sAssignFieldData } = this.props;
if (name === 'sAssignField') {
const iIndex = sAssignFieldData.findIndex(item => item.sId === sId);
const newData = sAssignFieldData[iIndex];
newData[sFieldName] = changeValue[sFieldName];
}
};
/** 渲染 */
render() {
const {
sAssignFieldData, visibleAssignmentField, sAssignFieldColumn, selectedRowKeys,
} = this.props;
/* 获取table中的props */
const app = {};
app.currentPage = null;
const commonConst = [
{
sId: '1000', sParentId: '100', sName: 'BtnAdd', showName: '新增',
},
{
sId: '1001', sParentId: '100', sName: 'BtnUpd', showName: '修改',
},
{
sId: '1002', sParentId: '100', sName: 'BtnDel', showName: '删除',
},
];
app.commonConst = commonConst;
app.token = '';
const config = {};
config.iFreezeColumn = 1;
const gdsconfigtbsAssignField = [];
const showoldsNameConfig = {
sId: commonUtils.createSid(),
sName: 'sOldName',
showName: '源字段',
bVisible: true,
iFitWidth: 200,
};
const shownewsNameConfig = {
sId: commonUtils.createSid(),
sName: 'sNewName',
showName: '现字段',
bVisible: true,
iFitWidth: 180,
};
gdsconfigtbsAssignField.push(showoldsNameConfig);
gdsconfigtbsAssignField.push(shownewsNameConfig);
config.gdsconfigformslave = gdsconfigtbsAssignField;
const assignmentFieldProps = {
...commonBusiness.getTableTypes('sAssignField', this.props),
tableProps: { AutoTableHeight: '320px', onChange: this.handleChange },
rowKey: this.rowKey,
size: 'small',
bordered: true, /* 显示边框 */
dataSource: sAssignFieldData, /* 数据s */
columns: sAssignFieldColumn, /* 表头 */
pagination: false, /* 不分页 */
tableBelone: 'table',
selectedRowKeys,
getFloatNum: this.getFloatNum,
config,
app: {
...this.props.app,
currentPane: {
...this.props.app.currentPane,
sModelsType: 'search/assignmentField',
},
},
onRow: (record) => { return { onClick: () => { this.onRowClick(record); }, onDoubleClick: () => { this.onDoubleClick(record); } }; },
onAddRow: this.props.onDataRowAdd,
onDelRow: this.props.onDataRowDel,
onCopyRow: this.props.onDataRowCopy,
onSelectRowChange: this.handleSelectRowChange,
onChange: this.handleChange,
onDataChange: this.handleChange,
...this.props.tableProps,
};
return (
<div className={styles.toolBar}>
<Modal
width="650px"
title="赋值字段"
visible={visibleAssignmentField}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<StaticEditTable {...assignmentFieldProps} noVlist setOpterationColumn="Y" />
</Modal>
</div>
);
}
}