@bit-sun/business-component 2.3.24 → 2.3.26

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