@bit-sun/business-component 3.1.10-alpha.1 → 3.1.10-alpha.11

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 (223) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/components/Functional/AddSelect/index.d.ts +1 -1
  9. package/dist/index.esm.js +485 -205
  10. package/dist/index.js +486 -206
  11. package/docs/index.md +21 -21
  12. package/lib/assets/drag.svg +17 -17
  13. package/lib/assets/exportFail.svg +37 -37
  14. package/lib/assets/exportProcessing.svg +28 -28
  15. package/lib/assets/exportSuccess.svg +34 -34
  16. package/lib/assets/label_icon_bottom.svg +25 -25
  17. package/lib/assets/upExport.svg +22 -22
  18. package/package.json +88 -88
  19. package/src/assets/32.svg +27 -27
  20. package/src/assets/addIcon.svg +17 -17
  21. package/src/assets/allfunc.svg +27 -27
  22. package/src/assets/arrowRight.svg +24 -24
  23. package/src/assets/arrow_top.svg +17 -17
  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 +398 -398
  48. package/src/components/Business/AddSelectBusiness/index.tsx +1116 -1116
  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/ChooseStore/index.tsx +193 -193
  53. package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +10 -10
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  61. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  62. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  63. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  64. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +163 -163
  65. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  66. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  67. package/src/components/Business/BsLayouts/Components/RightContent/i18n.ts +8 -8
  68. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +172 -172
  69. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  70. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  71. package/src/components/Business/BsLayouts/index.less +79 -79
  72. package/src/components/Business/BsLayouts/index.tsx +1606 -1606
  73. package/src/components/Business/BsLayouts/service.ts +10 -10
  74. package/src/components/Business/BsLayouts/utils.tsx +205 -205
  75. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +568 -566
  76. package/src/components/Business/BsSulaQueryTable/bssulaquerytable.less +5 -5
  77. package/src/components/Business/BsSulaQueryTable/index.less +227 -227
  78. package/src/components/Business/BsSulaQueryTable/index.tsx +767 -767
  79. package/src/components/Business/BsSulaQueryTable/setting.tsx +890 -888
  80. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  81. package/src/components/Business/BsSulaQueryTable/utils.tsx +709 -709
  82. package/src/components/Business/CommodityEntry/index.md +84 -84
  83. package/src/components/Business/CommodityEntry/index.tsx +82 -82
  84. package/src/components/Business/CommonAlert/index.tsx +23 -23
  85. package/src/components/Business/CommonGuideWrapper/index.less +121 -121
  86. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  87. package/src/components/Business/CommonGuideWrapper/index.tsx +94 -94
  88. package/src/components/Business/DetailPageWrapper/index.less +87 -87
  89. package/src/components/Business/DetailPageWrapper/index.tsx +327 -327
  90. package/src/components/Business/DetailPageWrapper/utils.tsx +166 -166
  91. package/src/components/Business/HomePageWrapper/index.less +33 -33
  92. package/src/components/Business/HomePageWrapper/index.md +45 -45
  93. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  94. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +823 -823
  95. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +205 -205
  96. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  97. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  98. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  99. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  100. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  101. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  102. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  103. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  104. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  105. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  106. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  107. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  108. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  109. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  110. package/src/components/Business/JsonQueryTable/index.less +16 -16
  111. package/src/components/Business/JsonQueryTable/index.md +328 -328
  112. package/src/components/Business/JsonQueryTable/index.tsx +534 -534
  113. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  114. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  115. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  116. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  117. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  118. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  119. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  120. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  121. package/src/components/Business/JsonQueryTable/static.ts +450 -450
  122. package/src/components/Business/SearchSelect/BusinessUtils.tsx +2326 -2318
  123. package/src/components/Business/SearchSelect/common.ts +134 -134
  124. package/src/components/Business/SearchSelect/index.md +1570 -1570
  125. package/src/components/Business/SearchSelect/index.tsx +55 -55
  126. package/src/components/Business/SearchSelect/utils.ts +125 -125
  127. package/src/components/Business/StateFlow/index.less +130 -130
  128. package/src/components/Business/StateFlow/index.md +60 -60
  129. package/src/components/Business/StateFlow/index.tsx +29 -29
  130. package/src/components/Business/TreeSearchSelect/index.md +239 -239
  131. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  132. package/src/components/Business/TreeSearchSelect/utils.ts +115 -115
  133. package/src/components/Business/columnSettingTable/columnSetting.tsx +818 -816
  134. package/src/components/Business/columnSettingTable/index.less +253 -253
  135. package/src/components/Business/columnSettingTable/index.md +372 -372
  136. package/src/components/Business/columnSettingTable/index.tsx +225 -225
  137. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +232 -232
  138. package/src/components/Business/columnSettingTable/utils.tsx +87 -87
  139. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -87
  140. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -21
  141. package/src/components/Business/moreTreeTable/index.less +99 -99
  142. package/src/components/Business/moreTreeTable/index.md +448 -448
  143. package/src/components/Business/moreTreeTable/index.tsx +387 -387
  144. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  145. package/src/components/Functional/AccessWrapper/index.tsx +33 -33
  146. package/src/components/Functional/AddSelect/helps.ts +81 -81
  147. package/src/components/Functional/AddSelect/index.less +367 -367
  148. package/src/components/Functional/AddSelect/index.md +155 -155
  149. package/src/components/Functional/AddSelect/index.tsx +1088 -1072
  150. package/src/components/Functional/AuthButton/index.tsx +15 -15
  151. package/src/components/Functional/BillEntry/index.less +371 -371
  152. package/src/components/Functional/BillEntry/index.md +39 -39
  153. package/src/components/Functional/BillEntry/index.tsx +771 -771
  154. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -62
  155. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -178
  156. package/src/components/Functional/BsAntdSula/index.ts +2 -2
  157. package/src/components/Functional/DataImport/index.less +63 -63
  158. package/src/components/Functional/DataImport/index.md +44 -44
  159. package/src/components/Functional/DataImport/index.tsx +782 -782
  160. package/src/components/Functional/DataValidation/index.less +63 -63
  161. package/src/components/Functional/DataValidation/index.md +52 -52
  162. package/src/components/Functional/DataValidation/index.tsx +788 -788
  163. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -5
  164. package/src/components/Functional/EllipsisTooltip/index.js +36 -36
  165. package/src/components/Functional/EllipsisTooltip/index.md +30 -30
  166. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  167. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +65 -65
  168. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  169. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  170. package/src/components/Functional/QueryMutipleInput/index.tsx +129 -129
  171. package/src/components/Functional/SearchSelect/index.less +121 -121
  172. package/src/components/Functional/SearchSelect/index.md +141 -141
  173. package/src/components/Functional/SearchSelect/index.tsx +1050 -1046
  174. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  175. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  176. package/src/components/Functional/TreeSearchSelect/index.tsx +224 -224
  177. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.tsx +358 -358
  178. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/function.js +255 -255
  179. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.tsx +57 -57
  180. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.tsx +129 -129
  181. package/src/components/Solution/RuleComponent/Formula.tsx +335 -335
  182. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -62
  183. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +774 -774
  184. package/src/components/Solution/RuleComponent/index.d.ts +34 -29
  185. package/src/components/Solution/RuleComponent/index.js +1680 -1663
  186. package/src/components/Solution/RuleComponent/index.less +247 -247
  187. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  188. package/src/components/Solution/RuleComponent/ruleFiled.js +2695 -2695
  189. package/src/components/Solution/RuleComponent/services.ts +13 -13
  190. package/src/components/Solution/RuleComponent/util.js +143 -143
  191. package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -6
  192. package/src/components/Solution/RuleSetter/baseRule.tsx +414 -414
  193. package/src/components/Solution/RuleSetter/function.ts +467 -467
  194. package/src/components/Solution/RuleSetter/index.less +221 -221
  195. package/src/components/Solution/RuleSetter/index.tsx +210 -210
  196. package/src/components/Solution/RuleSetter/service.js +276 -276
  197. package/src/index.ts +42 -42
  198. package/src/plugin/TableColumnSetting/index.less +247 -247
  199. package/src/plugin/TableColumnSetting/index.md +50 -50
  200. package/src/plugin/TableColumnSetting/index.tsx +725 -725
  201. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  202. package/src/styles/bsDefault.less +1933 -1933
  203. package/src/utils/CheckOneUser/index.md +39 -39
  204. package/src/utils/CheckOneUser/index.ts +51 -51
  205. package/src/utils/CustomLoginInfo.ts +55 -55
  206. package/src/utils/LocalstorageUtils.ts +134 -134
  207. package/src/utils/TableUtils.less +51 -51
  208. package/src/utils/TableUtils.tsx +691 -691
  209. package/src/utils/TreeUtils.ts +12 -12
  210. package/src/utils/auth.ts +38 -38
  211. package/src/utils/businessUtils.ts +434 -434
  212. package/src/utils/checkUtils.ts +39 -39
  213. package/src/utils/constant.ts +38 -38
  214. package/src/utils/enumConfig.ts +17 -17
  215. package/src/utils/getFormMode.js +12 -12
  216. package/src/utils/index.ts +21 -21
  217. package/src/utils/request.ts +53 -53
  218. package/src/utils/requestUtils.ts +197 -197
  219. package/src/utils/serialize.js +7 -7
  220. package/src/utils/utils.ts +266 -266
  221. package/src/utils/xlsxUtil.tsx +145 -145
  222. package/tsconfig.json +29 -29
  223. package/typings.d.ts +4 -4
@@ -1,1663 +1,1680 @@
1
- import React, { Component } from 'react';
2
- // @ts-ignore
3
- import _ from 'lodash';
4
- import moment from 'moment';
5
- import RuleField from './ruleFiled';
6
- import {
7
- Select,
8
- Button,
9
- Radio,
10
- Switch,
11
- Checkbox,
12
- InputNumber,
13
- TreeSelect,
14
- Popover,
15
- Input,
16
- DatePicker,
17
- Table,
18
- Divider,
19
- Space,
20
- Form as AntdForm,
21
- Modal,
22
- message,
23
- } from 'antd';
24
- import {
25
- PlusCircleOutlined,
26
- MinusCircleOutlined,
27
- DownOutlined,
28
- } from '@ant-design/icons';
29
- import './index.less';
30
- import {
31
- relateItems,
32
- getSpecialPropertyCode,
33
- getPropertyCode,
34
- isObj,
35
- } from './util';
36
- import { getDictionarySource, uuid } from '../../../utils/utils';
37
- import { coverToParallel } from '../../../utils/TreeUtils';
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 RenderCompItem from './RenderCompItem';
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
- otherMainInfo: {
158
- customSelectorConfig: element.customSelectorConfig
159
- }
160
- };
161
- if (element?.propertyList?.length) {
162
- child.children = this.parseChildTreeData(
163
- element.propertyList,
164
- `${element.code}`,
165
- `${item.name}-${element.name}`,
166
- item.code,
167
- );
168
- child.isLeaf = false;
169
- } else {
170
- child.isLeaf = true;
171
- child.metaObjectCode = item.code;
172
- }
173
- return child;
174
- }),
175
- }
176
- : {
177
- isLeaf: this.props.metaObjectCode ? true : false,
178
- metaObjectCode: this.props.metaObjectCode || item.code,
179
- ...item,
180
- dataTypeCode: item.valueType,
181
- dataChoiceBusinessType: item.choiceType,
182
- dataInputBusinessType: item.inputType,
183
- }),
184
- };
185
- });
186
- this.setState({
187
- initialRegularList: [...regularDataList],
188
- ruleTreeData: finalTreeDatas,
189
- });
190
- };
191
-
192
- parseChildTreeData = (list, parentKey, parentTitle, rootObjCode) => {
193
- return list.map((element) => {
194
- const infoVo = (element.info && JSON.parse(element.info)) || {};
195
- if (element.choiceType === 30) {
196
- this.dynamicDictCodeToRangeIdMap[
197
- `${rootObjCode}.${parentKey}.${element.code}`
198
- ] = infoVo?.dictionaryCode;
199
- } else if (element.choiceType === 20) {
200
- this.dictCodeToRangeIdMap[
201
- `${rootObjCode}.${parentKey}.${element.code}`
202
- ] = infoVo?.dictionaryCode;
203
- } else if (element.choiceType === 10) {
204
- // FIXME http://192.168.13.78/mep-fed-group/web/libs/business-component/-/merge_requests/45#note_115669
205
- const list =
206
- (Object.keys(infoVo).length &&
207
- infoVo.enumeration &&
208
- Object.keys(infoVo.enumeration).map((i) => ({
209
- code: i,
210
- name: infoVo.enumeration[i],
211
- }))) ||
212
- undefined;
213
- this.propertyCodeToRangeIdMap[
214
- `${rootObjCode}.${parentKey}.${element.code}`
215
- ] = list;
216
- } else {
217
- // this.propertyCodeToRangeIdMap[
218
- // `${rootObjCode}.${parentKey}.${element.code}`
219
- // ] = Object.keys(infoVo).length ? infoVo : undefined;
220
- }
221
- let child = {
222
- title: `${parentTitle}-${element.name}`,
223
- key: `${parentKey}.${element.id}`,
224
- pValue: `${parentKey}.${element.code}`,
225
- value: element.id,
226
- id: element.id,
227
- dataTypeCode: element.valueType,
228
- dataChoiceBusinessType: element.choiceType,
229
- dataInputBusinessType: element.inputType,
230
- info: element.info,
231
- otherMainInfo: {
232
- customSelectorConfig: element.customSelectorConfig
233
- }
234
- };
235
- if (element.propertyList) {
236
- child.children = this.parseChildTreeData(
237
- element.propertyList,
238
- `${parentKey}.${element.code}`,
239
- `${parentTitle}-${element.name}`,
240
- rootObjCode,
241
- );
242
- child.isLeaf = false;
243
- } else {
244
- child.isLeaf = true;
245
- child.metaObjectCode = rootObjCode;
246
- }
247
- return child;
248
- });
249
- };
250
-
251
- getDataTypeOperateList = (id) => {
252
- const { operationList, initialRegularList } = this.state;
253
- // let typeId = '';
254
- // initialRegularList.forEach(item => {
255
- // item.metaObjectResDto.elementResDtos.forEach(element => {
256
- // if (element.id == id) {
257
- // typeId = element.dataTypeCode;
258
- // }
259
- // })
260
- // })
261
- const list =
262
- operationList.find((item) => item.code == id)?.operationList || [];
263
- return this.props.isShowAllOperationList ? operationList : list;
264
- };
265
-
266
- handleValuesChange = (itemDetail, newValues, newValueNames) => {
267
- const { ruleClassData } = this.state;
268
- const { callBack } = this.props;
269
- itemDetail.params = [...newValues];
270
- itemDetail.paramNames = [...newValueNames];
271
- this.setState(
272
- {
273
- ruleClassData,
274
- },
275
- () => {
276
- callBack(ruleClassData);
277
- },
278
- );
279
- };
280
-
281
- setRelateDataList = (classDataItem) => {
282
- let relateDatas = {};
283
- relateItems.forEach((relateItem) => {
284
- this.getRelateData(
285
- relateItem,
286
- classDataItem.subExpression || {},
287
- relateDatas,
288
- );
289
- });
290
- return relateDatas;
291
- };
292
-
293
- getRelateData = (relateItem, classDataItem, relateDatas) => {
294
- if (
295
- classDataItem?.propertyPath &&
296
- getPropertyCode(classDataItem.propertyPath) == relateItem.propertyCode
297
- ) {
298
- relateDatas[relateItem.propertyCode] = classDataItem.params;
299
- } else {
300
- if (classDataItem.subExpression && classDataItem.subExpression.length) {
301
- classDataItem.subExpression.forEach((classData) => {
302
- this.getRelateData(relateItem, classData, relateDatas);
303
- });
304
- }
305
- }
306
- };
307
-
308
- renderRuleContent = () => {
309
- const { ruleClassData, currentRuleName, isEdit, editNameIndex } =
310
- this.state;
311
- const {
312
- ruleType,
313
- callBack,
314
- accountList = [],
315
- disabled,
316
- ruleTypeData,
317
- canDelete = false,
318
- ruleReturnConfig = [],
319
- onlyOneRule,
320
- onlyCondition,
321
- onlyAction,
322
- handleOperatingAction,
323
- ruleGroupInfo,
324
- needShowAction = true,
325
- extraConfig,
326
- customTitleSubStyle,
327
- customTitlePreStyle,
328
- } = this.props;
329
- const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1; // 业务调用规则实例设计器
330
- const ruleGroupName = ruleGroupInfo?.ruleGroupList?.[0]?.name || '规则分组';
331
- const priorityList = (ruleGroupInfo?.groupOtherPriorityList || []).concat(ruleClassData|| []);
332
- const canChangePriority = ruleGroupInfo?.canChangePriority;
333
- const isRuleGroupInstance = ruleGroupInfo?.type == 'group-instance'; // 规则组展示规则实例设计器
334
- const titlePre = {
335
- position: 'relative',
336
- top: '-10px',
337
- left: '20px',
338
- background: '#fff',
339
- width: '160px',
340
- textAlign: 'center',
341
- ...(customTitlePreStyle || {}),
342
- }; // height:22
343
- const titleSubCommon = {
344
- display: 'flex',
345
- justifyContent: 'center',
346
- }
347
- const titleSubPre = {
348
- ...titlePre,
349
- ...titleSubCommon,
350
- width: '166px',
351
- top: '-32px', // titlePre(height + top)
352
- left: '200px', // titlePre(2 * left + width) 左右间距为titlePre的left: 20px
353
- ...(customTitleSubStyle || {}),
354
- }; // height: 24
355
- const titleSubPre2 = {
356
- ...titlePre,
357
- ...titleSubCommon,
358
- width: '240px',
359
- top: '-56px', // titleSubPre(top + height)
360
- left: '386px', // titlePre(left + width + 20)
361
- }
362
- const ruleListBox = (!onlyOneRule || ruleGroupInfo) ? { border: '1px dashed #d9d9d9', marginBottom: 10, overflowX: 'clip', position: 'relative' } : {};
363
- const isRuleActionConfig =
364
- ruleTypeData?.length || ruleReturnConfig?.length;
365
- return (
366
- <div>
367
- {ruleClassData.map((item, classDataIndex) => {
368
- let extraInfo = {};
369
- if (isRuleActionConfig) {
370
- const { response = [] } = item.extraInfo;
371
- extraInfo = {
372
- ...item.extraInfo,
373
- response:
374
- Object.prototype.toString.call(response) === '[object Object]'
375
- ? [response]
376
- : Array.isArray(response)
377
- ? response
378
- : [],
379
- };
380
- }
381
- let relateDatas = this.setRelateDataList(item);
382
- const sActionProps = {
383
- extraInfo,
384
- ruleTypeData,
385
- item,
386
- classDataIndex,
387
- handleOperatingAction,
388
- disabled,
389
- };
390
- return (
391
- // rule-line-class方便开发自定义样式,勿删
392
- <div className={'rule-line-class'} style={ruleListBox}>
393
- {!onlyOneRule && !ruleGroupInfo && (
394
- <div style={titlePre}>规则{classDataIndex + 1}</div>
395
- )}
396
- {ruleGroupInfo && (
397
- <>
398
- <div style={titlePre}>
399
- <EllipsisTooltip
400
- visible={true}
401
- maxLength={10}
402
- title={ruleGroupName}
403
- />
404
- </div>
405
- {isRuleInstance && (
406
- <div style={titleSubPre}>
407
- <span
408
- style={{
409
- marginRight: 10,
410
- display: 'block',
411
- width: '100px',
412
- textAlign: 'right',
413
- overflow: 'hidden',
414
- textOverflow:'ellipsis',
415
- whiteSpace: 'nowrap'
416
- }}>
417
- 优先级
418
- </span>
419
- <Select
420
- size='small'
421
- disabled={canChangePriority ? !canChangePriority : disabled}
422
- style={{ width: 100 }}
423
- value={item.priority}
424
- onChange={(v) => {
425
- // 因为存在页签,前端校验不准确;而且若选择优先级之后想交换改也不方便,故交由后端校验
426
- // const isRepeate = priorityList.some((r) => r.priority == v)
427
- // if(isRepeate) {
428
- // message.warn('优先级不允许重复')
429
- // }
430
- // item.priority = isRepeate ? (item.priority||null) : v;
431
- item.priority = v
432
- this.setState(
433
- {
434
- ruleClassData,
435
- },
436
- () => {
437
- callBack(ruleClassData);
438
- },
439
- );
440
- }}
441
- >
442
- {priorityList?.map((s,sindex) => (
443
- <Option key={sindex+1} value={sindex+1}>{sindex+1}</Option>
444
- ))}
445
- </Select>
446
- </div>
447
- ) || null}
448
- {isRuleGroupInstance && (
449
- <div style={titleSubPre2}>
450
- <span style={{ marginRight: 10 }}>业务编码</span>
451
- <EllipsisTooltip
452
- visible={true}
453
- maxLength={24}
454
- title={item.extStrField01}
455
- />
456
- </div>
457
- )}
458
- {/* 规则组额外extStrField */}
459
- {
460
- extraConfig && extraConfig.map((extraItem, index) => (
461
- <div style={titleSubPre}>
462
- <span
463
- style={{
464
- marginRight: 10,
465
- display: 'block',
466
- width: '100px',
467
- textAlign: 'right',
468
- overflow: 'hidden',
469
- textOverflow:'ellipsis',
470
- whiteSpace: 'nowrap'
471
- }}
472
- >
473
- {extraItem?.label}
474
- </span>
475
- <Select
476
- size='small'
477
- style={{ width: 100 }}
478
- mode={extraItem?.mode || null}
479
- disabled={disabled}
480
- value={ extraItem?.mode === 'multiple' ? (item[extraItem?.code] ? item[extraItem?.code].split(',') : []) : item[extraItem?.code] }
481
- onChange={(v) => {
482
- item[extraItem?.code] = Array.isArray(v) ? v.join(',') : v;
483
- this.setState(
484
- {
485
- ruleClassData,
486
- },
487
- () => {
488
- callBack(ruleClassData);
489
- },
490
- );
491
- }}
492
- >
493
- {extraItem?.optionList?.map((s,sindex) => (
494
- <Option value={s?.value}>{s?.text}</Option>
495
- ))}
496
- </Select>
497
- </div>
498
- ))
499
- }
500
- </>
501
- )}
502
- <div
503
- style={{
504
- textAlign: 'right',
505
- display: canDelete ? 'block' : 'none',
506
- position: 'absolute',
507
- right: '5px',
508
- top: '5px',
509
- }}
510
- >
511
- <Button
512
- disabled={disabled}
513
- onClick={() => {
514
- const { ruleClassData } = this.state;
515
- ruleClassData.splice(classDataIndex, 1);
516
- this.setState(
517
- {
518
- ruleClassData,
519
- },
520
- () => {
521
- callBack(ruleClassData);
522
- },
523
- );
524
- }}
525
- type="link"
526
- danger
527
- >
528
- 删除规则
529
- </Button>
530
- </div>
531
- <div>
532
- {/* <div style={{ display: isEdit && editNameIndex == index ? 'none' : 'block' }}>
533
- <span className={'rule_name_title}>
534
- {item.ruleName}
535
- </span>
536
- <EditOutlined
537
- onClick={() => {
538
- this.setState({
539
- editNameIndex: index,
540
- currentRuleName: item.ruleName,
541
- isEdit: true
542
- })
543
- }}
544
- />
545
- </div> */}
546
- <div
547
- style={{
548
- display:
549
- isEdit && editNameIndex == index ? 'block' : 'none',
550
- marginTop: '10px',
551
- }}
552
- >
553
- <Input
554
- disabled={disabled}
555
- value={currentRuleName}
556
- style={{ width: '200px' }}
557
- onChange={(e) => {
558
- this.setState({
559
- currentRuleName: e.target.value,
560
- });
561
- }}
562
- />
563
- <Button
564
- disabled={disabled}
565
- type="link"
566
- onClick={() => {
567
- const { ruleClassData, currentRuleName } = this.state;
568
- ruleClassData[editNameIndex].ruleName = currentRuleName;
569
- this.setState({
570
- ruleClassData,
571
- isEdit: false,
572
- });
573
- }}
574
- >
575
- 保存
576
- </Button>
577
- <Button
578
- disabled={disabled}
579
- type="link"
580
- onClick={() => {
581
- this.setState({
582
- isEdit: false,
583
- });
584
- }}
585
- >
586
- 取消
587
- </Button>
588
- </div>
589
- </div>
590
- <div>
591
- {(onlyAction && <RenderSpecificAction {...sActionProps} />) || (
592
- <div className={'base_rule_line_content'}>
593
- <div className={'base_rule_item2'}>
594
- {item.subExpression &&
595
- this.renderRuleItem(
596
- item.subExpression,
597
- item,
598
- 1,
599
- classDataIndex,
600
- relateDatas,
601
- )}
602
- </div>
603
- {needShowAction && (
604
- <div className={'base_rule_item3'}>
605
- {(extraInfo &&
606
- isRuleActionConfig &&
607
- (!onlyCondition || !onlyAction) &&
608
- this.renderRuleTypeItem(
609
- extraInfo,
610
- item,
611
- 1,
612
- classDataIndex,
613
- ruleTypeData,
614
- ruleReturnConfig,
615
- isRuleInstance
616
- )) ||
617
- null}
618
- </div>
619
- ) || null}
620
- </div>
621
- )}
622
- </div>
623
- </div>
624
- );
625
- })}
626
- </div>
627
- );
628
- };
629
-
630
- handleAddRule = () => {
631
- const { ruleClassData } = this.state;
632
- const { callBack, ruleTypeData=[], ruleGroupInfo, ruleReturnConfig=[] } = this.props;
633
- const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1;
634
- const initKongData = {
635
- ruleName: `规则${ruleClassData?.length + 1}`,
636
- subExpression: {
637
- // "expressionType": "relation",
638
- operationType: 'relation',
639
- propertyPath: '',
640
- params: [],
641
- paramNames: [],
642
- },
643
- extraInfo: {
644
- response: ruleReturnConfig?.map((s) => {
645
- return {
646
- code: s?.code,
647
- value: s?.defaultValue || '',
648
- enable: false,
649
- };
650
- })||[],
651
- execute: ruleTypeData?.map((s) => {
652
- return {
653
- priority: 1,
654
- code: s.code,
655
- properties: {
656
- configPropertyCode: 'configPropertyValue',
657
- },
658
- };
659
- })||[],
660
- },
661
- }
662
- const initTemplateData = ruleGroupInfo?.templateData && Object.keys(ruleGroupInfo?.templateData)?.length ? {
663
- ruleName: `规则${ruleClassData?.length + 1}`,
664
- ..._.cloneDeep(ruleGroupInfo?.templateData)
665
- } : initKongData;
666
- const initNewData = isRuleInstance ? initTemplateData : initKongData
667
- ruleClassData.push(initNewData);
668
- this.setState(
669
- {
670
- ruleClassData,
671
- },
672
- () => {
673
- callBack(ruleClassData);
674
- },
675
- );
676
- };
677
-
678
- renderRuleItem = (
679
- itemDetail,
680
- parentDetail,
681
- floorIndex,
682
- classDataIndex,
683
- relateDatas,
684
- ) => {
685
- const { ruleTreeData } = this.state;
686
- const {
687
- callBack,
688
- initialThresholdQuery = {},
689
- disabled,
690
- systemVariableList,
691
- } = this.props;
692
- let thresholdQuery = {
693
- ...initialThresholdQuery,
694
- ...relateDatas,
695
- };
696
- let finalIndex = floorIndex + 1;
697
- let queryIdentify = '';
698
- let queryIdentifyType = '';
699
- if (
700
- this.propertyCodeToRangeIdMap[
701
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
702
- ]
703
- ) {
704
- queryIdentify =
705
- this.propertyCodeToRangeIdMap[
706
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
707
- ];
708
- queryIdentifyType = Array.isArray(queryIdentify)
709
- ? 'objectPropertyListIdentify'
710
- : 'objectPropertyCodeIdentify';
711
- } else if (
712
- getSpecialPropertyCode(getPropertyCode(itemDetail.propertyPath))
713
- ) {
714
- queryIdentify = getSpecialPropertyCode(
715
- getPropertyCode(itemDetail.propertyPath),
716
- );
717
- queryIdentifyType = 'specialPropertyIdentify';
718
- } else if (
719
- this.dictCodeToRangeIdMap[
720
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
721
- ]
722
- ) {
723
- queryIdentify =
724
- this.dictCodeToRangeIdMap[
725
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
726
- ];
727
- queryIdentifyType = 'dictCodeIdentify';
728
- } else if (
729
- this.dynamicDictCodeToRangeIdMap[
730
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
731
- ]
732
- ) {
733
- queryIdentify =
734
- this.dynamicDictCodeToRangeIdMap[
735
- `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
736
- ];
737
- queryIdentifyType = 'dynamicDictCodeIdentify';
738
- }
739
-
740
- const parallelTreeData = coverToParallel(ruleTreeData, []) || [];
741
- const currentTreeItem =
742
- itemDetail?.elementId &&
743
- parallelTreeData.find((i) => (i?.key?.indexOf('.') > -1 ? i.id : i.key) === itemDetail?.elementId);
744
- const dataChoiceBusinessType = currentTreeItem?.dataChoiceBusinessType;
745
- const dataInputBusinessType = currentTreeItem?.dataInputBusinessType;
746
- return (
747
- <div
748
- className={'rule_line_content'}
749
- style={{ display: 'flex', marginBottom: '0px', padding: '10px 0px' }}
750
- >
751
- <div
752
- className={'logical_operate_content'}
753
- style={{
754
- display: itemDetail.operationType == 'logic' ? 'block' : 'none',
755
- width: '60px',
756
- zIndex: 20,
757
- }}
758
- >
759
- <Popover
760
- content={
761
- <div>
762
- <p
763
- className={'choose_logical_type'}
764
- onClick={() => {
765
- this.handleLogicalTypeChange(itemDetail, 'or');
766
- }}
767
- >
768
- 或者
769
- </p>
770
- <p
771
- className={'choose_logical_type'}
772
- onClick={() => {
773
- this.handleLogicalTypeChange(itemDetail, 'and');
774
- }}
775
- >
776
- 并且
777
- </p>
778
- </div>
779
- }
780
- trigger="focus"
781
- >
782
- <Button
783
- disabled={disabled}
784
- type="link"
785
- className={'logical_item_btn'}
786
- >
787
- {itemDetail?.operationCode == 'or' ? '或者' : '并且'}
788
- <DownOutlined style={{ marginLeft: '6px' }} />
789
- </Button>
790
- </Popover>
791
- <span className={'top_line'}></span>
792
- <span className={'bottom_line'}></span>
793
- </div>
794
-
795
- <div style={{ flexGrow: 1 }}>
796
- {itemDetail.operationType == 'logic' ? (
797
- itemDetail?.subExpression?.map((item1) => {
798
- return this.renderRuleItem(
799
- item1,
800
- itemDetail,
801
- finalIndex,
802
- classDataIndex,
803
- relateDatas,
804
- );
805
- })
806
- ) : (
807
- <div style={{ display: 'flex', alignItems: 'center' }}>
808
- {/* todo */}
809
- <TreeSelect
810
- showSearch
811
- treeNodeFilterProp="title"
812
- value={itemDetail.elementId}
813
- disabled={disabled}
814
- onChange={(value, name, nodeInfo) => {
815
- if (!nodeInfo.triggerNode.props.isLeaf) return; //只有最末端叶子节点可选中
816
- const { ruleClassData } = this.state;
817
- itemDetail.propertyPath = nodeInfo.triggerNode.props.pValue;
818
- itemDetail.params = [];
819
- itemDetail.paramNames = [];
820
- itemDetail.operationCode = '';
821
- itemDetail.elementId = nodeInfo.triggerNode.props.id;
822
- itemDetail.elementName = nodeInfo.triggerNode.props.title;
823
- itemDetail.dataTypeCode =
824
- nodeInfo.triggerNode.props.dataTypeCode;
825
- itemDetail.metaObjectCode =
826
- nodeInfo.triggerNode.props.metaObjectCode;
827
- itemDetail.isInsertParam = false;
828
- this.setState(
829
- {
830
- ruleClassData,
831
- },
832
- () => {
833
- callBack(ruleClassData);
834
- },
835
- );
836
- }}
837
- style={{ width: '200px' }}
838
- treeData={ruleTreeData}
839
- />
840
- <Select
841
- value={itemDetail?.operationCode || ''}
842
- disabled={disabled}
843
- style={{ width: '150px', marginLeft: '10px' }}
844
- onChange={(value) => {
845
- const { ruleClassData } = this.state;
846
- itemDetail.operationCode = value;
847
- this.setState(
848
- {
849
- ruleClassData,
850
- },
851
- () => {
852
- callBack(ruleClassData);
853
- },
854
- );
855
- }}
856
- >
857
- {this.getDataTypeOperateList(itemDetail.dataTypeCode).map(
858
- (item) => (
859
- <Select.Option value={item.code} key={item.code}>
860
- {item.name}
861
- </Select.Option>
862
- ),
863
- )}
864
- </Select>
865
- {!itemDetail?.isInsertParam ? (
866
- <RuleField
867
- customerWidth={this.props.customerWidth}
868
- selectOperation={itemDetail?.operationCode || ''}
869
- disabled={disabled}
870
- initialThresholdQuery={thresholdQuery}
871
- dataTypeCode={itemDetail?.dataTypeCode || ''}
872
- dataChoiceBusinessType={dataChoiceBusinessType || ''}
873
- dataInputBusinessType={dataInputBusinessType || ''}
874
- itemDetail={itemDetail}
875
- queryIdentifyType={queryIdentifyType}
876
- queryIdentify={queryIdentify}
877
- propertyCode={getPropertyCode(itemDetail.propertyPath)}
878
- // propertyCode={`${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`}
879
- relateDatas={relateDatas}
880
- others={currentTreeItem?.otherMainInfo}
881
- values={itemDetail.params || []}
882
- valueNames={itemDetail.paramNames || []}
883
- callback={(newValues, newValueNames) => {
884
- this.handleValuesChange(
885
- itemDetail,
886
- newValues,
887
- newValueNames,
888
- );
889
- }}
890
- />
891
- ) : null}
892
- <Select
893
- disabled={disabled}
894
- value={
895
- itemDetail?.systemCode || itemDetail?.params?.[0]?.replace('{', '').replace('}', '') ||
896
- ''
897
- } // systemCode兼容用户结算组织那边使用规则
898
- style={{
899
- width: '250px',
900
- marginLeft: '10px',
901
- display: itemDetail?.isInsertParam ? '' : 'none',
902
- }}
903
- onChange={(value) => {
904
- const { ruleClassData } = this.state;
905
- itemDetail.params = [(value && `{${value}}`) || ''];
906
- const name = systemVariableList.find(
907
- (i) => i.code == value,
908
- )?.name;
909
- itemDetail.paramNames = [name || ''];
910
- itemDetail.systemCode = value;
911
- this.setState(
912
- {
913
- ruleClassData,
914
- },
915
- () => {
916
- callBack(ruleClassData);
917
- },
918
- );
919
- }}
920
- >
921
- {systemVariableList?.length
922
- ? systemVariableList.map((item) => (
923
- <Select.Option value={item.code} key={item.code}>
924
- {item.name}
925
- </Select.Option>
926
- ))
927
- : null}
928
- </Select>
929
- <PlusCircleOutlined
930
- className={'icon_btn_style'}
931
- onClick={() => {
932
- this.addChildRules(itemDetail);
933
- }}
934
- style={{
935
- color: '#008fe0',
936
- marginLeft: '15px',
937
- display: floorIndex > 4 || disabled ? 'none' : 'inline-block',
938
- }}
939
- />
940
- <MinusCircleOutlined
941
- className={'icon_btn_style'}
942
- onClick={() => {
943
- this.handleDeleteRule(
944
- itemDetail,
945
- parentDetail,
946
- classDataIndex,
947
- );
948
- }}
949
- style={{
950
- color: 'gray',
951
- display: disabled ? 'none' : 'inline-block',
952
- }}
953
- />
954
- <Button
955
- type="link"
956
- disabled={
957
- disabled || (itemDetail.operationCode === '' || !itemDetail.operationCode
958
- ? true
959
- : false)
960
- }
961
- onClick={() => {
962
- const { ruleClassData } = this.state;
963
- if (systemVariableList && Array.isArray(systemVariableList) && systemVariableList.length && systemVariableList[0].code!== '-1' ) {
964
- itemDetail.isInsertParam = !itemDetail.isInsertParam;
965
- if (itemDetail.isInsertParam) {
966
- itemDetail.type = 10;
967
- itemDetail.paramNames = [];
968
- itemDetail.params = [];
969
- } else {
970
- itemDetail.systemCode = null;
971
- }
972
-
973
- this.setState(
974
- {
975
- ruleClassData,
976
- },
977
- () => {
978
- callBack(ruleClassData);
979
- },
980
- );
981
- } else {
982
- message.warn('未配置规则变量');
983
- }
984
- }}
985
- >
986
- {itemDetail?.isInsertParam ? '取消插入参数' : '插入参数'}
987
- </Button>
988
- </div>
989
- )}
990
- <div
991
- style={{
992
- display:
993
- itemDetail.operationType == 'logic' && !disabled
994
- ? 'block'
995
- : 'none',
996
- }}
997
- >
998
- <span
999
- style={{ color: '#008fe0', cursor: 'pointer' }}
1000
- type="link"
1001
- onClick={() => {
1002
- this.addPeerRule(itemDetail);
1003
- }}
1004
- >
1005
- <PlusCircleOutlined
1006
- style={{
1007
- color: '#008fe0',
1008
- fontSize: '14px',
1009
- marginRight: '5px',
1010
- }}
1011
- />
1012
- 添加条件
1013
- </span>
1014
- </div>
1015
- </div>
1016
- </div>
1017
- );
1018
- };
1019
-
1020
- handleEditExtraInfoResponse = (code, val, parentDetail,classDataIndex, key) => {
1021
- const { ruleClassData } = this.state;
1022
- const { callBack } = this.props;
1023
- parentDetail.extraInfo.response = parentDetail.extraInfo.response.map((i) => {
1024
- if (i.code && key === i.code) {
1025
- i[code] = val;
1026
- return i;
1027
- }
1028
- return i;
1029
- });
1030
- ruleClassData[classDataIndex].extraInfo.response = ruleClassData[
1031
- classDataIndex
1032
- ].extraInfo.response.map((i) => {
1033
- if (i.code && key === i.code) {
1034
- i[code] = val;
1035
- return i;
1036
- }
1037
- return i;
1038
- });
1039
-
1040
- this.setState(
1041
- {
1042
- ruleClassData,
1043
- },
1044
- () => {
1045
- callBack(ruleClassData);
1046
- },
1047
- );
1048
- };
1049
- // 场景需要返回值2022.11.15
1050
- renderResItem = (
1051
- itemDetail,
1052
- parentDetail,
1053
- ruleReturnConfig,
1054
- selectRuleReturnData,
1055
- classDataIndex,
1056
- disabled,
1057
- boxStyle,
1058
- ) => {
1059
- const isRightText = ruleReturnConfig?.rightText?.length;
1060
-
1061
- const showValue = (code, type, functionItem, configItem) => {
1062
- let defaultValue = configItem.defaultValue;
1063
- const pCode = itemDetail.response?.find((i) => i.code == code)?.value;
1064
- if (type === 'input') {
1065
- return pCode === undefined ? pCode : pCode || defaultValue;
1066
- }
1067
- if(['date','dateTime','rangeTime'].includes(type)) {
1068
- if(['date','dateTime'].includes(type)) return pCode ? moment(pCode) : pCode;
1069
- if(['rangeTime'].includes(type)) {
1070
- const newPCode = Array.isArray(pCode) ? pCode : pCode?.split(',');
1071
- return pCode ? newPCode?.map((i) => moment(i)) : pCode;
1072
- }
1073
- }
1074
- if(configItem?.inputType === 30) {
1075
- const newPCode = Array.isArray(pCode) ? pCode?.map(s => isObj(s) ? s : ({ key: s, value: s })) : pCode?.split(',')?.map(s => ({ key: s, value: s }));
1076
- return newPCode || pCode || defaultValue;
1077
- }
1078
- return pCode || defaultValue;
1079
- };
1080
- const handleEdit = (code, val, functionItem) => {
1081
- let value = val;
1082
- if (isObj(code)) {
1083
- Object.keys(code).forEach((ite) => {
1084
- this.handleEditExtraInfoResponse(ite, code[ite], parentDetail,classDataIndex);
1085
- });
1086
- return;
1087
- }
1088
- if (Array.isArray(val) && val?.length) {
1089
- value = val.map((m) => m.value || m).join(',');
1090
- }
1091
- if (isObj(val)) {
1092
- value = val.value || val.PCDCode?.join('/');
1093
- }
1094
- this.handleEditExtraInfoResponse('value', value, parentDetail,classDataIndex,code);
1095
- };
1096
-
1097
- return (
1098
- <>
1099
- {selectRuleReturnData && selectRuleReturnData.length ? (
1100
- <div>
1101
- <div className={'rule_action_return_border'}>
1102
- <div className={'rule_border_title'}>返回值</div>
1103
- <div>
1104
- {selectRuleReturnData.map((item) => (
1105
- <div style={{ display: 'flex' }}>
1106
- {this.renderFormCompItem(
1107
- item,
1108
- showValue,
1109
- handleEdit,
1110
- {},
1111
- boxStyle,
1112
- disabled,
1113
- )}
1114
- <MinusCircleOutlined
1115
- className={'icon_btn_style'}
1116
- onClick={() => {
1117
- this.handleEditExtraInfoResponse(
1118
- 'enable',
1119
- false,
1120
- parentDetail,
1121
- classDataIndex,
1122
- item.code,
1123
- );
1124
- }}
1125
- style={{
1126
- color: 'gray',
1127
- marginLeft: isRightText ? '100px' : '15px',
1128
- marginTop: '15px',
1129
- display: disabled ? 'none' : 'inline-block',
1130
- }}
1131
- />
1132
- </div>
1133
- ))}
1134
- </div>
1135
- </div>
1136
- </div>
1137
- ) : (
1138
- <></>
1139
- )}
1140
- </>
1141
- );
1142
- };
1143
-
1144
-
1145
- renderFormCompItem = (
1146
- config,
1147
- showValue,
1148
- handleEdit,
1149
- parentItem,
1150
- boxStyle,
1151
- disabled
1152
- ) => {
1153
- if (!config) return;
1154
- return (
1155
- <div style={boxStyle}>
1156
- {(config?.leftText && (
1157
- <div style={{ flex: 'none', marginRight: 10 }}>
1158
- {config?.required && <span className="requiredMark" />}
1159
- {config.leftText}
1160
- </div>
1161
- )) ||
1162
- null}
1163
- {(!config?.leftText && config?.rightText && config?.required && (
1164
- <div style={{ flex: 'none', marginRight: 10 }}>
1165
- <span className="requiredMark" />
1166
- </div>
1167
- )) ||
1168
- null}
1169
- <RenderCompItem regularDataList={this.props.regularDataList} ites={config} showValue={(a, b, c = parentItem, d = config) => showValue(a, b, c, d)} handleEdit={(a, b, c = parentItem, d = config) => handleEdit(a, b, c, d)} disabled={disabled}></RenderCompItem>
1170
- {(config?.rightText && (
1171
- <div style={{ flex: 'none', marginLeft: 10 }}>{config.rightText}</div>
1172
- )) ||
1173
- null}
1174
- </div>
1175
- );
1176
- };
1177
-
1178
- renderActionList = (
1179
- itemDetail,
1180
- parentDetail,
1181
- handleRuleTypeData,
1182
- sRuleActionData,
1183
- classDataIndex,
1184
- disabled,
1185
- boxStyle,
1186
- ) => {
1187
- const showValue = (code, type, functionItem, configItem) => {
1188
- const functionIndex = handleRuleTypeData.findIndex(
1189
- (m) => m.code === functionItem.code,
1190
- );
1191
- const pCode =
1192
- itemDetail.execute[functionIndex] &&
1193
- itemDetail.execute[functionIndex].properties[code];
1194
- let defaultValue = configItem.defaultValue;
1195
- if (type === 'input') {
1196
- return pCode === undefined ? pCode : pCode || defaultValue;
1197
- }
1198
- return pCode || defaultValue;
1199
- };
1200
- const handleEdit = (code, val, functionItem) => {
1201
- const functionIndex = handleRuleTypeData.findIndex(
1202
- (m) => m.code === functionItem.code,
1203
- );
1204
- const { ruleClassData } = this.state;
1205
- const { callBack } = this.props;
1206
- parentDetail.extraInfo.execute[functionIndex]['properties'][code] = val;
1207
- parentDetail.extraInfo.execute[functionIndex]['code'] = functionItem.code;
1208
-
1209
- this.setState(
1210
- {
1211
- ruleClassData,
1212
- },
1213
- () => {
1214
- callBack(ruleClassData);
1215
- },
1216
- );
1217
- };
1218
-
1219
- return (
1220
- <>
1221
- {sRuleActionData && sRuleActionData.length ? (
1222
- <div>
1223
- <div className={'rule_action_return_border'}>
1224
- <div className={'rule_border_title'}>动作</div>
1225
- <div>
1226
- {sRuleActionData.map((i, index) => (
1227
- <div>
1228
- <div className={'rule_action_item'}>
1229
- {(i.valueList?.length &&
1230
- i.valueList.map((s) => {
1231
- return this.renderFormCompItem(
1232
- s,
1233
- showValue,
1234
- handleEdit,
1235
- i,
1236
- boxStyle,
1237
- disabled,
1238
- );
1239
- })) || (
1240
- <div style={boxStyle} key={i.functionName}>
1241
- <div>{i.functionName}</div>
1242
- </div>
1243
- )}
1244
- <MinusCircleOutlined
1245
- className={'icon_btn_style'}
1246
- onClick={() => {
1247
- this.handleDeleteRuleAction(classDataIndex, i.code);
1248
- }}
1249
- style={{
1250
- color: 'gray',
1251
- marginLeft: '15px',
1252
- marginTop: '15px',
1253
- display: disabled ? 'none' : 'inline-block',
1254
- }}
1255
- />
1256
- </div>
1257
- </div>
1258
- ))}
1259
- </div>
1260
- </div>
1261
- </div>
1262
- ) : (
1263
- <></>
1264
- )}
1265
- </>
1266
- );
1267
- };
1268
-
1269
- renderRuleTypeItem = (
1270
- itemDetail,
1271
- parentDetail,
1272
- floorIndex,
1273
- classDataIndex,
1274
- ruleTypeData,
1275
- ruleReturnConfig,
1276
- isRuleInstance
1277
- ) => {
1278
- const { modalParams } = this.state;
1279
- const { disabled } = this.props;
1280
- const isHaveRuleTypeData = ruleTypeData?.length;
1281
- const isHaveRuleReturnConfig = ruleReturnConfig?.length;
1282
- const handleRuleTypeData = isHaveRuleTypeData
1283
- ? ruleTypeData.sort((a, b) => a.priority - b.priority)
1284
- : [];
1285
-
1286
- const selectRuleActionCode = isHaveRuleTypeData
1287
- ? itemDetail.execute.filter((i) => i.isSelected).map((s) => s.code)
1288
- : [];
1289
-
1290
- const selectRuleReturnCode = isHaveRuleReturnConfig
1291
- ? _.compact(
1292
- itemDetail.response.filter((i) => i?.enable).map((s) => s?.code),
1293
- )
1294
- : [];
1295
-
1296
- const selectRuleActionData = isHaveRuleTypeData
1297
- ? handleRuleTypeData.filter((r) =>
1298
- selectRuleActionCode.some((s) => s === r.code),
1299
- )
1300
- : [];
1301
-
1302
- const selectRuleReturnData = isHaveRuleReturnConfig
1303
- ? itemDetail.response.length === 1 &&
1304
- !itemDetail.response[0]?.code &&
1305
- itemDetail.response[0]?.enable
1306
- ? [{ ...ruleReturnConfig[0], value: itemDetail.response[0]?.value }]
1307
- : ruleReturnConfig.filter((r) =>
1308
- selectRuleReturnCode.some((s) => s === r.code),
1309
- )
1310
- : [];
1311
-
1312
- const RuleActionItemStyle = {
1313
- display: 'flex',
1314
- // height: '30px',
1315
- // lineHeight: '30px',
1316
- margin: '10px 0px',
1317
- };
1318
-
1319
- const displayNoneActionStyle = (isRuleInstance && !isHaveRuleTypeData)? { display: 'none' }: {};
1320
- const displayNoneReturnValueStyle = (isRuleInstance && !isHaveRuleReturnConfig)? { display: 'none' }: {};
1321
-
1322
- return (
1323
- <div>
1324
- <div style={{ textAlign: 'right', display: 'flex', marginBottom: 10 }}>
1325
- <Button
1326
- disabled={disabled}
1327
- type="link"
1328
- style={displayNoneActionStyle}
1329
- onClick={() => {
1330
- if (isHaveRuleTypeData) {
1331
- this.setState({
1332
- modalParams: {
1333
- ...modalParams,
1334
- type: 'action',
1335
- dataSource: handleRuleTypeData,
1336
- classDataIndex,
1337
- visible: true,
1338
- },
1339
- });
1340
- } else {
1341
- message.warn('未配置执行动作');
1342
- }
1343
- }}
1344
- >
1345
- 新增动作
1346
- </Button>
1347
- <Button
1348
- disabled={disabled}
1349
- type="link"
1350
- style={displayNoneReturnValueStyle}
1351
- onClick={() => {
1352
- if (isHaveRuleReturnConfig) {
1353
- this.setState({
1354
- modalParams: {
1355
- ...modalParams,
1356
- type: 'returnResponse',
1357
- dataSource: ruleReturnConfig,
1358
- classDataIndex,
1359
- visible: true,
1360
- },
1361
- });
1362
- } else {
1363
- message.warn('未配置返回');
1364
- }
1365
- }}
1366
- >
1367
- 新增返回值
1368
- </Button>
1369
- </div>
1370
- {(isHaveRuleTypeData &&
1371
- this.renderActionList(
1372
- itemDetail,
1373
- parentDetail,
1374
- handleRuleTypeData,
1375
- selectRuleActionData,
1376
- classDataIndex,
1377
- disabled,
1378
- RuleActionItemStyle,
1379
- )) ||
1380
- null}
1381
- {(isHaveRuleReturnConfig &&
1382
- this.renderResItem(
1383
- itemDetail,
1384
- parentDetail,
1385
- ruleReturnConfig,
1386
- selectRuleReturnData,
1387
- classDataIndex,
1388
- disabled,
1389
- RuleActionItemStyle,
1390
- )) ||
1391
- null}
1392
- </div>
1393
- );
1394
- };
1395
-
1396
- //添加同一层级条件
1397
- addPeerRule = (itemDetail) => {
1398
- const { ruleClassData } = this.state;
1399
- const { callBack, disabled } = this.props;
1400
- if (disabled) return;
1401
- itemDetail.subExpression.push({
1402
- // "expressionType": "relation",
1403
- operationType: 'relation',
1404
- operationCode: '',
1405
- propertyPath: '',
1406
- params: [],
1407
- paramNames: [],
1408
- });
1409
- this.setState(
1410
- {
1411
- ruleClassData,
1412
- },
1413
- () => {
1414
- callBack(ruleClassData);
1415
- },
1416
- );
1417
- };
1418
-
1419
- //添加子层级条件
1420
- addChildRules = (itemDetail) => {
1421
- const { ruleClassData } = this.state;
1422
- const { callBack } = this.props;
1423
- const initialData = JSON.parse(JSON.stringify(itemDetail));
1424
- delete itemDetail.propertyPath;
1425
- delete itemDetail.params;
1426
- delete itemDetail.paramNames;
1427
- delete itemDetail.dataTypeCode;
1428
- delete itemDetail.elementId;
1429
- delete itemDetail.elementName;
1430
- delete itemDetail.metaObjectCode;
1431
- // itemDetail.expressionType = 'logic';
1432
- itemDetail.operationType = 'logic';
1433
- itemDetail.operationCode = 'and';
1434
- itemDetail.subExpression = [
1435
- initialData,
1436
- {
1437
- // "expressionType": "relation",
1438
- operationType: 'relation',
1439
- type: 20,
1440
- operationCode: '',
1441
- propertyPath: '',
1442
- params: [],
1443
- paramNames: [],
1444
- },
1445
- ];
1446
- this.setState(
1447
- {
1448
- ruleClassData,
1449
- },
1450
- () => {
1451
- callBack(ruleClassData);
1452
- },
1453
- );
1454
- };
1455
-
1456
- handleDeleteRule = (itemDetail, parentDetail, classDataIndex) => {
1457
- const { ruleClassData } = this.state;
1458
- const { callBack, metaObjectCode } = this.props;
1459
- if (parentDetail.ruleName) {
1460
- //删除根规则层级最后一条时整个规则项删除
1461
- ruleClassData.splice(classDataIndex, 1);
1462
- } else {
1463
- let deleteItemIndex = parentDetail.subExpression.findIndex(
1464
- (detailItem) =>
1465
- JSON.stringify(itemDetail) == JSON.stringify(detailItem),
1466
- );
1467
- if (parentDetail.subExpression.length > 2) {
1468
- parentDetail.subExpression.splice(deleteItemIndex, 1);
1469
- } else {
1470
- parentDetail.subExpression.splice(deleteItemIndex, 1);
1471
- // parentDetail.expressionType = parentDetail.subExpression[0].expressionType;
1472
- parentDetail.operationCode =
1473
- parentDetail.subExpression[0].operationCode;
1474
- parentDetail.operationType =
1475
- parentDetail.subExpression[0].operationType;
1476
-
1477
- if (parentDetail.subExpression[0].operationType == 'logic') {
1478
- parentDetail.subExpression = [
1479
- ...parentDetail.subExpression[0].subExpression,
1480
- ];
1481
- } else {
1482
- parentDetail.propertyPath =
1483
- parentDetail.subExpression[0].propertyPath;
1484
- parentDetail.params = [...parentDetail.subExpression[0].params];
1485
- parentDetail.paramNames = parentDetail.subExpression[0].paramNames
1486
- ? [...parentDetail.subExpression[0].paramNames]
1487
- : [];
1488
- parentDetail.metaObjectCode = metaObjectCode || parentDetail.subExpression[0].metaObjectCode;
1489
- parentDetail.elementId = parentDetail.subExpression[0].elementId;
1490
- parentDetail.elementName = parentDetail.subExpression[0].elementName;
1491
- parentDetail.dataTypeCode =
1492
- parentDetail.subExpression[0].dataTypeCode;
1493
- delete parentDetail.subExpression;
1494
- }
1495
- }
1496
- }
1497
- this.setState(
1498
- {
1499
- ruleClassData,
1500
- },
1501
- () => {
1502
- callBack(ruleClassData);
1503
- },
1504
- );
1505
- };
1506
-
1507
- handleLogicalTypeChange = (itemDetail, type) => {
1508
- const { ruleClassData } = this.state;
1509
- const { callBack } = this.props;
1510
- itemDetail.operationCode = type;
1511
- this.setState(
1512
- {
1513
- ruleClassData,
1514
- },
1515
- () => {
1516
- callBack(ruleClassData);
1517
- },
1518
- );
1519
- };
1520
-
1521
- // 新增执行顺序
1522
- handleSelectRuleAction = (keys, classDataIndex, type, callback) => {
1523
- callback();
1524
- const { callBack } = this.props;
1525
- const { ruleClassData } = this.state;
1526
- if (type === 'action') {
1527
- ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1528
- classDataIndex
1529
- ].extraInfo.execute.map((i) => {
1530
- if (i.code && keys.some((r) => r === i.code) && !i.isSelected) {
1531
- return { ...i, isSelected: true };
1532
- }
1533
- return i;
1534
- });
1535
- } else {
1536
- ruleClassData[classDataIndex].extraInfo.response = ruleClassData[
1537
- classDataIndex
1538
- ].extraInfo.response.map((i) => {
1539
- if (i.code && keys.some((r) => r === i.code) && !i.enable) {
1540
- return { ...i, enable: true };
1541
- }
1542
- return i;
1543
- });
1544
- }
1545
- // 处理数据
1546
- this.setState(
1547
- {
1548
- ruleClassData,
1549
- },
1550
- () => {
1551
- callBack(ruleClassData);
1552
- },
1553
- );
1554
- };
1555
-
1556
- handleDeleteRuleAction = (classDataIndex, functionCode) => {
1557
- const { callBack } = this.props;
1558
- const { ruleClassData } = this.state;
1559
- ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1560
- classDataIndex
1561
- ].extraInfo.execute.map((i) => {
1562
- if (i.code && functionCode === i.code && i.isSelected) {
1563
- return { ...i, isSelected: false };
1564
- }
1565
- return i;
1566
- });
1567
- // 处理数据
1568
- this.setState(
1569
- {
1570
- ruleClassData,
1571
- },
1572
- () => {
1573
- callBack(ruleClassData);
1574
- },
1575
- );
1576
- };
1577
-
1578
- render() {
1579
- const { onlyOneRule, callBack, disabled, headerButtonComponentFun } = this.props;
1580
- const { ruleClassData, modalParams } = this.state;
1581
- return (
1582
- <div className={'base_rule'}>
1583
- <div className={'base_rule_content'}>
1584
- {headerButtonComponentFun?headerButtonComponentFun(this.handleAddRule): (
1585
- <div
1586
- style={{
1587
- display: onlyOneRule ? 'none' : 'block',
1588
- }}
1589
- className={'base_rule_line_title'}
1590
- >
1591
- <Button
1592
- disabled={disabled}
1593
- onClick={this.handleAddRule}
1594
- className={'base_rule_btn_style'}
1595
- type="link"
1596
- >
1597
- 新增规则
1598
- </Button>
1599
- </div>
1600
- )}
1601
- <div>{this.renderRuleContent()}</div>
1602
- </div>
1603
- {(modalParams.visible && (
1604
- <Modal
1605
- title={modalParams.type === 'action' ? '新增动作' : '新增返回值'}
1606
- visible={modalParams.visible}
1607
- onCancel={() => {
1608
- this.setState({
1609
- modalParams: { ...modalParams, visible: false },
1610
- });
1611
- }}
1612
- maskClosable={false}
1613
- destroyOnClose
1614
- footer={null}
1615
- >
1616
- <Table
1617
- rowSelection={{
1618
- onChange: (keys, selectRows) => {
1619
- this.handleSelectRuleAction(
1620
- keys,
1621
- modalParams.classDataIndex,
1622
- modalParams?.type,
1623
- () => {
1624
- this.setState({
1625
- modalParams: { ...modalParams, visible: false },
1626
- });
1627
- },
1628
- );
1629
- },
1630
- }}
1631
- columns={
1632
- modalParams.type === 'action'
1633
- ? [
1634
- {
1635
- title: '执行动作名称',
1636
- key: 'functionName',
1637
- dataIndex: 'functionName',
1638
- },
1639
- ]
1640
- : [
1641
- {
1642
- title: '字段名称',
1643
- key: 'name',
1644
- dataIndex: 'name',
1645
- },
1646
- {
1647
- title: '字段编码',
1648
- key: 'code',
1649
- dataIndex: 'code',
1650
- },
1651
- ]
1652
- }
1653
- dataSource={modalParams?.dataSource}
1654
- rowKey={'code'}
1655
- />
1656
- </Modal>
1657
- )) ||
1658
- null}
1659
- </div>
1660
- );
1661
- }
1662
- }
1663
- export default RuleObjectComponent;
1
+ import React, { Component } from 'react';
2
+ // @ts-ignore
3
+ import _ from 'lodash';
4
+ import moment from 'moment';
5
+ import RuleField from './ruleFiled';
6
+ import {
7
+ Select,
8
+ Button,
9
+ Radio,
10
+ Switch,
11
+ Checkbox,
12
+ InputNumber,
13
+ TreeSelect,
14
+ Popover,
15
+ Input,
16
+ DatePicker,
17
+ Table,
18
+ Divider,
19
+ Space,
20
+ Form as AntdForm,
21
+ Modal,
22
+ message,
23
+ } from 'antd';
24
+ import {
25
+ PlusCircleOutlined,
26
+ MinusCircleOutlined,
27
+ DownOutlined,
28
+ } from '@ant-design/icons';
29
+ import './index.less';
30
+ import {
31
+ relateItems,
32
+ getSpecialPropertyCode,
33
+ getPropertyCode,
34
+ isObj,
35
+ } from './util';
36
+ import { getDictionarySource, uuid } from '../../../utils/utils';
37
+ import { coverToParallel } from '../../../utils/TreeUtils';
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 RenderCompItem from './RenderCompItem';
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
+ otherMainInfo: {
158
+ customSelectorConfig: element.customSelectorConfig
159
+ }
160
+ };
161
+ if (element?.propertyList?.length) {
162
+ child.children = this.parseChildTreeData(
163
+ element.propertyList,
164
+ `${element.code}`,
165
+ `${item.name}-${element.name}`,
166
+ item.code,
167
+ );
168
+ child.isLeaf = false;
169
+ } else {
170
+ child.isLeaf = true;
171
+ child.metaObjectCode = item.code;
172
+ }
173
+ return child;
174
+ }),
175
+ }
176
+ : {
177
+ isLeaf: this.props.metaObjectCode ? true : false,
178
+ metaObjectCode: this.props.metaObjectCode || item.code,
179
+ ...item,
180
+ dataTypeCode: item.valueType,
181
+ dataChoiceBusinessType: item.choiceType,
182
+ dataInputBusinessType: item.inputType,
183
+ }),
184
+ };
185
+ });
186
+ this.setState({
187
+ initialRegularList: [...regularDataList],
188
+ ruleTreeData: finalTreeDatas,
189
+ });
190
+ };
191
+
192
+ parseChildTreeData = (list, parentKey, parentTitle, rootObjCode) => {
193
+ return list.map((element) => {
194
+ const infoVo = (element.info && JSON.parse(element.info)) || {};
195
+ if (element.choiceType === 30) {
196
+ this.dynamicDictCodeToRangeIdMap[
197
+ `${rootObjCode}.${parentKey}.${element.code}`
198
+ ] = infoVo?.dictionaryCode;
199
+ } else if (element.choiceType === 20) {
200
+ this.dictCodeToRangeIdMap[
201
+ `${rootObjCode}.${parentKey}.${element.code}`
202
+ ] = infoVo?.dictionaryCode;
203
+ } else if (element.choiceType === 10) {
204
+ // FIXME http://192.168.13.78/mep-fed-group/web/libs/business-component/-/merge_requests/45#note_115669
205
+ const list =
206
+ (Object.keys(infoVo).length &&
207
+ infoVo.enumeration &&
208
+ Object.keys(infoVo.enumeration).map((i) => ({
209
+ code: i,
210
+ name: infoVo.enumeration[i],
211
+ }))) ||
212
+ undefined;
213
+ this.propertyCodeToRangeIdMap[
214
+ `${rootObjCode}.${parentKey}.${element.code}`
215
+ ] = list;
216
+ } else {
217
+ // this.propertyCodeToRangeIdMap[
218
+ // `${rootObjCode}.${parentKey}.${element.code}`
219
+ // ] = Object.keys(infoVo).length ? infoVo : undefined;
220
+ }
221
+ let child = {
222
+ title: `${parentTitle}-${element.name}`,
223
+ key: `${parentKey}.${element.id}`,
224
+ pValue: `${parentKey}.${element.code}`,
225
+ value: element.id,
226
+ id: element.id,
227
+ dataTypeCode: element.valueType,
228
+ dataChoiceBusinessType: element.choiceType,
229
+ dataInputBusinessType: element.inputType,
230
+ info: element.info,
231
+ otherMainInfo: {
232
+ customSelectorConfig: element.customSelectorConfig
233
+ }
234
+ };
235
+ if (element.propertyList) {
236
+ child.children = this.parseChildTreeData(
237
+ element.propertyList,
238
+ `${parentKey}.${element.code}`,
239
+ `${parentTitle}-${element.name}`,
240
+ rootObjCode,
241
+ );
242
+ child.isLeaf = false;
243
+ } else {
244
+ child.isLeaf = true;
245
+ child.metaObjectCode = rootObjCode;
246
+ }
247
+ return child;
248
+ });
249
+ };
250
+
251
+ getDataTypeOperateList = (id) => {
252
+ const { operationList, initialRegularList } = this.state;
253
+ // let typeId = '';
254
+ // initialRegularList.forEach(item => {
255
+ // item.metaObjectResDto.elementResDtos.forEach(element => {
256
+ // if (element.id == id) {
257
+ // typeId = element.dataTypeCode;
258
+ // }
259
+ // })
260
+ // })
261
+ const list =
262
+ operationList.find((item) => item.code == id)?.operationList || [];
263
+ return this.props.isShowAllOperationList ? operationList : list;
264
+ };
265
+
266
+ handleValuesChange = (itemDetail, newValues, newValueNames) => {
267
+ const { ruleClassData } = this.state;
268
+ const { callBack } = this.props;
269
+ itemDetail.params = [...newValues];
270
+ itemDetail.paramNames = [...newValueNames];
271
+ this.setState(
272
+ {
273
+ ruleClassData,
274
+ },
275
+ () => {
276
+ callBack(ruleClassData);
277
+ },
278
+ );
279
+ };
280
+
281
+ setRelateDataList = (classDataItem) => {
282
+ let relateDatas = {};
283
+ relateItems.forEach((relateItem) => {
284
+ this.getRelateData(
285
+ relateItem,
286
+ classDataItem.subExpression || {},
287
+ relateDatas,
288
+ );
289
+ });
290
+ return relateDatas;
291
+ };
292
+
293
+ getRelateData = (relateItem, classDataItem, relateDatas) => {
294
+ if (
295
+ classDataItem?.propertyPath &&
296
+ getPropertyCode(classDataItem.propertyPath) == relateItem.propertyCode
297
+ ) {
298
+ relateDatas[relateItem.propertyCode] = classDataItem.params;
299
+ } else {
300
+ if (classDataItem.subExpression && classDataItem.subExpression.length) {
301
+ classDataItem.subExpression.forEach((classData) => {
302
+ this.getRelateData(relateItem, classData, relateDatas);
303
+ });
304
+ }
305
+ }
306
+ };
307
+
308
+ renderRuleContent = () => {
309
+ const { ruleClassData, currentRuleName, isEdit, editNameIndex } =
310
+ this.state;
311
+ const {
312
+ ruleType,
313
+ callBack,
314
+ accountList = [],
315
+ disabled,
316
+ ruleTypeData,
317
+ canDelete = false,
318
+ ruleReturnConfig = [],
319
+ onlyOneRule,
320
+ onlyCondition,
321
+ onlyAction,
322
+ handleOperatingAction,
323
+ ruleGroupInfo,
324
+ needShowAction = true,
325
+ extraConfig,
326
+ customTitleSubStyle,
327
+ customTitlePreStyle,
328
+ leftRuleDisabled = false,
329
+ returnDisabled = false,
330
+ actionDisabled = false,
331
+ } = this.props;
332
+ const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1; // 业务调用规则实例设计器
333
+ const ruleGroupName = ruleGroupInfo?.ruleGroupList?.[0]?.name || '规则分组';
334
+ const priorityList = (ruleGroupInfo?.groupOtherPriorityList || []).concat(ruleClassData|| []);
335
+ const canChangePriority = ruleGroupInfo?.canChangePriority;
336
+ const isRuleGroupInstance = ruleGroupInfo?.type == 'group-instance'; // 规则组展示规则实例设计器
337
+ const titlePre = {
338
+ position: 'relative',
339
+ top: '-10px',
340
+ left: '20px',
341
+ background: '#fff',
342
+ width: '160px',
343
+ textAlign: 'center',
344
+ ...(customTitlePreStyle || {}),
345
+ }; // height:22
346
+ const titleSubCommon = {
347
+ display: 'flex',
348
+ justifyContent: 'center',
349
+ }
350
+ const titleSubPre = {
351
+ ...titlePre,
352
+ ...titleSubCommon,
353
+ width: '166px',
354
+ top: '-32px', // titlePre(height + top)
355
+ left: '200px', // titlePre(2 * left + width) 左右间距为titlePre的left: 20px
356
+ ...(customTitleSubStyle || {}),
357
+ }; // height: 24
358
+ const titleSubPre2 = {
359
+ ...titlePre,
360
+ ...titleSubCommon,
361
+ width: '240px',
362
+ top: '-56px', // titleSubPre(top + height)
363
+ left: '386px', // titlePre(left + width + 20)
364
+ }
365
+ const ruleListBox = (!onlyOneRule || ruleGroupInfo) ? { border: '1px dashed #d9d9d9', marginBottom: 10, overflowX: 'clip', position: 'relative' } : {};
366
+ const isRuleActionConfig =
367
+ ruleTypeData?.length || ruleReturnConfig?.length;
368
+ return (
369
+ <div>
370
+ {ruleClassData.map((item, classDataIndex) => {
371
+ let extraInfo = {};
372
+ if (isRuleActionConfig) {
373
+ const { response = [] } = item.extraInfo;
374
+ extraInfo = {
375
+ ...item.extraInfo,
376
+ response:
377
+ Object.prototype.toString.call(response) === '[object Object]'
378
+ ? [response]
379
+ : Array.isArray(response)
380
+ ? response
381
+ : [],
382
+ };
383
+ }
384
+ let relateDatas = this.setRelateDataList(item);
385
+ const sActionProps = {
386
+ extraInfo,
387
+ ruleTypeData,
388
+ item,
389
+ classDataIndex,
390
+ handleOperatingAction,
391
+ disabled,
392
+ };
393
+ return (
394
+ // rule-line-class方便开发自定义样式,勿删
395
+ <div className={'rule-line-class'} style={ruleListBox}>
396
+ {!onlyOneRule && !ruleGroupInfo && (
397
+ <div style={titlePre}>规则{classDataIndex + 1}</div>
398
+ )}
399
+ {ruleGroupInfo && (
400
+ <>
401
+ <div style={titlePre}>
402
+ <EllipsisTooltip
403
+ visible={true}
404
+ maxLength={10}
405
+ title={ruleGroupName}
406
+ />
407
+ </div>
408
+ {isRuleInstance && (
409
+ <div style={titleSubPre}>
410
+ <span
411
+ style={{
412
+ marginRight: 10,
413
+ display: 'block',
414
+ width: '100px',
415
+ textAlign: 'right',
416
+ overflow: 'hidden',
417
+ textOverflow:'ellipsis',
418
+ whiteSpace: 'nowrap'
419
+ }}>
420
+ 优先级
421
+ </span>
422
+ <Select
423
+ size='small'
424
+ disabled={canChangePriority ? !canChangePriority : ( disabled || leftRuleDisabled)}
425
+ style={{ width: 100 }}
426
+ value={item.priority}
427
+ onChange={(v) => {
428
+ // 因为存在页签,前端校验不准确;而且若选择优先级之后想交换改也不方便,故交由后端校验
429
+ // const isRepeate = priorityList.some((r) => r.priority == v)
430
+ // if(isRepeate) {
431
+ // message.warn('优先级不允许重复')
432
+ // }
433
+ // item.priority = isRepeate ? (item.priority||null) : v;
434
+ item.priority = v
435
+ this.setState(
436
+ {
437
+ ruleClassData,
438
+ },
439
+ () => {
440
+ callBack(ruleClassData);
441
+ },
442
+ );
443
+ }}
444
+ >
445
+ {priorityList?.map((s,sindex) => (
446
+ <Option key={sindex+1} value={sindex+1}>{sindex+1}</Option>
447
+ ))}
448
+ </Select>
449
+ </div>
450
+ ) || null}
451
+ {isRuleGroupInstance && (
452
+ <div style={titleSubPre2}>
453
+ <span style={{ marginRight: 10 }}>业务编码</span>
454
+ <EllipsisTooltip
455
+ visible={true}
456
+ maxLength={24}
457
+ title={item.extStrField01 || ''}
458
+ />
459
+ </div>
460
+ )}
461
+ {/* 规则组额外extStrField */}
462
+ {
463
+ extraConfig && extraConfig.map((extraItem, index) => (
464
+ <div style={titleSubPre}>
465
+ <span
466
+ style={{
467
+ marginRight: 10,
468
+ display: 'block',
469
+ width: '100px',
470
+ textAlign: 'right',
471
+ overflow: 'hidden',
472
+ textOverflow:'ellipsis',
473
+ whiteSpace: 'nowrap'
474
+ }}
475
+ >
476
+ {extraItem?.label}
477
+ </span>
478
+ <Select
479
+ size='small'
480
+ style={{ width: 100 }}
481
+ mode={extraItem?.mode || null}
482
+ disabled={disabled || leftRuleDisabled || returnDisabled || actionDisabled}
483
+ value={ extraItem?.mode === 'multiple' ? (item[extraItem?.code] ? item[extraItem?.code].split(',') : []) : item[extraItem?.code] }
484
+ onChange={(v) => {
485
+ item[extraItem?.code] = Array.isArray(v) ? v.join(',') : v;
486
+ this.setState(
487
+ {
488
+ ruleClassData,
489
+ },
490
+ () => {
491
+ callBack(ruleClassData);
492
+ },
493
+ );
494
+ }}
495
+ >
496
+ {extraItem?.optionList?.map((s,sindex) => (
497
+ <Option value={s?.value}>{s?.text}</Option>
498
+ ))}
499
+ </Select>
500
+ </div>
501
+ ))
502
+ }
503
+ </>
504
+ )}
505
+ <div
506
+ style={{
507
+ textAlign: 'right',
508
+ display: canDelete ? 'block' : 'none',
509
+ position: 'absolute',
510
+ right: '5px',
511
+ top: '5px',
512
+ }}
513
+ >
514
+ <Button
515
+ disabled={disabled || (leftRuleDisabled && returnDisabled && actionDisabled)}
516
+ onClick={() => {
517
+ const { ruleClassData } = this.state;
518
+ ruleClassData.splice(classDataIndex, 1);
519
+ this.setState(
520
+ {
521
+ ruleClassData,
522
+ },
523
+ () => {
524
+ callBack(ruleClassData);
525
+ },
526
+ );
527
+ }}
528
+ type="link"
529
+ danger
530
+ >
531
+ 删除规则
532
+ </Button>
533
+ </div>
534
+ <div>
535
+ {/* <div style={{ display: isEdit && editNameIndex == index ? 'none' : 'block' }}>
536
+ <span className={'rule_name_title}>
537
+ {item.ruleName}
538
+ </span>
539
+ <EditOutlined
540
+ onClick={() => {
541
+ this.setState({
542
+ editNameIndex: index,
543
+ currentRuleName: item.ruleName,
544
+ isEdit: true
545
+ })
546
+ }}
547
+ />
548
+ </div> */}
549
+ <div
550
+ style={{
551
+ display:
552
+ isEdit && editNameIndex == index ? 'block' : 'none',
553
+ marginTop: '10px',
554
+ }}
555
+ >
556
+ <Input
557
+ disabled={disabled || (leftRuleDisabled && returnDisabled && actionDisabled)}
558
+ value={currentRuleName}
559
+ style={{ width: '200px' }}
560
+ onChange={(e) => {
561
+ this.setState({
562
+ currentRuleName: e.target.value,
563
+ });
564
+ }}
565
+ />
566
+ <Button
567
+ disabled={disabled || (leftRuleDisabled && returnDisabled && actionDisabled)}
568
+ type="link"
569
+ onClick={() => {
570
+ const { ruleClassData, currentRuleName } = this.state;
571
+ ruleClassData[editNameIndex].ruleName = currentRuleName;
572
+ this.setState({
573
+ ruleClassData,
574
+ isEdit: false,
575
+ });
576
+ }}
577
+ >
578
+ 保存
579
+ </Button>
580
+ <Button
581
+ disabled={disabled}
582
+ type="link"
583
+ onClick={() => {
584
+ this.setState({
585
+ isEdit: false,
586
+ });
587
+ }}
588
+ >
589
+ 取消
590
+ </Button>
591
+ </div>
592
+ </div>
593
+ <div>
594
+ {(onlyAction && <RenderSpecificAction {...sActionProps} />) || (
595
+ <div className={'base_rule_line_content'}>
596
+ <div className={'base_rule_item2'}>
597
+ {item.subExpression &&
598
+ this.renderRuleItem(
599
+ item.subExpression,
600
+ item,
601
+ 1,
602
+ classDataIndex,
603
+ relateDatas,
604
+ )}
605
+ </div>
606
+ {needShowAction && (
607
+ <div className={'base_rule_item3'}>
608
+ {(extraInfo &&
609
+ isRuleActionConfig &&
610
+ (!onlyCondition || !onlyAction) &&
611
+ this.renderRuleTypeItem(
612
+ extraInfo,
613
+ item,
614
+ 1,
615
+ classDataIndex,
616
+ ruleTypeData,
617
+ ruleReturnConfig,
618
+ isRuleInstance
619
+ )) ||
620
+ null}
621
+ </div>
622
+ ) || null}
623
+ </div>
624
+ )}
625
+ </div>
626
+ </div>
627
+ );
628
+ })}
629
+ </div>
630
+ );
631
+ };
632
+
633
+ handleAddRule = () => {
634
+ const { ruleClassData } = this.state;
635
+ const { callBack, ruleTypeData=[], ruleGroupInfo, ruleReturnConfig=[] } = this.props;
636
+ const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1;
637
+ const initKongData = {
638
+ ruleName: `规则${ruleClassData?.length + 1}`,
639
+ subExpression: {
640
+ // "expressionType": "relation",
641
+ operationType: 'relation',
642
+ propertyPath: '',
643
+ params: [],
644
+ paramNames: [],
645
+ },
646
+ extraInfo: {
647
+ response: ruleReturnConfig?.map((s) => {
648
+ return {
649
+ code: s?.code,
650
+ value: s?.defaultValue || '',
651
+ enable: false,
652
+ };
653
+ })||[],
654
+ execute: ruleTypeData?.map((s) => {
655
+ return {
656
+ priority: 1,
657
+ code: s.code,
658
+ properties: {
659
+ configPropertyCode: 'configPropertyValue',
660
+ },
661
+ };
662
+ })||[],
663
+ },
664
+ }
665
+ const initTemplateData = ruleGroupInfo?.templateData && Object.keys(ruleGroupInfo?.templateData)?.length ? {
666
+ ruleName: `规则${ruleClassData?.length + 1}`,
667
+ ..._.cloneDeep(ruleGroupInfo?.templateData)
668
+ } : initKongData;
669
+ const initNewData = isRuleInstance ? initTemplateData : initKongData
670
+ ruleClassData.push(initNewData);
671
+ this.setState(
672
+ {
673
+ ruleClassData,
674
+ },
675
+ () => {
676
+ callBack(ruleClassData);
677
+ },
678
+ );
679
+ };
680
+
681
+ renderRuleItem = (
682
+ itemDetail,
683
+ parentDetail,
684
+ floorIndex,
685
+ classDataIndex,
686
+ relateDatas,
687
+ ) => {
688
+ const { ruleTreeData } = this.state;
689
+ const {
690
+ callBack,
691
+ initialThresholdQuery = {},
692
+ disabled,
693
+ systemVariableList,
694
+ leftRuleDisabled,
695
+ } = this.props;
696
+ let thresholdQuery = {
697
+ ...initialThresholdQuery,
698
+ ...relateDatas,
699
+ };
700
+ let finalIndex = floorIndex + 1;
701
+ let queryIdentify = '';
702
+ let queryIdentifyType = '';
703
+ if (
704
+ this.propertyCodeToRangeIdMap[
705
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
706
+ ]
707
+ ) {
708
+ queryIdentify =
709
+ this.propertyCodeToRangeIdMap[
710
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
711
+ ];
712
+ queryIdentifyType = Array.isArray(queryIdentify)
713
+ ? 'objectPropertyListIdentify'
714
+ : 'objectPropertyCodeIdentify';
715
+ } else if (
716
+ getSpecialPropertyCode(getPropertyCode(itemDetail.propertyPath))
717
+ ) {
718
+ queryIdentify = getSpecialPropertyCode(
719
+ getPropertyCode(itemDetail.propertyPath),
720
+ );
721
+ queryIdentifyType = 'specialPropertyIdentify';
722
+ } else if (
723
+ this.dictCodeToRangeIdMap[
724
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
725
+ ]
726
+ ) {
727
+ queryIdentify =
728
+ this.dictCodeToRangeIdMap[
729
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
730
+ ];
731
+ queryIdentifyType = 'dictCodeIdentify';
732
+ } else if (
733
+ this.dynamicDictCodeToRangeIdMap[
734
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
735
+ ]
736
+ ) {
737
+ queryIdentify =
738
+ this.dynamicDictCodeToRangeIdMap[
739
+ `${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`
740
+ ];
741
+ queryIdentifyType = 'dynamicDictCodeIdentify';
742
+ }
743
+
744
+ const parallelTreeData = coverToParallel(ruleTreeData, []) || [];
745
+ const currentTreeItem =
746
+ itemDetail?.elementId &&
747
+ parallelTreeData.find((i) => (i?.key?.indexOf('.') > -1 ? i.id : i.key) === itemDetail?.elementId);
748
+ const dataChoiceBusinessType = currentTreeItem?.dataChoiceBusinessType;
749
+ const dataInputBusinessType = currentTreeItem?.dataInputBusinessType;
750
+ return (
751
+ <div
752
+ className={'rule_line_content'}
753
+ style={{ display: 'flex', marginBottom: '0px', padding: '10px 0px' }}
754
+ >
755
+ <div
756
+ className={'logical_operate_content'}
757
+ style={{
758
+ display: itemDetail.operationType == 'logic' ? 'block' : 'none',
759
+ width: '60px',
760
+ zIndex: 20,
761
+ }}
762
+ >
763
+ <Popover
764
+ content={
765
+ <div>
766
+ <p
767
+ className={'choose_logical_type'}
768
+ onClick={() => {
769
+ this.handleLogicalTypeChange(itemDetail, 'or');
770
+ }}
771
+ >
772
+ 或者
773
+ </p>
774
+ <p
775
+ className={'choose_logical_type'}
776
+ onClick={() => {
777
+ this.handleLogicalTypeChange(itemDetail, 'and');
778
+ }}
779
+ >
780
+ 并且
781
+ </p>
782
+ </div>
783
+ }
784
+ trigger="focus"
785
+ >
786
+ <Button
787
+ disabled={disabled || leftRuleDisabled}
788
+ type="link"
789
+ className={'logical_item_btn'}
790
+ >
791
+ {itemDetail?.operationCode == 'or' ? '或者' : '并且'}
792
+ <DownOutlined style={{ marginLeft: '6px' }} />
793
+ </Button>
794
+ </Popover>
795
+ <span className={'top_line'}></span>
796
+ <span className={'bottom_line'}></span>
797
+ </div>
798
+
799
+ <div style={{ flexGrow: 1 }}>
800
+ {itemDetail.operationType == 'logic' ? (
801
+ itemDetail?.subExpression?.map((item1) => {
802
+ return this.renderRuleItem(
803
+ item1,
804
+ itemDetail,
805
+ finalIndex,
806
+ classDataIndex,
807
+ relateDatas,
808
+ );
809
+ })
810
+ ) : (
811
+ <div style={{ display: 'flex', alignItems: 'center' }}>
812
+ {/* todo */}
813
+ <TreeSelect
814
+ showSearch
815
+ treeNodeFilterProp="title"
816
+ value={itemDetail.elementId}
817
+ disabled={disabled || leftRuleDisabled}
818
+ onChange={(value, name, nodeInfo) => {
819
+ if (!nodeInfo.triggerNode.props.isLeaf) return; //只有最末端叶子节点可选中
820
+ const { ruleClassData } = this.state;
821
+ itemDetail.propertyPath = nodeInfo.triggerNode.props.pValue;
822
+ itemDetail.params = [];
823
+ itemDetail.paramNames = [];
824
+ itemDetail.operationCode = '';
825
+ itemDetail.elementId = nodeInfo.triggerNode.props.id;
826
+ itemDetail.elementName = nodeInfo.triggerNode.props.title;
827
+ itemDetail.dataTypeCode =
828
+ nodeInfo.triggerNode.props.dataTypeCode;
829
+ itemDetail.metaObjectCode =
830
+ nodeInfo.triggerNode.props.metaObjectCode;
831
+ itemDetail.isInsertParam = false;
832
+ this.setState(
833
+ {
834
+ ruleClassData,
835
+ },
836
+ () => {
837
+ callBack(ruleClassData);
838
+ },
839
+ );
840
+ }}
841
+ style={{ width: '200px' }}
842
+ treeData={ruleTreeData}
843
+ />
844
+ <Select
845
+ value={itemDetail?.operationCode || ''}
846
+ disabled={disabled || leftRuleDisabled}
847
+ style={{ width: '150px', marginLeft: '10px' }}
848
+ onChange={(value) => {
849
+ const { ruleClassData } = this.state;
850
+ itemDetail.operationCode = value;
851
+ this.setState(
852
+ {
853
+ ruleClassData,
854
+ },
855
+ () => {
856
+ callBack(ruleClassData);
857
+ },
858
+ );
859
+ }}
860
+ >
861
+ {this.getDataTypeOperateList(itemDetail.dataTypeCode).map(
862
+ (item) => (
863
+ <Select.Option value={item.code} key={item.code}>
864
+ {item.name}
865
+ </Select.Option>
866
+ ),
867
+ )}
868
+ </Select>
869
+ {!itemDetail?.isInsertParam ? (
870
+ <RuleField
871
+ customerWidth={this.props.customerWidth}
872
+ selectOperation={itemDetail?.operationCode || ''}
873
+ disabled={disabled || leftRuleDisabled}
874
+ initialThresholdQuery={thresholdQuery}
875
+ dataTypeCode={itemDetail?.dataTypeCode || ''}
876
+ dataChoiceBusinessType={dataChoiceBusinessType || ''}
877
+ dataInputBusinessType={dataInputBusinessType || ''}
878
+ itemDetail={itemDetail}
879
+ queryIdentifyType={queryIdentifyType}
880
+ queryIdentify={queryIdentify}
881
+ propertyCode={getPropertyCode(itemDetail.propertyPath)}
882
+ // propertyCode={`${itemDetail.metaObjectCode}.${itemDetail.propertyPath}`}
883
+ relateDatas={relateDatas}
884
+ others={currentTreeItem?.otherMainInfo}
885
+ values={itemDetail.params || []}
886
+ valueNames={itemDetail.paramNames || []}
887
+ callback={(newValues, newValueNames) => {
888
+ this.handleValuesChange(
889
+ itemDetail,
890
+ newValues,
891
+ newValueNames,
892
+ );
893
+ }}
894
+ />
895
+ ) : null}
896
+ <Select
897
+ disabled={disabled || leftRuleDisabled}
898
+ value={
899
+ itemDetail?.systemCode || itemDetail?.params?.[0]?.replace('{', '').replace('}', '') ||
900
+ ''
901
+ } // systemCode兼容用户结算组织那边使用规则
902
+ style={{
903
+ width: '250px',
904
+ marginLeft: '10px',
905
+ display: itemDetail?.isInsertParam ? '' : 'none',
906
+ }}
907
+ onChange={(value) => {
908
+ const { ruleClassData } = this.state;
909
+ itemDetail.params = [(value && `{${value}}`) || ''];
910
+ const name = systemVariableList.find(
911
+ (i) => i.code == value,
912
+ )?.name;
913
+ itemDetail.paramNames = [name || ''];
914
+ itemDetail.systemCode = value;
915
+ this.setState(
916
+ {
917
+ ruleClassData,
918
+ },
919
+ () => {
920
+ callBack(ruleClassData);
921
+ },
922
+ );
923
+ }}
924
+ >
925
+ {systemVariableList?.length
926
+ ? systemVariableList.map((item) => (
927
+ <Select.Option value={item.code} key={item.code}>
928
+ {item.name}
929
+ </Select.Option>
930
+ ))
931
+ : null}
932
+ </Select>
933
+ <PlusCircleOutlined
934
+ className={'icon_btn_style'}
935
+ onClick={() => {
936
+ this.addChildRules(itemDetail);
937
+ }}
938
+ style={{
939
+ color: '#008fe0',
940
+ marginLeft: '15px',
941
+ display: floorIndex > 4 || disabled || leftRuleDisabled ? 'none' : 'inline-block',
942
+ }}
943
+ />
944
+ <MinusCircleOutlined
945
+ className={'icon_btn_style'}
946
+ onClick={() => {
947
+ this.handleDeleteRule(
948
+ itemDetail,
949
+ parentDetail,
950
+ classDataIndex,
951
+ );
952
+ }}
953
+ style={{
954
+ color: 'gray',
955
+ display: disabled || leftRuleDisabled ? 'none' : 'inline-block',
956
+ }}
957
+ />
958
+ <Button
959
+ type="link"
960
+ disabled={
961
+ disabled || leftRuleDisabled || (itemDetail.operationCode === '' || !itemDetail.operationCode
962
+ ? true
963
+ : false)
964
+ }
965
+ onClick={() => {
966
+ const { ruleClassData } = this.state;
967
+ if (systemVariableList && Array.isArray(systemVariableList) && systemVariableList.length && systemVariableList[0].code!== '-1' ) {
968
+ itemDetail.isInsertParam = !itemDetail.isInsertParam;
969
+ if (itemDetail.isInsertParam) {
970
+ itemDetail.type = 10;
971
+ itemDetail.paramNames = [];
972
+ itemDetail.params = [];
973
+ } else {
974
+ itemDetail.systemCode = null;
975
+ }
976
+
977
+ this.setState(
978
+ {
979
+ ruleClassData,
980
+ },
981
+ () => {
982
+ callBack(ruleClassData);
983
+ },
984
+ );
985
+ } else {
986
+ message.warn('未配置规则变量');
987
+ }
988
+ }}
989
+ >
990
+ {itemDetail?.isInsertParam ? '取消插入参数' : '插入参数'}
991
+ </Button>
992
+ </div>
993
+ )}
994
+ <div
995
+ style={{
996
+ display:
997
+ itemDetail.operationType == 'logic' && !disabled && !leftRuleDisabled
998
+ ? 'block'
999
+ : 'none',
1000
+ }}
1001
+ >
1002
+ <span
1003
+ style={{ color: '#008fe0', cursor: 'pointer' }}
1004
+ type="link"
1005
+ onClick={() => {
1006
+ this.addPeerRule(itemDetail);
1007
+ }}
1008
+ >
1009
+ <PlusCircleOutlined
1010
+ style={{
1011
+ color: '#008fe0',
1012
+ fontSize: '14px',
1013
+ marginRight: '5px',
1014
+ }}
1015
+ />
1016
+ 添加条件
1017
+ </span>
1018
+ </div>
1019
+ </div>
1020
+ </div>
1021
+ );
1022
+ };
1023
+
1024
+ handleEditExtraInfoResponse = (code, val, parentDetail,classDataIndex, key) => {
1025
+ const { ruleClassData } = this.state;
1026
+ const { callBack } = this.props;
1027
+ parentDetail.extraInfo.response = parentDetail.extraInfo.response.map((i) => {
1028
+ if (i.code && key === i.code) {
1029
+ i[code] = val;
1030
+ return i;
1031
+ }
1032
+ return i;
1033
+ });
1034
+ ruleClassData[classDataIndex].extraInfo.response = ruleClassData[
1035
+ classDataIndex
1036
+ ].extraInfo.response.map((i) => {
1037
+ if (i.code && key === i.code) {
1038
+ i[code] = val;
1039
+ return i;
1040
+ }
1041
+ return i;
1042
+ });
1043
+
1044
+ this.setState(
1045
+ {
1046
+ ruleClassData,
1047
+ },
1048
+ () => {
1049
+ callBack(ruleClassData);
1050
+ },
1051
+ );
1052
+ };
1053
+ // 场景需要返回值2022.11.15
1054
+ renderResItem = (
1055
+ itemDetail,
1056
+ parentDetail,
1057
+ ruleReturnConfig,
1058
+ selectRuleReturnData,
1059
+ classDataIndex,
1060
+ disabled,
1061
+ boxStyle,
1062
+ returnDisabled,
1063
+ ) => {
1064
+ const isRightText = ruleReturnConfig?.rightText?.length;
1065
+
1066
+ const showValue = (code, type, functionItem, configItem) => {
1067
+ let defaultValue = configItem.defaultValue;
1068
+ const pCode = itemDetail.response?.find((i) => i.code == code)?.value;
1069
+ if (type === 'input') {
1070
+ return pCode === undefined ? pCode : pCode || defaultValue;
1071
+ }
1072
+ if(['date','dateTime','rangeTime'].includes(type)) {
1073
+ if(['date','dateTime'].includes(type)) return pCode ? moment(pCode) : pCode;
1074
+ if(['rangeTime'].includes(type)) {
1075
+ const newPCode = Array.isArray(pCode) ? pCode : pCode?.split(',');
1076
+ return pCode ? newPCode?.map((i) => moment(i)) : pCode;
1077
+ }
1078
+ }
1079
+ if(configItem?.inputType === 30) {
1080
+ const newPCode = Array.isArray(pCode) ? pCode?.map(s => isObj(s) ? s : ({ key: s, value: s })) : pCode?.split(',')?.map(s => ({ key: s, value: s }));
1081
+ return newPCode || pCode || defaultValue;
1082
+ }
1083
+ return pCode || defaultValue;
1084
+ };
1085
+ const handleEdit = (code, val, functionItem) => {
1086
+ let value = val;
1087
+ if (isObj(code)) {
1088
+ Object.keys(code).forEach((ite) => {
1089
+ this.handleEditExtraInfoResponse(ite, code[ite], parentDetail,classDataIndex);
1090
+ });
1091
+ return;
1092
+ }
1093
+ if (Array.isArray(val) && val?.length) {
1094
+ value = val.map((m) => m.value || m).join(',');
1095
+ }
1096
+ if (isObj(val)) {
1097
+ value = val.value || val.PCDCode?.join('/');
1098
+ }
1099
+ this.handleEditExtraInfoResponse('value', value, parentDetail,classDataIndex,code);
1100
+ };
1101
+
1102
+ return (
1103
+ <>
1104
+ {selectRuleReturnData && selectRuleReturnData.length ? (
1105
+ <div>
1106
+ <div className={'rule_action_return_border'}>
1107
+ <div className={'rule_border_title'}>返回值</div>
1108
+ <div>
1109
+ {selectRuleReturnData.map((item) => (
1110
+ <div style={{ display: 'flex' }}>
1111
+ {this.renderFormCompItem(
1112
+ item,
1113
+ showValue,
1114
+ handleEdit,
1115
+ {},
1116
+ boxStyle,
1117
+ disabled,
1118
+ returnDisabled,
1119
+ )}
1120
+ <MinusCircleOutlined
1121
+ className={'icon_btn_style'}
1122
+ onClick={() => {
1123
+ this.handleEditExtraInfoResponse(
1124
+ 'enable',
1125
+ false,
1126
+ parentDetail,
1127
+ classDataIndex,
1128
+ item.code,
1129
+ );
1130
+ }}
1131
+ style={{
1132
+ color: 'gray',
1133
+ marginLeft: isRightText ? '100px' : '15px',
1134
+ marginTop: '15px',
1135
+ display: disabled || returnDisabled ? 'none' : 'inline-block',
1136
+ }}
1137
+ />
1138
+ </div>
1139
+ ))}
1140
+ </div>
1141
+ </div>
1142
+ </div>
1143
+ ) : (
1144
+ <></>
1145
+ )}
1146
+ </>
1147
+ );
1148
+ };
1149
+
1150
+
1151
+ renderFormCompItem = (
1152
+ config,
1153
+ showValue,
1154
+ handleEdit,
1155
+ parentItem,
1156
+ boxStyle,
1157
+ disabled,
1158
+ returnOrActionDisabled,
1159
+ ) => {
1160
+ if (!config) return;
1161
+ return (
1162
+ <div style={boxStyle}>
1163
+ {(config?.leftText && (
1164
+ <div style={{ flex: 'none', marginRight: 10 }}>
1165
+ {config?.required && <span className="requiredMark" />}
1166
+ {config.leftText}
1167
+ </div>
1168
+ )) ||
1169
+ null}
1170
+ {(!config?.leftText && config?.rightText && config?.required && (
1171
+ <div style={{ flex: 'none', marginRight: 10 }}>
1172
+ <span className="requiredMark" />
1173
+ </div>
1174
+ )) ||
1175
+ null}
1176
+ <RenderCompItem regularDataList={this.props.regularDataList} ites={config} showValue={(a, b, c = parentItem, d = config) => showValue(a, b, c, d)} handleEdit={(a, b, c = parentItem, d = config) => handleEdit(a, b, c, d)} disabled={disabled || returnOrActionDisabled}></RenderCompItem>
1177
+ {(config?.rightText && (
1178
+ <div style={{ flex: 'none', marginLeft: 10 }}>{config.rightText}</div>
1179
+ )) ||
1180
+ null}
1181
+ </div>
1182
+ );
1183
+ };
1184
+
1185
+ renderActionList = (
1186
+ itemDetail,
1187
+ parentDetail,
1188
+ handleRuleTypeData,
1189
+ sRuleActionData,
1190
+ classDataIndex,
1191
+ disabled,
1192
+ boxStyle,
1193
+ actionDisabled,
1194
+ ) => {
1195
+ const showValue = (code, type, functionItem, configItem) => {
1196
+ const functionIndex = handleRuleTypeData.findIndex(
1197
+ (m) => m.code === functionItem.code,
1198
+ );
1199
+ const pCode =
1200
+ itemDetail.execute[functionIndex] &&
1201
+ itemDetail.execute[functionIndex].properties[code];
1202
+ let defaultValue = configItem.defaultValue;
1203
+ if (type === 'input') {
1204
+ return pCode === undefined ? pCode : pCode || defaultValue;
1205
+ }
1206
+ return pCode || defaultValue;
1207
+ };
1208
+ const handleEdit = (code, val, functionItem) => {
1209
+ const functionIndex = handleRuleTypeData.findIndex(
1210
+ (m) => m.code === functionItem.code,
1211
+ );
1212
+ const { ruleClassData } = this.state;
1213
+ const { callBack } = this.props;
1214
+ parentDetail.extraInfo.execute[functionIndex]['properties'][code] = val;
1215
+ parentDetail.extraInfo.execute[functionIndex]['code'] = functionItem.code;
1216
+
1217
+ this.setState(
1218
+ {
1219
+ ruleClassData,
1220
+ },
1221
+ () => {
1222
+ callBack(ruleClassData);
1223
+ },
1224
+ );
1225
+ };
1226
+
1227
+ return (
1228
+ <>
1229
+ {sRuleActionData && sRuleActionData.length ? (
1230
+ <div>
1231
+ <div className={'rule_action_return_border'}>
1232
+ <div className={'rule_border_title'}>动作</div>
1233
+ <div>
1234
+ {sRuleActionData.map((i, index) => (
1235
+ <div>
1236
+ <div className={'rule_action_item'}>
1237
+ {(i.valueList?.length &&
1238
+ i.valueList.map((s) => {
1239
+ return this.renderFormCompItem(
1240
+ s,
1241
+ showValue,
1242
+ handleEdit,
1243
+ i,
1244
+ boxStyle,
1245
+ disabled,
1246
+ actionDisabled,
1247
+ );
1248
+ })) || (
1249
+ <div style={boxStyle} key={i.functionName}>
1250
+ <div>{i.functionName}</div>
1251
+ </div>
1252
+ )}
1253
+ <MinusCircleOutlined
1254
+ className={'icon_btn_style'}
1255
+ onClick={() => {
1256
+ this.handleDeleteRuleAction(classDataIndex, i.code);
1257
+ }}
1258
+ style={{
1259
+ color: 'gray',
1260
+ marginLeft: '15px',
1261
+ marginTop: '15px',
1262
+ display: disabled || actionDisabled ? 'none' : 'inline-block',
1263
+ }}
1264
+ />
1265
+ </div>
1266
+ </div>
1267
+ ))}
1268
+ </div>
1269
+ </div>
1270
+ </div>
1271
+ ) : (
1272
+ <></>
1273
+ )}
1274
+ </>
1275
+ );
1276
+ };
1277
+
1278
+ renderRuleTypeItem = (
1279
+ itemDetail,
1280
+ parentDetail,
1281
+ floorIndex,
1282
+ classDataIndex,
1283
+ ruleTypeData,
1284
+ ruleReturnConfig,
1285
+ isRuleInstance
1286
+ ) => {
1287
+ const { modalParams } = this.state;
1288
+ const { disabled, actionDisabled = false, returnDisabled = false, noActionValue = false, noReturnValue = false } = this.props;
1289
+ const isHaveRuleTypeData = ruleTypeData?.length;
1290
+ const isHaveRuleReturnConfig = ruleReturnConfig?.length;
1291
+ const handleRuleTypeData = isHaveRuleTypeData
1292
+ ? ruleTypeData.sort((a, b) => a.priority - b.priority)
1293
+ : [];
1294
+
1295
+ const selectRuleActionCode = isHaveRuleTypeData
1296
+ ? itemDetail.execute.filter((i) => i.isSelected).map((s) => s.code)
1297
+ : [];
1298
+
1299
+ const selectRuleReturnCode = isHaveRuleReturnConfig
1300
+ ? _.compact(
1301
+ itemDetail.response.filter((i) => i?.enable).map((s) => s?.code),
1302
+ )
1303
+ : [];
1304
+
1305
+ const selectRuleActionData = isHaveRuleTypeData
1306
+ ? handleRuleTypeData.filter((r) =>
1307
+ selectRuleActionCode.some((s) => s === r.code),
1308
+ )
1309
+ : [];
1310
+
1311
+ const selectRuleReturnData = isHaveRuleReturnConfig
1312
+ ? itemDetail.response.length === 1 &&
1313
+ !itemDetail.response[0]?.code &&
1314
+ itemDetail.response[0]?.enable
1315
+ ? [{ ...ruleReturnConfig[0], value: itemDetail.response[0]?.value }]
1316
+ : ruleReturnConfig.filter((r) =>
1317
+ selectRuleReturnCode.some((s) => s === r.code),
1318
+ )
1319
+ : [];
1320
+
1321
+ const RuleActionItemStyle = {
1322
+ display: 'flex',
1323
+ // height: '30px',
1324
+ // lineHeight: '30px',
1325
+ margin: '10px 0px',
1326
+ };
1327
+
1328
+ const displayNoneActionStyle = (isRuleInstance && !isHaveRuleTypeData)? { display: 'none' }: {};
1329
+ const displayNoneReturnValueStyle = (isRuleInstance && !isHaveRuleReturnConfig)? { display: 'none' }: {};
1330
+
1331
+ return (
1332
+ <div>
1333
+ <div style={{ textAlign: 'right', display: 'flex', marginBottom: 10 }}>
1334
+ {
1335
+ !noActionValue ?
1336
+ <Button
1337
+ disabled={disabled || actionDisabled}
1338
+ type="link"
1339
+ style={displayNoneActionStyle}
1340
+ onClick={() => {
1341
+ if (isHaveRuleTypeData) {
1342
+ this.setState({
1343
+ modalParams: {
1344
+ ...modalParams,
1345
+ type: 'action',
1346
+ dataSource: handleRuleTypeData,
1347
+ classDataIndex,
1348
+ visible: true,
1349
+ },
1350
+ });
1351
+ } else {
1352
+ message.warn('未配置执行动作');
1353
+ }
1354
+ }}
1355
+ >
1356
+ 新增动作
1357
+ </Button>: <></>
1358
+ }
1359
+ {
1360
+ !noReturnValue ?
1361
+ <Button
1362
+ disabled={disabled || returnDisabled}
1363
+ type="link"
1364
+ style={displayNoneReturnValueStyle}
1365
+ onClick={() => {
1366
+ if (isHaveRuleReturnConfig) {
1367
+ this.setState({
1368
+ modalParams: {
1369
+ ...modalParams,
1370
+ type: 'returnResponse',
1371
+ dataSource: ruleReturnConfig,
1372
+ classDataIndex,
1373
+ visible: true,
1374
+ },
1375
+ });
1376
+ } else {
1377
+ message.warn('未配置返回');
1378
+ }
1379
+ }}
1380
+ >
1381
+ 新增返回值
1382
+ </Button> : <></>
1383
+ }
1384
+ </div>
1385
+ {(isHaveRuleTypeData && !noActionValue &&
1386
+ this.renderActionList(
1387
+ itemDetail,
1388
+ parentDetail,
1389
+ handleRuleTypeData,
1390
+ selectRuleActionData,
1391
+ classDataIndex,
1392
+ disabled,
1393
+ RuleActionItemStyle,
1394
+ actionDisabled,
1395
+ )) ||
1396
+ null}
1397
+ {(isHaveRuleReturnConfig && !noReturnValue &&
1398
+ this.renderResItem(
1399
+ itemDetail,
1400
+ parentDetail,
1401
+ ruleReturnConfig,
1402
+ selectRuleReturnData,
1403
+ classDataIndex,
1404
+ disabled,
1405
+ RuleActionItemStyle,
1406
+ returnDisabled,
1407
+ )) ||
1408
+ null}
1409
+ </div>
1410
+ );
1411
+ };
1412
+
1413
+ //添加同一层级条件
1414
+ addPeerRule = (itemDetail) => {
1415
+ const { ruleClassData } = this.state;
1416
+ const { callBack, disabled, leftRuleDisabled } = this.props;
1417
+ if (disabled || leftRuleDisabled) return;
1418
+ itemDetail.subExpression.push({
1419
+ // "expressionType": "relation",
1420
+ operationType: 'relation',
1421
+ operationCode: '',
1422
+ propertyPath: '',
1423
+ params: [],
1424
+ paramNames: [],
1425
+ });
1426
+ this.setState(
1427
+ {
1428
+ ruleClassData,
1429
+ },
1430
+ () => {
1431
+ callBack(ruleClassData);
1432
+ },
1433
+ );
1434
+ };
1435
+
1436
+ //添加子层级条件
1437
+ addChildRules = (itemDetail) => {
1438
+ const { ruleClassData } = this.state;
1439
+ const { callBack } = this.props;
1440
+ const initialData = JSON.parse(JSON.stringify(itemDetail));
1441
+ delete itemDetail.propertyPath;
1442
+ delete itemDetail.params;
1443
+ delete itemDetail.paramNames;
1444
+ delete itemDetail.dataTypeCode;
1445
+ delete itemDetail.elementId;
1446
+ delete itemDetail.elementName;
1447
+ delete itemDetail.metaObjectCode;
1448
+ // itemDetail.expressionType = 'logic';
1449
+ itemDetail.operationType = 'logic';
1450
+ itemDetail.operationCode = 'and';
1451
+ itemDetail.subExpression = [
1452
+ initialData,
1453
+ {
1454
+ // "expressionType": "relation",
1455
+ operationType: 'relation',
1456
+ type: 20,
1457
+ operationCode: '',
1458
+ propertyPath: '',
1459
+ params: [],
1460
+ paramNames: [],
1461
+ },
1462
+ ];
1463
+ this.setState(
1464
+ {
1465
+ ruleClassData,
1466
+ },
1467
+ () => {
1468
+ callBack(ruleClassData);
1469
+ },
1470
+ );
1471
+ };
1472
+
1473
+ handleDeleteRule = (itemDetail, parentDetail, classDataIndex) => {
1474
+ const { ruleClassData } = this.state;
1475
+ const { callBack, metaObjectCode } = this.props;
1476
+ if (parentDetail.ruleName) {
1477
+ //删除根规则层级最后一条时整个规则项删除
1478
+ ruleClassData.splice(classDataIndex, 1);
1479
+ } else {
1480
+ let deleteItemIndex = parentDetail.subExpression.findIndex(
1481
+ (detailItem) =>
1482
+ JSON.stringify(itemDetail) == JSON.stringify(detailItem),
1483
+ );
1484
+ if (parentDetail.subExpression.length > 2) {
1485
+ parentDetail.subExpression.splice(deleteItemIndex, 1);
1486
+ } else {
1487
+ parentDetail.subExpression.splice(deleteItemIndex, 1);
1488
+ // parentDetail.expressionType = parentDetail.subExpression[0].expressionType;
1489
+ parentDetail.operationCode =
1490
+ parentDetail.subExpression[0].operationCode;
1491
+ parentDetail.operationType =
1492
+ parentDetail.subExpression[0].operationType;
1493
+
1494
+ if (parentDetail.subExpression[0].operationType == 'logic') {
1495
+ parentDetail.subExpression = [
1496
+ ...parentDetail.subExpression[0].subExpression,
1497
+ ];
1498
+ } else {
1499
+ parentDetail.propertyPath =
1500
+ parentDetail.subExpression[0].propertyPath;
1501
+ parentDetail.params = [...parentDetail.subExpression[0].params];
1502
+ parentDetail.paramNames = parentDetail.subExpression[0].paramNames
1503
+ ? [...parentDetail.subExpression[0].paramNames]
1504
+ : [];
1505
+ parentDetail.metaObjectCode = metaObjectCode || parentDetail.subExpression[0].metaObjectCode;
1506
+ parentDetail.elementId = parentDetail.subExpression[0].elementId;
1507
+ parentDetail.elementName = parentDetail.subExpression[0].elementName;
1508
+ parentDetail.dataTypeCode =
1509
+ parentDetail.subExpression[0].dataTypeCode;
1510
+ delete parentDetail.subExpression;
1511
+ }
1512
+ }
1513
+ }
1514
+ this.setState(
1515
+ {
1516
+ ruleClassData,
1517
+ },
1518
+ () => {
1519
+ callBack(ruleClassData);
1520
+ },
1521
+ );
1522
+ };
1523
+
1524
+ handleLogicalTypeChange = (itemDetail, type) => {
1525
+ const { ruleClassData } = this.state;
1526
+ const { callBack } = this.props;
1527
+ itemDetail.operationCode = type;
1528
+ this.setState(
1529
+ {
1530
+ ruleClassData,
1531
+ },
1532
+ () => {
1533
+ callBack(ruleClassData);
1534
+ },
1535
+ );
1536
+ };
1537
+
1538
+ // 新增执行顺序
1539
+ handleSelectRuleAction = (keys, classDataIndex, type, callback) => {
1540
+ callback();
1541
+ const { callBack } = this.props;
1542
+ const { ruleClassData } = this.state;
1543
+ if (type === 'action') {
1544
+ ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1545
+ classDataIndex
1546
+ ].extraInfo.execute.map((i) => {
1547
+ if (i.code && keys.some((r) => r === i.code) && !i.isSelected) {
1548
+ return { ...i, isSelected: true };
1549
+ }
1550
+ return i;
1551
+ });
1552
+ } else {
1553
+ ruleClassData[classDataIndex].extraInfo.response = ruleClassData[
1554
+ classDataIndex
1555
+ ].extraInfo.response.map((i) => {
1556
+ if (i.code && keys.some((r) => r === i.code) && !i.enable) {
1557
+ return { ...i, enable: true };
1558
+ }
1559
+ return i;
1560
+ });
1561
+ }
1562
+ // 处理数据
1563
+ this.setState(
1564
+ {
1565
+ ruleClassData,
1566
+ },
1567
+ () => {
1568
+ callBack(ruleClassData);
1569
+ },
1570
+ );
1571
+ };
1572
+
1573
+ handleDeleteRuleAction = (classDataIndex, functionCode) => {
1574
+ const { callBack } = this.props;
1575
+ const { ruleClassData } = this.state;
1576
+ ruleClassData[classDataIndex].extraInfo.execute = ruleClassData[
1577
+ classDataIndex
1578
+ ].extraInfo.execute.map((i) => {
1579
+ if (i.code && functionCode === i.code && i.isSelected) {
1580
+ return { ...i, isSelected: false };
1581
+ }
1582
+ return i;
1583
+ });
1584
+ // 处理数据
1585
+ this.setState(
1586
+ {
1587
+ ruleClassData,
1588
+ },
1589
+ () => {
1590
+ callBack(ruleClassData);
1591
+ },
1592
+ );
1593
+ };
1594
+
1595
+ render() {
1596
+ const { onlyOneRule, callBack, disabled, leftRuleDisabled, returnDisabled, actionDisabled, headerButtonComponentFun } = this.props;
1597
+ const { ruleClassData, modalParams } = this.state;
1598
+ return (
1599
+ <div className={'base_rule'}>
1600
+ <div className={'base_rule_content'}>
1601
+ {headerButtonComponentFun?headerButtonComponentFun(this.handleAddRule): (
1602
+ <div
1603
+ style={{
1604
+ display: onlyOneRule ? 'none' : 'block',
1605
+ }}
1606
+ className={'base_rule_line_title'}
1607
+ >
1608
+ <Button
1609
+ disabled={disabled || leftRuleDisabled}
1610
+ onClick={this.handleAddRule}
1611
+ className={'base_rule_btn_style'}
1612
+ type="link"
1613
+ >
1614
+ 新增规则
1615
+ </Button>
1616
+ </div>
1617
+ )}
1618
+ <div>{this.renderRuleContent()}</div>
1619
+ </div>
1620
+ {(modalParams.visible && (
1621
+ <Modal
1622
+ title={modalParams.type === 'action' ? '新增动作' : '新增返回值'}
1623
+ visible={modalParams.visible}
1624
+ onCancel={() => {
1625
+ this.setState({
1626
+ modalParams: { ...modalParams, visible: false },
1627
+ });
1628
+ }}
1629
+ maskClosable={false}
1630
+ destroyOnClose
1631
+ footer={null}
1632
+ >
1633
+ <Table
1634
+ rowSelection={{
1635
+ onChange: (keys, selectRows) => {
1636
+ this.handleSelectRuleAction(
1637
+ keys,
1638
+ modalParams.classDataIndex,
1639
+ modalParams?.type,
1640
+ () => {
1641
+ this.setState({
1642
+ modalParams: { ...modalParams, visible: false },
1643
+ });
1644
+ },
1645
+ );
1646
+ },
1647
+ }}
1648
+ columns={
1649
+ modalParams.type === 'action'
1650
+ ? [
1651
+ {
1652
+ title: '执行动作名称',
1653
+ key: 'functionName',
1654
+ dataIndex: 'functionName',
1655
+ },
1656
+ ]
1657
+ : [
1658
+ {
1659
+ title: '字段名称',
1660
+ key: 'name',
1661
+ dataIndex: 'name',
1662
+ },
1663
+ {
1664
+ title: '字段编码',
1665
+ key: 'code',
1666
+ dataIndex: 'code',
1667
+ },
1668
+ ]
1669
+ }
1670
+ dataSource={modalParams?.dataSource}
1671
+ rowKey={'code'}
1672
+ />
1673
+ </Modal>
1674
+ )) ||
1675
+ null}
1676
+ </div>
1677
+ );
1678
+ }
1679
+ }
1680
+ export default RuleObjectComponent;