kts-components-document-access-point 1.4.2 → 1.4.5

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 +28 -8
  8. package/dist/index.js +28 -8
  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 -79
  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,157 +1,157 @@
1
- import React from 'react';
2
- import {
3
- Button,
4
- Collapse,
5
- Drawer,
6
- Space,
7
- Divider,
8
- message,
9
- } from 'kts-components-antd-x4';
10
- import DocumentsEdit from '../../';
11
- import AddRuleButton from './ui/AddRuleButton';
12
- import RuleForm from './ui/RuleForm';
13
- import DelRuleButton from './ui/DelRuleButton';
14
- import { IOperator } from '../../DocumentsEditController/DocumentsEditControllerState/RuleState';
15
- import { PropertiesType } from '../../DocumentsEditController/DocumentsEditControllerState/IProperties';
16
-
17
- const { Panel } = Collapse;
18
-
19
- export default () => {
20
-
21
- const controller = DocumentsEdit.useDocumentsEditController();
22
-
23
- /** 只读模式 */
24
- const readOnly = controller.useMemo(s => s.readOnly, []);
25
-
26
- /** 正在编辑规则的字段 */
27
- const ruleProperties = controller.useMemo(s => s.ruleState.ruleProperties, []);
28
-
29
- /** 算子字典 */
30
- const operatorMap = controller.useMemo(s => s.ruleState.operatorMap, []);
31
-
32
- /** 正在编辑规则的字段 */
33
- const rules = controller.useMemo(s => {
34
- const ref = s.ruleState.ruleProperties?.ref;
35
- if (!ref) return [];
36
- if (ref.items) {
37
- return ref.items.rules || [];
38
- } else {
39
- return ref.rules || [];
40
- }
41
- }, []);
42
-
43
- const onClose = React.useCallback(() => { controller.pipeline(async s => s.ruleState.ruleProperties = undefined)() }, [controller]);
44
-
45
- const onSubmit = React.useCallback(async () => {
46
- if (!ruleProperties) return;
47
-
48
- const formList = controller.state.ruleState.formList;
49
- const sum: any[] = [];
50
- let i = 0;
51
- try {
52
- for (; i < formList.length; i++) {
53
- const ruleValue = algorithmFormat(await formList[i].validateFields(), operatorMap, ruleProperties.ref.type);
54
- ruleValue._index = parseInt(ruleValue._index);
55
- sum.push(ruleValue);
56
- }
57
-
58
- await controller.pipeline(async s => {
59
- if (!s.ruleState.ruleProperties) return;
60
-
61
- // 数组特殊处理-
62
- const obj = s.schema.definitions[s.ruleState.ruleProperties.value.$refName];
63
- if (obj.type === 'array' && obj.items) {
64
- obj.items.rules = sum;
65
- } else {
66
- obj.rules = sum;
67
- }
68
-
69
- s.schema = { ...s.schema };
70
- s.ruleState.ruleProperties = undefined;
71
- })()
72
- } catch (error: any) {
73
- const _index = formList[i].getFieldValue('_index');
74
- const ms = `[规则${_index}] ${error.errorFields[0].errors[0]}`;
75
- message.error({ key: ms, content: ms });
76
- }
77
- }, [controller, operatorMap, ruleProperties])
78
-
79
- return (
80
- <Drawer
81
- title="编辑验证规则"
82
- placement="right"
83
- width={500}
84
- onClose={onClose}
85
- visible={!!ruleProperties}
86
- destroyOnClose={true}
87
- footer={
88
- readOnly
89
- ? <></>
90
- : <Space>
91
- <Button onClick={onSubmit} type="primary" >确定</Button>
92
- <Button onClick={onClose} >取消</Button>
93
- </Space>
94
- }
95
- >
96
- {
97
- rules.length
98
- ? <Collapse >
99
- {rules.map((e, i) => {
100
- if (!e) return;
101
- return (
102
- <Panel
103
- key={e._index}
104
- header={e._index}
105
- forceRender={true}
106
- extra={<DelRuleButton index={i} />}
107
- >
108
- <RuleForm index={i} />
109
- </Panel>
110
- )
111
- })}
112
- </Collapse>
113
- : <></>
114
- }
115
- <Divider />
116
- <AddRuleButton />
117
- </Drawer>
118
- );
119
- };
120
-
121
- /**
122
- * @param operator 需要格式化的数据
123
- * @param operatorMap 配送数据
124
- * @param type 当前字段的类型
125
- * @returns 格式话好的 operator
126
- */
127
- function algorithmFormat(operator: any, operatorMap: { [key: string]: IOperator }, type: PropertiesType) {
128
- operator = { ...operator };
129
- for (let key in operator) {
130
- switch (operatorMap[key]?.type) {
131
- case 'number':
132
- operator[key] = operator[key] ? parseFloat(operator[key]) : undefined;
133
- break;
134
- case 'integer':
135
- operator[key] = operator[key] ? parseInt(operator[key]) : undefined;
136
- break;
137
- case 'boolean':
138
- operator[key] = !!operator[key];
139
- break;
140
- case 'array':
141
- operator[key] = operator[key].split(',').map((e: string) => {
142
- if (operator.algorithm === 'enumInteger') {
143
- return parseInt(e);
144
- } else if (operator.algorithm === 'enumNumber') {
145
- return parseFloat(e);
146
- }
147
- return e;
148
- });
149
- break;
150
- case 'string|date':
151
- case 'string|date-time':
152
- operator[key] = operator[key] ? operator[key].toString() : undefined;
153
- break;
154
- }
155
- }
156
- return operator;
1
+ import React from 'react';
2
+ import {
3
+ Button,
4
+ Collapse,
5
+ Drawer,
6
+ Space,
7
+ Divider,
8
+ message,
9
+ } from 'kts-components-antd-x4';
10
+ import DocumentsEdit from '../../';
11
+ import AddRuleButton from './ui/AddRuleButton';
12
+ import RuleForm from './ui/RuleForm';
13
+ import DelRuleButton from './ui/DelRuleButton';
14
+ import { IOperator } from '../../DocumentsEditController/DocumentsEditControllerState/RuleState';
15
+ import { PropertiesType } from '../../DocumentsEditController/DocumentsEditControllerState/IProperties';
16
+
17
+ const { Panel } = Collapse;
18
+
19
+ export default () => {
20
+
21
+ const controller = DocumentsEdit.useDocumentsEditController();
22
+
23
+ /** 只读模式 */
24
+ const readOnly = controller.useMemo(s => s.readOnly, []);
25
+
26
+ /** 正在编辑规则的字段 */
27
+ const ruleProperties = controller.useMemo(s => s.ruleState.ruleProperties, []);
28
+
29
+ /** 算子字典 */
30
+ const operatorMap = controller.useMemo(s => s.ruleState.operatorMap, []);
31
+
32
+ /** 正在编辑规则的字段 */
33
+ const rules = controller.useMemo(s => {
34
+ const ref = s.ruleState.ruleProperties?.ref;
35
+ if (!ref) return [];
36
+ if (ref.items) {
37
+ return ref.items.rules || [];
38
+ } else {
39
+ return ref.rules || [];
40
+ }
41
+ }, []);
42
+
43
+ const onClose = React.useCallback(() => { controller.pipeline(async s => s.ruleState.ruleProperties = undefined)() }, [controller]);
44
+
45
+ const onSubmit = React.useCallback(async () => {
46
+ if (!ruleProperties) return;
47
+
48
+ const formList = controller.state.ruleState.formList;
49
+ const sum: any[] = [];
50
+ let i = 0;
51
+ try {
52
+ for (; i < formList.length; i++) {
53
+ const ruleValue = algorithmFormat(await formList[i].validateFields(), operatorMap, ruleProperties.ref.type);
54
+ ruleValue._index = parseInt(ruleValue._index);
55
+ sum.push(ruleValue);
56
+ }
57
+
58
+ await controller.pipeline(async s => {
59
+ if (!s.ruleState.ruleProperties) return;
60
+
61
+ // 数组特殊处理-
62
+ const obj = s.schema.definitions[s.ruleState.ruleProperties.value.$refName];
63
+ if (obj.type === 'array' && obj.items) {
64
+ obj.items.rules = sum;
65
+ } else {
66
+ obj.rules = sum;
67
+ }
68
+
69
+ s.schema = { ...s.schema };
70
+ s.ruleState.ruleProperties = undefined;
71
+ })()
72
+ } catch (error: any) {
73
+ const _index = formList[i].getFieldValue('_index');
74
+ const ms = `[规则${_index}] ${error.errorFields[0].errors[0]}`;
75
+ message.error({ key: ms, content: ms });
76
+ }
77
+ }, [controller, operatorMap, ruleProperties])
78
+
79
+ return (
80
+ <Drawer
81
+ title="编辑验证规则"
82
+ placement="right"
83
+ width={500}
84
+ onClose={onClose}
85
+ visible={!!ruleProperties}
86
+ destroyOnClose={true}
87
+ footer={
88
+ readOnly
89
+ ? <></>
90
+ : <Space>
91
+ <Button onClick={onSubmit} type="primary" >确定</Button>
92
+ <Button onClick={onClose} >取消</Button>
93
+ </Space>
94
+ }
95
+ >
96
+ {
97
+ rules.length
98
+ ? <Collapse >
99
+ {rules.map((e, i) => {
100
+ if (!e) return;
101
+ return (
102
+ <Panel
103
+ key={e._index}
104
+ header={e._index}
105
+ forceRender={true}
106
+ extra={<DelRuleButton index={i} />}
107
+ >
108
+ <RuleForm index={i} />
109
+ </Panel>
110
+ )
111
+ })}
112
+ </Collapse>
113
+ : <></>
114
+ }
115
+ <Divider />
116
+ <AddRuleButton />
117
+ </Drawer>
118
+ );
119
+ };
120
+
121
+ /**
122
+ * @param operator 需要格式化的数据
123
+ * @param operatorMap 配送数据
124
+ * @param type 当前字段的类型
125
+ * @returns 格式话好的 operator
126
+ */
127
+ function algorithmFormat(operator: any, operatorMap: { [key: string]: IOperator }, type: PropertiesType) {
128
+ operator = { ...operator };
129
+ for (let key in operator) {
130
+ switch (operatorMap[key]?.type) {
131
+ case 'number':
132
+ operator[key] = operator[key] ? parseFloat(operator[key]) : undefined;
133
+ break;
134
+ case 'integer':
135
+ operator[key] = operator[key] ? parseInt(operator[key]) : undefined;
136
+ break;
137
+ case 'boolean':
138
+ operator[key] = !!operator[key];
139
+ break;
140
+ case 'array':
141
+ operator[key] = operator[key].split(',').map((e: string) => {
142
+ if (operator.algorithm === 'enumInteger') {
143
+ return parseInt(e);
144
+ } else if (operator.algorithm === 'enumNumber') {
145
+ return parseFloat(e);
146
+ }
147
+ return e;
148
+ });
149
+ break;
150
+ case 'string|date':
151
+ case 'string|date-time':
152
+ operator[key] = operator[key] ? operator[key].toString() : undefined;
153
+ break;
154
+ }
155
+ }
156
+ return operator;
157
157
  }
@@ -1,49 +1,49 @@
1
- import React from 'react';
2
- import {
3
- Button,
4
- } from 'kts-components-antd-x4';
5
- import DocumentsEdit from '../../../../';
6
-
7
- export default () => {
8
-
9
- const controller = DocumentsEdit.useDocumentsEditController();
10
-
11
- const readOnly = controller.useMemo(s => s.readOnly, [])
12
-
13
- /** 最大的索引 */
14
- const maxIndex = controller.useMemo(s => {
15
- const ref = s.ruleState.ruleProperties?.ref;
16
- if (!ref) return 0;
17
-
18
- const rules = ref.items ? ref.items.rules : ref.rules;
19
- if (!rules) return 0;
20
-
21
- let sum = 0;
22
- rules.forEach(e => {
23
- if (parseInt(`${e._index}`) > sum) sum = e._index
24
- })
25
- return parseInt(`${sum}`);
26
- }, [])
27
-
28
- const onClick = React.useCallback(() => {
29
- controller.pipeline(async s => {
30
- if (!s.ruleState.ruleProperties) return;
31
-
32
- const ref = s.ruleState.ruleProperties?.ref;
33
- if (!ref) return;
34
-
35
- if (s.ruleState.ruleProperties.ref.items) {
36
- s.ruleState.ruleProperties.ref.items.rules = [...s.ruleState.ruleProperties.ref.items.rules || [], { _index: maxIndex + 1 } as any]
37
- } else {
38
- s.ruleState.ruleProperties.ref.rules = [...s.ruleState.ruleProperties.ref.rules || [], { _index: maxIndex + 1 } as any]
39
- }
40
- })()
41
- }, [controller, maxIndex])
42
-
43
- if (readOnly) return <></>;
44
-
45
- return (
46
- <Button onClick={onClick} >新增一条</Button>
47
- );
48
- };
49
-
1
+ import React from 'react';
2
+ import {
3
+ Button,
4
+ } from 'kts-components-antd-x4';
5
+ import DocumentsEdit from '../../../../';
6
+
7
+ export default () => {
8
+
9
+ const controller = DocumentsEdit.useDocumentsEditController();
10
+
11
+ const readOnly = controller.useMemo(s => s.readOnly, [])
12
+
13
+ /** 最大的索引 */
14
+ const maxIndex = controller.useMemo(s => {
15
+ const ref = s.ruleState.ruleProperties?.ref;
16
+ if (!ref) return 0;
17
+
18
+ const rules = ref.items ? ref.items.rules : ref.rules;
19
+ if (!rules) return 0;
20
+
21
+ let sum = 0;
22
+ rules.forEach(e => {
23
+ if (parseInt(`${e._index}`) > sum) sum = e._index
24
+ })
25
+ return parseInt(`${sum}`);
26
+ }, [])
27
+
28
+ const onClick = React.useCallback(() => {
29
+ controller.pipeline(async s => {
30
+ if (!s.ruleState.ruleProperties) return;
31
+
32
+ const ref = s.ruleState.ruleProperties?.ref;
33
+ if (!ref) return;
34
+
35
+ if (s.ruleState.ruleProperties.ref.items) {
36
+ s.ruleState.ruleProperties.ref.items.rules = [...s.ruleState.ruleProperties.ref.items.rules || [], { _index: maxIndex + 1 } as any]
37
+ } else {
38
+ s.ruleState.ruleProperties.ref.rules = [...s.ruleState.ruleProperties.ref.rules || [], { _index: maxIndex + 1 } as any]
39
+ }
40
+ })()
41
+ }, [controller, maxIndex])
42
+
43
+ if (readOnly) return <></>;
44
+
45
+ return (
46
+ <Button onClick={onClick} >新增一条</Button>
47
+ );
48
+ };
49
+
@@ -1,31 +1,31 @@
1
- import React from 'react';
2
- import DocumentsEdit from '../../../../';
3
-
4
- export default (props: { index: number }) => {
5
-
6
- const controller = DocumentsEdit.useDocumentsEditController();
7
-
8
- const readOnly = controller.useMemo(s => s.readOnly, []);
9
-
10
- const onClick = React.useCallback(async e => {
11
- e.stopPropagation()
12
- await controller.wait();
13
- await controller.pipeline(async s => {
14
- if (!s.ruleState.ruleProperties) return;
15
-
16
- if (s.ruleState.ruleProperties.ref.items) {
17
- s.ruleState.ruleProperties.ref.items.rules?.splice(props.index, 1);
18
- s.ruleState.ruleProperties.ref.items.rules = s.ruleState.ruleProperties.ref.items.rules?.slice() ?? [];
19
- } else {
20
- s.ruleState.ruleProperties.ref.rules?.splice(props.index, 1);
21
- s.ruleState.ruleProperties.ref.rules = s.ruleState.ruleProperties.ref.rules?.slice() ?? [];
22
- }
23
- })()
24
- }, [controller, props.index])
25
-
26
- if (readOnly) return <></>
27
-
28
- return (
29
- <span className="ktsAntX-btn-dangerous ktsAntX-btn-link" onClick={onClick} >删除</span>
30
- );
31
- };
1
+ import React from 'react';
2
+ import DocumentsEdit from '../../../../';
3
+
4
+ export default (props: { index: number }) => {
5
+
6
+ const controller = DocumentsEdit.useDocumentsEditController();
7
+
8
+ const readOnly = controller.useMemo(s => s.readOnly, []);
9
+
10
+ const onClick = React.useCallback(async e => {
11
+ e.stopPropagation()
12
+ await controller.wait();
13
+ await controller.pipeline(async s => {
14
+ if (!s.ruleState.ruleProperties) return;
15
+
16
+ if (s.ruleState.ruleProperties.ref.items) {
17
+ s.ruleState.ruleProperties.ref.items.rules?.splice(props.index, 1);
18
+ s.ruleState.ruleProperties.ref.items.rules = s.ruleState.ruleProperties.ref.items.rules?.slice() ?? [];
19
+ } else {
20
+ s.ruleState.ruleProperties.ref.rules?.splice(props.index, 1);
21
+ s.ruleState.ruleProperties.ref.rules = s.ruleState.ruleProperties.ref.rules?.slice() ?? [];
22
+ }
23
+ })()
24
+ }, [controller, props.index])
25
+
26
+ if (readOnly) return <></>
27
+
28
+ return (
29
+ <span className="ktsAntX-btn-dangerous ktsAntX-btn-link" onClick={onClick} >删除</span>
30
+ );
31
+ };