aldehyde 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/dist/163.js +2 -0
- package/dist/163.js.LICENSE.txt +43 -0
- package/dist/41.js +1 -0
- package/dist/aldehyde.js +2 -0
- package/dist/aldehyde.js.LICENSE.txt +122 -0
- package/dist/chemstruc-graph.js +1 -0
- package/dist/css/163-24392163d3c7b54ea806.css +11 -0
- package/dist/css/290-5e8e152675ab7d201c00.css +886 -0
- package/dist/css/chemstruc-graph-87868f791bf92fb80db9.css +29 -0
- package/dist/css/main-2e6725ec1b56da516cee.css +256 -0
- package/dist/html-editor-draft.js +2 -0
- package/dist/html-editor-draft.js.LICENSE.txt +5 -0
- package/dist/images/logo-06f6a5d8.png +0 -0
- package/dist/index.html +4 -0
- package/dist/signature.js +2 -0
- package/dist/signature.js.LICENSE.txt +17 -0
- package/package.json +180 -0
- package/src/components/chart/antd/Chart.js +32 -0
- package/src/components/chart/antd/Chart10000.js +90 -0
- package/src/components/chart/antd/Max2DimLineChart.js +128 -0
- package/src/components/chart/antd/PieChart1.js +54 -0
- package/src/components/chart/antd/PieChart2.js +56 -0
- package/src/components/chart/antd/chart-utils.tsx +50 -0
- package/src/components/chart/antd/column-chart-sub.tsx +67 -0
- package/src/components/chart/antd/line-chart-sub.tsx +65 -0
- package/src/components/chart/antd/pie-chart-sub.tsx +54 -0
- package/src/components/chart/antd/statview-d2-chart.tsx +125 -0
- package/src/components/chart/statview-l2-chart.tsx +69 -0
- package/src/components/controls/action/index.css +9 -0
- package/src/components/controls/action/index.tsx +228 -0
- package/src/components/controls/action/utils.tsx +122 -0
- package/src/components/controls/auto-complete/index.tsx +80 -0
- package/src/components/controls/cascader/index.js +97 -0
- package/src/components/controls/chemstruc/graph.tsx +150 -0
- package/src/components/controls/chemstruc/index.css +28 -0
- package/src/components/controls/collapse-card/index.css +9 -0
- package/src/components/controls/collapse-card/index.tsx +59 -0
- package/src/components/controls/color-picker/index.css +27 -0
- package/src/components/controls/color-picker/index.tsx +88 -0
- package/src/components/controls/cquery/cquick-button.tsx +117 -0
- package/src/components/controls/date-picker/index.tsx +141 -0
- package/src/components/controls/entity-select/entity-select.tsx +277 -0
- package/src/components/controls/entity-select/index.css +6 -0
- package/src/components/controls/entity-select/popover-entity-select.tsx +112 -0
- package/src/components/controls/entry-control.tsx +240 -0
- package/src/components/controls/enum-badge/index.tsx +28 -0
- package/src/components/controls/enum-tag/index.tsx +30 -0
- package/src/components/controls/file-view/drawer-file-view.tsx +69 -0
- package/src/components/controls/file-view/index.tsx +145 -0
- package/src/components/controls/html-editor/draft.tsx +161 -0
- package/src/components/controls/html-editor/tinymce.js +55 -0
- package/src/components/controls/input-number/index.tsx +101 -0
- package/src/components/controls/input-range/index.tsx +48 -0
- package/src/components/controls/password-setter/index.css +3 -0
- package/src/components/controls/password-setter/index.js +70 -0
- package/src/components/controls/progress/index.tsx +61 -0
- package/src/components/controls/relation-existion/index.css +4 -0
- package/src/components/controls/relation-existion/index.tsx +108 -0
- package/src/components/controls/rfield/index.css +4 -0
- package/src/components/controls/rfield/index.tsx +161 -0
- package/src/components/controls/signature/index.tsx +162 -0
- package/src/components/controls/steps/index.tsx +58 -0
- package/src/components/controls/text/ellipsis-text.tsx +70 -0
- package/src/components/controls/upload/index.tsx +122 -0
- package/src/components/controls/view-control.tsx +177 -0
- package/src/components/detail/button/cquery-button-bar.tsx +112 -0
- package/src/components/detail/button/index.css +43 -0
- package/src/components/detail/button/submit-button-bar.tsx +151 -0
- package/src/components/detail/dtmpl.css +53 -0
- package/src/components/detail/edit/dtmpl-edit.tsx +218 -0
- package/src/components/detail/edit/fields-edit-card.tsx +103 -0
- package/src/components/detail/edit/modal-dtmpl-edit.tsx +198 -0
- package/src/components/detail/edit/modal-row-edit.tsx +72 -0
- package/src/components/detail/edit/post-result/index.tsx +52 -0
- package/src/components/detail/edit/row-edit-card.tsx +125 -0
- package/src/components/detail/edit/row-editor.tsx +71 -0
- package/src/components/detail/rightbar/index.css +35 -0
- package/src/components/detail/rightbar/index.tsx +76 -0
- package/src/components/detail/view/act-dtmpl-view.tsx +155 -0
- package/src/components/detail/view/dtmpl-view.tsx +143 -0
- package/src/components/detail/view/field-view-group.tsx +73 -0
- package/src/components/detail/view/modal-dtmpl-view.tsx +56 -0
- package/src/components/detail/view/snapshot-timeline.tsx +130 -0
- package/src/components/exportor/export-frame.css +3 -0
- package/src/components/exportor/export-frame.tsx +194 -0
- package/src/components/exportor/index.tsx +60 -0
- package/src/components/form/criteria-form.tsx +241 -0
- package/src/components/form/dtmpl-form.css +4 -0
- package/src/components/form/dtmpl-form.tsx +272 -0
- package/src/components/form/field-group-form.tsx +75 -0
- package/src/components/form/fields-form.tsx +51 -0
- package/src/components/form/form-Item-group.tsx +99 -0
- package/src/components/form/index.css +13 -0
- package/src/components/import/excel-import.tsx +316 -0
- package/src/components/import/index.css +54 -0
- package/src/components/import/template-builder.js +474 -0
- package/src/components/import/template.css +51 -0
- package/src/components/layout/MainPage.tsx +230 -0
- package/src/components/layout/footer/index.css +6 -0
- package/src/components/layout/footer/index.js +17 -0
- package/src/components/layout/header/index.css +86 -0
- package/src/components/layout/header/index.tsx +58 -0
- package/src/components/layout/menu/block.tsx +88 -0
- package/src/components/layout/menu/l2menu-message-bar.tsx +118 -0
- package/src/components/layout/menu/l2menu-quick-bar.tsx +132 -0
- package/src/components/layout/menu/menu-2layers.tsx +92 -0
- package/src/components/layout/menu/menu-render.tsx +49 -0
- package/src/components/layout/menu/reset-password.tsx +185 -0
- package/src/components/layout/menu/user-bar.tsx +97 -0
- package/src/components/layout/menu/userinfo-bar.tsx +70 -0
- package/src/components/layout/sidebar/index.css +26 -0
- package/src/components/layout/sidebar/index.tsx +38 -0
- package/src/components/login.js +137 -0
- package/src/components/module/criteria-page.tsx +175 -0
- package/src/components/module/dtmpl-page.tsx +70 -0
- package/src/components/module/ltmpl-page.tsx +181 -0
- package/src/components/routable/dtmpl-route.tsx +96 -0
- package/src/components/routable/import-route.tsx +28 -0
- package/src/components/routable/ltmpl-route.tsx +158 -0
- package/src/components/table/act-table.tsx +635 -0
- package/src/components/table/column/column-selector.tsx +79 -0
- package/src/components/table/column/index.css +14 -0
- package/src/components/table/index.css +45 -0
- package/src/components/table/l2-act-table.tsx +85 -0
- package/src/components/table/modal-select-table.tsx +248 -0
- package/src/components/table/pagination.css +15 -0
- package/src/components/table/pagination.tsx +72 -0
- package/src/components/table/query-table.tsx +331 -0
- package/src/components/table/relation-table.tsx +600 -0
- package/src/components/table/select-table.tsx +247 -0
- package/src/components/table/selected-rows-card.tsx +62 -0
- package/src/components/table/stat/restat.tsx +79 -0
- package/src/components/table/table-util.tsx +33 -0
- package/src/components/tmpl/control-type-supportor.tsx +97 -0
- package/src/components/tmpl/hc-data-source.tsx +230 -0
- package/src/components/tmpl/hcservice-v3.tsx +624 -0
- package/src/components/tmpl/interface.tsx +308 -0
- package/src/components/tmpl/superagent.js +93 -0
- package/src/components/tmpl/tmpl-config-analysis.tsx +111 -0
- package/src/components/units/EncryptUtils.js +38 -0
- package/src/components/units/image.d.ts +8 -0
- package/src/components/units/index.tsx +536 -0
- package/src/components/units/logo.png +0 -0
- package/src/components/units/storage.js +3 -0
- package/src/components/welcome/HCWelcome.js +232 -0
- package/src/components/welcome/index.css +13 -0
- package/src/components/welcome/logo.png +0 -0
- package/src/components/welcome/quick-entrance.tsx +77 -0
- package/src/components/welcome/workbench.tsx +76 -0
- package/src/index.js +4 -0
- package/src/style/common.css +79 -0
- package/src/style/coverstyle.css +49 -0
- package/src/style/transstyle.css +24 -0
- package/tsconfig.json +106 -0
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {Button, Input, message, Table, Tooltip} from 'antd';
|
|
3
|
+
import {
|
|
4
|
+
AlignLeftOutlined,
|
|
5
|
+
DeleteOutlined,
|
|
6
|
+
EditOutlined,
|
|
7
|
+
FormOutlined,
|
|
8
|
+
PlusSquareOutlined,
|
|
9
|
+
SnippetsOutlined
|
|
10
|
+
} from '@ant-design/icons';
|
|
11
|
+
import "./index.css";
|
|
12
|
+
import {DtmplData, FieldGroupConfig, SelectedRow, ViewOrEdit} from "../tmpl/interface";
|
|
13
|
+
import SupportInputTypes from '../tmpl/control-type-supportor';
|
|
14
|
+
import TableUnits from "./table-util";
|
|
15
|
+
import ViewControl from "../controls/view-control";
|
|
16
|
+
import ModalDtmplView from '../detail/view/modal-dtmpl-view';
|
|
17
|
+
import ModalDtmplEdit from '../detail/edit/modal-dtmpl-edit'
|
|
18
|
+
import ModelSelectTable from './modal-select-table';
|
|
19
|
+
import HcserviceV3 from "../tmpl/hcservice-v3";
|
|
20
|
+
import CollapseCard from '../controls/collapse-card'
|
|
21
|
+
import RowEditor from '../detail/edit/row-editor'
|
|
22
|
+
import Action from "../controls/action";
|
|
23
|
+
|
|
24
|
+
interface RelationTableProps {
|
|
25
|
+
parentId: string,
|
|
26
|
+
loading: boolean,
|
|
27
|
+
viewOrEdit: ViewOrEdit,
|
|
28
|
+
refreshId?: string;
|
|
29
|
+
fieldGroupConfig: FieldGroupConfig;
|
|
30
|
+
value: DtmplData[];
|
|
31
|
+
onChange?: (fieldGroupConfig: FieldGroupConfig, value: DtmplData[]) => void;
|
|
32
|
+
initCollapse?: boolean,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
interface RelationTableStat {
|
|
36
|
+
selectedCode: string,
|
|
37
|
+
showDtmplView: boolean,
|
|
38
|
+
showDtmplEdit: boolean,
|
|
39
|
+
showSelectTable: boolean,
|
|
40
|
+
tableLoading: boolean,
|
|
41
|
+
showRowEdit: boolean,
|
|
42
|
+
selectedDtmplData: DtmplData,
|
|
43
|
+
filterStr: string,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class RelationTable extends React.PureComponent<RelationTableProps, RelationTableStat> {
|
|
48
|
+
|
|
49
|
+
state = {
|
|
50
|
+
showDtmplView: false,
|
|
51
|
+
selectedCode: undefined,
|
|
52
|
+
showSelectTable: false,
|
|
53
|
+
showDtmplEdit: false,
|
|
54
|
+
tableLoading: false,
|
|
55
|
+
showRowEdit: false,
|
|
56
|
+
selectedDtmplData: undefined,
|
|
57
|
+
filterStr: undefined,
|
|
58
|
+
// columns:[],
|
|
59
|
+
// dataSource:[],
|
|
60
|
+
// current:1,
|
|
61
|
+
// title:undefined,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async componentDidMount() {
|
|
65
|
+
// const {fieldGroupConfig} = this.props;
|
|
66
|
+
// if (fieldGroupConfig.displayConfig.includes('folded')) {
|
|
67
|
+
// this.setState({
|
|
68
|
+
// collapse: true,
|
|
69
|
+
// })
|
|
70
|
+
// }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async componentDidUpdate(prevProps) {
|
|
74
|
+
// const {fieldGroupConfig} = this.props;
|
|
75
|
+
// const {fieldGroupConfig: preFieldGroupConfig} = prevProps;
|
|
76
|
+
// if (fieldGroupConfig != preFieldGroupConfig) {
|
|
77
|
+
// if (fieldGroupConfig.displayConfig.includes('folded')) {
|
|
78
|
+
// this.setState({
|
|
79
|
+
// collapse: true,
|
|
80
|
+
// })
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
buildDataSource = () => {
|
|
86
|
+
|
|
87
|
+
const {filterStr} = this.state;
|
|
88
|
+
const {viewOrEdit, value, fieldGroupConfig} = this.props;
|
|
89
|
+
const {title, buttons, fields, showRelationName, relationNames, showRowNum} = fieldGroupConfig;
|
|
90
|
+
|
|
91
|
+
let dataSource = undefined;
|
|
92
|
+
|
|
93
|
+
/** 构建 dataSource **/
|
|
94
|
+
if (value) {
|
|
95
|
+
dataSource = [];
|
|
96
|
+
value.forEach((item, index) => {
|
|
97
|
+
let flag = true;
|
|
98
|
+
if (filterStr) {
|
|
99
|
+
flag = false;
|
|
100
|
+
for (let value of Object.values(item.fieldMap)) {
|
|
101
|
+
if (value && value.toString().indexOf(filterStr) >= 0) {
|
|
102
|
+
flag = true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (flag) {
|
|
107
|
+
let row = {
|
|
108
|
+
key: index,
|
|
109
|
+
relationLabel: item.relationLabel,
|
|
110
|
+
code: item.code,//增加code,为了删除操作
|
|
111
|
+
...item.fieldMap
|
|
112
|
+
};
|
|
113
|
+
dataSource.push(row);
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return dataSource;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
buildColumns = () => {
|
|
123
|
+
|
|
124
|
+
const {viewOrEdit, value, fieldGroupConfig} = this.props;
|
|
125
|
+
const {title, buttons, fields, showRelationName, relationNames, showRowNum} = fieldGroupConfig;
|
|
126
|
+
let columns = [];
|
|
127
|
+
/** 构建column **/
|
|
128
|
+
let s = 0;
|
|
129
|
+
fields.forEach((item) => {
|
|
130
|
+
let column = {};
|
|
131
|
+
columns.push(column);
|
|
132
|
+
column['title'] = item.title;
|
|
133
|
+
column['dataIndex'] = item.id;
|
|
134
|
+
s++;
|
|
135
|
+
let itemType = SupportInputTypes.getControlType(item, null);
|
|
136
|
+
if (s < 10) {
|
|
137
|
+
TableUnits.sort(column, itemType);
|
|
138
|
+
}
|
|
139
|
+
column['render'] = (text, record) => {
|
|
140
|
+
return <ViewControl holderType={'table'} fieldConfig={item} value={record[item.id]}/>
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
if (showRelationName) {//判断是否有关系属性
|
|
144
|
+
let rela = {
|
|
145
|
+
dataIndex: "relationLabel",
|
|
146
|
+
name: "relation",
|
|
147
|
+
title: "关系",
|
|
148
|
+
type: "relation",
|
|
149
|
+
editable: true,
|
|
150
|
+
fieldAvailable: true,
|
|
151
|
+
id: '10000',//关系默认id是'10000'
|
|
152
|
+
options: relationNames,
|
|
153
|
+
}
|
|
154
|
+
columns.unshift(rela)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//添加操作列
|
|
158
|
+
|
|
159
|
+
const viewable = buttons.includes('detail');
|
|
160
|
+
const rowEdit = buttons.includes('rowEdit');
|
|
161
|
+
const dtmplEdit = buttons.includes('dtmplEdit');
|
|
162
|
+
const deletable = buttons.includes('delete');
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
if (viewOrEdit == 'edit' && (viewable || rowEdit || dtmplEdit || deletable)) {
|
|
166
|
+
const actionColumn = {};
|
|
167
|
+
columns.push(actionColumn);
|
|
168
|
+
actionColumn['title'] = '操作';
|
|
169
|
+
actionColumn['fixed'] = "right";
|
|
170
|
+
actionColumn['key'] = "action";
|
|
171
|
+
actionColumn['render'] = (record) => {
|
|
172
|
+
return <div className="actionbtn">
|
|
173
|
+
{/*详情*/}
|
|
174
|
+
{viewable ?
|
|
175
|
+
<Button
|
|
176
|
+
title="当前实体"
|
|
177
|
+
type='primary'
|
|
178
|
+
icon={<AlignLeftOutlined/>}
|
|
179
|
+
size="small"
|
|
180
|
+
onClick={() => this.showEntityView(record)}
|
|
181
|
+
></Button> : ""}
|
|
182
|
+
{/*模板编辑*/}
|
|
183
|
+
{dtmplEdit ?
|
|
184
|
+
<Button
|
|
185
|
+
title="编辑当实体"
|
|
186
|
+
type='primary'
|
|
187
|
+
icon={<FormOutlined/>}
|
|
188
|
+
size="small"
|
|
189
|
+
onClick={() => this.showEditDtmplModel(record)}
|
|
190
|
+
></Button> : ""}
|
|
191
|
+
{fieldGroupConfig.rowActions && fieldGroupConfig.rowActions.length > 0 ?
|
|
192
|
+
fieldGroupConfig.rowActions.map((action) => {
|
|
193
|
+
return <Action key={action.id} data={[record]} actionConfig={action} doAction={this.doRowAction} buttonSize={'small'} ></Action>
|
|
194
|
+
}) : ""}
|
|
195
|
+
{/*行编辑*/}
|
|
196
|
+
{rowEdit ?
|
|
197
|
+
// <Popover placement="leftBottom" content={<RowEditCard fieldGroupConfig={fieldGroupConfig} dtmplData={this.getRowEditData(record.code)} onOk={this.handleRowEdit} ></RowEditCard>} trigger="click">
|
|
198
|
+
// <Tooltip placement="left" title="编辑当前行">
|
|
199
|
+
// <Button
|
|
200
|
+
// type='primary'
|
|
201
|
+
// icon={<EditOutlined/>}
|
|
202
|
+
// size="small"
|
|
203
|
+
// // onClick={() => {
|
|
204
|
+
// // this.showRowEditModel(record.code)
|
|
205
|
+
// // }}
|
|
206
|
+
// ></Button> </Tooltip></Popover>
|
|
207
|
+
<RowEditor buttonIcon={<EditOutlined/>} dtmplData={this.getRowEditData(record.code)}
|
|
208
|
+
fieldGroupConfig={fieldGroupConfig}
|
|
209
|
+
onOk={this.handleRowEdit}
|
|
210
|
+
tooltipTitle={"编辑当前行"}></RowEditor> : ""}
|
|
211
|
+
{/*删除*/}
|
|
212
|
+
{deletable ?
|
|
213
|
+
<Tooltip placement="right" title="删除当前行">
|
|
214
|
+
<Button
|
|
215
|
+
danger
|
|
216
|
+
type='primary'
|
|
217
|
+
icon={<DeleteOutlined/>}
|
|
218
|
+
size="small"
|
|
219
|
+
onClick={() => this.delete(record)}
|
|
220
|
+
></Button></Tooltip> : ""}
|
|
221
|
+
</div>
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
} else if (viewOrEdit == 'view' && (viewable)) {
|
|
225
|
+
const actionColumn = {};
|
|
226
|
+
columns.push(actionColumn);
|
|
227
|
+
actionColumn['title'] = '操作';
|
|
228
|
+
actionColumn['fixed'] = "right";
|
|
229
|
+
actionColumn['key'] = "action";
|
|
230
|
+
actionColumn['render'] = (record) => {
|
|
231
|
+
return <div className="actionbtn">
|
|
232
|
+
{/*详情*/}
|
|
233
|
+
{viewable ?
|
|
234
|
+
<Button
|
|
235
|
+
title="当前实体"
|
|
236
|
+
type='primary'
|
|
237
|
+
icon={<AlignLeftOutlined/>}
|
|
238
|
+
size="small"
|
|
239
|
+
onClick={() => this.showEntityView(record)}
|
|
240
|
+
></Button> : ""}
|
|
241
|
+
</div>
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return columns;
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
doRowAction = async (actionId: string, codes: string[],params:object) => {
|
|
250
|
+
await this.doAction(actionId, [{title: undefined, code:codes[0]}],params);
|
|
251
|
+
this.handleDtmplEdit(codes[0]);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
doAction = async (actionId: string, selectedRows: SelectedRow[],params) => {
|
|
255
|
+
this.setState({
|
|
256
|
+
tableLoading: true,
|
|
257
|
+
})
|
|
258
|
+
let result: boolean = await HcserviceV3.postActions( actionId, selectedRows,params);
|
|
259
|
+
{
|
|
260
|
+
this.setState({
|
|
261
|
+
tableLoading: false,
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
showEntityView = (record) => {
|
|
267
|
+
console.log('tabel record:', record);
|
|
268
|
+
this.setState({
|
|
269
|
+
selectedCode: record.code,
|
|
270
|
+
showDtmplView: true,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
hiddenEntityView = () => {
|
|
275
|
+
this.setState({
|
|
276
|
+
showDtmplView: false,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
hiddenEntityEdit = () => {
|
|
280
|
+
this.setState({
|
|
281
|
+
showDtmplEdit: false,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
editRow = (record) => {
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
delete = (record) => {
|
|
289
|
+
const {value, fieldGroupConfig, onChange} = this.props;
|
|
290
|
+
//追加
|
|
291
|
+
const selectdDatas = [];
|
|
292
|
+
if (value) {
|
|
293
|
+
for (let v of value) {
|
|
294
|
+
if (v.code != record.code) {
|
|
295
|
+
selectdDatas.push(v);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
onChange(fieldGroupConfig, selectdDatas);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
searchValue = (filterStr: string) => {
|
|
304
|
+
this.setState({
|
|
305
|
+
filterStr
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
tabChange = () => {
|
|
310
|
+
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
showSelect = () => {
|
|
314
|
+
console.log('showSelectTable click');
|
|
315
|
+
this.setState({
|
|
316
|
+
showSelectTable: true,
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
select = async (selectedRows: SelectedRow[]) => {
|
|
321
|
+
this.setState({
|
|
322
|
+
showSelectTable: false
|
|
323
|
+
})
|
|
324
|
+
if (!selectedRows || selectedRows.length <= 0) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
//查询
|
|
329
|
+
const codes: string[] = [];
|
|
330
|
+
for (let row of selectedRows) {
|
|
331
|
+
codes.push(row.code);
|
|
332
|
+
}
|
|
333
|
+
await this.add(codes);
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
add = async (codes: string[]) => {
|
|
339
|
+
const {value, fieldGroupConfig, onChange} = this.props;
|
|
340
|
+
const {title, fields, showRelationName, relationNames, showRowNum} = fieldGroupConfig;
|
|
341
|
+
this.setState({
|
|
342
|
+
tableLoading: true,
|
|
343
|
+
})
|
|
344
|
+
let selectdDatas: DtmplData[] = await HcserviceV3.requestSelectedData(fieldGroupConfig.id, codes);
|
|
345
|
+
|
|
346
|
+
//添加默认关系
|
|
347
|
+
if (selectdDatas) {
|
|
348
|
+
for (let d of selectdDatas) {
|
|
349
|
+
d['relationLabel'] = relationNames[0];
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
//追加
|
|
354
|
+
if (value) {
|
|
355
|
+
selectdDatas.unshift(...value);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
onChange(fieldGroupConfig, selectdDatas);
|
|
359
|
+
this.setState({
|
|
360
|
+
tableLoading: false,
|
|
361
|
+
})
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// edit = async (code: string) => {
|
|
365
|
+
//
|
|
366
|
+
// }
|
|
367
|
+
|
|
368
|
+
// showRowEditModel = (code?: string) => {
|
|
369
|
+
// const {value} = this.props;
|
|
370
|
+
// let selectedDtmplData = undefined;
|
|
371
|
+
// if (code) {
|
|
372
|
+
// for (let dtmplData of value) {
|
|
373
|
+
// if (code == dtmplData.code) {
|
|
374
|
+
// selectedDtmplData = dtmplData;
|
|
375
|
+
// break;
|
|
376
|
+
// }
|
|
377
|
+
// }
|
|
378
|
+
// }
|
|
379
|
+
// this.setState({
|
|
380
|
+
// showRowEdit: true,
|
|
381
|
+
// selectedDtmplData,
|
|
382
|
+
// })
|
|
383
|
+
// }
|
|
384
|
+
|
|
385
|
+
getRowEditData = (code?: string) => {
|
|
386
|
+
const {value} = this.props;
|
|
387
|
+
let data = undefined;
|
|
388
|
+
if (code) {
|
|
389
|
+
for (let dtmplData of value) {
|
|
390
|
+
if (code == dtmplData.code) {
|
|
391
|
+
data = dtmplData;
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return data;
|
|
397
|
+
}
|
|
398
|
+
handleDtmplAdd = async (code: string) => {
|
|
399
|
+
this.setState({
|
|
400
|
+
showDtmplEdit: false,
|
|
401
|
+
})
|
|
402
|
+
await this.add([code]);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
handleDtmplEdit = async (code: string) => {
|
|
406
|
+
const {value, fieldGroupConfig, onChange} = this.props;
|
|
407
|
+
const {title, fields, showRelationName, relationNames, showRowNum} = fieldGroupConfig;
|
|
408
|
+
this.setState({
|
|
409
|
+
tableLoading: true,
|
|
410
|
+
showDtmplEdit: false,
|
|
411
|
+
})
|
|
412
|
+
let data: DtmplData = (await HcserviceV3.requestSelectedData(fieldGroupConfig.id, [code]))[0];
|
|
413
|
+
let datas: DtmplData[] = [...value];
|
|
414
|
+
|
|
415
|
+
if (datas && data) {
|
|
416
|
+
for (let v of datas) {
|
|
417
|
+
if (v.code == data.code) {
|
|
418
|
+
v.fieldMap = data.fieldMap;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
onChange(fieldGroupConfig, datas);
|
|
423
|
+
this.setState({
|
|
424
|
+
tableLoading: false,
|
|
425
|
+
})
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
handleRowEdit = (dtmplData: DtmplData) => {
|
|
429
|
+
const {value, fieldGroupConfig, onChange} = this.props;
|
|
430
|
+
let datas: DtmplData[] = [];
|
|
431
|
+
if (value) {
|
|
432
|
+
datas = [...value];
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
let isAdd = true;
|
|
436
|
+
for (let v of datas) {
|
|
437
|
+
if (v.code == dtmplData.code) {
|
|
438
|
+
isAdd = false;
|
|
439
|
+
v.editStatus = dtmplData.editStatus;
|
|
440
|
+
v.fieldMap = dtmplData.fieldMap;
|
|
441
|
+
v.relationLabel = dtmplData.relationLabel;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (isAdd) {
|
|
446
|
+
datas.unshift(dtmplData);
|
|
447
|
+
}
|
|
448
|
+
onChange(fieldGroupConfig, datas);
|
|
449
|
+
if (isAdd) {
|
|
450
|
+
message.success('已添加');
|
|
451
|
+
} else {
|
|
452
|
+
message.success('已修改');
|
|
453
|
+
}
|
|
454
|
+
//this.hiddenRowEdit();
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
showAddDtmplModel = () => {
|
|
458
|
+
this.setState({
|
|
459
|
+
showDtmplEdit: true,
|
|
460
|
+
selectedCode: undefined,
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
showEditDtmplModel = (record) => {
|
|
464
|
+
this.setState({
|
|
465
|
+
showDtmplEdit: true,
|
|
466
|
+
selectedCode: record.code,
|
|
467
|
+
})
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
buildButtons = () => {
|
|
471
|
+
const {fieldGroupConfig, viewOrEdit, value} = this.props;
|
|
472
|
+
const {buttons} = fieldGroupConfig;
|
|
473
|
+
const {showRowEdit} = this.state;
|
|
474
|
+
const buttonDisabled: boolean = fieldGroupConfig.max ? fieldGroupConfig.max <= (value ? value.length : 0) : false;
|
|
475
|
+
|
|
476
|
+
if (viewOrEdit == 'edit') {
|
|
477
|
+
return <>
|
|
478
|
+
{buttons.includes('rowAdd') ?
|
|
479
|
+
// <Popover placement="rightBottom" content={<RowEditCard fieldGroupConfig={fieldGroupConfig} onOk={this.handleRowEdit} ></RowEditCard>} trigger="click">
|
|
480
|
+
// // <Button
|
|
481
|
+
// // disabled={buttonDisabled}
|
|
482
|
+
// // type='primary'
|
|
483
|
+
// // icon={<PlusOutlined/>}
|
|
484
|
+
// // size="small"
|
|
485
|
+
// // // onClick={() => {
|
|
486
|
+
// // // this.showRowEditModel()
|
|
487
|
+
// // // }}
|
|
488
|
+
// // style={{marginBottom: 10, marginRight: 10}}
|
|
489
|
+
// // >新建一行</Button></Popover>
|
|
490
|
+
<RowEditor buttonStyle={{marginBottom: 10, marginRight: 10}} buttonTitle={"新建一行"}
|
|
491
|
+
fieldGroupConfig={fieldGroupConfig}
|
|
492
|
+
onOk={this.handleRowEdit}
|
|
493
|
+
></RowEditor>
|
|
494
|
+
: ''}
|
|
495
|
+
{buttons.includes('dtmplAdd') ?
|
|
496
|
+
<Button
|
|
497
|
+
disabled={buttonDisabled}
|
|
498
|
+
type='primary'
|
|
499
|
+
icon={<PlusSquareOutlined/>}
|
|
500
|
+
size="small"
|
|
501
|
+
onClick={this.showAddDtmplModel}
|
|
502
|
+
style={{marginBottom: 10, marginRight: 10}}
|
|
503
|
+
>新增</Button> : ""}
|
|
504
|
+
{buttons.includes('selectAdd') ?
|
|
505
|
+
<Button
|
|
506
|
+
disabled={buttonDisabled}
|
|
507
|
+
type='primary'
|
|
508
|
+
icon={<SnippetsOutlined/>}
|
|
509
|
+
size="small"
|
|
510
|
+
onClick={this.showSelect}
|
|
511
|
+
style={{marginBottom: 10, marginRight: 10}}
|
|
512
|
+
>选择</Button> : ""}
|
|
513
|
+
</>
|
|
514
|
+
} else {
|
|
515
|
+
return "";
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// hiddenRowEdit = () => {
|
|
520
|
+
// this.setState({
|
|
521
|
+
// showRowEdit: false,
|
|
522
|
+
// })
|
|
523
|
+
// }
|
|
524
|
+
|
|
525
|
+
render() {
|
|
526
|
+
|
|
527
|
+
const {fieldGroupConfig, value, parentId, loading, initCollapse} = this.props;
|
|
528
|
+
const {selectedCode, showDtmplView, showSelectTable, showDtmplEdit, tableLoading, showRowEdit, selectedDtmplData} = this.state;
|
|
529
|
+
|
|
530
|
+
const {buttons} = fieldGroupConfig;
|
|
531
|
+
let page = {
|
|
532
|
+
pageSize: 10,
|
|
533
|
+
hideOnSinglePage: true,
|
|
534
|
+
defaultCurrent: 1,
|
|
535
|
+
total: value ? value.length : undefined,
|
|
536
|
+
showTotal: (total) => {
|
|
537
|
+
return `总共有${total}条`;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
let exceptCodes = [];
|
|
541
|
+
if (value) {
|
|
542
|
+
for (let v of value) {
|
|
543
|
+
exceptCodes.push(v.code);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
return (
|
|
549
|
+
fieldGroupConfig.displayConfig.includes('nonDataNonDisplayed') && (!value || value.length <= 0) ? "" :
|
|
550
|
+
<>
|
|
551
|
+
<CollapseCard
|
|
552
|
+
initCollapse={initCollapse || fieldGroupConfig.displayConfig.includes('folded')}
|
|
553
|
+
title={fieldGroupConfig.title}
|
|
554
|
+
id={parentId + fieldGroupConfig.id}
|
|
555
|
+
className={`hoverable`}
|
|
556
|
+
headStyle={{background: "#f2f4f5"}}
|
|
557
|
+
loading={loading}
|
|
558
|
+
extra={<Input.Search onSearch={this.searchValue} allowClear placeholder="关键字搜索"/>
|
|
559
|
+
}
|
|
560
|
+
>
|
|
561
|
+
<div className="editTableList">
|
|
562
|
+
{this.buildButtons()}
|
|
563
|
+
<Table scroll={{scrollToFirstRowOnChange: false}}
|
|
564
|
+
bordered
|
|
565
|
+
loading={tableLoading}
|
|
566
|
+
dataSource={this.buildDataSource()}
|
|
567
|
+
columns={this.buildColumns()}
|
|
568
|
+
pagination={page}
|
|
569
|
+
onChange={this.tabChange}
|
|
570
|
+
/>
|
|
571
|
+
</div>
|
|
572
|
+
</CollapseCard>
|
|
573
|
+
{buttons.includes('detail') ?
|
|
574
|
+
<ModalDtmplView visible={showDtmplView} onCancel={this.hiddenEntityView}
|
|
575
|
+
sourceId={fieldGroupConfig.id}
|
|
576
|
+
code={selectedCode}> </ModalDtmplView> : ""}
|
|
577
|
+
{buttons.includes('dtmplEdit') || buttons.includes('dtmplAdd') ?
|
|
578
|
+
<ModalDtmplEdit visible={showDtmplEdit} onCancel={this.hiddenEntityEdit}
|
|
579
|
+
sourceId={fieldGroupConfig.id}
|
|
580
|
+
code={selectedCode}
|
|
581
|
+
onOk={selectedCode ? this.handleDtmplEdit : this.handleDtmplAdd}> </ModalDtmplEdit>
|
|
582
|
+
: ""}
|
|
583
|
+
{/*{buttons.includes('rowEdit') || buttons.includes('rowAdd') ?*/}
|
|
584
|
+
{/* <ModalRowEdit visible={showRowEdit} onCancel={this.hiddenRowEdit}*/}
|
|
585
|
+
{/* onOk={this.handleRowEdit} dtmplData={selectedDtmplData}*/}
|
|
586
|
+
{/* fieldGroupConfig={fieldGroupConfig}> </ModalRowEdit>*/}
|
|
587
|
+
{/* : ""}*/}
|
|
588
|
+
{buttons.includes('selectAdd') ?
|
|
589
|
+
<ModelSelectTable maxSelectedRows={fieldGroupConfig.max} visible={showSelectTable}
|
|
590
|
+
onOK={this.select} onCancel={() => {
|
|
591
|
+
this.setState({showSelectTable: false})
|
|
592
|
+
}} exceptCodes={exceptCodes}
|
|
593
|
+
sourceId={fieldGroupConfig.id}></ModelSelectTable> : ""}
|
|
594
|
+
|
|
595
|
+
</>
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export default RelationTable;
|