kts-components-document-access-point 1.4.3 → 1.4.6

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.
Files changed (123) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +4 -4
  3. package/.prettierignore +7 -7
  4. package/.prettierrc +11 -11
  5. package/.umirc.ts +11 -11
  6. package/README.md +3 -3
  7. package/dist/index.esm.js +9 -5
  8. package/dist/index.js +9 -5
  9. package/docs/index.md +3 -3
  10. package/index.html +12 -12
  11. package/package.json +56 -56
  12. package/src/DocumentWhiteList/___demo___/base/index.tsx +7 -7
  13. package/src/DocumentWhiteList/___demo___/setService/index.tsx +23 -23
  14. package/src/DocumentWhiteList/control/actions/addblack/index.ts +14 -14
  15. package/src/DocumentWhiteList/control/actions/addwhite/index.ts +14 -14
  16. package/src/DocumentWhiteList/control/actions/blacklist/index.ts +22 -22
  17. package/src/DocumentWhiteList/control/actions/checkclient/index.ts +14 -14
  18. package/src/DocumentWhiteList/control/actions/demo/index.ts +4 -4
  19. package/src/DocumentWhiteList/control/actions/didilist/index.ts +18 -18
  20. package/src/DocumentWhiteList/control/actions/enableblacklist/index.ts +17 -17
  21. package/src/DocumentWhiteList/control/actions/enablelist/index.ts +18 -18
  22. package/src/DocumentWhiteList/control/actions/enablewhitelist/index.ts +17 -17
  23. package/src/DocumentWhiteList/control/actions/getmode/index.ts +14 -14
  24. package/src/DocumentWhiteList/control/actions/setmode/index.ts +14 -14
  25. package/src/DocumentWhiteList/control/actions/synclist/index.ts +19 -19
  26. package/src/DocumentWhiteList/control/actions/whitelist/index.ts +22 -22
  27. package/src/DocumentWhiteList/control/index.tsx +42 -42
  28. package/src/DocumentWhiteList/control/state/index.ts +47 -47
  29. package/src/DocumentWhiteList/index.md +5 -5
  30. package/src/DocumentWhiteList/index.tsx +40 -40
  31. package/src/DocumentWhiteList/interface/index.ts +30 -30
  32. package/src/DocumentWhiteList/ui/clientmodal/index.tsx +190 -190
  33. package/src/DocumentWhiteList/ui/main/black.tsx +132 -132
  34. package/src/DocumentWhiteList/ui/main/index.tsx +49 -49
  35. package/src/DocumentWhiteList/ui/main/switchmode.tsx +52 -52
  36. package/src/DocumentWhiteList/ui/main/white.tsx +120 -120
  37. package/src/DocumentWhiteList/ui/pageheader/BlackHeader.tsx +143 -143
  38. package/src/DocumentWhiteList/ui/pageheader/WhiteHeader.tsx +152 -152
  39. package/src/DocumentWhiteList/ui/pageui/index.tsx +64 -64
  40. package/src/DocumentWhiteList/ui/whitemodal/index.tsx +146 -146
  41. package/src/DocumentWhiteList/util/ConfigEnum.ts +8 -8
  42. package/src/DocumentsCont/___demo___/base/index.tsx +7 -7
  43. package/src/DocumentsCont/___demo___/setService/index.tsx +25 -25
  44. package/src/DocumentsCont/index.md +9 -9
  45. package/src/DocumentsCont/index.tsx +54 -51
  46. package/src/DocumentsDemo/Controller/index.tsx +14 -14
  47. package/src/DocumentsDemo/Controller/whitelist.ts +22 -22
  48. package/src/DocumentsDemo/Text.tsx +22 -22
  49. package/src/DocumentsDemo/___demo___/base/index.tsx +7 -7
  50. package/src/DocumentsDemo/index.md +6 -6
  51. package/src/DocumentsDemo/index.tsx +38 -38
  52. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/IProperties/index.ts +69 -69
  53. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/IRules/index.ts +18 -18
  54. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/ISchema/index.ts +14 -14
  55. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/PropertyTableState/index.ts +12 -12
  56. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/RuleState/index.ts +336 -336
  57. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/index.ts +51 -51
  58. package/src/DocumentsEdit/DocumentsEditController/actions/addProperties/index.ts +37 -37
  59. package/src/DocumentsEdit/DocumentsEditController/actions/delProperties/index.ts +48 -48
  60. package/src/DocumentsEdit/DocumentsEditController/actions/editProperties/index.ts +93 -93
  61. package/src/DocumentsEdit/DocumentsEditController/index.tsx +21 -21
  62. package/src/DocumentsEdit/___demo___/conventional/index.tsx +10 -10
  63. package/src/DocumentsEdit/___demo___/monitor/index.tsx +1421 -1421
  64. package/src/DocumentsEdit/___demo___/readOnly/index.tsx +16 -16
  65. package/src/DocumentsEdit/constant/propertyColumns/index.tsx +65 -65
  66. package/src/DocumentsEdit/index.less +45 -45
  67. package/src/DocumentsEdit/index.md +10 -10
  68. package/src/DocumentsEdit/index.tsx +117 -117
  69. package/src/DocumentsEdit/tools/index.ts +88 -88
  70. package/src/DocumentsEdit/ui/AddPropertyButton/index.tsx +238 -238
  71. package/src/DocumentsEdit/ui/Breadcrumb/index.tsx +51 -51
  72. package/src/DocumentsEdit/ui/EditProperty/index.tsx +290 -290
  73. package/src/DocumentsEdit/ui/EditRule/index.tsx +156 -156
  74. package/src/DocumentsEdit/ui/EditRule/ui/AddRuleButton/index.tsx +49 -49
  75. package/src/DocumentsEdit/ui/EditRule/ui/DelRuleButton/index.tsx +31 -31
  76. package/src/DocumentsEdit/ui/EditRule/ui/RuleForm/fn/algorithmFormComponent/index.tsx +142 -142
  77. package/src/DocumentsEdit/ui/EditRule/ui/RuleForm/index.tsx +154 -154
  78. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/index.less +4 -4
  79. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/index.tsx +70 -70
  80. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/ui/AddChildPropertyButton/index.tsx +34 -34
  81. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/ui/AddRuleButton/index.tsx +64 -64
  82. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/ui/EditPropertyButton/index.tsx +31 -31
  83. package/src/DocumentsEdit/ui/PropertyTable/index.less +19 -19
  84. package/src/DocumentsEdit/ui/PropertyTable/index.tsx +18 -18
  85. package/src/DocumentsEdit/ui/RefPropertyButton/index.tsx +121 -121
  86. package/src/DocumentsList/DocumentsListController/DocumentsListControllerState/index.ts +55 -55
  87. package/src/DocumentsList/DocumentsListController/actions/demo/index.ts +4 -4
  88. package/src/DocumentsList/DocumentsListController/actions/typelist/index.ts +15 -15
  89. package/src/DocumentsList/DocumentsListController/index.tsx +16 -16
  90. package/src/DocumentsList/___demo___/list/index.tsx +4 -4
  91. package/src/DocumentsList/index.less +22 -22
  92. package/src/DocumentsList/index.md +3 -3
  93. package/src/DocumentsList/index.tsx +46 -46
  94. package/src/DocumentsList/ui/ModalComfirm/index.tsx +94 -92
  95. package/src/DocumentsList/ui/PageHeader/SendHeader.tsx +230 -230
  96. package/src/DocumentsList/ui/PageHeader/index.tsx +325 -325
  97. package/src/DocumentsList/ui/PageUI/index.tsx +65 -65
  98. package/src/DocumentsList/ui/RuleTable/index.tsx +163 -163
  99. package/src/DocumentsList/ui/sendlist/index.tsx +151 -151
  100. package/src/DocumentsList/util/ConfigEnum.ts +11 -11
  101. package/src/DocumentsRule/control/actions/batchsend/index.ts +13 -13
  102. package/src/DocumentsRule/control/actions/configsave/index.ts +14 -14
  103. package/src/DocumentsRule/control/actions/configupdate/index.ts +13 -13
  104. package/src/DocumentsRule/control/actions/getconfigbyid/index.ts +14 -14
  105. package/src/DocumentsRule/control/actions/getrecordbyid/index.ts +14 -14
  106. package/src/DocumentsRule/control/actions/gettemplate/index.ts +15 -15
  107. package/src/DocumentsRule/control/actions/listbysubjectid/index.ts +13 -13
  108. package/src/DocumentsRule/control/actions/typelist/index.ts +13 -13
  109. package/src/DocumentsRule/control/index.tsx +30 -30
  110. package/src/DocumentsRule/control/state/index.ts +42 -42
  111. package/src/DocumentsRule/index.md +1 -1
  112. package/src/DocumentsRule/index.tsx +25 -25
  113. package/src/DocumentsRule/interface/index.ts +28 -28
  114. package/src/DocumentsRule/ui/main/index.tsx +362 -362
  115. package/src/DocumentsService/index.ts +18 -18
  116. package/src/index.ts +9 -9
  117. package/tsconfig.json +29 -29
  118. package/typings.d.ts +3 -3
  119. package/docs-dist/404.html +0 -38
  120. package/docs-dist/index.html +0 -38
  121. package/docs-dist/static/icon.050945f2.svg +0 -1
  122. package/docs-dist/umi.css +0 -11
  123. package/docs-dist/umi.js +0 -1
@@ -1,142 +1,142 @@
1
-
2
- import { IOperator } from "../../../../../../DocumentsEditController/DocumentsEditControllerState/RuleState";
3
- import IProperties from "../../../../../../DocumentsEditController/DocumentsEditControllerState/IProperties";
4
- import { DatePicker, Form, Input, Select, Switch, Tooltip } from "kts-components-antd-x4";
5
- import React from "react";
6
- import Icon from "@ant-design/icons";
7
- import { ReactComponent as IconSvg } from './icon.svg';
8
- import moment from "moment";
9
-
10
- /** 生成规则表单 */
11
- export default function algorithmFormComponent(operator: IOperator, ruleProperties?: IProperties, readOnly?: boolean) {
12
- if (!ruleProperties) return <></>;
13
-
14
- const info = ruleProperties.items ? ruleProperties.items : ruleProperties;
15
-
16
- function renderFormItem(child: React.ReactChild) {
17
- return (
18
- <Form.Item key={`algorithmForm_${operator.name}`} {...operator}>
19
- {child}
20
- </Form.Item>
21
- )
22
- }
23
-
24
- if (operator.enum) {
25
- return renderFormItem(
26
- <Select disabled={readOnly} >
27
- {operator.enum.map((e, i) => {
28
- return (
29
- <Select.Option key={i} value={e.value}>{e.label}</Select.Option>
30
- )
31
- })}
32
- </Select>
33
- )
34
- }
35
-
36
- switch (operator.type) {
37
- case 'integer':
38
- return renderFormItem(
39
- <Input readOnly={readOnly} />
40
- )
41
-
42
- case 'number':
43
- return renderFormItem(
44
- <Input readOnly={readOnly} />
45
- )
46
-
47
- case 'string':
48
- return renderFormItem(
49
- <Input readOnly={readOnly} />
50
- )
51
-
52
- case 'string|date':
53
- if (info.format === 'date-time') {
54
- return renderFormItem(
55
- <MyDatePickerTime disabled={readOnly} />
56
- )
57
- } else {
58
- return renderFormItem(
59
- <MyDatePicker disabled={readOnly} />
60
- )
61
- }
62
-
63
- case 'array':
64
- return (
65
- <Form.Item
66
- key={`algorithmForm_${operator.name}`}
67
- {...operator}
68
- rules={[
69
- ...(operator.rules || []),
70
- {
71
- validator: async (rule, value: string) => {
72
- if (!value) return;
73
- if (value.indexOf(',') >= 0) throw new Error('请使用英文","');
74
-
75
- switch (info.type) {
76
- case 'number':
77
- if (value.split(',').some(e => !/((^[1-9]\d*$)|^[0]$)|(^[0-9]*\.[0-9]+$)/.test(`${e}`)))
78
- throw new Error('只能输入数字');
79
- break;
80
- case 'integer':
81
- if (value.split(',').some(e => !/(^[1-9]\d*$)|^[0]$/.test(`${e}`)))
82
- throw new Error('只能输入整数');
83
- break;
84
- case 'string':
85
- if (value.split(',').some(e => !e))
86
- throw new Error('不能有空的项');
87
- break;
88
- }
89
- }
90
- }
91
- ]}
92
- >
93
- <MyArray readOnly={readOnly} />
94
- </Form.Item>
95
- )
96
-
97
- case 'boolean':
98
- return (
99
- <Form.Item valuePropName="checked" key={`algorithmForm_${operator.name}`} {...operator}>
100
- <Switch disabled={readOnly} />
101
- </Form.Item>
102
- )
103
- }
104
- return <></>
105
- }
106
-
107
- const MyDatePickerTime = (props: { value?: any, disabled?: boolean, onChange?: (e: any) => void }) => {
108
- const onChange = React.useCallback((e: moment.Moment | null) => {
109
- props.onChange && props.onChange(e ? e.format('YYYY-MM-DDTHH:mm:ss') : undefined)
110
- }, [props.onChange])
111
- const value = React.useMemo(() => props.value ? moment(props.value) : undefined, [props.value])
112
- return <DatePicker disabled={props.disabled} value={value} onChange={onChange} showTime />
113
- }
114
-
115
- const MyDatePicker = (props: { value?: any, disabled?: boolean, onChange?: (e: any) => void }) => {
116
- const onChange = React.useCallback((e: moment.Moment | null) => {
117
- props.onChange && props.onChange(e ? e.format('YYYY-MM-DD') : undefined)
118
- }, [props.onChange])
119
- const value = React.useMemo(() => props.value ? moment(props.value) : undefined, [props.value])
120
- return <DatePicker disabled={props.disabled} value={value} onChange={onChange} />
121
- }
122
-
123
- const MyArray = (props: { readOnly?: boolean, value?: string[] | string, onChange?: (e: string) => void }) => {
124
- const readOnly = !!props.readOnly;
125
-
126
- const onChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
127
- props.onChange && props.onChange(e.target.value);
128
- }, [])
129
-
130
- return (
131
- <Input
132
- value={props.value instanceof Array ? props.value.join(',') : props.value}
133
- onChange={onChange}
134
- readOnly={readOnly}
135
- suffix={
136
- <Tooltip title="若有多个值,请使用英文逗号“,”隔开。">
137
- <Icon component={IconSvg} style={{ color: 'rgba(0,0,0,.45)' }} />
138
- </Tooltip>
139
- }
140
- />
141
- )
142
- }
1
+
2
+ import { IOperator } from "../../../../../../DocumentsEditController/DocumentsEditControllerState/RuleState";
3
+ import IProperties from "../../../../../../DocumentsEditController/DocumentsEditControllerState/IProperties";
4
+ import { DatePicker, Form, Input, Select, Switch, Tooltip } from "kts-components-antd-x4";
5
+ import React from "react";
6
+ import Icon from "@ant-design/icons";
7
+ import { ReactComponent as IconSvg } from './icon.svg';
8
+ import moment from "moment";
9
+
10
+ /** 生成规则表单 */
11
+ export default function algorithmFormComponent(operator: IOperator, ruleProperties?: IProperties, readOnly?: boolean) {
12
+ if (!ruleProperties) return <></>;
13
+
14
+ const info = ruleProperties.items ? ruleProperties.items : ruleProperties;
15
+
16
+ function renderFormItem(child: React.ReactChild) {
17
+ return (
18
+ <Form.Item key={`algorithmForm_${operator.name}`} {...operator}>
19
+ {child}
20
+ </Form.Item>
21
+ )
22
+ }
23
+
24
+ if (operator.enum) {
25
+ return renderFormItem(
26
+ <Select disabled={readOnly} >
27
+ {operator.enum.map((e, i) => {
28
+ return (
29
+ <Select.Option key={i} value={e.value}>{e.label}</Select.Option>
30
+ )
31
+ })}
32
+ </Select>
33
+ )
34
+ }
35
+
36
+ switch (operator.type) {
37
+ case 'integer':
38
+ return renderFormItem(
39
+ <Input readOnly={readOnly} />
40
+ )
41
+
42
+ case 'number':
43
+ return renderFormItem(
44
+ <Input readOnly={readOnly} />
45
+ )
46
+
47
+ case 'string':
48
+ return renderFormItem(
49
+ <Input readOnly={readOnly} />
50
+ )
51
+
52
+ case 'string|date':
53
+ if (info.format === 'date-time') {
54
+ return renderFormItem(
55
+ <MyDatePickerTime disabled={readOnly} />
56
+ )
57
+ } else {
58
+ return renderFormItem(
59
+ <MyDatePicker disabled={readOnly} />
60
+ )
61
+ }
62
+
63
+ case 'array':
64
+ return (
65
+ <Form.Item
66
+ key={`algorithmForm_${operator.name}`}
67
+ {...operator}
68
+ rules={[
69
+ ...(operator.rules || []),
70
+ {
71
+ validator: async (rule, value: string) => {
72
+ if (!value) return;
73
+ if (value.indexOf(',') >= 0) throw new Error('请使用英文","');
74
+
75
+ switch (info.type) {
76
+ case 'number':
77
+ if (value.split(',').some(e => !/((^[1-9]\d*$)|^[0]$)|(^[0-9]*\.[0-9]+$)/.test(`${e}`)))
78
+ throw new Error('只能输入数字');
79
+ break;
80
+ case 'integer':
81
+ if (value.split(',').some(e => !/(^[1-9]\d*$)|^[0]$/.test(`${e}`)))
82
+ throw new Error('只能输入整数');
83
+ break;
84
+ case 'string':
85
+ if (value.split(',').some(e => !e))
86
+ throw new Error('不能有空的项');
87
+ break;
88
+ }
89
+ }
90
+ }
91
+ ]}
92
+ >
93
+ <MyArray readOnly={readOnly} />
94
+ </Form.Item>
95
+ )
96
+
97
+ case 'boolean':
98
+ return (
99
+ <Form.Item valuePropName="checked" key={`algorithmForm_${operator.name}`} {...operator}>
100
+ <Switch disabled={readOnly} />
101
+ </Form.Item>
102
+ )
103
+ }
104
+ return <></>
105
+ }
106
+
107
+ const MyDatePickerTime = (props: { value?: any, disabled?: boolean, onChange?: (e: any) => void }) => {
108
+ const onChange = React.useCallback((e: moment.Moment | null) => {
109
+ props.onChange && props.onChange(e ? e.format('YYYY-MM-DDTHH:mm:ss') : undefined)
110
+ }, [props.onChange])
111
+ const value = React.useMemo(() => props.value ? moment(props.value) : undefined, [props.value])
112
+ return <DatePicker disabled={props.disabled} value={value} onChange={onChange} showTime />
113
+ }
114
+
115
+ const MyDatePicker = (props: { value?: any, disabled?: boolean, onChange?: (e: any) => void }) => {
116
+ const onChange = React.useCallback((e: moment.Moment | null) => {
117
+ props.onChange && props.onChange(e ? e.format('YYYY-MM-DD') : undefined)
118
+ }, [props.onChange])
119
+ const value = React.useMemo(() => props.value ? moment(props.value) : undefined, [props.value])
120
+ return <DatePicker disabled={props.disabled} value={value} onChange={onChange} />
121
+ }
122
+
123
+ const MyArray = (props: { readOnly?: boolean, value?: string[] | string, onChange?: (e: string) => void }) => {
124
+ const readOnly = !!props.readOnly;
125
+
126
+ const onChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
127
+ props.onChange && props.onChange(e.target.value);
128
+ }, [])
129
+
130
+ return (
131
+ <Input
132
+ value={props.value instanceof Array ? props.value.join(',') : props.value}
133
+ onChange={onChange}
134
+ readOnly={readOnly}
135
+ suffix={
136
+ <Tooltip title="若有多个值,请使用英文逗号“,”隔开。">
137
+ <Icon component={IconSvg} style={{ color: 'rgba(0,0,0,.45)' }} />
138
+ </Tooltip>
139
+ }
140
+ />
141
+ )
142
+ }
@@ -1,155 +1,155 @@
1
- import React from 'react';
2
- import {
3
- Form,
4
- Input,
5
- Radio,
6
- Select,
7
- } from 'kts-components-antd-x4';
8
- import DocumentsEdit from '../../../../';
9
- import algorithmFormComponent from './fn/algorithmFormComponent';
10
- import { IDataSource } from '../../../../../DocumentsEdit/DocumentsEditController/DocumentsEditControllerState';
11
-
12
- export default (props: { index: number }) => {
13
-
14
- const [form] = Form.useForm();
15
-
16
- const controller = DocumentsEdit.useDocumentsEditController();
17
-
18
- /** 只读模式 */
19
- const readOnly = controller.useMemo(s => s.readOnly, []);
20
-
21
- /** 可以用的算法 */
22
- const algorithm = controller.useMemo(s => s.ruleState.algorithm, [])
23
-
24
- /** 正在编辑规则的字段 */
25
- const ruleProperties = controller.useMemo(s => s.ruleState.ruleProperties, [])
26
-
27
- /** 算子字典 */
28
- const operatorMap = controller.useMemo(s => s.ruleState.operatorMap, [])
29
-
30
- const rules = controller.useMemo(s => {
31
- const ref = s.ruleState.ruleProperties?.ref;
32
- if (!ref) return [];
33
- if (ref.items) {
34
- return ref.items.rules ? ref.items.rules : []
35
- } else {
36
- return ref.rules ? ref.rules : [];
37
- }
38
- }, [])
39
-
40
- /** 正在编辑的规则 */
41
- const rule = React.useMemo(() => {
42
- return rules[props.index];
43
- }, [rules, props.index])
44
-
45
- /** 选中的算法 */
46
- const [selectedAlgorithm, setSelectedAlgorithm] = React.useState<string | undefined>(rule.algorithm)
47
-
48
- const onChangeForm = React.useCallback(async (_: any, values: any) => {
49
- setSelectedAlgorithm(values.algorithm);
50
- }, [controller, form])
51
-
52
- /** 规则表单 */
53
- const algorithmForm = React.useMemo(() => {
54
-
55
- const a = algorithm.filter(e => e.name === selectedAlgorithm)[0];
56
- if (!a) return;
57
-
58
- return a.operator.map(e => algorithmFormComponent(operatorMap[e], ruleProperties?.ref, readOnly));
59
- }, [algorithm, operatorMap, selectedAlgorithm, ruleProperties, readOnly])
60
-
61
- React.useEffect(() => {
62
- controller.pipeline(async s => { s.ruleState.formList.push(form) })();
63
- return () => {
64
- controller.pipeline(async s => {
65
- s.ruleState.formList.splice(s.ruleState.formList.indexOf(form), 1);
66
- })()
67
- }
68
- }, [form, controller])
69
-
70
- React.useEffect(() => {
71
- const v: any = {};
72
- for (let key in rule) {
73
- if (typeof rule[key] === 'number') {
74
- v[key] = `${rule[key]}`;
75
- } else if (rule[key] instanceof Array) {
76
- v[key] = rule[key].join(',');
77
- } else {
78
- v[key] = rule[key];
79
- }
80
- }
81
- form.setFieldsValue(v);
82
- }, [form, rule])
83
-
84
- return (
85
- <Form
86
- form={form}
87
- layout="horizontal"
88
- labelCol={{ span: 8 }}
89
- wrapperCol={{ span: 16 }}
90
- onValuesChange={onChangeForm}
91
- >
92
- <Form.Item hidden name="_index" initialValue={rule?._index} key={rule?._index} />
93
- <Form.Item
94
- name="name"
95
- label="校验规则名称"
96
- rules={[
97
- { required: true, message: "请输入校验规则名称" },
98
- { max: 20, message: '只能输入20个字符' },
99
- ]}
100
- >
101
- <Input readOnly={readOnly} />
102
- </Form.Item>
103
-
104
- <Form.Item
105
- name="message"
106
- label="校验不通过提示"
107
- rules={[
108
- { required: true, message: "请输入校验不通过提示" },
109
- { max: 50, message: '只能输入50个字符' },
110
- ]}
111
- >
112
- <Input readOnly={readOnly} />
113
- </Form.Item>
114
-
115
- <Form.Item
116
- name="checkType"
117
- label="阻断流程性质"
118
- initialValue="control"
119
- >
120
- <Radio.Group disabled={readOnly} >
121
- <Radio value="control">控制性</Radio>
122
- <Radio value="notice">提示性</Radio>
123
- </Radio.Group>
124
- </Form.Item>
125
-
126
- <Form.Item
127
- name="algorithm"
128
- label="规则算法"
129
- >
130
- <Select allowClear disabled={readOnly}>
131
- {algorithm.filter(e => e.type === getPropertiesType(ruleProperties)).map((e, i) => {
132
- return (
133
- <Select.Option key={e.name} value={e.name}>{e.label}</Select.Option>
134
- )
135
- })}
136
- </Select>
137
- </Form.Item>
138
-
139
- {algorithmForm}
140
- </Form>
141
- );
142
- };
143
-
144
- /** 获取字段对应的规则数据 */
145
- function getPropertiesType(ruleProperties?: IDataSource) {
146
- if (!ruleProperties) return '';
147
-
148
- const pr = ruleProperties.ref.items || ruleProperties.ref;
149
-
150
- if (pr.type === 'string' && pr.format) {
151
- return `string|${pr.format}`;
152
- }
153
-
154
- return pr.type;
1
+ import React from 'react';
2
+ import {
3
+ Form,
4
+ Input,
5
+ Radio,
6
+ Select,
7
+ } from 'kts-components-antd-x4';
8
+ import DocumentsEdit from '../../../../';
9
+ import algorithmFormComponent from './fn/algorithmFormComponent';
10
+ import { IDataSource } from '../../../../../DocumentsEdit/DocumentsEditController/DocumentsEditControllerState';
11
+
12
+ export default (props: { index: number }) => {
13
+
14
+ const [form] = Form.useForm();
15
+
16
+ const controller = DocumentsEdit.useDocumentsEditController();
17
+
18
+ /** 只读模式 */
19
+ const readOnly = controller.useMemo(s => s.readOnly, []);
20
+
21
+ /** 可以用的算法 */
22
+ const algorithm = controller.useMemo(s => s.ruleState.algorithm, [])
23
+
24
+ /** 正在编辑规则的字段 */
25
+ const ruleProperties = controller.useMemo(s => s.ruleState.ruleProperties, [])
26
+
27
+ /** 算子字典 */
28
+ const operatorMap = controller.useMemo(s => s.ruleState.operatorMap, [])
29
+
30
+ const rules = controller.useMemo(s => {
31
+ const ref = s.ruleState.ruleProperties?.ref;
32
+ if (!ref) return [];
33
+ if (ref.items) {
34
+ return ref.items.rules ? ref.items.rules : []
35
+ } else {
36
+ return ref.rules ? ref.rules : [];
37
+ }
38
+ }, [])
39
+
40
+ /** 正在编辑的规则 */
41
+ const rule = React.useMemo(() => {
42
+ return rules[props.index];
43
+ }, [rules, props.index])
44
+
45
+ /** 选中的算法 */
46
+ const [selectedAlgorithm, setSelectedAlgorithm] = React.useState<string | undefined>(rule.algorithm)
47
+
48
+ const onChangeForm = React.useCallback(async (_: any, values: any) => {
49
+ setSelectedAlgorithm(values.algorithm);
50
+ }, [controller, form])
51
+
52
+ /** 规则表单 */
53
+ const algorithmForm = React.useMemo(() => {
54
+
55
+ const a = algorithm.filter(e => e.name === selectedAlgorithm)[0];
56
+ if (!a) return;
57
+
58
+ return a.operator.map(e => algorithmFormComponent(operatorMap[e], ruleProperties?.ref, readOnly));
59
+ }, [algorithm, operatorMap, selectedAlgorithm, ruleProperties, readOnly])
60
+
61
+ React.useEffect(() => {
62
+ controller.pipeline(async s => { s.ruleState.formList.push(form) })();
63
+ return () => {
64
+ controller.pipeline(async s => {
65
+ s.ruleState.formList.splice(s.ruleState.formList.indexOf(form), 1);
66
+ })()
67
+ }
68
+ }, [form, controller])
69
+
70
+ React.useEffect(() => {
71
+ const v: any = {};
72
+ for (let key in rule) {
73
+ if (typeof rule[key] === 'number') {
74
+ v[key] = `${rule[key]}`;
75
+ } else if (rule[key] instanceof Array) {
76
+ v[key] = rule[key].join(',');
77
+ } else {
78
+ v[key] = rule[key];
79
+ }
80
+ }
81
+ form.setFieldsValue(v);
82
+ }, [form, rule])
83
+
84
+ return (
85
+ <Form
86
+ form={form}
87
+ layout="horizontal"
88
+ labelCol={{ span: 8 }}
89
+ wrapperCol={{ span: 16 }}
90
+ onValuesChange={onChangeForm}
91
+ >
92
+ <Form.Item hidden name="_index" initialValue={rule?._index} key={rule?._index} />
93
+ <Form.Item
94
+ name="name"
95
+ label="校验规则名称"
96
+ rules={[
97
+ { required: true, message: "请输入校验规则名称" },
98
+ { max: 20, message: '只能输入20个字符' },
99
+ ]}
100
+ >
101
+ <Input readOnly={readOnly} />
102
+ </Form.Item>
103
+
104
+ <Form.Item
105
+ name="message"
106
+ label="校验不通过提示"
107
+ rules={[
108
+ { required: true, message: "请输入校验不通过提示" },
109
+ { max: 50, message: '只能输入50个字符' },
110
+ ]}
111
+ >
112
+ <Input readOnly={readOnly} />
113
+ </Form.Item>
114
+
115
+ <Form.Item
116
+ name="checkType"
117
+ label="阻断流程性质"
118
+ initialValue="control"
119
+ >
120
+ <Radio.Group disabled={readOnly} >
121
+ <Radio value="control">控制性</Radio>
122
+ <Radio value="notice">提示性</Radio>
123
+ </Radio.Group>
124
+ </Form.Item>
125
+
126
+ <Form.Item
127
+ name="algorithm"
128
+ label="规则算法"
129
+ >
130
+ <Select allowClear disabled={readOnly}>
131
+ {algorithm.filter(e => e.type === getPropertiesType(ruleProperties)).map((e, i) => {
132
+ return (
133
+ <Select.Option key={e.name} value={e.name}>{e.label}</Select.Option>
134
+ )
135
+ })}
136
+ </Select>
137
+ </Form.Item>
138
+
139
+ {algorithmForm}
140
+ </Form>
141
+ );
142
+ };
143
+
144
+ /** 获取字段对应的规则数据 */
145
+ function getPropertiesType(ruleProperties?: IDataSource) {
146
+ if (!ruleProperties) return '';
147
+
148
+ const pr = ruleProperties.ref.items || ruleProperties.ref;
149
+
150
+ if (pr.type === 'string' && pr.format) {
151
+ return `string|${pr.format}`;
152
+ }
153
+
154
+ return pr.type;
155
155
  }
@@ -1,5 +1,5 @@
1
- .kts-documents-edit-property-table-button-list{
2
- .ktsAntX-btn-link{
3
- padding: 4px !important;
4
- }
1
+ .kts-documents-edit-property-table-button-list{
2
+ .ktsAntX-btn-link{
3
+ padding: 4px !important;
4
+ }
5
5
  }