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,117 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {Drawer, Space,Button,ButtonProps} from 'antd'
|
|
3
|
+
import {CQueryConfig} from "../../tmpl/interface";
|
|
4
|
+
import LtmplPage from "./../../module/ltmpl-page";
|
|
5
|
+
import {
|
|
6
|
+
AlignLeftOutlined,
|
|
7
|
+
CalculatorOutlined,
|
|
8
|
+
DownloadOutlined,
|
|
9
|
+
EditOutlined,
|
|
10
|
+
EyeInvisibleOutlined,
|
|
11
|
+
EyeOutlined,
|
|
12
|
+
FundOutlined,
|
|
13
|
+
LineChartOutlined,
|
|
14
|
+
MenuOutlined,
|
|
15
|
+
PlusOutlined,
|
|
16
|
+
ReloadOutlined,
|
|
17
|
+
RetweetOutlined,
|
|
18
|
+
TableOutlined,
|
|
19
|
+
UploadOutlined,
|
|
20
|
+
CopyOutlined
|
|
21
|
+
} from '@ant-design/icons';
|
|
22
|
+
|
|
23
|
+
import DtmplPage from '../../module/dtmpl-page'
|
|
24
|
+
import ModalDtmplEdit from "../../detail/edit/modal-dtmpl-edit";
|
|
25
|
+
|
|
26
|
+
interface CquickButtonProps extends ButtonProps{
|
|
27
|
+
mainCode:string;
|
|
28
|
+
cQueryConfig:CQueryConfig;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface CquickButtonState {
|
|
32
|
+
showDraw:boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const outlinedMap={
|
|
36
|
+
EditOutlined:<EditOutlined/>
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class CquickButton extends React.PureComponent<CquickButtonProps, CquickButtonState> {
|
|
41
|
+
state={
|
|
42
|
+
showDraw:false,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
showDraw=(currentId:string)=>{
|
|
49
|
+
// console.log("点击了L2MenuQuickBar",currentId);
|
|
50
|
+
this.setState({
|
|
51
|
+
showDraw:true
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
closeDrawer=()=>{
|
|
57
|
+
this.setState({
|
|
58
|
+
showDraw:false
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
render() {
|
|
64
|
+
const {cQueryConfig,mainCode,type,...button}=this.props;
|
|
65
|
+
const {showDraw,} = this.state;
|
|
66
|
+
|
|
67
|
+
console.log("cQuery mainCode",mainCode);
|
|
68
|
+
let mcode=mainCode && mainCode.indexOf("@R@")>0?mainCode.split("@R@")[0]:mainCode;
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
{type=='text'?<span className={'cquickTextButton'} onClick={()=>{
|
|
72
|
+
this.setState({
|
|
73
|
+
showDraw:!showDraw
|
|
74
|
+
})
|
|
75
|
+
}}>{cQueryConfig.title}</span> :<Button {...button} onClick={()=>{
|
|
76
|
+
this.setState({
|
|
77
|
+
showDraw:!showDraw
|
|
78
|
+
})
|
|
79
|
+
}}>{outlinedMap[cQueryConfig.title]?outlinedMap[cQueryConfig.title]:cQueryConfig.title}</Button>}
|
|
80
|
+
{!showDraw?null:
|
|
81
|
+
cQueryConfig.type=='edit'?
|
|
82
|
+
<ModalDtmplEdit visible={showDraw} onCancel={()=>{
|
|
83
|
+
this.setState({
|
|
84
|
+
showDraw:false,
|
|
85
|
+
})}}
|
|
86
|
+
sourceId={cQueryConfig.id}
|
|
87
|
+
code={mcode}
|
|
88
|
+
onOk={this.closeDrawer}> </ModalDtmplEdit>:
|
|
89
|
+
<Drawer
|
|
90
|
+
placement={'left'}
|
|
91
|
+
title="关联查询"
|
|
92
|
+
closable={true}
|
|
93
|
+
mask={false}
|
|
94
|
+
onClose={this.closeDrawer}
|
|
95
|
+
visible={showDraw}
|
|
96
|
+
width={'calc(100% - 280px)'}
|
|
97
|
+
style={{
|
|
98
|
+
maxWidth: 1960,
|
|
99
|
+
}}
|
|
100
|
+
extra={
|
|
101
|
+
<Space>
|
|
102
|
+
<Button onClick={this.closeDrawer}>关闭</Button>
|
|
103
|
+
</Space>
|
|
104
|
+
}
|
|
105
|
+
>
|
|
106
|
+
{
|
|
107
|
+
<LtmplPage sourceId={cQueryConfig.id} mainCode={mcode}></LtmplPage>
|
|
108
|
+
}
|
|
109
|
+
</Drawer>
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
</>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default CquickButton;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {DatePicker as AntdDatePicker,TimePicker} from "antd";
|
|
3
|
+
import moment from "moment";
|
|
4
|
+
import {FieldConfig,EControlProps} from "../../tmpl/interface";
|
|
5
|
+
import Units from "../../units";
|
|
6
|
+
import TmplConfigAnalysis from './../../tmpl/tmpl-config-analysis'
|
|
7
|
+
|
|
8
|
+
const {RangePicker} = AntdDatePicker;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
interface DataPickerProps extends EControlProps{
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const DatePicker: React.FC<DataPickerProps> = (props) => {
|
|
17
|
+
|
|
18
|
+
const {id,value:propsValue, itemType, fieldConfig, onChange,style} = props;
|
|
19
|
+
let value=propsValue;
|
|
20
|
+
let format = Units.getMomentFormat(itemType);
|
|
21
|
+
|
|
22
|
+
const changeValue = (value) => {
|
|
23
|
+
if (onChange) {
|
|
24
|
+
onChange(value?moment(value).format(format):undefined);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const changeRangeValue = (value:any[]) => {
|
|
29
|
+
if (onChange) {
|
|
30
|
+
if(!value){
|
|
31
|
+
onChange(value);
|
|
32
|
+
}else if(value.length===2 && value[0] && value[1]){
|
|
33
|
+
onChange(moment(value[0]).format(format)+"~"+moment(value[1]).format(format));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// if(value && value.startsWith("$$current")){
|
|
39
|
+
// switch (itemType) {
|
|
40
|
+
// case 'daterange':
|
|
41
|
+
// case 'datetimerange':
|
|
42
|
+
// changeRangeValue(TmplConfigAnalysis.current(value,format));
|
|
43
|
+
// break;
|
|
44
|
+
// default:
|
|
45
|
+
// changeValue(TmplConfigAnalysis.current(value,format)[0]);
|
|
46
|
+
// break;
|
|
47
|
+
// }
|
|
48
|
+
//
|
|
49
|
+
// }
|
|
50
|
+
|
|
51
|
+
let entryControl = undefined;
|
|
52
|
+
|
|
53
|
+
let momentValue;
|
|
54
|
+
switch (itemType) {
|
|
55
|
+
case 'date-YY':
|
|
56
|
+
case 'date-M1':
|
|
57
|
+
case 'date':
|
|
58
|
+
momentValue = value ? moment(value, format) : undefined;
|
|
59
|
+
let picker = itemType == 'date-YY' ? 'year' : itemType == 'date-M1' ? "month" : "date"
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
entryControl = <AntdDatePicker
|
|
62
|
+
id={id}
|
|
63
|
+
style={{...style}}
|
|
64
|
+
picker={picker}
|
|
65
|
+
format={format}
|
|
66
|
+
value={momentValue}
|
|
67
|
+
disabled={fieldConfig.disabled}
|
|
68
|
+
onChange={changeValue}
|
|
69
|
+
/>;
|
|
70
|
+
break;
|
|
71
|
+
case 'datetime-HH':
|
|
72
|
+
case 'datetime-mm':
|
|
73
|
+
case 'datetime':
|
|
74
|
+
momentValue = value ? moment(value, format) : undefined;
|
|
75
|
+
entryControl = <AntdDatePicker
|
|
76
|
+
id={id}
|
|
77
|
+
style={{...style}}
|
|
78
|
+
showTime={{format: Units.getDateTimeFormat(itemType)}}
|
|
79
|
+
picker='date'
|
|
80
|
+
format={format}
|
|
81
|
+
value={momentValue}
|
|
82
|
+
disabled={fieldConfig.disabled}
|
|
83
|
+
onChange={changeValue}
|
|
84
|
+
/>;
|
|
85
|
+
break;
|
|
86
|
+
case 'daterange-YY':
|
|
87
|
+
case 'daterange-M1':
|
|
88
|
+
case 'daterange':
|
|
89
|
+
let v1 = value && value.indexOf("~") > 0 ? value.split("~")[0] : undefined
|
|
90
|
+
let v2 = value && value.indexOf("~") > 0 ? value.split("~")[1] : undefined
|
|
91
|
+
momentValue = [v1 ? moment(v1, format) : undefined, v2 ? moment(v2, format) : undefined];
|
|
92
|
+
picker = itemType == 'daterange-YY' ? 'year' : itemType == 'daterange-M1' ? "month" : "date"
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
entryControl = <RangePicker id={id} picker={picker}
|
|
95
|
+
style={{...style}}
|
|
96
|
+
format={format}
|
|
97
|
+
value={momentValue}
|
|
98
|
+
disabled={fieldConfig.disabled}
|
|
99
|
+
onChange={changeRangeValue}/>;
|
|
100
|
+
break;
|
|
101
|
+
case 'datetimerange-HH':
|
|
102
|
+
case 'datetimerange-mm':
|
|
103
|
+
case 'datetimerange':
|
|
104
|
+
const v3 = value && value.indexOf("~") > 0 ? value.split("~")[0] : undefined
|
|
105
|
+
const v4 = value && value.indexOf("~") > 0 ? value.split("~")[1] : undefined
|
|
106
|
+
momentValue = [v3 ? moment(v3, format) : undefined, v4 ? moment(v4, format) : undefined];
|
|
107
|
+
entryControl = <RangePicker id={id} showTime={{format: Units.getDateTimeFormat(itemType)}}
|
|
108
|
+
format={format}
|
|
109
|
+
style={{...style}}
|
|
110
|
+
value={momentValue}
|
|
111
|
+
disabled={fieldConfig.disabled}
|
|
112
|
+
onChange={changeRangeValue}/>;
|
|
113
|
+
break;
|
|
114
|
+
case 'time-HH':
|
|
115
|
+
case 'time-mm':
|
|
116
|
+
case 'time':
|
|
117
|
+
momentValue = value ? moment(value, format) : undefined;
|
|
118
|
+
entryControl =
|
|
119
|
+
<TimePicker id={id} value={momentValue}
|
|
120
|
+
style={{...style}}
|
|
121
|
+
disabled={fieldConfig.disabled} onChange={changeValue}
|
|
122
|
+
format={format}/>;
|
|
123
|
+
break;
|
|
124
|
+
case 'timerange-HH':
|
|
125
|
+
case 'timerange-mm':
|
|
126
|
+
case 'timerange':
|
|
127
|
+
const v5 = value && value.indexOf("~") > 0 ? value.split("~")[0] : undefined
|
|
128
|
+
const v6 = value && value.indexOf("~") > 0 ? value.split("~")[1] : undefined
|
|
129
|
+
momentValue = [v5 ? moment(v5, format) : undefined, v6 ? moment(v6, format) : undefined];
|
|
130
|
+
entryControl = <TimePicker.RangePicker id={id} value={momentValue}
|
|
131
|
+
style={{...style}}
|
|
132
|
+
disabled={fieldConfig.disabled}
|
|
133
|
+
onChange={changeRangeValue} format={format}/>;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return entryControl;
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default DatePicker;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {Button, Select, Spin} from 'antd'
|
|
3
|
+
import {EControlProps, PageInfo, QueryData, QueryKey, SelectConfig, SourceName} from "../../tmpl/interface";
|
|
4
|
+
import {SearchOutlined} from '@ant-design/icons';
|
|
5
|
+
import debounce from 'lodash/debounce';
|
|
6
|
+
import './index.css';
|
|
7
|
+
import HcserviceV3 from "../../tmpl/hcservice-v3";
|
|
8
|
+
import HCDataSource from "../../tmpl/hc-data-source";
|
|
9
|
+
|
|
10
|
+
interface InnerEntitySelectProps extends EControlProps {
|
|
11
|
+
maxSelected?: number,
|
|
12
|
+
onEntityClick?: (code: string) => void,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface InnerEntitySelectState {
|
|
16
|
+
titleId: string,
|
|
17
|
+
optionCacheKey: string,
|
|
18
|
+
pageNo:number,
|
|
19
|
+
loading: boolean,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type OptionCache = {
|
|
23
|
+
queryKey: QueryKey,
|
|
24
|
+
pageInfo: PageInfo,
|
|
25
|
+
touchEnd: boolean,
|
|
26
|
+
options: any,
|
|
27
|
+
searchValue: string,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type LoadDataSource = {
|
|
31
|
+
options: any[],
|
|
32
|
+
touchEnd: boolean,
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default class EntitySelect extends React.PureComponent<InnerEntitySelectProps, InnerEntitySelectState> {
|
|
37
|
+
|
|
38
|
+
static defaultProps = {
|
|
39
|
+
maxSelected: 100,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
state = {
|
|
43
|
+
titleId: undefined,
|
|
44
|
+
optionCacheKey: undefined,
|
|
45
|
+
pageNo:1,
|
|
46
|
+
loading: false,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//没有过滤值的
|
|
50
|
+
optionsCache: Map<string, OptionCache> = new Map();
|
|
51
|
+
selectConfig: SelectConfig = undefined;
|
|
52
|
+
|
|
53
|
+
toOption = (code: string, title: string, onEntityClick) => {
|
|
54
|
+
let option = {
|
|
55
|
+
value: code + '@R@' + title,
|
|
56
|
+
showlabel: onEntityClick ? <Button size={'small'} style={{padding: '0px'}} type="link" title=""
|
|
57
|
+
onClick={(e) => {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
onEntityClick(code);
|
|
60
|
+
}}>{title}
|
|
61
|
+
</Button> : title,
|
|
62
|
+
label: title,
|
|
63
|
+
};
|
|
64
|
+
return option;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
toOptions = (value, onEntityClick) => {
|
|
68
|
+
let options: object[] = [];
|
|
69
|
+
console.log('options value', value);
|
|
70
|
+
|
|
71
|
+
let valueArray: string[];
|
|
72
|
+
if (value instanceof Array) {
|
|
73
|
+
valueArray = value;
|
|
74
|
+
} else {
|
|
75
|
+
if (value) {
|
|
76
|
+
valueArray = [value];
|
|
77
|
+
} else {
|
|
78
|
+
valueArray = [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for (let v of valueArray) {
|
|
83
|
+
if (v) {
|
|
84
|
+
let vs = v.split("@R@");
|
|
85
|
+
options.push(this.toOption(vs[0], vs[1], onEntityClick));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
console.log('options', options);
|
|
89
|
+
return options;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fetchNextPage = async () => {
|
|
93
|
+
|
|
94
|
+
const {optionCacheKey, titleId} = this.state;
|
|
95
|
+
let optionCache = this.optionsCache.get(optionCacheKey);
|
|
96
|
+
let pageInfo = optionCache.pageInfo;
|
|
97
|
+
if (!optionCache.touchEnd) {
|
|
98
|
+
pageInfo.pageNo = pageInfo.pageNo + 1;
|
|
99
|
+
let dataSource = await this.loadData(optionCache.queryKey.key, {...pageInfo}, titleId);
|
|
100
|
+
if (dataSource) {
|
|
101
|
+
optionCache.options = [...optionCache.options, ...dataSource.options];
|
|
102
|
+
optionCache.touchEnd = dataSource.touchEnd;
|
|
103
|
+
}
|
|
104
|
+
this.setState({
|
|
105
|
+
pageNo:pageInfo.pageNo,
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fetchOptions = async (searchText) => {
|
|
111
|
+
const { fieldConfig} = this.props;
|
|
112
|
+
|
|
113
|
+
this.setState({
|
|
114
|
+
loading: true,
|
|
115
|
+
})
|
|
116
|
+
let optionCacheKey = "withoutValue";
|
|
117
|
+
//先从缓存里拿
|
|
118
|
+
if (searchText) {
|
|
119
|
+
optionCacheKey = searchText;
|
|
120
|
+
}
|
|
121
|
+
let titleId = this.state.titleId;
|
|
122
|
+
let optionCache = this.optionsCache.get(optionCacheKey);
|
|
123
|
+
if (!optionCache) {
|
|
124
|
+
if (!this.selectConfig) {
|
|
125
|
+
this.selectConfig = await HCDataSource.requestSelectConfig( fieldConfig.id);
|
|
126
|
+
}
|
|
127
|
+
let pageInfo = {
|
|
128
|
+
pageNo: 1,
|
|
129
|
+
pageSize: 4,
|
|
130
|
+
virtualEndPageNo: undefined,
|
|
131
|
+
};
|
|
132
|
+
let selectConfig = this.selectConfig;
|
|
133
|
+
titleId = selectConfig.columns[1].id;
|
|
134
|
+
//得到第一个过滤条件
|
|
135
|
+
let firstCriteria = selectConfig.criterias[0];
|
|
136
|
+
let formItemName = 'undefinedCriteria';
|
|
137
|
+
if (firstCriteria) {
|
|
138
|
+
formItemName = 'c_' + firstCriteria.id;
|
|
139
|
+
}
|
|
140
|
+
const {defaultPageSize} = selectConfig;
|
|
141
|
+
if (defaultPageSize) {
|
|
142
|
+
pageInfo.pageSize = defaultPageSize;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 构建 dataSource **/
|
|
146
|
+
//构建过滤条件
|
|
147
|
+
let criteriaData = {};
|
|
148
|
+
criteriaData[formItemName] = searchText;
|
|
149
|
+
let queryKey: QueryKey = await HcserviceV3.requestLtmplQueryKey( fieldConfig.id, {...criteriaData, ...pageInfo});
|
|
150
|
+
let sourceData = await this.loadData(queryKey.key, pageInfo, titleId);
|
|
151
|
+
optionCache = {
|
|
152
|
+
options: sourceData.options,
|
|
153
|
+
pageInfo,
|
|
154
|
+
queryKey,
|
|
155
|
+
searchValue: searchText,
|
|
156
|
+
touchEnd: sourceData.touchEnd
|
|
157
|
+
};
|
|
158
|
+
this.optionsCache.set(optionCacheKey, optionCache);
|
|
159
|
+
this.setState({
|
|
160
|
+
optionCacheKey,
|
|
161
|
+
titleId,
|
|
162
|
+
loading: false,
|
|
163
|
+
})
|
|
164
|
+
} else {
|
|
165
|
+
if (this.state.optionCacheKey == optionCacheKey && optionCacheKey == 'withoutValue') {
|
|
166
|
+
this.setState({
|
|
167
|
+
loading: false,
|
|
168
|
+
optionCacheKey,
|
|
169
|
+
})
|
|
170
|
+
} else {
|
|
171
|
+
debounce(() => {
|
|
172
|
+
this.setState({
|
|
173
|
+
loading: false,
|
|
174
|
+
optionCacheKey,
|
|
175
|
+
})
|
|
176
|
+
}, 500)();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
onChange = (values: any[]) => {
|
|
184
|
+
if (values && values.length > this.props.maxSelected) {
|
|
185
|
+
console.log('selected value:', values);
|
|
186
|
+
let newValues = [...values];
|
|
187
|
+
newValues.shift();
|
|
188
|
+
this.onChange(newValues);
|
|
189
|
+
} else {
|
|
190
|
+
this.props.onChange(values);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
loadData = async (queryKey: string, pageInfo: PageInfo, titleId: string): Promise<LoadDataSource> => {
|
|
196
|
+
const {onEntityClick} = this.props;
|
|
197
|
+
|
|
198
|
+
let queryData: QueryData = await HcserviceV3.requestQueryData(queryKey, pageInfo);
|
|
199
|
+
let options: object[] = [];
|
|
200
|
+
pageInfo = queryData.pageInfo;
|
|
201
|
+
queryData.entities.forEach((item, index) => {
|
|
202
|
+
//先得到第一个
|
|
203
|
+
let title = item.fieldMap[titleId];
|
|
204
|
+
let option = this.toOption(item.code, title, onEntityClick);
|
|
205
|
+
options.push(option);
|
|
206
|
+
})
|
|
207
|
+
return {options, touchEnd: queryData.touchEnd};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
debounceFetcher = () => {
|
|
211
|
+
const loadOptions = (val) => {
|
|
212
|
+
this.fetchOptions(val);
|
|
213
|
+
};
|
|
214
|
+
return debounce(loadOptions, 800);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
debounceFetchNextPage = () => {
|
|
218
|
+
// this.setState({
|
|
219
|
+
// loading: true,
|
|
220
|
+
// })
|
|
221
|
+
debounce(this.fetchNextPage, 200)();
|
|
222
|
+
// this.setState({
|
|
223
|
+
// loading: false,
|
|
224
|
+
// })
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
render() {
|
|
229
|
+
const {id,value, fieldConfig, onChange, style, maxSelected, onEntityClick} = this.props;
|
|
230
|
+
const {optionCacheKey, loading} = this.state;
|
|
231
|
+
let initOptions = this.toOptions(value, onEntityClick);
|
|
232
|
+
let exists;
|
|
233
|
+
let properOptions = [...initOptions];
|
|
234
|
+
if (optionCacheKey) {
|
|
235
|
+
for (let option of this.optionsCache.get(optionCacheKey).options) {
|
|
236
|
+
exists = false;
|
|
237
|
+
for (let init of initOptions) {
|
|
238
|
+
if (init['value'] == option['value']) {
|
|
239
|
+
exists = true;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (!exists) {
|
|
243
|
+
properOptions.push(option);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return <Select
|
|
249
|
+
id={id}
|
|
250
|
+
style={{...style}}
|
|
251
|
+
onChange={this.onChange}
|
|
252
|
+
value={value}
|
|
253
|
+
mode="multiple"
|
|
254
|
+
placeholder={`请选择${fieldConfig.title}`}
|
|
255
|
+
notFoundContent={loading ? <Spin size={'small'}></Spin> : "无数据"}
|
|
256
|
+
allowClear={true}
|
|
257
|
+
showArrow={true}
|
|
258
|
+
suffixIcon={<SearchOutlined/>}
|
|
259
|
+
onSearch={this.debounceFetcher()}
|
|
260
|
+
onClick={() => {
|
|
261
|
+
debounce(this.fetchOptions, 100)(undefined)
|
|
262
|
+
}}
|
|
263
|
+
options={loading ? [] : properOptions}
|
|
264
|
+
onPopupScroll={(e) => {
|
|
265
|
+
const {target} = e;
|
|
266
|
+
// console.log("target['scrollTop'] + target['offsetHeight']",target['scrollTop'] + target['offsetHeight']+1);
|
|
267
|
+
// console.log("target['scrollHeight']",target['scrollHeight']);
|
|
268
|
+
// target.scrollTop + target.offsetHeight === target.scrollHeight 判断是否滑动到底部
|
|
269
|
+
if (target['scrollTop'] + target['offsetHeight'] + 1 >= target['scrollHeight']) {
|
|
270
|
+
this.debounceFetchNextPage();
|
|
271
|
+
}
|
|
272
|
+
}}>
|
|
273
|
+
</Select>
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {Button, Popover, Select} from 'antd'
|
|
3
|
+
import {EControlProps, SelectedRow, SourceName} from "../../tmpl/interface";
|
|
4
|
+
import {SearchOutlined} from '@ant-design/icons';
|
|
5
|
+
import SelectTable from '../../table/select-table'
|
|
6
|
+
import './index.css'
|
|
7
|
+
|
|
8
|
+
interface EntitySelectProps extends EControlProps {
|
|
9
|
+
maxSelected?: number,
|
|
10
|
+
onEntityClick?: (code: string) => void,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
interface EntitySelectState {
|
|
14
|
+
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default class EntitySelect extends React.PureComponent<EntitySelectProps, EntitySelectState> {
|
|
18
|
+
|
|
19
|
+
static defaultProps = {
|
|
20
|
+
maxSelected: 100,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
state = {}
|
|
24
|
+
|
|
25
|
+
onClick = () => {
|
|
26
|
+
this.setState({
|
|
27
|
+
showSelectTable: true,
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
onSelect = (selectedRows: SelectedRow[]) => {
|
|
32
|
+
const {value, onChange} = this.props;
|
|
33
|
+
let newValue = [];
|
|
34
|
+
if (selectedRows) {
|
|
35
|
+
for (let row of selectedRows) {
|
|
36
|
+
newValue.push(row.code + '@R@' + row.title);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
onChange(newValue);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
const {id,value, itemType, fieldConfig, onChange, style, maxSelected, onEntityClick} = this.props;
|
|
45
|
+
const {} = this.state;
|
|
46
|
+
let selectedRows: SelectedRow[] = [];
|
|
47
|
+
let relationOptions = []
|
|
48
|
+
|
|
49
|
+
let valueArray: string[];
|
|
50
|
+
if (value instanceof Array) {
|
|
51
|
+
valueArray = value;
|
|
52
|
+
} else {
|
|
53
|
+
if (value) {
|
|
54
|
+
valueArray = [value];
|
|
55
|
+
} else {
|
|
56
|
+
valueArray = [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
valueArray.forEach((v) => {
|
|
61
|
+
if (v.indexOf('@R@') > 0) {
|
|
62
|
+
let vs = v.split('@R@');
|
|
63
|
+
selectedRows.push({code: vs[0], title: vs[1]});
|
|
64
|
+
relationOptions.push({
|
|
65
|
+
value: v,
|
|
66
|
+
label: onEntityClick ? <Button size={'small'} style={{padding: '0px'}} type="link" title=""
|
|
67
|
+
onClick={(e) => {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
onEntityClick(vs[0]);
|
|
70
|
+
}}>{vs[1]}
|
|
71
|
+
</Button> : vs[1]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
return <>
|
|
77
|
+
<Popover overlayClassName={'-popover'} placement="bottom" color={'#f0f0f0'}
|
|
78
|
+
overlayStyle={{maxWidth: 'calc(100vw - 60px)', maxHeight: 'calc(100vh - 50px)',}}
|
|
79
|
+
overlayInnerStyle={{padding: '0px'}}
|
|
80
|
+
// getPopupContainer={(triggerNode) => {
|
|
81
|
+
// return triggerNode.parentNode;}}
|
|
82
|
+
content={<div style={{
|
|
83
|
+
height: 300,
|
|
84
|
+
backgroundColor: '#fafafa',
|
|
85
|
+
overflow: 'auto',
|
|
86
|
+
borderStyle: 'solid',
|
|
87
|
+
borderRadius: '6px',
|
|
88
|
+
borderWidth: '0px',
|
|
89
|
+
borderColor: '#8c8c8c'
|
|
90
|
+
}}><SelectTable maxSelectedRows={maxSelected} selectedRows={selectedRows} sourceId={fieldConfig.id}
|
|
91
|
+
onChange={this.onSelect}></SelectTable></div>}
|
|
92
|
+
trigger="click">
|
|
93
|
+
<Select id={id} style={{...style}}
|
|
94
|
+
value={value}
|
|
95
|
+
mode="multiple"
|
|
96
|
+
placeholder={`请选择${fieldConfig.title}`}
|
|
97
|
+
notFoundContent="请选择"
|
|
98
|
+
allowClear={true}
|
|
99
|
+
showArrow={true}
|
|
100
|
+
suffixIcon={<SearchOutlined/>}
|
|
101
|
+
dropdownStyle={{display: 'none'}}
|
|
102
|
+
onChange={(value) => {
|
|
103
|
+
onChange(value)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
options={relationOptions}
|
|
107
|
+
>
|
|
108
|
+
</Select>
|
|
109
|
+
</Popover>
|
|
110
|
+
</>;
|
|
111
|
+
}
|
|
112
|
+
}
|