@bit-sun/business-component 2.4.31-alpha.9 → 2.4.32

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