@bit-sun/business-component 2.3.13 → 2.3.14

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 (201) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
  9. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
  10. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  11. package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
  12. package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
  13. package/dist/index.esm.js +941 -894
  14. package/dist/index.js +947 -900
  15. package/dist/utils/utils.d.ts +1 -1
  16. package/docs/index.md +21 -21
  17. package/lib/assets/drag.svg +17 -17
  18. package/lib/assets/exportFail.svg +37 -37
  19. package/lib/assets/exportProcessing.svg +28 -28
  20. package/lib/assets/exportSuccess.svg +34 -34
  21. package/lib/assets/label_icon_bottom.svg +25 -25
  22. package/lib/assets/upExport.svg +22 -22
  23. package/package.json +78 -78
  24. package/src/assets/32.svg +27 -27
  25. package/src/assets/addIcon.svg +17 -17
  26. package/src/assets/allfunc.svg +27 -27
  27. package/src/assets/arrowRight.svg +24 -24
  28. package/src/assets/btn-delete.svg +29 -29
  29. package/src/assets/btn-edit.svg +19 -19
  30. package/src/assets/btn-more.svg +17 -17
  31. package/src/assets/btn-submit.svg +19 -19
  32. package/src/assets/caidan.svg +11 -11
  33. package/src/assets/close.svg +26 -26
  34. package/src/assets/drag.svg +17 -17
  35. package/src/assets/exportFail.svg +37 -37
  36. package/src/assets/exportProcessing.svg +28 -28
  37. package/src/assets/exportSuccess.svg +34 -34
  38. package/src/assets/fixed-left-active.svg +11 -11
  39. package/src/assets/fixed-left.svg +15 -15
  40. package/src/assets/fixed-right-active.svg +11 -11
  41. package/src/assets/fixed-right.svg +15 -15
  42. package/src/assets/guanbi.svg +15 -15
  43. package/src/assets/icon-quanping.svg +15 -15
  44. package/src/assets/icon-shezhi.svg +17 -17
  45. package/src/assets/label_icon_bottom.svg +25 -25
  46. package/src/assets/list-no-img.svg +21 -21
  47. package/src/assets/morentouxiang-32.svg +23 -23
  48. package/src/assets/scanning.svg +24 -24
  49. package/src/assets/upExport.svg +22 -22
  50. package/src/common/ENUM.ts +41 -41
  51. package/src/components/Business/AddSelectBusiness/index.md +161 -161
  52. package/src/components/Business/AddSelectBusiness/index.tsx +861 -861
  53. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  54. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  55. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  61. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  62. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  63. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  64. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  65. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  66. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  67. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  68. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  69. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +155 -155
  70. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  71. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  72. package/src/components/Business/BsLayouts/index.less +79 -79
  73. package/src/components/Business/BsLayouts/index.tsx +1484 -1484
  74. package/src/components/Business/BsLayouts/service.ts +10 -10
  75. package/src/components/Business/BsLayouts/utils.tsx +203 -203
  76. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +564 -564
  77. package/src/components/Business/BsSulaQueryTable/index.less +221 -221
  78. package/src/components/Business/BsSulaQueryTable/index.tsx +535 -535
  79. package/src/components/Business/BsSulaQueryTable/setting.tsx +852 -852
  80. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  81. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  82. package/src/components/Business/CommodityEntry/index.md +70 -70
  83. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  84. package/src/components/Business/CommonAlert/index.tsx +23 -23
  85. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  86. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  87. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  88. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  89. package/src/components/Business/DetailPageWrapper/index.tsx +313 -313
  90. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  91. package/src/components/Business/HomePageWrapper/index.less +33 -33
  92. package/src/components/Business/HomePageWrapper/index.md +45 -45
  93. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  94. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  95. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +205 -205
  96. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  97. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  98. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  99. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  100. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  101. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  102. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  103. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  104. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  105. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  106. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  107. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  108. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  109. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  110. package/src/components/Business/JsonQueryTable/index.less +16 -16
  111. package/src/components/Business/JsonQueryTable/index.md +328 -328
  112. package/src/components/Business/JsonQueryTable/index.tsx +535 -535
  113. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  114. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  115. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  116. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  117. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  118. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  119. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  120. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  121. package/src/components/Business/JsonQueryTable/static.ts +390 -390
  122. package/src/components/Business/SearchSelect/BusinessUtils.ts +1756 -1756
  123. package/src/components/Business/SearchSelect/common.ts +64 -64
  124. package/src/components/Business/SearchSelect/index.md +1326 -1326
  125. package/src/components/Business/SearchSelect/index.tsx +51 -51
  126. package/src/components/Business/SearchSelect/utils.ts +100 -100
  127. package/src/components/Business/StateFlow/index.less +130 -130
  128. package/src/components/Business/StateFlow/index.md +60 -60
  129. package/src/components/Business/StateFlow/index.tsx +29 -29
  130. package/src/components/Business/TreeSearchSelect/index.md +154 -154
  131. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  132. package/src/components/Business/TreeSearchSelect/utils.ts +75 -75
  133. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  134. package/src/components/Business/columnSettingTable/index.less +247 -247
  135. package/src/components/Business/columnSettingTable/index.md +357 -357
  136. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  137. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  138. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  139. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +86 -86
  140. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -21
  141. package/src/components/Business/moreTreeTable/index.less +99 -99
  142. package/src/components/Business/moreTreeTable/index.md +448 -448
  143. package/src/components/Business/moreTreeTable/index.tsx +387 -387
  144. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  145. package/src/components/Functional/AddSelect/helps.ts +14 -14
  146. package/src/components/Functional/AddSelect/index.less +367 -367
  147. package/src/components/Functional/AddSelect/index.md +155 -155
  148. package/src/components/Functional/AddSelect/index.tsx +1279 -1279
  149. package/src/components/Functional/BillEntry/index.less +371 -371
  150. package/src/components/Functional/BillEntry/index.md +39 -39
  151. package/src/components/Functional/BillEntry/index.tsx +772 -772
  152. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -62
  153. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -178
  154. package/src/components/Functional/BsAntdSula/index.ts +2 -2
  155. package/src/components/Functional/DataImport/index.less +63 -63
  156. package/src/components/Functional/DataImport/index.md +44 -44
  157. package/src/components/Functional/DataImport/index.tsx +695 -695
  158. package/src/components/Functional/DataValidation/index.less +63 -63
  159. package/src/components/Functional/DataValidation/index.md +39 -39
  160. package/src/components/Functional/DataValidation/index.tsx +687 -687
  161. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -5
  162. package/src/components/Functional/EllipsisTooltip/index.js +36 -36
  163. package/src/components/Functional/EllipsisTooltip/index.md +30 -30
  164. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  165. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  166. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  167. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  168. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  169. package/src/components/Functional/SearchSelect/index.less +115 -115
  170. package/src/components/Functional/SearchSelect/index.md +141 -141
  171. package/src/components/Functional/SearchSelect/index.tsx +874 -858
  172. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  173. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  174. package/src/components/Functional/TreeSearchSelect/index.tsx +163 -163
  175. package/src/components/Solution/RuleComponent/Formula.tsx +335 -335
  176. package/src/components/Solution/RuleComponent/index.d.ts +29 -29
  177. package/src/components/Solution/RuleComponent/index.js +2028 -2028
  178. package/src/components/Solution/RuleComponent/index.less +230 -230
  179. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  180. package/src/components/Solution/RuleComponent/ruleFiled.js +2107 -2107
  181. package/src/components/Solution/RuleComponent/services.ts +13 -13
  182. package/src/components/Solution/RuleComponent/util.js +139 -139
  183. package/src/index.ts +38 -38
  184. package/src/plugin/TableColumnSetting/index.less +247 -247
  185. package/src/plugin/TableColumnSetting/index.md +50 -50
  186. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  187. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  188. package/src/styles/bsDefault.less +1912 -1912
  189. package/src/utils/CheckOneUser/index.md +39 -39
  190. package/src/utils/CheckOneUser/index.ts +51 -51
  191. package/src/utils/LocalstorageUtils.ts +90 -90
  192. package/src/utils/TableUtils.tsx +18 -18
  193. package/src/utils/checkUtils.ts +39 -39
  194. package/src/utils/enumConfig.ts +11 -11
  195. package/src/utils/getFormMode.js +12 -12
  196. package/src/utils/index.ts +4 -4
  197. package/src/utils/requestUtils.ts +34 -34
  198. package/src/utils/serialize.js +7 -7
  199. package/src/utils/utils.ts +212 -212
  200. package/tsconfig.json +29 -29
  201. package/typings.d.ts +4 -4
@@ -1,2028 +1,2028 @@
1
- import React, { Component } from 'react';
2
- // @ts-ignore
3
- import _ from 'lodash';
4
- import RuleField from './ruleFiled';
5
- import {
6
- Select,
7
- Button,
8
- Radio,
9
- Switch,
10
- Checkbox,
11
- InputNumber,
12
- TreeSelect,
13
- Popover,
14
- Input,
15
- DatePicker,
16
- Table,
17
- Divider,
18
- Space,
19
- Form as AntdForm,
20
- Modal,
21
- message,
22
- } from 'antd';
23
- import {
24
- PlusCircleOutlined,
25
- MinusCircleOutlined,
26
- DownOutlined,
27
- } from '@ant-design/icons';
28
- import './index.less';
29
- import {
30
- relateItems,
31
- getSpecialPropertyCode,
32
- getPropertyCode,
33
- isObj,
34
- } from './util';
35
- import { getDictionarySource, uuid } from '../../../utils/utils';
36
- import {
37
- BusinessSearchSelect,
38
- BusinessTreeSearchSelect,
39
- EllipsisTooltip,
40
- BsCascader,
41
- } from '../../../index';
42
- import { request } from 'bssula';
43
- import Formula from './Formula';
44
- import RenderSpecificAction from './renderSpecificAction';
45
-
46
- const { RangePicker } = DatePicker;
47
-
48
- class RuleObjectComponent extends Component {
49
- constructor(props) {
50
- super(props);
51
- this.state = {
52
- editNameIndex: 0,
53
- isEdit: false,
54
- ruleTreeData: [],
55
- initialRegularList: [],
56
- operationList: [],
57
- ruleClassData: [],
58
- modalParams: {
59
- visible: false,
60
- },
61
- };
62
- this.propertyCodeToRangeIdMap = {};
63
- this.dictCodeToRangeIdMap = {};
64
- this.dynamicDictCodeToRangeIdMap = {};
65
- }
66
-
67
- componentDidMount(props) {
68
- const { ruleClassData, operationList, regularDataList } = this.props;
69
- this.setRegularData(regularDataList);
70
- this.setState({
71
- ruleClassData,
72
- operationList,
73
- });
74
- }
75
-
76
- componentWillReceiveProps(nextProps) {
77
- const { ruleClassData, operationList, regularDataList } = this.state;
78
- if (
79
- nextProps.ruleClassData &&
80
- this.props.ruleClassData != nextProps.ruleClassData &&
81
- JSON.stringify(nextProps.ruleClassData) != JSON.stringify(ruleClassData)
82
- ) {
83
- this.setState({
84
- ruleClassData: nextProps.ruleClassData,
85
- });
86
- }
87
-
88
- if (
89
- nextProps.operationList &&
90
- this.props.operationList != nextProps.operationList
91
- ) {
92
- this.setState({
93
- operationList: nextProps.operationList,
94
- });
95
- }
96
-
97
- if (
98
- nextProps.regularDataList &&
99
- this.props.regularDataList != nextProps.regularDataList
100
- ) {
101
- this.setRegularData(nextProps.regularDataList);
102
- }
103
- }
104
-
105
- setRegularData = (regularDataList) => {
106
- this.propertyCodeToRangeIdMap = {};
107
- this.dictCodeToRangeIdMap = {};
108
- this.dynamicDictCodeToRangeIdMap = {};
109
- const finalTreeDatas = regularDataList.map((item) => {
110
- return {
111
- title: item.name,
112
- key: item.id,
113
- value: item.code,
114
- ...(item?.propertyList?.length
115
- ? {
116
- children: item.propertyList.map((element) => {
117
- const infoVo = (element.info && JSON.parse(element.info)) || {};
118
- if (element.choiceType === 30) {
119
- this.dynamicDictCodeToRangeIdMap[
120
- `${item.code}.${element.code}`
121
- ] = infoVo?.dictionaryCode;
122
- } else if (element.choiceType === 20) {
123
- this.dictCodeToRangeIdMap[`${item.code}.${element.code}`] =
124
- infoVo?.dictionaryCode;
125
- } else if (element.choiceType === 10) {
126
- const list =
127
- (Object.keys(infoVo).length &&
128
- infoVo.enumeration &&
129
- Object.keys(infoVo.enumeration).map((i) => ({
130
- code: i,
131
- name: infoVo.enumeration[i],
132
- }))) ||
133
- undefined;
134
- this.propertyCodeToRangeIdMap[
135
- `${item.code}.${element.code}`
136
- ] = list;
137
- } else {
138
- this.propertyCodeToRangeIdMap[
139
- `${item.code}.${element.code}`
140
- ] = Object.keys(infoVo).length ? infoVo : undefined;
141
- }
142
- let child = {
143
- title: `${item.name}-${element.name}`,
144
- key: element.id,
145
- value: `${element.code}`,
146
- id: element.id,
147
- dataTypeCode: element.valueType,
148
- dataChoiceBusinessType: element.choiceType,
149
- dataInputBusinessType: element.inputType,
150
- info: element.info,
151
- };
152
- if (element?.propertyList?.length) {
153
- child.children = this.parseChildTreeData(
154
- element.propertyList,
155
- `${element.code}`,
156
- `${item.name}-${element.name}`,
157
- item.code,
158
- );
159
- child.isLeaf = false;
160
- } else {
161
- child.isLeaf = true;
162
- child.metaObjectCode = item.code;
163
- }
164
- return child;
165
- }),
166
- }
167
- : {}),
168
- };
169
- });
170
- this.setState({
171
- initialRegularList: [...regularDataList],
172
- ruleTreeData: finalTreeDatas,
173
- });
174
- };
175
-
176
- parseChildTreeData = (list, parentKey, parentTitle, rootObjCode) => {
177
- return list.map((element) => {
178
- const infoVo = (element.info && JSON.parse(element.info)) || {};
179
- if (element.choiceType === 30) {
180
- this.dynamicDictCodeToRangeIdMap[
181
- `${rootObjCode}.${parentKey}.${element.code}`
182
- ] = infoVo?.dictionaryCode;
183
- } else if (element.choiceType === 20) {
184
- this.dictCodeToRangeIdMap[
185
- `${rootObjCode}.${parentKey}.${element.code}`
186
- ] = infoVo?.dictionaryCode;
187
- } else if (element.choiceType === 10) {
188
- const list =
189
- (Object.keys(infoVo).length &&
190
- infoVo.enumeration &&
191
- Object.keys(infoVo.enumeration).map((i) => ({
192
- code: i,
193
- name: infoVo.enumeration[i],
194
- }))) ||
195
- undefined;
196
- this.propertyCodeToRangeIdMap[
197
- `${rootObjCode}.${parentKey}.${element.code}`
198
- ] = list;
199
- } else {
200
- this.propertyCodeToRangeIdMap[
201
- `${rootObjCode}.${parentKey}.${element.code}`
202
- ] = Object.keys(infoVo).length ? infoVo : undefined;
203
- }
204
- let child = {
205
- title: `${parentTitle}-${element.name}`,
206
- key: `${parentKey}.${element.id}`,
207
- value: `${parentKey}.${element.code}`,
208
- id: element.id,
209
- dataTypeCode: element.valueType,
210
- dataChoiceBusinessType: element.choiceType,
211
- dataInputBusinessType: element.inputType,
212
- info: element.info,
213
- };
214
- if (element.propertyList) {
215
- child.children = this.parseChildTreeData(
216
- element.propertyList,
217
- `${parentKey}.${element.code}`,
218
- `${parentTitle}-${element.name}`,
219
- rootObjCode,
220
- );
221
- child.isLeaf = false;
222
- } else {
223
- child.isLeaf = true;
224
- child.metaObjectCode = rootObjCode;
225
- }
226
- return child;
227
- });
228
- };
229
-
230
- getDataTypeOperateList = (id) => {
231
- const { operationList, initialRegularList } = this.state;
232
- // let typeId = '';
233
- // initialRegularList.forEach(item => {
234
- // item.metaObjectResDto.elementResDtos.forEach(element => {
235
- // if (element.id == id) {
236
- // typeId = element.dataTypeCode;
237
- // }
238
- // })
239
- // })
240
- const list =
241
- operationList.find((item) => item.code == id)?.operationList || [];
242
- return list;
243
- };
244
-
245
- handleValuesChange = (itemDetail, newValues, newValueNames) => {
246
- const { ruleClassData } = this.state;
247
- const { callBack } = this.props;
248
- itemDetail.params = [...newValues];
249
- itemDetail.paramNames = [...newValueNames];
250
- this.setState(
251
- {
252
- ruleClassData,
253
- },
254
- () => {
255
- callBack(ruleClassData);
256
- },
257
- );
258
- };
259
-
260
- setRelateDataList = (classDataItem) => {
261
- let relateDatas = {};
262
- relateItems.forEach((relateItem) => {
263
- this.getRelateData(
264
- relateItem,
265
- classDataItem.subExpression || {},
266
- relateDatas,
267
- );
268
- });
269
- return relateDatas;
270
- };
271
-
272
- getRelateData = (relateItem, classDataItem, relateDatas) => {
273
- if (
274
- classDataItem?.propertyPath &&
275
- getPropertyCode(classDataItem.propertyPath) == relateItem.propertyCode
276
- ) {
277
- relateDatas[relateItem.propertyCode] = classDataItem.params;
278
- } else {
279
- if (classDataItem.subExpression && classDataItem.subExpression.length) {
280
- classDataItem.subExpression.forEach((classData) => {
281
- this.getRelateData(relateItem, classData, relateDatas);
282
- });
283
- }
284
- }
285
- };
286
-
287
- renderRuleContent = () => {
288
- const { ruleClassData, currentRuleName, isEdit, editNameIndex } =
289
- this.state;
290
- const {
291
- ruleType,
292
- callBack,
293
- accountList = [],
294
- disabled,
295
- ruleTypeData,
296
- canDelete = false,
297
- ruleReturnConfig = {},
298
- onlyOneRule,
299
- onlyCondition,
300
- onlyAction,
301
- handleOperatingAction,
302
- ruleGroupInfo,
303
- } = this.props;
304
- const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1;
305
- const ruleGroupName = ruleGroupInfo?.ruleGroupList?.[0]?.name || '规则分组';
306
- const priorityList = (ruleGroupInfo?.groupOtherPriorityList || []).concat(ruleClassData|| []);
307
- const canChangePriority = ruleGroupInfo?.canChangePriority;
308
- const titlePre = {
309
- position: 'relative',
310
- top: '-10px',
311
- left: '20px',
312
- background: '#fff',
313
- width: '160px',
314
- textAlign: 'center',
315
- };
316
- const titleSubPre = {
317
- ...titlePre,
318
- top: '-33px',
319
- left: '280px',
320
- width: '160px',
321
- }
322
- const ruleListBox = (!onlyOneRule || ruleGroupInfo) ? { border: '1px dashed #d9d9d9', marginBottom: 10 } : {};
323
- const isRuleActionConfig =
324
- ruleTypeData?.length || Object.keys(ruleReturnConfig)?.length;
325
- return (
326
- <div>
327
- {ruleClassData.map((item, classDataIndex) => {
328
- let extraInfo = {};
329
- if (isRuleActionConfig) {
330
- extraInfo = {
331
- ...item.extraInfo,
332
- };
333
- }
334
- let relateDatas = this.setRelateDataList(item);
335
- const sActionProps = {
336
- extraInfo,
337
- ruleTypeData,
338
- item,
339
- classDataIndex,
340
- handleOperatingAction,
341
- disabled,
342
- };
343
- return (
344
- <div style={ruleListBox}>
345
- {!onlyOneRule && !ruleGroupInfo && (
346
- <div style={titlePre}>规则{classDataIndex + 1}</div>
347
- )}
348
- {ruleGroupInfo && (
349
- <>
350
- <div style={titlePre}>
351
- <EllipsisTooltip
352
- visible={true}
353
- maxLength={10}
354
- title={ruleGroupName}
355
- />
356
- </div>
357
- {isRuleInstance && (
358
- <div style={titleSubPre}>
359
- <span style={{ marginRight: 10 }}>优先级</span>
360
- <Select
361
- disabled={canChangePriority ? !canChangePriority : disabled}
362
- style={{ width: 100 }}
363
- value={item.priority}
364
- onChange={(v) => {
365
- // 因为存在页签,前端校验不准确;而且若选择优先级之后想交换改也不方便,故交由后端校验
366
- // const isRepeate = priorityList.some((r) => r.priority == v)
367
- // if(isRepeate) {
368
- // message.warn('优先级不允许重复')
369
- // }
370
- // item.priority = isRepeate ? (item.priority||null) : v;
371
- item.priority = v
372
- this.setState(
373
- {
374
- ruleClassData,
375
- },
376
- () => {
377
- callBack(ruleClassData);
378
- },
379
- );
380
- }}
381
- >
382
- {priorityList?.map((s,sindex) => (
383
- <Option key={sindex+1} value={sindex+1}>{sindex+1}</Option>
384
- ))}
385
- </Select>
386
- </div>
387
- ) || null}
388
- </>
389
- )}
390
- <div
391
- style={{
392
- textAlign: 'right',
393
- marginTop: '-24px',
394
- display: canDelete ? 'block' : 'none',
395
- }}
396
- >
397
- <Button
398
- disabled={disabled}
399
- onClick={() => {
400
- const { ruleClassData } = this.state;
401
- ruleClassData.splice(classDataIndex, 1);
402
- this.setState(
403
- {
404
- ruleClassData,
405
- },
406
- () => {
407
- callBack(ruleClassData);
408
- },
409
- );
410
- }}
411
- type="link"
412
- danger
413
- >
414
- 删除规则
415
- </Button>
416
- </div>
417
- <div>
418
- {/* <div style={{ display: isEdit && editNameIndex == index ? 'none' : 'block' }}>
419
- <span className={'rule_name_title}>
420
- {item.ruleName}
421
- </span>
422
- <EditOutlined
423
- onClick={() => {
424
- this.setState({
425
- editNameIndex: index,
426
- currentRuleName: item.ruleName,
427
- isEdit: true
428
- })
429
- }}
430
- />
431
- </div> */}
432
- <div
433
- style={{
434
- display:
435
- isEdit && editNameIndex == index ? 'block' : 'none',
436
- marginTop: '10px',
437
- }}
438
- >
439
- <Input
440
- value={currentRuleName}
441
- style={{ width: '200px' }}
442
- onChange={(e) => {
443
- this.setState({
444
- currentRuleName: e.target.value,
445
- });
446
- }}
447
- />
448
- <Button
449
- type="link"
450
- onClick={() => {
451
- const { ruleClassData, currentRuleName } = this.state;
452
- ruleClassData[editNameIndex].ruleName = currentRuleName;
453
- this.setState({
454
- ruleClassData,
455
- isEdit: false,
456
- });
457
- }}
458
- >
459
- 保存
460
- </Button>
461
- <Button
462
- type="link"
463
- onClick={() => {
464
- this.setState({
465
- isEdit: false,
466
- });
467
- }}
468
- >
469
- 取消
470
- </Button>
471
- </div>
472
- </div>
473
- <div>
474
- {(onlyAction && <RenderSpecificAction {...sActionProps} />) || (
475
- <div className={'base_rule_line_content'}>
476
- <div className={'base_rule_item2'}>
477
- {item.subExpression &&
478
- this.renderRuleItem(
479
- item.subExpression,
480
- item,
481
- 1,
482
- classDataIndex,
483
- relateDatas,
484
- )}
485
- </div>
486
- <div className={'base_rule_item3'}>
487
- {(extraInfo &&
488
- isRuleActionConfig &&
489
- (!onlyCondition || !onlyAction) &&
490
- this.renderRuleTypeItem(
491
- extraInfo,
492
- item,
493
- 1,
494
- classDataIndex,
495
- ruleTypeData,
496
- ruleReturnConfig,
497
- isRuleInstance
498
- )) ||
499
- null}
500
- </div>
501
- </div>
502
- )}
503
- </div>
504
- </div>
505
- );
506
- })}
507
- </div>
508
- );
509
- };
510
-
511
- handleAddRule = () => {
512
- const { ruleClassData } = this.state;
513
- const { callBack, ruleTypeData, ruleGroupInfo } = this.props;
514
- const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1;
515
- const initKongData = {
516
- ruleName: `规则${ruleClassData?.length + 1}`,
517
- subExpression: {
518
- // "expressionType": "relation",
519
- operationType: 'relation',
520
- propertyPath: '',
521
- params: [],
522
- paramNames: [],
523
- },
524
- extraInfo: {
525
- response: {
526
- enable: false,
527
- value: '',
528
- },
529
- execute: ruleTypeData.map((s) => {
530
- return {
531
- priority: 1,
532
- code: s.code,
533
- properties: {
534
- configPropertyCode: 'configPropertyValue',
535
- },
536
- };
537
- }),
538
- },
539
- }
540
- const initTemplateData = ruleGroupInfo?.templateData && Object.keys(ruleGroupInfo?.templateData)?.length ? {
541
- ruleName: `规则${ruleClassData?.length + 1}`,
542
- ..._.cloneDeep(ruleGroupInfo?.templateData)
543
- } : initKongData;
544
- const initNewData = isRuleInstance ? initTemplateData : initKongData
545
- ruleClassData.push(initNewData);
546
- this.setState(
547
- {
548
- ruleClassData,
549
- },
550
- () => {
551
- callBack(ruleClassData);
552
- },
553
- );
554
- };
555
-
556
- // 树结构 转化成 平行树 (递归函数)
557
- coverToParallel = (treeData, result) => {
558
- treeData.forEach((el) => {
559
- result.push(el);
560
- if (el.children && el.children.length > 0) {
561
- // 子级递归
562
- this.coverToParallel(el.children, result);
563
- }
564
- });
565
- return result;
566
- };
567
-
568
- renderRuleItem = (
569
- itemDetail,
570
- parentDetail,
571
- floorIndex,
572
- classDataIndex,
573
- relateDatas,
574
- ) => {
575
- const { ruleTreeData } = this.state;
576
- const {
577
- callBack,
578
- initialThresholdQuery = {},
579
- disabled,
580
- systemVariableList,
581
- } = this.props;
582
- let thresholdQuery = {
583
- ...initialThresholdQuery,
584
- ...relateDatas,
585
- };
586
- let finalIndex = floorIndex + 1;
587
- let queryIdentify = '';
588
- let queryIdentifyType = '';
589
- if (
590
- this.propertyCodeToRangeIdMap[
591
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
592
- ]
593
- ) {
594
- queryIdentify =
595
- this.propertyCodeToRangeIdMap[
596
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
597
- ];
598
- queryIdentifyType = Array.isArray(queryIdentify)
599
- ? 'objectPropertyListIdentify'
600
- : 'objectPropertyCodeIdentify';
601
- } else if (
602
- getSpecialPropertyCode(getPropertyCode(itemDetail.propertyPath))
603
- ) {
604
- queryIdentify = getSpecialPropertyCode(
605
- getPropertyCode(itemDetail.propertyPath),
606
- );
607
- queryIdentifyType = 'specialPropertyIdentify';
608
- } else if (
609
- this.dictCodeToRangeIdMap[
610
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
611
- ]
612
- ) {
613
- queryIdentify =
614
- this.dictCodeToRangeIdMap[
615
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
616
- ];
617
- queryIdentifyType = 'dictCodeIdentify';
618
- } else if (
619
- this.dynamicDictCodeToRangeIdMap[
620
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
621
- ]
622
- ) {
623
- queryIdentify =
624
- this.dynamicDictCodeToRangeIdMap[
625
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
626
- ];
627
- queryIdentifyType = 'dynamicDictCodeIdentify';
628
- }
629
-
630
- const parallelTreeData = this.coverToParallel(ruleTreeData, []) || [];
631
- const currentTreeItem =
632
- itemDetail?.elementId &&
633
- parallelTreeData.find((i) => i.key === itemDetail?.elementId);
634
- const dataChoiceBusinessType = currentTreeItem?.dataChoiceBusinessType;
635
- const dataInputBusinessType = currentTreeItem?.dataInputBusinessType;
636
- return (
637
- <div
638
- className={'rule_line_content'}
639
- style={{ display: 'flex', marginBottom: '0px', padding: '10px 0px' }}
640
- >
641
- <div
642
- className={'logical_operate_content'}
643
- style={{
644
- display: itemDetail.operationType == 'logic' ? 'block' : 'none',
645
- width: '60px',
646
- zIndex: 20,
647
- }}
648
- >
649
- <Popover
650
- content={
651
- <div>
652
- <p
653
- className={'choose_logical_type'}
654
- onClick={() => {
655
- this.handleLogicalTypeChange(itemDetail, 'or');
656
- }}
657
- >
658
- OR
659
- </p>
660
- <p
661
- className={'choose_logical_type'}
662
- onClick={() => {
663
- this.handleLogicalTypeChange(itemDetail, 'and');
664
- }}
665
- >
666
- AND
667
- </p>
668
- </div>
669
- }
670
- trigger="focus"
671
- >
672
- <Button
673
- disabled={disabled}
674
- type="link"
675
- className={'logical_item_btn'}
676
- >
677
- {itemDetail?.operationCode == 'or' ? 'OR' : 'AND'}
678
- <DownOutlined style={{ marginLeft: '6px' }} />
679
- </Button>
680
- </Popover>
681
- <span className={'top_line'}></span>
682
- <span className={'bottom_line'}></span>
683
- </div>
684
-
685
- <div style={{ flexGrow: 1 }}>
686
- {itemDetail.operationType == 'logic' ? (
687
- itemDetail?.subExpression?.map((item1) => {
688
- return this.renderRuleItem(
689
- item1,
690
- itemDetail,
691
- finalIndex,
692
- classDataIndex,
693
- relateDatas,
694
- );
695
- })
696
- ) : (
697
- <div style={{ display: 'flex', alignItems: 'center' }}>
698
- <TreeSelect
699
- value={itemDetail.propertyPath}
700
- disabled={disabled}
701
- onChange={(value, name, nodeInfo) => {
702
- if (!nodeInfo.triggerNode.props.isLeaf) return; //只有最末端叶子节点可选中
703
- const { ruleClassData } = this.state;
704
- itemDetail.propertyPath = value;
705
- itemDetail.params = [];
706
- itemDetail.paramNames = [];
707
- itemDetail.operationCode = '';
708
- itemDetail.elementId = nodeInfo.triggerNode.props.id;
709
- itemDetail.elementName = nodeInfo.triggerNode.props.title;
710
- itemDetail.dataTypeCode =
711
- nodeInfo.triggerNode.props.dataTypeCode;
712
- itemDetail.metaObjectCode =
713
- nodeInfo.triggerNode.props.metaObjectCode;
714
- itemDetail.isInsertParam = false;
715
- this.setState(
716
- {
717
- ruleClassData,
718
- },
719
- () => {
720
- callBack(ruleClassData);
721
- },
722
- );
723
- }}
724
- style={{ width: '200px' }}
725
- treeData={ruleTreeData}
726
- />
727
- <Select
728
- value={itemDetail?.operationCode || ''}
729
- disabled={disabled}
730
- style={{ width: '150px', marginLeft: '10px' }}
731
- onChange={(value) => {
732
- const { ruleClassData } = this.state;
733
- itemDetail.operationCode = value;
734
- this.setState(
735
- {
736
- ruleClassData,
737
- },
738
- () => {
739
- callBack(ruleClassData);
740
- },
741
- );
742
- }}
743
- >
744
- {this.getDataTypeOperateList(itemDetail.dataTypeCode).map(
745
- (item) => (
746
- <Select.Option value={item.code} key={item.code}>
747
- {item.name}
748
- </Select.Option>
749
- ),
750
- )}
751
- </Select>
752
- {!itemDetail?.isInsertParam ? (
753
- <RuleField
754
- selectOperation={itemDetail?.operationCode || ''}
755
- disabled={disabled}
756
- initialThresholdQuery={thresholdQuery}
757
- dataTypeCode={itemDetail?.dataTypeCode || ''}
758
- dataChoiceBusinessType={dataChoiceBusinessType || ''}
759
- dataInputBusinessType={dataInputBusinessType || ''}
760
- itemDetail={itemDetail}
761
- queryIdentifyType={queryIdentifyType}
762
- queryIdentify={queryIdentify}
763
- propertyCode={getPropertyCode(itemDetail.propertyPath)}
764
- // propertyCode={`${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`}
765
- relateDatas={relateDatas}
766
- values={itemDetail.params || []}
767
- valueNames={itemDetail.paramNames || []}
768
- callback={(newValues, newValueNames) => {
769
- this.handleValuesChange(
770
- itemDetail,
771
- newValues,
772
- newValueNames,
773
- );
774
- }}
775
- />
776
- ) : null}
777
- <Select
778
- disabled={disabled}
779
- value={
780
- itemDetail?.params?.[0]?.replace('{', '').replace('}', '') ||
781
- ''
782
- }
783
- style={{
784
- width: '150px',
785
- marginLeft: '10px',
786
- display: itemDetail?.isInsertParam ? '' : 'none',
787
- }}
788
- onChange={(value) => {
789
- const { ruleClassData } = this.state;
790
- console.log(itemDetail);
791
- itemDetail.params = [(value && `{${value}}`) || ''];
792
- const name = systemVariableList.find(
793
- (i) => i.code == value,
794
- )?.name;
795
- itemDetail.paramNames = [name || ''];
796
- this.setState(
797
- {
798
- ruleClassData,
799
- },
800
- () => {
801
- callBack(ruleClassData);
802
- },
803
- );
804
- }}
805
- >
806
- {systemVariableList
807
- ? systemVariableList.map((item) => (
808
- <Select.Option value={item.code} key={item.code}>
809
- {item.name}
810
- </Select.Option>
811
- ))
812
- : null}
813
- </Select>
814
- <PlusCircleOutlined
815
- className={'icon_btn_style'}
816
- onClick={() => {
817
- this.addChildRules(itemDetail);
818
- }}
819
- style={{
820
- color: '#008fe0',
821
- marginLeft: '15px',
822
- display: floorIndex > 4 || disabled ? 'none' : 'inline-block',
823
- }}
824
- />
825
- <MinusCircleOutlined
826
- className={'icon_btn_style'}
827
- onClick={() => {
828
- this.handleDeleteRule(
829
- itemDetail,
830
- parentDetail,
831
- classDataIndex,
832
- );
833
- }}
834
- style={{
835
- color: 'gray',
836
- display: disabled ? 'none' : 'inline-block',
837
- }}
838
- />
839
- <Button
840
- type="link"
841
- disabled={
842
- disabled || itemDetail.operationCode === '' || !itemDetail.operationCode
843
- ? true
844
- : false
845
- }
846
- onClick={() => {
847
- const { ruleClassData } = this.state;
848
- if (systemVariableList?.length) {
849
- itemDetail.isInsertParam = !itemDetail.isInsertParam;
850
- delete itemDetail.params;
851
- delete itemDetail.paramNames;
852
- this.setState(
853
- {
854
- ruleClassData,
855
- },
856
- () => {
857
- callBack(ruleClassData);
858
- },
859
- );
860
- } else {
861
- message.warn('未配置规则变量');
862
- }
863
- }}
864
- >
865
- {itemDetail?.isInsertParam ? '取消插入参数' : '插入参数'}
866
- </Button>
867
- </div>
868
- )}
869
- <div
870
- style={{
871
- display:
872
- itemDetail.operationType == 'logic' && !disabled
873
- ? 'block'
874
- : 'none',
875
- }}
876
- >
877
- <span
878
- style={{ color: '#008fe0', cursor: 'pointer' }}
879
- type="link"
880
- onClick={() => {
881
- this.addPeerRule(itemDetail);
882
- }}
883
- >
884
- <PlusCircleOutlined
885
- style={{
886
- color: '#008fe0',
887
- fontSize: '14px',
888
- marginRight: '5px',
889
- }}
890
- />
891
- 添加条件
892
- </span>
893
- </div>
894
- </div>
895
- </div>
896
- );
897
- };
898
-
899
- handleEditExtraInfoResponse = (code, val, parentDetail) => {
900
- const { ruleClassData } = this.state;
901
- const { callBack } = this.props;
902
- parentDetail.extraInfo.response[code] = val;
903
- this.setState(
904
- {
905
- ruleClassData,
906
- },
907
- () => {
908
- callBack(ruleClassData);
909
- },
910
- );
911
- };
912
- // 场景需要返回值2022.11.15
913
- renderResItem = (
914
- itemDetail,
915
- parentDetail,
916
- ruleReturnConfig,
917
- disabled,
918
- boxStyle,
919
- ) => {
920
- const isShowResponse = itemDetail.response['enable'];
921
- const isRightText = ruleReturnConfig?.rightText?.length;
922
-
923
- const showValue = (code, type, functionItem, configItem) => {
924
- let defaultValue = configItem.defaultValue;
925
- const pCode = itemDetail.response['value'];
926
- if (type === 'input') {
927
- return pCode === undefined ? pCode : pCode || defaultValue;
928
- }
929
- return pCode || defaultValue;
930
- };
931
- const handleEdit = (code, val) => {
932
- let value = val;
933
- if (isObj(code)) {
934
- Object.keys(code).forEach((ite) => {
935
- this.handleEditExtraInfoResponse(ite, code[ite], parentDetail);
936
- });
937
- return;
938
- }
939
- if (Array.isArray(val)) {
940
- value = val.map((m) => m.value || m).join(',');
941
- }
942
- if (isObj(val)) {
943
- value = val.value || val.PCDCode?.join('/');
944
- }
945
- this.handleEditExtraInfoResponse('value', value, parentDetail);
946
- };
947
-
948
- return (
949
- (isShowResponse && (
950
- <div style={{ display: 'flex' }}>
951
- {this.renderFormCompItem(
952
- ruleReturnConfig,
953
- showValue,
954
- handleEdit,
955
- {},
956
- boxStyle,
957
- disabled
958
- )}
959
- <MinusCircleOutlined
960
- className={'icon_btn_style'}
961
- onClick={() => {
962
- this.handleEditExtraInfoResponse('enable', false, parentDetail);
963
- }}
964
- style={{
965
- color: 'gray',
966
- marginLeft: isRightText ? '100px' : '15px',
967
- marginTop: '15px',
968
- display: disabled ? 'none' : 'inline-block',
969
- }}
970
- />
971
- </div>
972
- )) ||
973
- null
974
- );
975
- };
976
-
977
- renderCompItem = (ites, showValue, handleEdit,disabled) => {
978
- const { regularDataList } = this.props;
979
- let fieldListGroup = regularDataList.map((item) => {
980
- const Item = {
981
- id: item.id,
982
- code: item.code,
983
- name: item.name,
984
- value: item.code,
985
- };
986
- if (item.propertyList) {
987
- Item.propertyList = item.propertyList.map((field) => ({
988
- id: field.id,
989
- code: field.code,
990
- name: field.name,
991
- value: `${item.code}.${field.code}`,
992
- valueText: `${item.name}.${field.name}`,
993
- }));
994
- }
995
- return Item;
996
- });
997
- if (!ites) return;
998
- const styleCommon = {
999
- width: '200px',
1000
- ...(ites?.rightText ? { marginLeft: 10 } : {}),
1001
- };
1002
- const style2 = {
1003
- width: '100px',
1004
- };
1005
- return (
1006
- <>
1007
- {/* 输入/字符串 */}
1008
- {(ites?.inputType === 10 && ites?.valueType === 21 && (
1009
- <Input
1010
- disabled={disabled}
1011
- allowClear={true}
1012
- onClear={() => {
1013
- handleEdit(ites.code, undefined);
1014
- }}
1015
- defaultValue={showValue(ites.code, 'input')}
1016
- style={styleCommon}
1017
- onBlur={(e) => {
1018
- handleEdit(
1019
- ites.code,
1020
- String(e.target.value).trim() == ''
1021
- ? undefined
1022
- : e.target.value,
1023
- );
1024
- }}
1025
- />
1026
- )) ||
1027
- null}
1028
- {/* 输入 / 长整数23/小数22 */}
1029
- {(ites?.inputType === 10 &&
1030
- (ites?.valueType === 23 || ites?.valueType === 22) && (
1031
- <InputNumber
1032
- disabled={disabled}
1033
- max={Number.MAX_SAFE_INTEGER}
1034
- min={ites?.valueType === 23 ? 0 : Number.MIN_SAFE_INTEGER}
1035
- precision={ites?.valueType === 23 ? 0 : 2}
1036
- defaultValue={ites.defaultValue}
1037
- style={style2}
1038
- value={showValue(ites.code)}
1039
- onChange={(value) => {
1040
- handleEdit(ites.code, value);
1041
- }}
1042
- />
1043
- )) ||
1044
- null}
1045
- {/* 输入/日期 */}
1046
- {(ites?.inputType === 10 && ites?.valueType === 41 && (
1047
- <DatePicker
1048
- disabled={disabled}
1049
- defaultValue={ites.defaultValue}
1050
- style={style2}
1051
- value={showValue(ites.code)}
1052
- onChange={(value) => {
1053
- handleEdit(ites.code, value);
1054
- }}
1055
- />
1056
- )) ||
1057
- null}
1058
- {/* 输入/时间 */}
1059
- {(ites?.inputType === 10 && ites?.valueType === 40 && (
1060
- <RangePicker
1061
- showTime
1062
- disabled={disabled}
1063
- defaultValue={ites.defaultValue}
1064
- style={style2}
1065
- value={showValue(ites.code)}
1066
- onChange={(value) => {
1067
- handleEdit(ites.code, value);
1068
- }}
1069
- />
1070
- )) ||
1071
- null}
1072
- {/* 输入/布尔值 */}
1073
- {(ites?.inputType === 10 && ites?.valueType === 24 && (
1074
- <Switch
1075
- disabled={disabled}
1076
- defaultChecked={!!ites.defaultValue}
1077
- style={style2}
1078
- checked={showValue(ites.code)}
1079
- onChange={(value) => {
1080
- handleEdit(ites.code, value);
1081
- }}
1082
- />
1083
- )) ||
1084
- null}
1085
- {/* 单选/多选 自定义 */}
1086
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1087
- ites?.choiceType === 10 && (
1088
- <Select
1089
- disabled={disabled}
1090
- allowClear
1091
- showArrow
1092
- {...(ites?.inputType === 30
1093
- ? {
1094
- mode: 'multiple',
1095
- }
1096
- : {})}
1097
- defaultValue={ites.defaultValue}
1098
- style={styleCommon}
1099
- value={showValue(ites.code)}
1100
- onChange={(value) => {
1101
- handleEdit(ites.code, value);
1102
- }}
1103
- >
1104
- {Object.keys(ites.enumeration).map((it) => (
1105
- <Select.Option key={it} value={it}>
1106
- {ites.enumeration[it]}
1107
- </Select.Option>
1108
- ))}
1109
- </Select>
1110
- )) ||
1111
- null}
1112
- {/* 单选/多选 数据字典 */}
1113
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1114
- ites?.choiceType === 20 && (
1115
- <Select
1116
- disabled={disabled}
1117
- {...(ites?.inputType === 30
1118
- ? {
1119
- mode: 'multiple',
1120
- }
1121
- : {})}
1122
- defaultValue={ites.defaultValue}
1123
- style={styleCommon}
1124
- value={showValue(ites.code)}
1125
- onChange={(value) => {
1126
- handleEdit(ites.code, value);
1127
- }}
1128
- >
1129
- {getDictionarySource(ites?.dictionaryCode).map((it) => (
1130
- <Select.Option key={it.value} value={it.value}>
1131
- {it.text}
1132
- </Select.Option>
1133
- ))}
1134
- </Select>
1135
- )) ||
1136
- null}
1137
- {/* 单选/多选 仓库选择器(物理仓) */}
1138
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1139
- ites?.choiceType === 110 && (
1140
- <BusinessSearchSelect
1141
- selectBusinessType="physicalWarehouse"
1142
- selectProps={{
1143
- style: styleCommon,
1144
- placeholder: '请选择物理仓',
1145
- ...(ites?.inputType === 30
1146
- ? {
1147
- mode: 'multiple',
1148
- maxTagCount: 1,
1149
- }
1150
- : {}),
1151
- }}
1152
- disabled={disabled}
1153
- labelInValue={true}
1154
- value={showValue(ites.code)}
1155
- requestConfig={{
1156
- mappingValueField: 'physicalWarehouseCode',
1157
- filterInit: 'qp-physicalWarehouseCode-in',
1158
- }}
1159
- onChange={(value) => {
1160
- handleEdit(ites.code, value);
1161
- }}
1162
- getPopupContainer={() => document.body}
1163
- />
1164
- )) ||
1165
- null}
1166
- {/* 单选/多选 仓库选择器(逻辑仓) */}
1167
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1168
- ites?.choiceType === 120 && (
1169
- <BusinessSearchSelect
1170
- selectBusinessType="realWarehouse"
1171
- selectProps={{
1172
- style: styleCommon,
1173
- placeholder: '请选择逻辑仓',
1174
- ...(ites?.inputType === 30
1175
- ? {
1176
- mode: 'multiple',
1177
- maxTagCount: 1,
1178
- }
1179
- : {}),
1180
- }}
1181
- disabled={disabled}
1182
- labelInValue={true}
1183
- value={showValue(ites.code)}
1184
- requestConfig={{
1185
- mappingValueField: 'realWarehouseCode',
1186
- filterInit: 'qp-realWarehouseCode-in',
1187
- }}
1188
- onChange={(value) => {
1189
- handleEdit(ites.code, value);
1190
- }}
1191
- getPopupContainer={() => document.body}
1192
- />
1193
- )) ||
1194
- null}
1195
- {/* 单选/多选 仓库选择器(虚拟仓) */}
1196
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1197
- ites?.choiceType === 130 && (
1198
- <BusinessSearchSelect
1199
- selectBusinessType="virtualWarehouse"
1200
- selectProps={{
1201
- style: styleCommon,
1202
- placeholder: '请选择虚拟仓',
1203
- ...(ites?.inputType === 30
1204
- ? {
1205
- mode: 'multiple',
1206
- maxTagCount: 1,
1207
- }
1208
- : {}),
1209
- }}
1210
- disabled={disabled}
1211
- labelInValue={true}
1212
- value={showValue(ites.code)}
1213
- requestConfig={{
1214
- mappingValueField: 'virtualWarehouseCode',
1215
- filterInit: 'qp-virtualWarehouseCode-in',
1216
- }}
1217
- onChange={(value) => {
1218
- handleEdit(ites.code, value);
1219
- }}
1220
- getPopupContainer={() => document.body}
1221
- />
1222
- )) ||
1223
- null}
1224
- {/* 单选/多选 仓库选择器(渠道仓) */}
1225
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1226
- ites?.choiceType === 140 && (
1227
- <BusinessSearchSelect
1228
- selectBusinessType="channelWarehouse"
1229
- selectProps={{
1230
- style: styleCommon,
1231
- placeholder: '请选择渠道仓',
1232
- ...(ites?.inputType === 30
1233
- ? {
1234
- mode: 'multiple',
1235
- maxTagCount: 1,
1236
- }
1237
- : {}),
1238
- }}
1239
- disabled={disabled}
1240
- labelInValue={true}
1241
- value={showValue(ites.code)}
1242
- requestConfig={{
1243
- mappingValueField: 'channelWarehouseCode',
1244
- filterInit: 'qp-channelWarehouseCode-in',
1245
- }}
1246
- onChange={(value) => {
1247
- handleEdit(ites.code, value);
1248
- }}
1249
- getPopupContainer={() => document.body}
1250
- />
1251
- )) ||
1252
- null}
1253
- {/* 单选/多选 商品SPU选择器 */}
1254
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1255
- ites?.choiceType === 150 && (
1256
- <BusinessSearchSelect
1257
- selectBusinessType="spuCommodity"
1258
- selectProps={{
1259
- style: styleCommon,
1260
- placeholder: '请选择SPU',
1261
- ...(ites?.inputType === 30
1262
- ? {
1263
- mode: 'multiple',
1264
- maxTagCount: 1,
1265
- }
1266
- : {}),
1267
- }}
1268
- disabled={disabled}
1269
- labelInValue={true}
1270
- value={showValue(ites.code)}
1271
- requestConfig={{
1272
- filterInit: 'qp-itemCode-in',
1273
- }}
1274
- onChange={(value) => {
1275
- handleEdit(ites.code, value);
1276
- }}
1277
- getPopupContainer={() => document.body}
1278
- />
1279
- )) ||
1280
- null}
1281
- {/* 单选/多选 商品SKU选择器 */}
1282
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1283
- ites?.choiceType === 160 && (
1284
- <BusinessSearchSelect
1285
- selectBusinessType="skuCommodity"
1286
- selectProps={{
1287
- style: styleCommon,
1288
- placeholder: '请选择商品',
1289
- ...(ites?.inputType === 30
1290
- ? {
1291
- mode: 'multiple',
1292
- maxTagCount: 1,
1293
- }
1294
- : {}),
1295
- }}
1296
- disabled={disabled}
1297
- labelInValue={true}
1298
- value={showValue(ites.code)}
1299
- requestConfig={{
1300
- filterInit: 'qp-skuCode-in',
1301
- }}
1302
- onChange={(value) => {
1303
- handleEdit(ites.code, value);
1304
- }}
1305
- getPopupContainer={() => document.body}
1306
- />
1307
- )) ||
1308
- null}
1309
- {/* 单选/多选 省市区 */}
1310
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1311
- ites?.choiceType === 190 && (
1312
- <BsCascader
1313
- disabled={disabled}
1314
- isAll={true}
1315
- needNameAndCode={true}
1316
- notChangeOnSelect={true}
1317
- initRequestSource={async () => {
1318
- return await request({
1319
- url: '/basic/bscArea/getBscAreaList?qp-level-eq=1&qp-pid-eq=100000',
1320
- method: 'get',
1321
- converter: ({ data }) => {
1322
- const handleData =
1323
- data && data[0]
1324
- ? data?.map((item) => {
1325
- return {
1326
- text: item.name,
1327
- value: item.id,
1328
- level: item.level,
1329
- id: item.id,
1330
- };
1331
- })
1332
- : [];
1333
- return handleData;
1334
- },
1335
- });
1336
- }}
1337
- value={showValue(ites.code)}
1338
- onChange={(value) => {
1339
- handleEdit(ites.code, value);
1340
- }}
1341
- getPopupContainer={() => document.body}
1342
- />
1343
- )) ||
1344
- null}
1345
- {/* 单选/多选 行政组织选择器 */}
1346
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1347
- ites?.choiceType === 210 && (
1348
- <BusinessTreeSearchSelect
1349
- disabled={disabled}
1350
- treeCheckable={ites?.inputType === 30}
1351
- businessType="department"
1352
- labelInValue={true}
1353
- value={showValue(ites.code)}
1354
- style={styleCommon}
1355
- onChange={(value) => {
1356
- handleEdit(ites.code, value);
1357
- }}
1358
- getPopupContainer={() => document.body}
1359
- />
1360
- )) ||
1361
- null}
1362
- {/* 单选/多选 采购组织选择器 */}
1363
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1364
- ites?.choiceType === 220 && (
1365
- <BusinessTreeSearchSelect
1366
- disabled={disabled}
1367
- treeCheckable={ites?.inputType === 30}
1368
- businessType="purchase-organization"
1369
- labelInValue={true}
1370
- value={showValue(ites.code)}
1371
- style={styleCommon}
1372
- onChange={(value) => {
1373
- handleEdit(ites.code, value);
1374
- }}
1375
- getPopupContainer={() => document.body}
1376
- />
1377
- )) ||
1378
- null}
1379
- {/* 单选/多选 销售组织选择器 */}
1380
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1381
- ites?.choiceType === 230 && (
1382
- <BusinessTreeSearchSelect
1383
- disabled={disabled}
1384
- treeCheckable={ites?.inputType === 30}
1385
- businessType="sales-organization"
1386
- labelInValue={true}
1387
- value={showValue(ites.code)}
1388
- style={styleCommon}
1389
- onChange={(value) => {
1390
- handleEdit(ites.code, value);
1391
- }}
1392
- getPopupContainer={() => document.body}
1393
- />
1394
- )) ||
1395
- null}
1396
- {/* 单选/多选 供应商选择器 */}
1397
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1398
- ites?.choiceType === 240 && (
1399
- <BusinessSearchSelect
1400
- selectBusinessType="supplier2"
1401
- selectProps={{
1402
- style: styleCommon,
1403
- placeholder: '请选择供应商',
1404
- ...(ites?.inputType === 30
1405
- ? {
1406
- mode: 'multiple',
1407
- maxTagCount: 1,
1408
- }
1409
- : {}),
1410
- }}
1411
- disabled={disabled}
1412
- labelInValue={true}
1413
- value={showValue(ites.code)}
1414
- requestConfig={{
1415
- filterInit: 'qp-code-in',
1416
- }}
1417
- onChange={(value) => {
1418
- handleEdit(ites.code, value);
1419
- }}
1420
- getPopupContainer={() => document.body}
1421
- />
1422
- )) ||
1423
- null}
1424
- {/* 单选/多选 客户选择器 */}
1425
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1426
- ites?.choiceType === 250 && (
1427
- <BusinessSearchSelect
1428
- selectBusinessType="customer2"
1429
- selectProps={{
1430
- style: styleCommon,
1431
- placeholder: '请选择客户',
1432
- ...(ites?.inputType === 30
1433
- ? {
1434
- mode: 'multiple',
1435
- maxTagCount: 1,
1436
- }
1437
- : {}),
1438
- }}
1439
- disabled={disabled}
1440
- labelInValue={true}
1441
- value={showValue(ites.code)}
1442
- requestConfig={{
1443
- filterInit: 'qp-code-in',
1444
- }}
1445
- onChange={(value) => {
1446
- handleEdit(ites.code, value);
1447
- }}
1448
- getPopupContainer={() => document.body}
1449
- />
1450
- )) ||
1451
- null}
1452
- {/* 单选/多选 店铺选择器 */}
1453
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1454
- ites?.choiceType === 260 && (
1455
- <BusinessSearchSelect
1456
- selectBusinessType="shopFile2"
1457
- selectProps={{
1458
- style: styleCommon,
1459
- placeholder: '请选择店铺',
1460
- ...(ites?.inputType === 30
1461
- ? {
1462
- mode: 'multiple',
1463
- maxTagCount: 1,
1464
- }
1465
- : {}),
1466
- }}
1467
- disabled={disabled}
1468
- labelInValue={true}
1469
- value={showValue(ites.code)}
1470
- requestConfig={{
1471
- filterInit: 'qp-code-in',
1472
- }}
1473
- onChange={(value) => {
1474
- handleEdit(ites.code, value);
1475
- }}
1476
- getPopupContainer={() => document.body}
1477
- />
1478
- )) ||
1479
- null}
1480
- {/* 单选/多选 员工选择器 */}
1481
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1482
- ites?.choiceType === 270 && (
1483
- <BusinessSearchSelect
1484
- selectBusinessType="employee2"
1485
- selectProps={{
1486
- style: styleCommon,
1487
- placeholder: '请选择员工',
1488
- ...(ites?.inputType === 30
1489
- ? {
1490
- mode: 'multiple',
1491
- maxTagCount: 1,
1492
- }
1493
- : {}),
1494
- }}
1495
- disabled={disabled}
1496
- labelInValue={true}
1497
- value={showValue(ites.code)}
1498
- requestConfig={{
1499
- filterInit: 'qp-id-in',
1500
- }}
1501
- onChange={(value) => {
1502
- handleEdit(ites.code, value);
1503
- }}
1504
- getPopupContainer={() => document.body}
1505
- />
1506
- )) ||
1507
- null}
1508
- {/* 单选/多选 库存组织选择器 */}
1509
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1510
- ites?.choiceType === 280 && (
1511
- <BusinessTreeSearchSelect
1512
- disabled={disabled}
1513
- treeCheckable={ites?.inputType === 30}
1514
- businessType="stock-organization"
1515
- labelInValue={true}
1516
- value={showValue(ites.code)}
1517
- style={styleCommon}
1518
- onChange={(value) => {
1519
- handleEdit(ites.code, value);
1520
- }}
1521
- getPopupContainer={() => document.body}
1522
- />
1523
- )) ||
1524
- null}
1525
- {/* 单选/多选 配送方式选择器 */}
1526
- {((ites?.inputType === 20 || ites?.inputType === 30) &&
1527
- ites?.choiceType === 310 && (
1528
- <BusinessSearchSelect
1529
- selectBusinessType="deliveryMode"
1530
- selectProps={{
1531
- style: styleCommon,
1532
- placeholder: '请选择配送方式',
1533
- ...(ites?.inputType === 30
1534
- ? {
1535
- mode: 'multiple',
1536
- maxTagCount: 1,
1537
- }
1538
- : {}),
1539
- }}
1540
- disabled={disabled}
1541
- labelInValue={true}
1542
- value={showValue(ites.code)}
1543
- requestConfig={{
1544
- filterInit: 'qp-code-in',
1545
- }}
1546
- onChange={(value) => {
1547
- handleEdit(ites.code, value);
1548
- }}
1549
- getPopupContainer={() => document.body}
1550
- />
1551
- )) ||
1552
- null}
1553
- {/* 表达式 */}
1554
- {ites?.inputType === 40 && (
1555
- <div style={{ display: 'flex' }}>
1556
- <Formula
1557
- disabled={disabled}
1558
- key={showValue(ites.code)}
1559
- setValue={(val, formulaName) => {
1560
- console.log(val, 'val');
1561
- const value = val.map((item) => {
1562
- return item.value.replace(
1563
- /[a-zA-Z_]+\.\w+/g,
1564
- (i) => '{' + i + '}',
1565
- );
1566
- });
1567
- handleEdit(ites.code, value.join(''));
1568
- handleEdit({
1569
- inputType: 40,
1570
- formulaName,
1571
- });
1572
- }}
1573
- record={{ expression: showValue(ites.code) }}
1574
- sourceData={fieldListGroup}
1575
- />
1576
- </div>
1577
- )}
1578
- </>
1579
- );
1580
- };
1581
-
1582
- renderFormCompItem = (
1583
- config,
1584
- showValue,
1585
- handleEdit,
1586
- parentItem,
1587
- boxStyle,
1588
- disabled
1589
- ) => {
1590
- if (!config) return;
1591
- return (
1592
- <div style={boxStyle}>
1593
- {(config?.leftText && (
1594
- <div style={{ flex: 'none', marginRight: 10 }}>
1595
- {config?.required && <span className="requiredMark" />}
1596
- {config.leftText}
1597
- </div>
1598
- )) ||
1599
- null}
1600
- {(!config?.leftText && config?.rightText && config?.required && (
1601
- <div style={{ flex: 'none', marginRight: 10 }}>
1602
- <span className="requiredMark" />
1603
- </div>
1604
- )) ||
1605
- null}
1606
- {this.renderCompItem(
1607
- config,
1608
- (a, b, c = parentItem, d = config) => showValue(a, b, c, d),
1609
- (a, b, c = parentItem, d = config) => handleEdit(a, b, c, d),
1610
- disabled
1611
- )}
1612
- {(config?.rightText && (
1613
- <div style={{ flex: 'none', marginLeft: 10 }}>{config.rightText}</div>
1614
- )) ||
1615
- null}
1616
- </div>
1617
- );
1618
- };
1619
-
1620
- renderActionList = (
1621
- itemDetail,
1622
- parentDetail,
1623
- handleRuleTypeData,
1624
- sRuleActionData,
1625
- classDataIndex,
1626
- disabled,
1627
- boxStyle,
1628
- ) => {
1629
- const showValue = (code, type, functionItem, configItem) => {
1630
- const functionIndex = handleRuleTypeData.findIndex(
1631
- (m) => m.code === functionItem.code,
1632
- );
1633
- const pCode =
1634
- itemDetail.execute[functionIndex] &&
1635
- itemDetail.execute[functionIndex].properties[code];
1636
- let defaultValue = configItem.defaultValue;
1637
- if (type === 'input') {
1638
- return pCode === undefined ? pCode : pCode || defaultValue;
1639
- }
1640
- return pCode || defaultValue;
1641
- };
1642
- const handleEdit = (code, val, functionItem) => {
1643
- const functionIndex = handleRuleTypeData.findIndex(
1644
- (m) => m.code === functionItem.code,
1645
- );
1646
- const { ruleClassData } = this.state;
1647
- const { callBack } = this.props;
1648
- parentDetail.extraInfo.execute[functionIndex]['properties'][code] = val;
1649
- parentDetail.extraInfo.execute[functionIndex]['code'] = functionItem.code;
1650
-
1651
- this.setState(
1652
- {
1653
- ruleClassData,
1654
- },
1655
- () => {
1656
- callBack(ruleClassData);
1657
- },
1658
- );
1659
- };
1660
-
1661
- return (
1662
- <>
1663
- {sRuleActionData.map((i, index) => (
1664
- <div>
1665
- <div style={{ display: 'flex' }}>
1666
- {(i.valueList?.length &&
1667
- i.valueList.map((s) => {
1668
- return this.renderFormCompItem(
1669
- s,
1670
- showValue,
1671
- handleEdit,
1672
- i,
1673
- boxStyle,
1674
- disabled
1675
- );
1676
- })) || (
1677
- <div style={boxStyle} key={i.functionName}>
1678
- <div>{i.functionName}</div>
1679
- </div>
1680
- )}
1681
- <MinusCircleOutlined
1682
- className={'icon_btn_style'}
1683
- onClick={() => {
1684
- this.handleDeleteRuleAction(classDataIndex, i.code);
1685
- }}
1686
- style={{
1687
- color: 'gray',
1688
- marginLeft: '15px',
1689
- marginTop: '15px',
1690
- display: disabled ? 'none' : 'inline-block',
1691
- }}
1692
- />
1693
- </div>
1694
- </div>
1695
- ))}
1696
- </>
1697
- );
1698
- };
1699
-
1700
- renderRuleTypeItem = (
1701
- itemDetail,
1702
- parentDetail,
1703
- floorIndex,
1704
- classDataIndex,
1705
- ruleTypeData,
1706
- ruleReturnConfig,
1707
- isRuleInstance
1708
- ) => {
1709
- const { modalParams } = this.state;
1710
- const { disabled } = this.props;
1711
- const isHaveRuleTypeData = ruleTypeData?.length;
1712
- const isHaveRuleReturnConfig = Object.keys(ruleReturnConfig)?.length;
1713
- const handleRuleTypeData = isHaveRuleTypeData
1714
- ? ruleTypeData.sort((a, b) => a.priority - b.priority)
1715
- : [];
1716
-
1717
- const selectRuleActionCode = isHaveRuleTypeData
1718
- ? itemDetail.execute.filter((i) => i.isSelected).map((s) => s.code)
1719
- : [];
1720
- const selectRuleActionData = isHaveRuleTypeData
1721
- ? handleRuleTypeData.filter((r) =>
1722
- selectRuleActionCode.some((s) => s === r.code),
1723
- )
1724
- : [];
1725
-
1726
- const RuleActionItemStyle = {
1727
- display: 'flex',
1728
- height: '30px',
1729
- lineHeight: '30px',
1730
- margin: '10px 0px',
1731
- };
1732
- return (
1733
- <div>
1734
- <div style={{ textAlign: 'right', display: isRuleInstance ? 'none' : 'flex' }}>
1735
- <Button
1736
- type="link"
1737
- onClick={() => {
1738
- if (isHaveRuleTypeData) {
1739
- this.setState({
1740
- modalParams: {
1741
- ...modalParams,
1742
- ruleActionData: handleRuleTypeData,
1743
- classDataIndex,
1744
- visible: true,
1745
- },
1746
- });
1747
- } else {
1748
- message.warn('未配置执行动作');
1749
- }
1750
- }}
1751
- >
1752
- 新增动作
1753
- </Button>
1754
- <Button
1755
- type="link"
1756
- onClick={() => {
1757
- if (isHaveRuleReturnConfig) {
1758
- this.handleEditExtraInfoResponse('enable', true, parentDetail);
1759
- } else {
1760
- message.warn('未配置返回');
1761
- }
1762
- }}
1763
- >
1764
- 新增返回值
1765
- </Button>
1766
- </div>
1767
- {(isHaveRuleReturnConfig &&
1768
- this.renderResItem(
1769
- itemDetail,
1770
- parentDetail,
1771
- ruleReturnConfig,
1772
- disabled,
1773
- RuleActionItemStyle,
1774
- )) ||
1775
- null}
1776
- {(isHaveRuleTypeData &&
1777
- this.renderActionList(
1778
- itemDetail,
1779
- parentDetail,
1780
- handleRuleTypeData,
1781
- selectRuleActionData,
1782
- classDataIndex,
1783
- disabled,
1784
- RuleActionItemStyle,
1785
- )) ||
1786
- null}
1787
- </div>
1788
- );
1789
- };
1790
-
1791
- //添加同一层级条件
1792
- addPeerRule = (itemDetail) => {
1793
- const { ruleClassData } = this.state;
1794
- const { callBack, disabled } = this.props;
1795
- if (disabled) return;
1796
- itemDetail.subExpression.push({
1797
- // "expressionType": "relation",
1798
- operationType: 'relation',
1799
- operationCode: '',
1800
- propertyPath: '',
1801
- params: [],
1802
- paramNames: [],
1803
- });
1804
- this.setState(
1805
- {
1806
- ruleClassData,
1807
- },
1808
- () => {
1809
- callBack(ruleClassData);
1810
- },
1811
- );
1812
- };
1813
-
1814
- //添加子层级条件
1815
- addChildRules = (itemDetail) => {
1816
- const { ruleClassData } = this.state;
1817
- const { callBack } = this.props;
1818
- const initialData = JSON.parse(JSON.stringify(itemDetail));
1819
- delete itemDetail.propertyPath;
1820
- delete itemDetail.params;
1821
- delete itemDetail.paramNames;
1822
- delete itemDetail.dataTypeCode;
1823
- delete itemDetail.elementId;
1824
- delete itemDetail.elementName;
1825
- delete itemDetail.metaObjectCode;
1826
- // itemDetail.expressionType = 'logic';
1827
- itemDetail.operationType = 'logic';
1828
- itemDetail.operationCode = 'and';
1829
- itemDetail.subExpression = [
1830
- initialData,
1831
- {
1832
- // "expressionType": "relation",
1833
- operationType: 'relation',
1834
- operationCode: '',
1835
- propertyPath: '',
1836
- params: [],
1837
- paramNames: [],
1838
- },
1839
- ];
1840
- this.setState(
1841
- {
1842
- ruleClassData,
1843
- },
1844
- () => {
1845
- callBack(ruleClassData);
1846
- },
1847
- );
1848
- };
1849
-
1850
- handleDeleteRule = (itemDetail, parentDetail, classDataIndex) => {
1851
- const { ruleClassData } = this.state;
1852
- const { callBack } = this.props;
1853
- if (parentDetail.ruleName) {
1854
- //删除根规则层级最后一条时整个规则项删除
1855
- ruleClassData.splice(classDataIndex, 1);
1856
- } else {
1857
- let deleteItemIndex = parentDetail.subExpression.findIndex(
1858
- (detailItem) =>
1859
- JSON.stringify(itemDetail) == JSON.stringify(detailItem),
1860
- );
1861
- if (parentDetail.subExpression.length > 2) {
1862
- parentDetail.subExpression.splice(deleteItemIndex, 1);
1863
- } else {
1864
- parentDetail.subExpression.splice(deleteItemIndex, 1);
1865
- // parentDetail.expressionType = parentDetail.subExpression[0].expressionType;
1866
- parentDetail.operationCode =
1867
- parentDetail.subExpression[0].operationCode;
1868
- parentDetail.operationType =
1869
- parentDetail.subExpression[0].operationType;
1870
-
1871
- if (parentDetail.subExpression[0].operationType == 'logic') {
1872
- parentDetail.subExpression = [
1873
- ...parentDetail.subExpression[0].subExpression,
1874
- ];
1875
- } else {
1876
- parentDetail.propertyPath =
1877
- parentDetail.subExpression[0].propertyPath;
1878
- parentDetail.params = [...parentDetail.subExpression[0].params];
1879
- parentDetail.paramNames = parentDetail.subExpression[0].paramNames
1880
- ? [...parentDetail.subExpression[0].paramNames]
1881
- : [];
1882
- parentDetail.metaObjectCode =
1883
- parentDetail.subExpression[0].metaObjectCode;
1884
- parentDetail.elementId = parentDetail.subExpression[0].elementId;
1885
- parentDetail.elementName = parentDetail.subExpression[0].elementName;
1886
- parentDetail.dataTypeCode =
1887
- parentDetail.subExpression[0].dataTypeCode;
1888
- delete parentDetail.subExpression;
1889
- }
1890
- }
1891
- }
1892
- this.setState(
1893
- {
1894
- ruleClassData,
1895
- },
1896
- () => {
1897
- callBack(ruleClassData);
1898
- },
1899
- );
1900
- };
1901
-
1902
- handleLogicalTypeChange = (itemDetail, type) => {
1903
- const { ruleClassData } = this.state;
1904
- const { callBack } = this.props;
1905
- itemDetail.operationCode = type;
1906
- this.setState(
1907
- {
1908
- ruleClassData,
1909
- },
1910
- () => {
1911
- callBack(ruleClassData);
1912
- },
1913
- );
1914
- };
1915
-
1916
- // 新增执行顺序
1917
- handleSelectRuleAction = (keys, classDataIndex, callback) => {
1918
- callback();
1919
- const { callBack } = this.props;
1920
- const { ruleClassData } = this.state;
1921
- ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1922
- classDataIndex
1923
- ].extraInfo.execute.map((i) => {
1924
- if (i.code && keys.some((r) => r === i.code) && !i.isSelected) {
1925
- return { ...i, isSelected: true };
1926
- }
1927
- return i;
1928
- });
1929
- // 处理数据
1930
- this.setState(
1931
- {
1932
- ruleClassData,
1933
- },
1934
- () => {
1935
- callBack(ruleClassData);
1936
- },
1937
- );
1938
- };
1939
-
1940
- handleDeleteRuleAction = (classDataIndex, functionCode) => {
1941
- const { callBack } = this.props;
1942
- const { ruleClassData } = this.state;
1943
- ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1944
- classDataIndex
1945
- ].extraInfo.execute.map((i) => {
1946
- if (i.code && functionCode === i.code && i.isSelected) {
1947
- return { ...i, isSelected: false };
1948
- }
1949
- return i;
1950
- });
1951
- // 处理数据
1952
- this.setState(
1953
- {
1954
- ruleClassData,
1955
- },
1956
- () => {
1957
- callBack(ruleClassData);
1958
- },
1959
- );
1960
- };
1961
-
1962
- render() {
1963
- const { onlyOneRule, callBack } = this.props;
1964
- const { ruleClassData, modalParams } = this.state;
1965
- return (
1966
- <div className={'base_rule'}>
1967
- <div className={'base_rule_content'}>
1968
- <div
1969
- style={{
1970
- display: onlyOneRule ? 'none' : 'block',
1971
- }}
1972
- className={'base_rule_line_title'}
1973
- >
1974
- <Button
1975
- onClick={this.handleAddRule}
1976
- className={'base_rule_btn_style'}
1977
- type="link"
1978
- >
1979
- 新增规则
1980
- </Button>
1981
- </div>
1982
- <div>{this.renderRuleContent()}</div>
1983
- </div>
1984
- {(modalParams.visible && (
1985
- <Modal
1986
- title={`新增动作`}
1987
- visible={modalParams.visible}
1988
- onCancel={() => {
1989
- this.setState({
1990
- modalParams: { ...modalParams, visible: false },
1991
- });
1992
- }}
1993
- maskClosable={false}
1994
- destroyOnClose
1995
- footer={null}
1996
- >
1997
- <Table
1998
- rowSelection={{
1999
- onChange: (keys, selectRows) => {
2000
- this.handleSelectRuleAction(
2001
- keys,
2002
- modalParams.classDataIndex,
2003
- () => {
2004
- this.setState({
2005
- modalParams: { ...modalParams, visible: false },
2006
- });
2007
- },
2008
- );
2009
- },
2010
- }}
2011
- columns={[
2012
- {
2013
- title: '执行动作名称',
2014
- key: 'functionName',
2015
- dataIndex: 'functionName',
2016
- },
2017
- ]}
2018
- dataSource={modalParams?.ruleActionData}
2019
- rowKey={'code'}
2020
- />
2021
- </Modal>
2022
- )) ||
2023
- null}
2024
- </div>
2025
- );
2026
- }
2027
- }
2028
- export default RuleObjectComponent;
1
+ import React, { Component } from 'react';
2
+ // @ts-ignore
3
+ import _ from 'lodash';
4
+ import RuleField from './ruleFiled';
5
+ import {
6
+ Select,
7
+ Button,
8
+ Radio,
9
+ Switch,
10
+ Checkbox,
11
+ InputNumber,
12
+ TreeSelect,
13
+ Popover,
14
+ Input,
15
+ DatePicker,
16
+ Table,
17
+ Divider,
18
+ Space,
19
+ Form as AntdForm,
20
+ Modal,
21
+ message,
22
+ } from 'antd';
23
+ import {
24
+ PlusCircleOutlined,
25
+ MinusCircleOutlined,
26
+ DownOutlined,
27
+ } from '@ant-design/icons';
28
+ import './index.less';
29
+ import {
30
+ relateItems,
31
+ getSpecialPropertyCode,
32
+ getPropertyCode,
33
+ isObj,
34
+ } from './util';
35
+ import { getDictionarySource, uuid } from '../../../utils/utils';
36
+ import {
37
+ BusinessSearchSelect,
38
+ BusinessTreeSearchSelect,
39
+ EllipsisTooltip,
40
+ BsCascader,
41
+ } from '../../../index';
42
+ import { request } from 'bssula';
43
+ import Formula from './Formula';
44
+ import RenderSpecificAction from './renderSpecificAction';
45
+
46
+ const { RangePicker } = DatePicker;
47
+
48
+ class RuleObjectComponent extends Component {
49
+ constructor(props) {
50
+ super(props);
51
+ this.state = {
52
+ editNameIndex: 0,
53
+ isEdit: false,
54
+ ruleTreeData: [],
55
+ initialRegularList: [],
56
+ operationList: [],
57
+ ruleClassData: [],
58
+ modalParams: {
59
+ visible: false,
60
+ },
61
+ };
62
+ this.propertyCodeToRangeIdMap = {};
63
+ this.dictCodeToRangeIdMap = {};
64
+ this.dynamicDictCodeToRangeIdMap = {};
65
+ }
66
+
67
+ componentDidMount(props) {
68
+ const { ruleClassData, operationList, regularDataList } = this.props;
69
+ this.setRegularData(regularDataList);
70
+ this.setState({
71
+ ruleClassData,
72
+ operationList,
73
+ });
74
+ }
75
+
76
+ componentWillReceiveProps(nextProps) {
77
+ const { ruleClassData, operationList, regularDataList } = this.state;
78
+ if (
79
+ nextProps.ruleClassData &&
80
+ this.props.ruleClassData != nextProps.ruleClassData &&
81
+ JSON.stringify(nextProps.ruleClassData) != JSON.stringify(ruleClassData)
82
+ ) {
83
+ this.setState({
84
+ ruleClassData: nextProps.ruleClassData,
85
+ });
86
+ }
87
+
88
+ if (
89
+ nextProps.operationList &&
90
+ this.props.operationList != nextProps.operationList
91
+ ) {
92
+ this.setState({
93
+ operationList: nextProps.operationList,
94
+ });
95
+ }
96
+
97
+ if (
98
+ nextProps.regularDataList &&
99
+ this.props.regularDataList != nextProps.regularDataList
100
+ ) {
101
+ this.setRegularData(nextProps.regularDataList);
102
+ }
103
+ }
104
+
105
+ setRegularData = (regularDataList) => {
106
+ this.propertyCodeToRangeIdMap = {};
107
+ this.dictCodeToRangeIdMap = {};
108
+ this.dynamicDictCodeToRangeIdMap = {};
109
+ const finalTreeDatas = regularDataList.map((item) => {
110
+ return {
111
+ title: item.name,
112
+ key: item.id,
113
+ value: item.code,
114
+ ...(item?.propertyList?.length
115
+ ? {
116
+ children: item.propertyList.map((element) => {
117
+ const infoVo = (element.info && JSON.parse(element.info)) || {};
118
+ if (element.choiceType === 30) {
119
+ this.dynamicDictCodeToRangeIdMap[
120
+ `${item.code}.${element.code}`
121
+ ] = infoVo?.dictionaryCode;
122
+ } else if (element.choiceType === 20) {
123
+ this.dictCodeToRangeIdMap[`${item.code}.${element.code}`] =
124
+ infoVo?.dictionaryCode;
125
+ } else if (element.choiceType === 10) {
126
+ const list =
127
+ (Object.keys(infoVo).length &&
128
+ infoVo.enumeration &&
129
+ Object.keys(infoVo.enumeration).map((i) => ({
130
+ code: i,
131
+ name: infoVo.enumeration[i],
132
+ }))) ||
133
+ undefined;
134
+ this.propertyCodeToRangeIdMap[
135
+ `${item.code}.${element.code}`
136
+ ] = list;
137
+ } else {
138
+ this.propertyCodeToRangeIdMap[
139
+ `${item.code}.${element.code}`
140
+ ] = Object.keys(infoVo).length ? infoVo : undefined;
141
+ }
142
+ let child = {
143
+ title: `${item.name}-${element.name}`,
144
+ key: element.id,
145
+ value: `${element.code}`,
146
+ id: element.id,
147
+ dataTypeCode: element.valueType,
148
+ dataChoiceBusinessType: element.choiceType,
149
+ dataInputBusinessType: element.inputType,
150
+ info: element.info,
151
+ };
152
+ if (element?.propertyList?.length) {
153
+ child.children = this.parseChildTreeData(
154
+ element.propertyList,
155
+ `${element.code}`,
156
+ `${item.name}-${element.name}`,
157
+ item.code,
158
+ );
159
+ child.isLeaf = false;
160
+ } else {
161
+ child.isLeaf = true;
162
+ child.metaObjectCode = item.code;
163
+ }
164
+ return child;
165
+ }),
166
+ }
167
+ : {}),
168
+ };
169
+ });
170
+ this.setState({
171
+ initialRegularList: [...regularDataList],
172
+ ruleTreeData: finalTreeDatas,
173
+ });
174
+ };
175
+
176
+ parseChildTreeData = (list, parentKey, parentTitle, rootObjCode) => {
177
+ return list.map((element) => {
178
+ const infoVo = (element.info && JSON.parse(element.info)) || {};
179
+ if (element.choiceType === 30) {
180
+ this.dynamicDictCodeToRangeIdMap[
181
+ `${rootObjCode}.${parentKey}.${element.code}`
182
+ ] = infoVo?.dictionaryCode;
183
+ } else if (element.choiceType === 20) {
184
+ this.dictCodeToRangeIdMap[
185
+ `${rootObjCode}.${parentKey}.${element.code}`
186
+ ] = infoVo?.dictionaryCode;
187
+ } else if (element.choiceType === 10) {
188
+ const list =
189
+ (Object.keys(infoVo).length &&
190
+ infoVo.enumeration &&
191
+ Object.keys(infoVo.enumeration).map((i) => ({
192
+ code: i,
193
+ name: infoVo.enumeration[i],
194
+ }))) ||
195
+ undefined;
196
+ this.propertyCodeToRangeIdMap[
197
+ `${rootObjCode}.${parentKey}.${element.code}`
198
+ ] = list;
199
+ } else {
200
+ this.propertyCodeToRangeIdMap[
201
+ `${rootObjCode}.${parentKey}.${element.code}`
202
+ ] = Object.keys(infoVo).length ? infoVo : undefined;
203
+ }
204
+ let child = {
205
+ title: `${parentTitle}-${element.name}`,
206
+ key: `${parentKey}.${element.id}`,
207
+ value: `${parentKey}.${element.code}`,
208
+ id: element.id,
209
+ dataTypeCode: element.valueType,
210
+ dataChoiceBusinessType: element.choiceType,
211
+ dataInputBusinessType: element.inputType,
212
+ info: element.info,
213
+ };
214
+ if (element.propertyList) {
215
+ child.children = this.parseChildTreeData(
216
+ element.propertyList,
217
+ `${parentKey}.${element.code}`,
218
+ `${parentTitle}-${element.name}`,
219
+ rootObjCode,
220
+ );
221
+ child.isLeaf = false;
222
+ } else {
223
+ child.isLeaf = true;
224
+ child.metaObjectCode = rootObjCode;
225
+ }
226
+ return child;
227
+ });
228
+ };
229
+
230
+ getDataTypeOperateList = (id) => {
231
+ const { operationList, initialRegularList } = this.state;
232
+ // let typeId = '';
233
+ // initialRegularList.forEach(item => {
234
+ // item.metaObjectResDto.elementResDtos.forEach(element => {
235
+ // if (element.id == id) {
236
+ // typeId = element.dataTypeCode;
237
+ // }
238
+ // })
239
+ // })
240
+ const list =
241
+ operationList.find((item) => item.code == id)?.operationList || [];
242
+ return list;
243
+ };
244
+
245
+ handleValuesChange = (itemDetail, newValues, newValueNames) => {
246
+ const { ruleClassData } = this.state;
247
+ const { callBack } = this.props;
248
+ itemDetail.params = [...newValues];
249
+ itemDetail.paramNames = [...newValueNames];
250
+ this.setState(
251
+ {
252
+ ruleClassData,
253
+ },
254
+ () => {
255
+ callBack(ruleClassData);
256
+ },
257
+ );
258
+ };
259
+
260
+ setRelateDataList = (classDataItem) => {
261
+ let relateDatas = {};
262
+ relateItems.forEach((relateItem) => {
263
+ this.getRelateData(
264
+ relateItem,
265
+ classDataItem.subExpression || {},
266
+ relateDatas,
267
+ );
268
+ });
269
+ return relateDatas;
270
+ };
271
+
272
+ getRelateData = (relateItem, classDataItem, relateDatas) => {
273
+ if (
274
+ classDataItem?.propertyPath &&
275
+ getPropertyCode(classDataItem.propertyPath) == relateItem.propertyCode
276
+ ) {
277
+ relateDatas[relateItem.propertyCode] = classDataItem.params;
278
+ } else {
279
+ if (classDataItem.subExpression && classDataItem.subExpression.length) {
280
+ classDataItem.subExpression.forEach((classData) => {
281
+ this.getRelateData(relateItem, classData, relateDatas);
282
+ });
283
+ }
284
+ }
285
+ };
286
+
287
+ renderRuleContent = () => {
288
+ const { ruleClassData, currentRuleName, isEdit, editNameIndex } =
289
+ this.state;
290
+ const {
291
+ ruleType,
292
+ callBack,
293
+ accountList = [],
294
+ disabled,
295
+ ruleTypeData,
296
+ canDelete = false,
297
+ ruleReturnConfig = {},
298
+ onlyOneRule,
299
+ onlyCondition,
300
+ onlyAction,
301
+ handleOperatingAction,
302
+ ruleGroupInfo,
303
+ } = this.props;
304
+ const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1;
305
+ const ruleGroupName = ruleGroupInfo?.ruleGroupList?.[0]?.name || '规则分组';
306
+ const priorityList = (ruleGroupInfo?.groupOtherPriorityList || []).concat(ruleClassData|| []);
307
+ const canChangePriority = ruleGroupInfo?.canChangePriority;
308
+ const titlePre = {
309
+ position: 'relative',
310
+ top: '-10px',
311
+ left: '20px',
312
+ background: '#fff',
313
+ width: '160px',
314
+ textAlign: 'center',
315
+ };
316
+ const titleSubPre = {
317
+ ...titlePre,
318
+ top: '-33px',
319
+ left: '280px',
320
+ width: '160px',
321
+ }
322
+ const ruleListBox = (!onlyOneRule || ruleGroupInfo) ? { border: '1px dashed #d9d9d9', marginBottom: 10 } : {};
323
+ const isRuleActionConfig =
324
+ ruleTypeData?.length || Object.keys(ruleReturnConfig)?.length;
325
+ return (
326
+ <div>
327
+ {ruleClassData.map((item, classDataIndex) => {
328
+ let extraInfo = {};
329
+ if (isRuleActionConfig) {
330
+ extraInfo = {
331
+ ...item.extraInfo,
332
+ };
333
+ }
334
+ let relateDatas = this.setRelateDataList(item);
335
+ const sActionProps = {
336
+ extraInfo,
337
+ ruleTypeData,
338
+ item,
339
+ classDataIndex,
340
+ handleOperatingAction,
341
+ disabled,
342
+ };
343
+ return (
344
+ <div style={ruleListBox}>
345
+ {!onlyOneRule && !ruleGroupInfo && (
346
+ <div style={titlePre}>规则{classDataIndex + 1}</div>
347
+ )}
348
+ {ruleGroupInfo && (
349
+ <>
350
+ <div style={titlePre}>
351
+ <EllipsisTooltip
352
+ visible={true}
353
+ maxLength={10}
354
+ title={ruleGroupName}
355
+ />
356
+ </div>
357
+ {isRuleInstance && (
358
+ <div style={titleSubPre}>
359
+ <span style={{ marginRight: 10 }}>优先级</span>
360
+ <Select
361
+ disabled={canChangePriority ? !canChangePriority : disabled}
362
+ style={{ width: 100 }}
363
+ value={item.priority}
364
+ onChange={(v) => {
365
+ // 因为存在页签,前端校验不准确;而且若选择优先级之后想交换改也不方便,故交由后端校验
366
+ // const isRepeate = priorityList.some((r) => r.priority == v)
367
+ // if(isRepeate) {
368
+ // message.warn('优先级不允许重复')
369
+ // }
370
+ // item.priority = isRepeate ? (item.priority||null) : v;
371
+ item.priority = v
372
+ this.setState(
373
+ {
374
+ ruleClassData,
375
+ },
376
+ () => {
377
+ callBack(ruleClassData);
378
+ },
379
+ );
380
+ }}
381
+ >
382
+ {priorityList?.map((s,sindex) => (
383
+ <Option key={sindex+1} value={sindex+1}>{sindex+1}</Option>
384
+ ))}
385
+ </Select>
386
+ </div>
387
+ ) || null}
388
+ </>
389
+ )}
390
+ <div
391
+ style={{
392
+ textAlign: 'right',
393
+ marginTop: '-24px',
394
+ display: canDelete ? 'block' : 'none',
395
+ }}
396
+ >
397
+ <Button
398
+ disabled={disabled}
399
+ onClick={() => {
400
+ const { ruleClassData } = this.state;
401
+ ruleClassData.splice(classDataIndex, 1);
402
+ this.setState(
403
+ {
404
+ ruleClassData,
405
+ },
406
+ () => {
407
+ callBack(ruleClassData);
408
+ },
409
+ );
410
+ }}
411
+ type="link"
412
+ danger
413
+ >
414
+ 删除规则
415
+ </Button>
416
+ </div>
417
+ <div>
418
+ {/* <div style={{ display: isEdit && editNameIndex == index ? 'none' : 'block' }}>
419
+ <span className={'rule_name_title}>
420
+ {item.ruleName}
421
+ </span>
422
+ <EditOutlined
423
+ onClick={() => {
424
+ this.setState({
425
+ editNameIndex: index,
426
+ currentRuleName: item.ruleName,
427
+ isEdit: true
428
+ })
429
+ }}
430
+ />
431
+ </div> */}
432
+ <div
433
+ style={{
434
+ display:
435
+ isEdit && editNameIndex == index ? 'block' : 'none',
436
+ marginTop: '10px',
437
+ }}
438
+ >
439
+ <Input
440
+ value={currentRuleName}
441
+ style={{ width: '200px' }}
442
+ onChange={(e) => {
443
+ this.setState({
444
+ currentRuleName: e.target.value,
445
+ });
446
+ }}
447
+ />
448
+ <Button
449
+ type="link"
450
+ onClick={() => {
451
+ const { ruleClassData, currentRuleName } = this.state;
452
+ ruleClassData[editNameIndex].ruleName = currentRuleName;
453
+ this.setState({
454
+ ruleClassData,
455
+ isEdit: false,
456
+ });
457
+ }}
458
+ >
459
+ 保存
460
+ </Button>
461
+ <Button
462
+ type="link"
463
+ onClick={() => {
464
+ this.setState({
465
+ isEdit: false,
466
+ });
467
+ }}
468
+ >
469
+ 取消
470
+ </Button>
471
+ </div>
472
+ </div>
473
+ <div>
474
+ {(onlyAction && <RenderSpecificAction {...sActionProps} />) || (
475
+ <div className={'base_rule_line_content'}>
476
+ <div className={'base_rule_item2'}>
477
+ {item.subExpression &&
478
+ this.renderRuleItem(
479
+ item.subExpression,
480
+ item,
481
+ 1,
482
+ classDataIndex,
483
+ relateDatas,
484
+ )}
485
+ </div>
486
+ <div className={'base_rule_item3'}>
487
+ {(extraInfo &&
488
+ isRuleActionConfig &&
489
+ (!onlyCondition || !onlyAction) &&
490
+ this.renderRuleTypeItem(
491
+ extraInfo,
492
+ item,
493
+ 1,
494
+ classDataIndex,
495
+ ruleTypeData,
496
+ ruleReturnConfig,
497
+ isRuleInstance
498
+ )) ||
499
+ null}
500
+ </div>
501
+ </div>
502
+ )}
503
+ </div>
504
+ </div>
505
+ );
506
+ })}
507
+ </div>
508
+ );
509
+ };
510
+
511
+ handleAddRule = () => {
512
+ const { ruleClassData } = this.state;
513
+ const { callBack, ruleTypeData, ruleGroupInfo } = this.props;
514
+ const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1;
515
+ const initKongData = {
516
+ ruleName: `规则${ruleClassData?.length + 1}`,
517
+ subExpression: {
518
+ // "expressionType": "relation",
519
+ operationType: 'relation',
520
+ propertyPath: '',
521
+ params: [],
522
+ paramNames: [],
523
+ },
524
+ extraInfo: {
525
+ response: {
526
+ enable: false,
527
+ value: '',
528
+ },
529
+ execute: ruleTypeData.map((s) => {
530
+ return {
531
+ priority: 1,
532
+ code: s.code,
533
+ properties: {
534
+ configPropertyCode: 'configPropertyValue',
535
+ },
536
+ };
537
+ }),
538
+ },
539
+ }
540
+ const initTemplateData = ruleGroupInfo?.templateData && Object.keys(ruleGroupInfo?.templateData)?.length ? {
541
+ ruleName: `规则${ruleClassData?.length + 1}`,
542
+ ..._.cloneDeep(ruleGroupInfo?.templateData)
543
+ } : initKongData;
544
+ const initNewData = isRuleInstance ? initTemplateData : initKongData
545
+ ruleClassData.push(initNewData);
546
+ this.setState(
547
+ {
548
+ ruleClassData,
549
+ },
550
+ () => {
551
+ callBack(ruleClassData);
552
+ },
553
+ );
554
+ };
555
+
556
+ // 树结构 转化成 平行树 (递归函数)
557
+ coverToParallel = (treeData, result) => {
558
+ treeData.forEach((el) => {
559
+ result.push(el);
560
+ if (el.children && el.children.length > 0) {
561
+ // 子级递归
562
+ this.coverToParallel(el.children, result);
563
+ }
564
+ });
565
+ return result;
566
+ };
567
+
568
+ renderRuleItem = (
569
+ itemDetail,
570
+ parentDetail,
571
+ floorIndex,
572
+ classDataIndex,
573
+ relateDatas,
574
+ ) => {
575
+ const { ruleTreeData } = this.state;
576
+ const {
577
+ callBack,
578
+ initialThresholdQuery = {},
579
+ disabled,
580
+ systemVariableList,
581
+ } = this.props;
582
+ let thresholdQuery = {
583
+ ...initialThresholdQuery,
584
+ ...relateDatas,
585
+ };
586
+ let finalIndex = floorIndex + 1;
587
+ let queryIdentify = '';
588
+ let queryIdentifyType = '';
589
+ if (
590
+ this.propertyCodeToRangeIdMap[
591
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
592
+ ]
593
+ ) {
594
+ queryIdentify =
595
+ this.propertyCodeToRangeIdMap[
596
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
597
+ ];
598
+ queryIdentifyType = Array.isArray(queryIdentify)
599
+ ? 'objectPropertyListIdentify'
600
+ : 'objectPropertyCodeIdentify';
601
+ } else if (
602
+ getSpecialPropertyCode(getPropertyCode(itemDetail.propertyPath))
603
+ ) {
604
+ queryIdentify = getSpecialPropertyCode(
605
+ getPropertyCode(itemDetail.propertyPath),
606
+ );
607
+ queryIdentifyType = 'specialPropertyIdentify';
608
+ } else if (
609
+ this.dictCodeToRangeIdMap[
610
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
611
+ ]
612
+ ) {
613
+ queryIdentify =
614
+ this.dictCodeToRangeIdMap[
615
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
616
+ ];
617
+ queryIdentifyType = 'dictCodeIdentify';
618
+ } else if (
619
+ this.dynamicDictCodeToRangeIdMap[
620
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
621
+ ]
622
+ ) {
623
+ queryIdentify =
624
+ this.dynamicDictCodeToRangeIdMap[
625
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
626
+ ];
627
+ queryIdentifyType = 'dynamicDictCodeIdentify';
628
+ }
629
+
630
+ const parallelTreeData = this.coverToParallel(ruleTreeData, []) || [];
631
+ const currentTreeItem =
632
+ itemDetail?.elementId &&
633
+ parallelTreeData.find((i) => i.key === itemDetail?.elementId);
634
+ const dataChoiceBusinessType = currentTreeItem?.dataChoiceBusinessType;
635
+ const dataInputBusinessType = currentTreeItem?.dataInputBusinessType;
636
+ return (
637
+ <div
638
+ className={'rule_line_content'}
639
+ style={{ display: 'flex', marginBottom: '0px', padding: '10px 0px' }}
640
+ >
641
+ <div
642
+ className={'logical_operate_content'}
643
+ style={{
644
+ display: itemDetail.operationType == 'logic' ? 'block' : 'none',
645
+ width: '60px',
646
+ zIndex: 20,
647
+ }}
648
+ >
649
+ <Popover
650
+ content={
651
+ <div>
652
+ <p
653
+ className={'choose_logical_type'}
654
+ onClick={() => {
655
+ this.handleLogicalTypeChange(itemDetail, 'or');
656
+ }}
657
+ >
658
+ OR
659
+ </p>
660
+ <p
661
+ className={'choose_logical_type'}
662
+ onClick={() => {
663
+ this.handleLogicalTypeChange(itemDetail, 'and');
664
+ }}
665
+ >
666
+ AND
667
+ </p>
668
+ </div>
669
+ }
670
+ trigger="focus"
671
+ >
672
+ <Button
673
+ disabled={disabled}
674
+ type="link"
675
+ className={'logical_item_btn'}
676
+ >
677
+ {itemDetail?.operationCode == 'or' ? 'OR' : 'AND'}
678
+ <DownOutlined style={{ marginLeft: '6px' }} />
679
+ </Button>
680
+ </Popover>
681
+ <span className={'top_line'}></span>
682
+ <span className={'bottom_line'}></span>
683
+ </div>
684
+
685
+ <div style={{ flexGrow: 1 }}>
686
+ {itemDetail.operationType == 'logic' ? (
687
+ itemDetail?.subExpression?.map((item1) => {
688
+ return this.renderRuleItem(
689
+ item1,
690
+ itemDetail,
691
+ finalIndex,
692
+ classDataIndex,
693
+ relateDatas,
694
+ );
695
+ })
696
+ ) : (
697
+ <div style={{ display: 'flex', alignItems: 'center' }}>
698
+ <TreeSelect
699
+ value={itemDetail.propertyPath}
700
+ disabled={disabled}
701
+ onChange={(value, name, nodeInfo) => {
702
+ if (!nodeInfo.triggerNode.props.isLeaf) return; //只有最末端叶子节点可选中
703
+ const { ruleClassData } = this.state;
704
+ itemDetail.propertyPath = value;
705
+ itemDetail.params = [];
706
+ itemDetail.paramNames = [];
707
+ itemDetail.operationCode = '';
708
+ itemDetail.elementId = nodeInfo.triggerNode.props.id;
709
+ itemDetail.elementName = nodeInfo.triggerNode.props.title;
710
+ itemDetail.dataTypeCode =
711
+ nodeInfo.triggerNode.props.dataTypeCode;
712
+ itemDetail.metaObjectCode =
713
+ nodeInfo.triggerNode.props.metaObjectCode;
714
+ itemDetail.isInsertParam = false;
715
+ this.setState(
716
+ {
717
+ ruleClassData,
718
+ },
719
+ () => {
720
+ callBack(ruleClassData);
721
+ },
722
+ );
723
+ }}
724
+ style={{ width: '200px' }}
725
+ treeData={ruleTreeData}
726
+ />
727
+ <Select
728
+ value={itemDetail?.operationCode || ''}
729
+ disabled={disabled}
730
+ style={{ width: '150px', marginLeft: '10px' }}
731
+ onChange={(value) => {
732
+ const { ruleClassData } = this.state;
733
+ itemDetail.operationCode = value;
734
+ this.setState(
735
+ {
736
+ ruleClassData,
737
+ },
738
+ () => {
739
+ callBack(ruleClassData);
740
+ },
741
+ );
742
+ }}
743
+ >
744
+ {this.getDataTypeOperateList(itemDetail.dataTypeCode).map(
745
+ (item) => (
746
+ <Select.Option value={item.code} key={item.code}>
747
+ {item.name}
748
+ </Select.Option>
749
+ ),
750
+ )}
751
+ </Select>
752
+ {!itemDetail?.isInsertParam ? (
753
+ <RuleField
754
+ selectOperation={itemDetail?.operationCode || ''}
755
+ disabled={disabled}
756
+ initialThresholdQuery={thresholdQuery}
757
+ dataTypeCode={itemDetail?.dataTypeCode || ''}
758
+ dataChoiceBusinessType={dataChoiceBusinessType || ''}
759
+ dataInputBusinessType={dataInputBusinessType || ''}
760
+ itemDetail={itemDetail}
761
+ queryIdentifyType={queryIdentifyType}
762
+ queryIdentify={queryIdentify}
763
+ propertyCode={getPropertyCode(itemDetail.propertyPath)}
764
+ // propertyCode={`${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`}
765
+ relateDatas={relateDatas}
766
+ values={itemDetail.params || []}
767
+ valueNames={itemDetail.paramNames || []}
768
+ callback={(newValues, newValueNames) => {
769
+ this.handleValuesChange(
770
+ itemDetail,
771
+ newValues,
772
+ newValueNames,
773
+ );
774
+ }}
775
+ />
776
+ ) : null}
777
+ <Select
778
+ disabled={disabled}
779
+ value={
780
+ itemDetail?.params?.[0]?.replace('{', '').replace('}', '') ||
781
+ ''
782
+ }
783
+ style={{
784
+ width: '150px',
785
+ marginLeft: '10px',
786
+ display: itemDetail?.isInsertParam ? '' : 'none',
787
+ }}
788
+ onChange={(value) => {
789
+ const { ruleClassData } = this.state;
790
+ console.log(itemDetail);
791
+ itemDetail.params = [(value && `{${value}}`) || ''];
792
+ const name = systemVariableList.find(
793
+ (i) => i.code == value,
794
+ )?.name;
795
+ itemDetail.paramNames = [name || ''];
796
+ this.setState(
797
+ {
798
+ ruleClassData,
799
+ },
800
+ () => {
801
+ callBack(ruleClassData);
802
+ },
803
+ );
804
+ }}
805
+ >
806
+ {systemVariableList
807
+ ? systemVariableList.map((item) => (
808
+ <Select.Option value={item.code} key={item.code}>
809
+ {item.name}
810
+ </Select.Option>
811
+ ))
812
+ : null}
813
+ </Select>
814
+ <PlusCircleOutlined
815
+ className={'icon_btn_style'}
816
+ onClick={() => {
817
+ this.addChildRules(itemDetail);
818
+ }}
819
+ style={{
820
+ color: '#008fe0',
821
+ marginLeft: '15px',
822
+ display: floorIndex > 4 || disabled ? 'none' : 'inline-block',
823
+ }}
824
+ />
825
+ <MinusCircleOutlined
826
+ className={'icon_btn_style'}
827
+ onClick={() => {
828
+ this.handleDeleteRule(
829
+ itemDetail,
830
+ parentDetail,
831
+ classDataIndex,
832
+ );
833
+ }}
834
+ style={{
835
+ color: 'gray',
836
+ display: disabled ? 'none' : 'inline-block',
837
+ }}
838
+ />
839
+ <Button
840
+ type="link"
841
+ disabled={
842
+ disabled || itemDetail.operationCode === '' || !itemDetail.operationCode
843
+ ? true
844
+ : false
845
+ }
846
+ onClick={() => {
847
+ const { ruleClassData } = this.state;
848
+ if (systemVariableList?.length) {
849
+ itemDetail.isInsertParam = !itemDetail.isInsertParam;
850
+ delete itemDetail.params;
851
+ delete itemDetail.paramNames;
852
+ this.setState(
853
+ {
854
+ ruleClassData,
855
+ },
856
+ () => {
857
+ callBack(ruleClassData);
858
+ },
859
+ );
860
+ } else {
861
+ message.warn('未配置规则变量');
862
+ }
863
+ }}
864
+ >
865
+ {itemDetail?.isInsertParam ? '取消插入参数' : '插入参数'}
866
+ </Button>
867
+ </div>
868
+ )}
869
+ <div
870
+ style={{
871
+ display:
872
+ itemDetail.operationType == 'logic' && !disabled
873
+ ? 'block'
874
+ : 'none',
875
+ }}
876
+ >
877
+ <span
878
+ style={{ color: '#008fe0', cursor: 'pointer' }}
879
+ type="link"
880
+ onClick={() => {
881
+ this.addPeerRule(itemDetail);
882
+ }}
883
+ >
884
+ <PlusCircleOutlined
885
+ style={{
886
+ color: '#008fe0',
887
+ fontSize: '14px',
888
+ marginRight: '5px',
889
+ }}
890
+ />
891
+ 添加条件
892
+ </span>
893
+ </div>
894
+ </div>
895
+ </div>
896
+ );
897
+ };
898
+
899
+ handleEditExtraInfoResponse = (code, val, parentDetail) => {
900
+ const { ruleClassData } = this.state;
901
+ const { callBack } = this.props;
902
+ parentDetail.extraInfo.response[code] = val;
903
+ this.setState(
904
+ {
905
+ ruleClassData,
906
+ },
907
+ () => {
908
+ callBack(ruleClassData);
909
+ },
910
+ );
911
+ };
912
+ // 场景需要返回值2022.11.15
913
+ renderResItem = (
914
+ itemDetail,
915
+ parentDetail,
916
+ ruleReturnConfig,
917
+ disabled,
918
+ boxStyle,
919
+ ) => {
920
+ const isShowResponse = itemDetail.response['enable'];
921
+ const isRightText = ruleReturnConfig?.rightText?.length;
922
+
923
+ const showValue = (code, type, functionItem, configItem) => {
924
+ let defaultValue = configItem.defaultValue;
925
+ const pCode = itemDetail.response['value'];
926
+ if (type === 'input') {
927
+ return pCode === undefined ? pCode : pCode || defaultValue;
928
+ }
929
+ return pCode || defaultValue;
930
+ };
931
+ const handleEdit = (code, val) => {
932
+ let value = val;
933
+ if (isObj(code)) {
934
+ Object.keys(code).forEach((ite) => {
935
+ this.handleEditExtraInfoResponse(ite, code[ite], parentDetail);
936
+ });
937
+ return;
938
+ }
939
+ if (Array.isArray(val)) {
940
+ value = val.map((m) => m.value || m).join(',');
941
+ }
942
+ if (isObj(val)) {
943
+ value = val.value || val.PCDCode?.join('/');
944
+ }
945
+ this.handleEditExtraInfoResponse('value', value, parentDetail);
946
+ };
947
+
948
+ return (
949
+ (isShowResponse && (
950
+ <div style={{ display: 'flex' }}>
951
+ {this.renderFormCompItem(
952
+ ruleReturnConfig,
953
+ showValue,
954
+ handleEdit,
955
+ {},
956
+ boxStyle,
957
+ disabled
958
+ )}
959
+ <MinusCircleOutlined
960
+ className={'icon_btn_style'}
961
+ onClick={() => {
962
+ this.handleEditExtraInfoResponse('enable', false, parentDetail);
963
+ }}
964
+ style={{
965
+ color: 'gray',
966
+ marginLeft: isRightText ? '100px' : '15px',
967
+ marginTop: '15px',
968
+ display: disabled ? 'none' : 'inline-block',
969
+ }}
970
+ />
971
+ </div>
972
+ )) ||
973
+ null
974
+ );
975
+ };
976
+
977
+ renderCompItem = (ites, showValue, handleEdit,disabled) => {
978
+ const { regularDataList } = this.props;
979
+ let fieldListGroup = regularDataList.map((item) => {
980
+ const Item = {
981
+ id: item.id,
982
+ code: item.code,
983
+ name: item.name,
984
+ value: item.code,
985
+ };
986
+ if (item.propertyList) {
987
+ Item.propertyList = item.propertyList.map((field) => ({
988
+ id: field.id,
989
+ code: field.code,
990
+ name: field.name,
991
+ value: `${item.code}.${field.code}`,
992
+ valueText: `${item.name}.${field.name}`,
993
+ }));
994
+ }
995
+ return Item;
996
+ });
997
+ if (!ites) return;
998
+ const styleCommon = {
999
+ width: '200px',
1000
+ ...(ites?.rightText ? { marginLeft: 10 } : {}),
1001
+ };
1002
+ const style2 = {
1003
+ width: '100px',
1004
+ };
1005
+ return (
1006
+ <>
1007
+ {/* 输入/字符串 */}
1008
+ {(ites?.inputType === 10 && ites?.valueType === 21 && (
1009
+ <Input
1010
+ disabled={disabled}
1011
+ allowClear={true}
1012
+ onClear={() => {
1013
+ handleEdit(ites.code, undefined);
1014
+ }}
1015
+ defaultValue={showValue(ites.code, 'input')}
1016
+ style={styleCommon}
1017
+ onBlur={(e) => {
1018
+ handleEdit(
1019
+ ites.code,
1020
+ String(e.target.value).trim() == ''
1021
+ ? undefined
1022
+ : e.target.value,
1023
+ );
1024
+ }}
1025
+ />
1026
+ )) ||
1027
+ null}
1028
+ {/* 输入 / 长整数23/小数22 */}
1029
+ {(ites?.inputType === 10 &&
1030
+ (ites?.valueType === 23 || ites?.valueType === 22) && (
1031
+ <InputNumber
1032
+ disabled={disabled}
1033
+ max={Number.MAX_SAFE_INTEGER}
1034
+ min={ites?.valueType === 23 ? 0 : Number.MIN_SAFE_INTEGER}
1035
+ precision={ites?.valueType === 23 ? 0 : 2}
1036
+ defaultValue={ites.defaultValue}
1037
+ style={style2}
1038
+ value={showValue(ites.code)}
1039
+ onChange={(value) => {
1040
+ handleEdit(ites.code, value);
1041
+ }}
1042
+ />
1043
+ )) ||
1044
+ null}
1045
+ {/* 输入/日期 */}
1046
+ {(ites?.inputType === 10 && ites?.valueType === 41 && (
1047
+ <DatePicker
1048
+ disabled={disabled}
1049
+ defaultValue={ites.defaultValue}
1050
+ style={style2}
1051
+ value={showValue(ites.code)}
1052
+ onChange={(value) => {
1053
+ handleEdit(ites.code, value);
1054
+ }}
1055
+ />
1056
+ )) ||
1057
+ null}
1058
+ {/* 输入/时间 */}
1059
+ {(ites?.inputType === 10 && ites?.valueType === 40 && (
1060
+ <RangePicker
1061
+ showTime
1062
+ disabled={disabled}
1063
+ defaultValue={ites.defaultValue}
1064
+ style={style2}
1065
+ value={showValue(ites.code)}
1066
+ onChange={(value) => {
1067
+ handleEdit(ites.code, value);
1068
+ }}
1069
+ />
1070
+ )) ||
1071
+ null}
1072
+ {/* 输入/布尔值 */}
1073
+ {(ites?.inputType === 10 && ites?.valueType === 24 && (
1074
+ <Switch
1075
+ disabled={disabled}
1076
+ defaultChecked={!!ites.defaultValue}
1077
+ style={style2}
1078
+ checked={showValue(ites.code)}
1079
+ onChange={(value) => {
1080
+ handleEdit(ites.code, value);
1081
+ }}
1082
+ />
1083
+ )) ||
1084
+ null}
1085
+ {/* 单选/多选 自定义 */}
1086
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1087
+ ites?.choiceType === 10 && (
1088
+ <Select
1089
+ disabled={disabled}
1090
+ allowClear
1091
+ showArrow
1092
+ {...(ites?.inputType === 30
1093
+ ? {
1094
+ mode: 'multiple',
1095
+ }
1096
+ : {})}
1097
+ defaultValue={ites.defaultValue}
1098
+ style={styleCommon}
1099
+ value={showValue(ites.code)}
1100
+ onChange={(value) => {
1101
+ handleEdit(ites.code, value);
1102
+ }}
1103
+ >
1104
+ {Object.keys(ites.enumeration).map((it) => (
1105
+ <Select.Option key={it} value={it}>
1106
+ {ites.enumeration[it]}
1107
+ </Select.Option>
1108
+ ))}
1109
+ </Select>
1110
+ )) ||
1111
+ null}
1112
+ {/* 单选/多选 数据字典 */}
1113
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1114
+ ites?.choiceType === 20 && (
1115
+ <Select
1116
+ disabled={disabled}
1117
+ {...(ites?.inputType === 30
1118
+ ? {
1119
+ mode: 'multiple',
1120
+ }
1121
+ : {})}
1122
+ defaultValue={ites.defaultValue}
1123
+ style={styleCommon}
1124
+ value={showValue(ites.code)}
1125
+ onChange={(value) => {
1126
+ handleEdit(ites.code, value);
1127
+ }}
1128
+ >
1129
+ {getDictionarySource(ites?.dictionaryCode).map((it) => (
1130
+ <Select.Option key={it.value} value={it.value}>
1131
+ {it.text}
1132
+ </Select.Option>
1133
+ ))}
1134
+ </Select>
1135
+ )) ||
1136
+ null}
1137
+ {/* 单选/多选 仓库选择器(物理仓) */}
1138
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1139
+ ites?.choiceType === 110 && (
1140
+ <BusinessSearchSelect
1141
+ selectBusinessType="physicalWarehouse"
1142
+ selectProps={{
1143
+ style: styleCommon,
1144
+ placeholder: '请选择物理仓',
1145
+ ...(ites?.inputType === 30
1146
+ ? {
1147
+ mode: 'multiple',
1148
+ maxTagCount: 1,
1149
+ }
1150
+ : {}),
1151
+ }}
1152
+ disabled={disabled}
1153
+ labelInValue={true}
1154
+ value={showValue(ites.code)}
1155
+ requestConfig={{
1156
+ mappingValueField: 'physicalWarehouseCode',
1157
+ filterInit: 'qp-physicalWarehouseCode-in',
1158
+ }}
1159
+ onChange={(value) => {
1160
+ handleEdit(ites.code, value);
1161
+ }}
1162
+ getPopupContainer={() => document.body}
1163
+ />
1164
+ )) ||
1165
+ null}
1166
+ {/* 单选/多选 仓库选择器(逻辑仓) */}
1167
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1168
+ ites?.choiceType === 120 && (
1169
+ <BusinessSearchSelect
1170
+ selectBusinessType="realWarehouse"
1171
+ selectProps={{
1172
+ style: styleCommon,
1173
+ placeholder: '请选择逻辑仓',
1174
+ ...(ites?.inputType === 30
1175
+ ? {
1176
+ mode: 'multiple',
1177
+ maxTagCount: 1,
1178
+ }
1179
+ : {}),
1180
+ }}
1181
+ disabled={disabled}
1182
+ labelInValue={true}
1183
+ value={showValue(ites.code)}
1184
+ requestConfig={{
1185
+ mappingValueField: 'realWarehouseCode',
1186
+ filterInit: 'qp-realWarehouseCode-in',
1187
+ }}
1188
+ onChange={(value) => {
1189
+ handleEdit(ites.code, value);
1190
+ }}
1191
+ getPopupContainer={() => document.body}
1192
+ />
1193
+ )) ||
1194
+ null}
1195
+ {/* 单选/多选 仓库选择器(虚拟仓) */}
1196
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1197
+ ites?.choiceType === 130 && (
1198
+ <BusinessSearchSelect
1199
+ selectBusinessType="virtualWarehouse"
1200
+ selectProps={{
1201
+ style: styleCommon,
1202
+ placeholder: '请选择虚拟仓',
1203
+ ...(ites?.inputType === 30
1204
+ ? {
1205
+ mode: 'multiple',
1206
+ maxTagCount: 1,
1207
+ }
1208
+ : {}),
1209
+ }}
1210
+ disabled={disabled}
1211
+ labelInValue={true}
1212
+ value={showValue(ites.code)}
1213
+ requestConfig={{
1214
+ mappingValueField: 'virtualWarehouseCode',
1215
+ filterInit: 'qp-virtualWarehouseCode-in',
1216
+ }}
1217
+ onChange={(value) => {
1218
+ handleEdit(ites.code, value);
1219
+ }}
1220
+ getPopupContainer={() => document.body}
1221
+ />
1222
+ )) ||
1223
+ null}
1224
+ {/* 单选/多选 仓库选择器(渠道仓) */}
1225
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1226
+ ites?.choiceType === 140 && (
1227
+ <BusinessSearchSelect
1228
+ selectBusinessType="channelWarehouse"
1229
+ selectProps={{
1230
+ style: styleCommon,
1231
+ placeholder: '请选择渠道仓',
1232
+ ...(ites?.inputType === 30
1233
+ ? {
1234
+ mode: 'multiple',
1235
+ maxTagCount: 1,
1236
+ }
1237
+ : {}),
1238
+ }}
1239
+ disabled={disabled}
1240
+ labelInValue={true}
1241
+ value={showValue(ites.code)}
1242
+ requestConfig={{
1243
+ mappingValueField: 'channelWarehouseCode',
1244
+ filterInit: 'qp-channelWarehouseCode-in',
1245
+ }}
1246
+ onChange={(value) => {
1247
+ handleEdit(ites.code, value);
1248
+ }}
1249
+ getPopupContainer={() => document.body}
1250
+ />
1251
+ )) ||
1252
+ null}
1253
+ {/* 单选/多选 商品SPU选择器 */}
1254
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1255
+ ites?.choiceType === 150 && (
1256
+ <BusinessSearchSelect
1257
+ selectBusinessType="spuCommodity"
1258
+ selectProps={{
1259
+ style: styleCommon,
1260
+ placeholder: '请选择SPU',
1261
+ ...(ites?.inputType === 30
1262
+ ? {
1263
+ mode: 'multiple',
1264
+ maxTagCount: 1,
1265
+ }
1266
+ : {}),
1267
+ }}
1268
+ disabled={disabled}
1269
+ labelInValue={true}
1270
+ value={showValue(ites.code)}
1271
+ requestConfig={{
1272
+ filterInit: 'qp-itemCode-in',
1273
+ }}
1274
+ onChange={(value) => {
1275
+ handleEdit(ites.code, value);
1276
+ }}
1277
+ getPopupContainer={() => document.body}
1278
+ />
1279
+ )) ||
1280
+ null}
1281
+ {/* 单选/多选 商品SKU选择器 */}
1282
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1283
+ ites?.choiceType === 160 && (
1284
+ <BusinessSearchSelect
1285
+ selectBusinessType="skuCommodity"
1286
+ selectProps={{
1287
+ style: styleCommon,
1288
+ placeholder: '请选择商品',
1289
+ ...(ites?.inputType === 30
1290
+ ? {
1291
+ mode: 'multiple',
1292
+ maxTagCount: 1,
1293
+ }
1294
+ : {}),
1295
+ }}
1296
+ disabled={disabled}
1297
+ labelInValue={true}
1298
+ value={showValue(ites.code)}
1299
+ requestConfig={{
1300
+ filterInit: 'qp-skuCode-in',
1301
+ }}
1302
+ onChange={(value) => {
1303
+ handleEdit(ites.code, value);
1304
+ }}
1305
+ getPopupContainer={() => document.body}
1306
+ />
1307
+ )) ||
1308
+ null}
1309
+ {/* 单选/多选 省市区 */}
1310
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1311
+ ites?.choiceType === 190 && (
1312
+ <BsCascader
1313
+ disabled={disabled}
1314
+ isAll={true}
1315
+ needNameAndCode={true}
1316
+ notChangeOnSelect={true}
1317
+ initRequestSource={async () => {
1318
+ return await request({
1319
+ url: '/basic/bscArea/getBscAreaList?qp-level-eq=1&qp-pid-eq=100000',
1320
+ method: 'get',
1321
+ converter: ({ data }) => {
1322
+ const handleData =
1323
+ data && data[0]
1324
+ ? data?.map((item) => {
1325
+ return {
1326
+ text: item.name,
1327
+ value: item.id,
1328
+ level: item.level,
1329
+ id: item.id,
1330
+ };
1331
+ })
1332
+ : [];
1333
+ return handleData;
1334
+ },
1335
+ });
1336
+ }}
1337
+ value={showValue(ites.code)}
1338
+ onChange={(value) => {
1339
+ handleEdit(ites.code, value);
1340
+ }}
1341
+ getPopupContainer={() => document.body}
1342
+ />
1343
+ )) ||
1344
+ null}
1345
+ {/* 单选/多选 行政组织选择器 */}
1346
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1347
+ ites?.choiceType === 210 && (
1348
+ <BusinessTreeSearchSelect
1349
+ disabled={disabled}
1350
+ treeCheckable={ites?.inputType === 30}
1351
+ businessType="department"
1352
+ labelInValue={true}
1353
+ value={showValue(ites.code)}
1354
+ style={styleCommon}
1355
+ onChange={(value) => {
1356
+ handleEdit(ites.code, value);
1357
+ }}
1358
+ getPopupContainer={() => document.body}
1359
+ />
1360
+ )) ||
1361
+ null}
1362
+ {/* 单选/多选 采购组织选择器 */}
1363
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1364
+ ites?.choiceType === 220 && (
1365
+ <BusinessTreeSearchSelect
1366
+ disabled={disabled}
1367
+ treeCheckable={ites?.inputType === 30}
1368
+ businessType="purchase-organization"
1369
+ labelInValue={true}
1370
+ value={showValue(ites.code)}
1371
+ style={styleCommon}
1372
+ onChange={(value) => {
1373
+ handleEdit(ites.code, value);
1374
+ }}
1375
+ getPopupContainer={() => document.body}
1376
+ />
1377
+ )) ||
1378
+ null}
1379
+ {/* 单选/多选 销售组织选择器 */}
1380
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1381
+ ites?.choiceType === 230 && (
1382
+ <BusinessTreeSearchSelect
1383
+ disabled={disabled}
1384
+ treeCheckable={ites?.inputType === 30}
1385
+ businessType="sales-organization"
1386
+ labelInValue={true}
1387
+ value={showValue(ites.code)}
1388
+ style={styleCommon}
1389
+ onChange={(value) => {
1390
+ handleEdit(ites.code, value);
1391
+ }}
1392
+ getPopupContainer={() => document.body}
1393
+ />
1394
+ )) ||
1395
+ null}
1396
+ {/* 单选/多选 供应商选择器 */}
1397
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1398
+ ites?.choiceType === 240 && (
1399
+ <BusinessSearchSelect
1400
+ selectBusinessType="supplier2"
1401
+ selectProps={{
1402
+ style: styleCommon,
1403
+ placeholder: '请选择供应商',
1404
+ ...(ites?.inputType === 30
1405
+ ? {
1406
+ mode: 'multiple',
1407
+ maxTagCount: 1,
1408
+ }
1409
+ : {}),
1410
+ }}
1411
+ disabled={disabled}
1412
+ labelInValue={true}
1413
+ value={showValue(ites.code)}
1414
+ requestConfig={{
1415
+ filterInit: 'qp-code-in',
1416
+ }}
1417
+ onChange={(value) => {
1418
+ handleEdit(ites.code, value);
1419
+ }}
1420
+ getPopupContainer={() => document.body}
1421
+ />
1422
+ )) ||
1423
+ null}
1424
+ {/* 单选/多选 客户选择器 */}
1425
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1426
+ ites?.choiceType === 250 && (
1427
+ <BusinessSearchSelect
1428
+ selectBusinessType="customer2"
1429
+ selectProps={{
1430
+ style: styleCommon,
1431
+ placeholder: '请选择客户',
1432
+ ...(ites?.inputType === 30
1433
+ ? {
1434
+ mode: 'multiple',
1435
+ maxTagCount: 1,
1436
+ }
1437
+ : {}),
1438
+ }}
1439
+ disabled={disabled}
1440
+ labelInValue={true}
1441
+ value={showValue(ites.code)}
1442
+ requestConfig={{
1443
+ filterInit: 'qp-code-in',
1444
+ }}
1445
+ onChange={(value) => {
1446
+ handleEdit(ites.code, value);
1447
+ }}
1448
+ getPopupContainer={() => document.body}
1449
+ />
1450
+ )) ||
1451
+ null}
1452
+ {/* 单选/多选 店铺选择器 */}
1453
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1454
+ ites?.choiceType === 260 && (
1455
+ <BusinessSearchSelect
1456
+ selectBusinessType="shopFile2"
1457
+ selectProps={{
1458
+ style: styleCommon,
1459
+ placeholder: '请选择店铺',
1460
+ ...(ites?.inputType === 30
1461
+ ? {
1462
+ mode: 'multiple',
1463
+ maxTagCount: 1,
1464
+ }
1465
+ : {}),
1466
+ }}
1467
+ disabled={disabled}
1468
+ labelInValue={true}
1469
+ value={showValue(ites.code)}
1470
+ requestConfig={{
1471
+ filterInit: 'qp-code-in',
1472
+ }}
1473
+ onChange={(value) => {
1474
+ handleEdit(ites.code, value);
1475
+ }}
1476
+ getPopupContainer={() => document.body}
1477
+ />
1478
+ )) ||
1479
+ null}
1480
+ {/* 单选/多选 员工选择器 */}
1481
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1482
+ ites?.choiceType === 270 && (
1483
+ <BusinessSearchSelect
1484
+ selectBusinessType="employee2"
1485
+ selectProps={{
1486
+ style: styleCommon,
1487
+ placeholder: '请选择员工',
1488
+ ...(ites?.inputType === 30
1489
+ ? {
1490
+ mode: 'multiple',
1491
+ maxTagCount: 1,
1492
+ }
1493
+ : {}),
1494
+ }}
1495
+ disabled={disabled}
1496
+ labelInValue={true}
1497
+ value={showValue(ites.code)}
1498
+ requestConfig={{
1499
+ filterInit: 'qp-id-in',
1500
+ }}
1501
+ onChange={(value) => {
1502
+ handleEdit(ites.code, value);
1503
+ }}
1504
+ getPopupContainer={() => document.body}
1505
+ />
1506
+ )) ||
1507
+ null}
1508
+ {/* 单选/多选 库存组织选择器 */}
1509
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1510
+ ites?.choiceType === 280 && (
1511
+ <BusinessTreeSearchSelect
1512
+ disabled={disabled}
1513
+ treeCheckable={ites?.inputType === 30}
1514
+ businessType="stock-organization"
1515
+ labelInValue={true}
1516
+ value={showValue(ites.code)}
1517
+ style={styleCommon}
1518
+ onChange={(value) => {
1519
+ handleEdit(ites.code, value);
1520
+ }}
1521
+ getPopupContainer={() => document.body}
1522
+ />
1523
+ )) ||
1524
+ null}
1525
+ {/* 单选/多选 配送方式选择器 */}
1526
+ {((ites?.inputType === 20 || ites?.inputType === 30) &&
1527
+ ites?.choiceType === 310 && (
1528
+ <BusinessSearchSelect
1529
+ selectBusinessType="deliveryMode"
1530
+ selectProps={{
1531
+ style: styleCommon,
1532
+ placeholder: '请选择配送方式',
1533
+ ...(ites?.inputType === 30
1534
+ ? {
1535
+ mode: 'multiple',
1536
+ maxTagCount: 1,
1537
+ }
1538
+ : {}),
1539
+ }}
1540
+ disabled={disabled}
1541
+ labelInValue={true}
1542
+ value={showValue(ites.code)}
1543
+ requestConfig={{
1544
+ filterInit: 'qp-code-in',
1545
+ }}
1546
+ onChange={(value) => {
1547
+ handleEdit(ites.code, value);
1548
+ }}
1549
+ getPopupContainer={() => document.body}
1550
+ />
1551
+ )) ||
1552
+ null}
1553
+ {/* 表达式 */}
1554
+ {ites?.inputType === 40 && (
1555
+ <div style={{ display: 'flex' }}>
1556
+ <Formula
1557
+ disabled={disabled}
1558
+ key={showValue(ites.code)}
1559
+ setValue={(val, formulaName) => {
1560
+ console.log(val, 'val');
1561
+ const value = val.map((item) => {
1562
+ return item.value.replace(
1563
+ /[a-zA-Z_]+\.\w+/g,
1564
+ (i) => '{' + i + '}',
1565
+ );
1566
+ });
1567
+ handleEdit(ites.code, value.join(''));
1568
+ handleEdit({
1569
+ inputType: 40,
1570
+ formulaName,
1571
+ });
1572
+ }}
1573
+ record={{ expression: showValue(ites.code) }}
1574
+ sourceData={fieldListGroup}
1575
+ />
1576
+ </div>
1577
+ )}
1578
+ </>
1579
+ );
1580
+ };
1581
+
1582
+ renderFormCompItem = (
1583
+ config,
1584
+ showValue,
1585
+ handleEdit,
1586
+ parentItem,
1587
+ boxStyle,
1588
+ disabled
1589
+ ) => {
1590
+ if (!config) return;
1591
+ return (
1592
+ <div style={boxStyle}>
1593
+ {(config?.leftText && (
1594
+ <div style={{ flex: 'none', marginRight: 10 }}>
1595
+ {config?.required && <span className="requiredMark" />}
1596
+ {config.leftText}
1597
+ </div>
1598
+ )) ||
1599
+ null}
1600
+ {(!config?.leftText && config?.rightText && config?.required && (
1601
+ <div style={{ flex: 'none', marginRight: 10 }}>
1602
+ <span className="requiredMark" />
1603
+ </div>
1604
+ )) ||
1605
+ null}
1606
+ {this.renderCompItem(
1607
+ config,
1608
+ (a, b, c = parentItem, d = config) => showValue(a, b, c, d),
1609
+ (a, b, c = parentItem, d = config) => handleEdit(a, b, c, d),
1610
+ disabled
1611
+ )}
1612
+ {(config?.rightText && (
1613
+ <div style={{ flex: 'none', marginLeft: 10 }}>{config.rightText}</div>
1614
+ )) ||
1615
+ null}
1616
+ </div>
1617
+ );
1618
+ };
1619
+
1620
+ renderActionList = (
1621
+ itemDetail,
1622
+ parentDetail,
1623
+ handleRuleTypeData,
1624
+ sRuleActionData,
1625
+ classDataIndex,
1626
+ disabled,
1627
+ boxStyle,
1628
+ ) => {
1629
+ const showValue = (code, type, functionItem, configItem) => {
1630
+ const functionIndex = handleRuleTypeData.findIndex(
1631
+ (m) => m.code === functionItem.code,
1632
+ );
1633
+ const pCode =
1634
+ itemDetail.execute[functionIndex] &&
1635
+ itemDetail.execute[functionIndex].properties[code];
1636
+ let defaultValue = configItem.defaultValue;
1637
+ if (type === 'input') {
1638
+ return pCode === undefined ? pCode : pCode || defaultValue;
1639
+ }
1640
+ return pCode || defaultValue;
1641
+ };
1642
+ const handleEdit = (code, val, functionItem) => {
1643
+ const functionIndex = handleRuleTypeData.findIndex(
1644
+ (m) => m.code === functionItem.code,
1645
+ );
1646
+ const { ruleClassData } = this.state;
1647
+ const { callBack } = this.props;
1648
+ parentDetail.extraInfo.execute[functionIndex]['properties'][code] = val;
1649
+ parentDetail.extraInfo.execute[functionIndex]['code'] = functionItem.code;
1650
+
1651
+ this.setState(
1652
+ {
1653
+ ruleClassData,
1654
+ },
1655
+ () => {
1656
+ callBack(ruleClassData);
1657
+ },
1658
+ );
1659
+ };
1660
+
1661
+ return (
1662
+ <>
1663
+ {sRuleActionData.map((i, index) => (
1664
+ <div>
1665
+ <div style={{ display: 'flex' }}>
1666
+ {(i.valueList?.length &&
1667
+ i.valueList.map((s) => {
1668
+ return this.renderFormCompItem(
1669
+ s,
1670
+ showValue,
1671
+ handleEdit,
1672
+ i,
1673
+ boxStyle,
1674
+ disabled
1675
+ );
1676
+ })) || (
1677
+ <div style={boxStyle} key={i.functionName}>
1678
+ <div>{i.functionName}</div>
1679
+ </div>
1680
+ )}
1681
+ <MinusCircleOutlined
1682
+ className={'icon_btn_style'}
1683
+ onClick={() => {
1684
+ this.handleDeleteRuleAction(classDataIndex, i.code);
1685
+ }}
1686
+ style={{
1687
+ color: 'gray',
1688
+ marginLeft: '15px',
1689
+ marginTop: '15px',
1690
+ display: disabled ? 'none' : 'inline-block',
1691
+ }}
1692
+ />
1693
+ </div>
1694
+ </div>
1695
+ ))}
1696
+ </>
1697
+ );
1698
+ };
1699
+
1700
+ renderRuleTypeItem = (
1701
+ itemDetail,
1702
+ parentDetail,
1703
+ floorIndex,
1704
+ classDataIndex,
1705
+ ruleTypeData,
1706
+ ruleReturnConfig,
1707
+ isRuleInstance
1708
+ ) => {
1709
+ const { modalParams } = this.state;
1710
+ const { disabled } = this.props;
1711
+ const isHaveRuleTypeData = ruleTypeData?.length;
1712
+ const isHaveRuleReturnConfig = Object.keys(ruleReturnConfig)?.length;
1713
+ const handleRuleTypeData = isHaveRuleTypeData
1714
+ ? ruleTypeData.sort((a, b) => a.priority - b.priority)
1715
+ : [];
1716
+
1717
+ const selectRuleActionCode = isHaveRuleTypeData
1718
+ ? itemDetail.execute.filter((i) => i.isSelected).map((s) => s.code)
1719
+ : [];
1720
+ const selectRuleActionData = isHaveRuleTypeData
1721
+ ? handleRuleTypeData.filter((r) =>
1722
+ selectRuleActionCode.some((s) => s === r.code),
1723
+ )
1724
+ : [];
1725
+
1726
+ const RuleActionItemStyle = {
1727
+ display: 'flex',
1728
+ height: '30px',
1729
+ lineHeight: '30px',
1730
+ margin: '10px 0px',
1731
+ };
1732
+ return (
1733
+ <div>
1734
+ <div style={{ textAlign: 'right', display: isRuleInstance ? 'none' : 'flex' }}>
1735
+ <Button
1736
+ type="link"
1737
+ onClick={() => {
1738
+ if (isHaveRuleTypeData) {
1739
+ this.setState({
1740
+ modalParams: {
1741
+ ...modalParams,
1742
+ ruleActionData: handleRuleTypeData,
1743
+ classDataIndex,
1744
+ visible: true,
1745
+ },
1746
+ });
1747
+ } else {
1748
+ message.warn('未配置执行动作');
1749
+ }
1750
+ }}
1751
+ >
1752
+ 新增动作
1753
+ </Button>
1754
+ <Button
1755
+ type="link"
1756
+ onClick={() => {
1757
+ if (isHaveRuleReturnConfig) {
1758
+ this.handleEditExtraInfoResponse('enable', true, parentDetail);
1759
+ } else {
1760
+ message.warn('未配置返回');
1761
+ }
1762
+ }}
1763
+ >
1764
+ 新增返回值
1765
+ </Button>
1766
+ </div>
1767
+ {(isHaveRuleReturnConfig &&
1768
+ this.renderResItem(
1769
+ itemDetail,
1770
+ parentDetail,
1771
+ ruleReturnConfig,
1772
+ disabled,
1773
+ RuleActionItemStyle,
1774
+ )) ||
1775
+ null}
1776
+ {(isHaveRuleTypeData &&
1777
+ this.renderActionList(
1778
+ itemDetail,
1779
+ parentDetail,
1780
+ handleRuleTypeData,
1781
+ selectRuleActionData,
1782
+ classDataIndex,
1783
+ disabled,
1784
+ RuleActionItemStyle,
1785
+ )) ||
1786
+ null}
1787
+ </div>
1788
+ );
1789
+ };
1790
+
1791
+ //添加同一层级条件
1792
+ addPeerRule = (itemDetail) => {
1793
+ const { ruleClassData } = this.state;
1794
+ const { callBack, disabled } = this.props;
1795
+ if (disabled) return;
1796
+ itemDetail.subExpression.push({
1797
+ // "expressionType": "relation",
1798
+ operationType: 'relation',
1799
+ operationCode: '',
1800
+ propertyPath: '',
1801
+ params: [],
1802
+ paramNames: [],
1803
+ });
1804
+ this.setState(
1805
+ {
1806
+ ruleClassData,
1807
+ },
1808
+ () => {
1809
+ callBack(ruleClassData);
1810
+ },
1811
+ );
1812
+ };
1813
+
1814
+ //添加子层级条件
1815
+ addChildRules = (itemDetail) => {
1816
+ const { ruleClassData } = this.state;
1817
+ const { callBack } = this.props;
1818
+ const initialData = JSON.parse(JSON.stringify(itemDetail));
1819
+ delete itemDetail.propertyPath;
1820
+ delete itemDetail.params;
1821
+ delete itemDetail.paramNames;
1822
+ delete itemDetail.dataTypeCode;
1823
+ delete itemDetail.elementId;
1824
+ delete itemDetail.elementName;
1825
+ delete itemDetail.metaObjectCode;
1826
+ // itemDetail.expressionType = 'logic';
1827
+ itemDetail.operationType = 'logic';
1828
+ itemDetail.operationCode = 'and';
1829
+ itemDetail.subExpression = [
1830
+ initialData,
1831
+ {
1832
+ // "expressionType": "relation",
1833
+ operationType: 'relation',
1834
+ operationCode: '',
1835
+ propertyPath: '',
1836
+ params: [],
1837
+ paramNames: [],
1838
+ },
1839
+ ];
1840
+ this.setState(
1841
+ {
1842
+ ruleClassData,
1843
+ },
1844
+ () => {
1845
+ callBack(ruleClassData);
1846
+ },
1847
+ );
1848
+ };
1849
+
1850
+ handleDeleteRule = (itemDetail, parentDetail, classDataIndex) => {
1851
+ const { ruleClassData } = this.state;
1852
+ const { callBack } = this.props;
1853
+ if (parentDetail.ruleName) {
1854
+ //删除根规则层级最后一条时整个规则项删除
1855
+ ruleClassData.splice(classDataIndex, 1);
1856
+ } else {
1857
+ let deleteItemIndex = parentDetail.subExpression.findIndex(
1858
+ (detailItem) =>
1859
+ JSON.stringify(itemDetail) == JSON.stringify(detailItem),
1860
+ );
1861
+ if (parentDetail.subExpression.length > 2) {
1862
+ parentDetail.subExpression.splice(deleteItemIndex, 1);
1863
+ } else {
1864
+ parentDetail.subExpression.splice(deleteItemIndex, 1);
1865
+ // parentDetail.expressionType = parentDetail.subExpression[0].expressionType;
1866
+ parentDetail.operationCode =
1867
+ parentDetail.subExpression[0].operationCode;
1868
+ parentDetail.operationType =
1869
+ parentDetail.subExpression[0].operationType;
1870
+
1871
+ if (parentDetail.subExpression[0].operationType == 'logic') {
1872
+ parentDetail.subExpression = [
1873
+ ...parentDetail.subExpression[0].subExpression,
1874
+ ];
1875
+ } else {
1876
+ parentDetail.propertyPath =
1877
+ parentDetail.subExpression[0].propertyPath;
1878
+ parentDetail.params = [...parentDetail.subExpression[0].params];
1879
+ parentDetail.paramNames = parentDetail.subExpression[0].paramNames
1880
+ ? [...parentDetail.subExpression[0].paramNames]
1881
+ : [];
1882
+ parentDetail.metaObjectCode =
1883
+ parentDetail.subExpression[0].metaObjectCode;
1884
+ parentDetail.elementId = parentDetail.subExpression[0].elementId;
1885
+ parentDetail.elementName = parentDetail.subExpression[0].elementName;
1886
+ parentDetail.dataTypeCode =
1887
+ parentDetail.subExpression[0].dataTypeCode;
1888
+ delete parentDetail.subExpression;
1889
+ }
1890
+ }
1891
+ }
1892
+ this.setState(
1893
+ {
1894
+ ruleClassData,
1895
+ },
1896
+ () => {
1897
+ callBack(ruleClassData);
1898
+ },
1899
+ );
1900
+ };
1901
+
1902
+ handleLogicalTypeChange = (itemDetail, type) => {
1903
+ const { ruleClassData } = this.state;
1904
+ const { callBack } = this.props;
1905
+ itemDetail.operationCode = type;
1906
+ this.setState(
1907
+ {
1908
+ ruleClassData,
1909
+ },
1910
+ () => {
1911
+ callBack(ruleClassData);
1912
+ },
1913
+ );
1914
+ };
1915
+
1916
+ // 新增执行顺序
1917
+ handleSelectRuleAction = (keys, classDataIndex, callback) => {
1918
+ callback();
1919
+ const { callBack } = this.props;
1920
+ const { ruleClassData } = this.state;
1921
+ ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1922
+ classDataIndex
1923
+ ].extraInfo.execute.map((i) => {
1924
+ if (i.code && keys.some((r) => r === i.code) && !i.isSelected) {
1925
+ return { ...i, isSelected: true };
1926
+ }
1927
+ return i;
1928
+ });
1929
+ // 处理数据
1930
+ this.setState(
1931
+ {
1932
+ ruleClassData,
1933
+ },
1934
+ () => {
1935
+ callBack(ruleClassData);
1936
+ },
1937
+ );
1938
+ };
1939
+
1940
+ handleDeleteRuleAction = (classDataIndex, functionCode) => {
1941
+ const { callBack } = this.props;
1942
+ const { ruleClassData } = this.state;
1943
+ ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1944
+ classDataIndex
1945
+ ].extraInfo.execute.map((i) => {
1946
+ if (i.code && functionCode === i.code && i.isSelected) {
1947
+ return { ...i, isSelected: false };
1948
+ }
1949
+ return i;
1950
+ });
1951
+ // 处理数据
1952
+ this.setState(
1953
+ {
1954
+ ruleClassData,
1955
+ },
1956
+ () => {
1957
+ callBack(ruleClassData);
1958
+ },
1959
+ );
1960
+ };
1961
+
1962
+ render() {
1963
+ const { onlyOneRule, callBack } = this.props;
1964
+ const { ruleClassData, modalParams } = this.state;
1965
+ return (
1966
+ <div className={'base_rule'}>
1967
+ <div className={'base_rule_content'}>
1968
+ <div
1969
+ style={{
1970
+ display: onlyOneRule ? 'none' : 'block',
1971
+ }}
1972
+ className={'base_rule_line_title'}
1973
+ >
1974
+ <Button
1975
+ onClick={this.handleAddRule}
1976
+ className={'base_rule_btn_style'}
1977
+ type="link"
1978
+ >
1979
+ 新增规则
1980
+ </Button>
1981
+ </div>
1982
+ <div>{this.renderRuleContent()}</div>
1983
+ </div>
1984
+ {(modalParams.visible && (
1985
+ <Modal
1986
+ title={`新增动作`}
1987
+ visible={modalParams.visible}
1988
+ onCancel={() => {
1989
+ this.setState({
1990
+ modalParams: { ...modalParams, visible: false },
1991
+ });
1992
+ }}
1993
+ maskClosable={false}
1994
+ destroyOnClose
1995
+ footer={null}
1996
+ >
1997
+ <Table
1998
+ rowSelection={{
1999
+ onChange: (keys, selectRows) => {
2000
+ this.handleSelectRuleAction(
2001
+ keys,
2002
+ modalParams.classDataIndex,
2003
+ () => {
2004
+ this.setState({
2005
+ modalParams: { ...modalParams, visible: false },
2006
+ });
2007
+ },
2008
+ );
2009
+ },
2010
+ }}
2011
+ columns={[
2012
+ {
2013
+ title: '执行动作名称',
2014
+ key: 'functionName',
2015
+ dataIndex: 'functionName',
2016
+ },
2017
+ ]}
2018
+ dataSource={modalParams?.ruleActionData}
2019
+ rowKey={'code'}
2020
+ />
2021
+ </Modal>
2022
+ )) ||
2023
+ null}
2024
+ </div>
2025
+ );
2026
+ }
2027
+ }
2028
+ export default RuleObjectComponent;