@bit-sun/business-component 2.3.22-beta9 → 2.3.23-beta01

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