@bit-sun/business-component 2.4.19 → 2.4.21

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