@bit-sun/business-component 4.0.0-alpha.3 → 4.0.2

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 (241) hide show
  1. package/.editorconfig +16 -0
  2. package/.fatherrc.ts +5 -0
  3. package/.gitlab-ci.yml +179 -0
  4. package/.prettierignore +7 -0
  5. package/.prettierrc +11 -0
  6. package/.umirc.ts +74 -0
  7. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +1 -1
  8. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +1 -1
  9. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +1 -1
  10. package/dist/components/Business/columnSettingTable/index.d.ts +1 -0
  11. package/dist/components/Common/ParagraphCopier/index.d.ts +8 -0
  12. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +3 -0
  13. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.d.ts +2 -0
  14. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +3 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.esm.js +1901 -639
  17. package/dist/index.js +1903 -636
  18. package/dist/utils/requestUtils.d.ts +1 -0
  19. package/dist/utils/utils.d.ts +3 -0
  20. package/docs/index.md +21 -0
  21. package/package.json +9 -14
  22. package/src/assets/32.svg +28 -0
  23. package/src/assets/addIcon.svg +18 -0
  24. package/src/assets/allfunc.svg +28 -0
  25. package/src/assets/arrowRight.svg +25 -0
  26. package/src/assets/arrow_top.png +0 -0
  27. package/src/assets/arrow_top.svg +18 -0
  28. package/src/assets/btn-delete.svg +30 -0
  29. package/src/assets/btn-edit.svg +20 -0
  30. package/src/assets/btn-more.svg +18 -0
  31. package/src/assets/btn-submit.svg +20 -0
  32. package/src/assets/caidan.svg +12 -0
  33. package/src/assets/close.svg +26 -0
  34. package/src/assets/closeicon.png +0 -0
  35. package/src/assets/drag.svg +17 -0
  36. package/src/assets/exportFail.svg +38 -0
  37. package/src/assets/exportProcessing.svg +29 -0
  38. package/src/assets/exportSuccess.svg +35 -0
  39. package/src/assets/exportlogo.png +0 -0
  40. package/src/assets/fixed-left-active.svg +12 -0
  41. package/src/assets/fixed-left.svg +16 -0
  42. package/src/assets/fixed-right-active.svg +12 -0
  43. package/src/assets/fixed-right.svg +16 -0
  44. package/src/assets/guanbi.svg +16 -0
  45. package/src/assets/icon-quanping.svg +16 -0
  46. package/src/assets/icon-shezhi.svg +18 -0
  47. package/src/assets/label_icon_bottom.svg +26 -0
  48. package/src/assets/list-no-img.svg +22 -0
  49. package/src/assets/morentouxiang-32.svg +24 -0
  50. package/src/assets/right.png +0 -0
  51. package/src/assets/scanning.svg +25 -0
  52. package/src/assets/upExport.svg +23 -0
  53. package/src/assets/xinglan-icon-out.png +0 -0
  54. package/src/common/ENUM.ts +41 -0
  55. package/src/components/Business/AddSelectBusiness/index.md +398 -0
  56. package/src/components/Business/AddSelectBusiness/index.tsx +1116 -0
  57. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -0
  58. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -0
  59. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -0
  60. package/src/components/Business/BsLayouts/Components/ChooseStore/index.less +0 -0
  61. package/src/components/Business/BsLayouts/Components/ChooseStore/index.tsx +193 -0
  62. package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +10 -0
  63. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -0
  64. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +38 -0
  65. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +243 -0
  66. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +385 -0
  67. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +286 -0
  68. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +75 -0
  69. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +171 -0
  70. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +65 -0
  71. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +154 -0
  72. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +73 -0
  73. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +163 -0
  74. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -0
  75. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -0
  76. package/src/components/Business/BsLayouts/Components/RightContent/i18n.ts +9 -0
  77. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +172 -0
  78. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +161 -0
  79. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +76 -0
  80. package/src/components/Business/BsLayouts/index.less +80 -0
  81. package/src/components/Business/BsLayouts/index.tsx +1602 -0
  82. package/src/components/Business/BsLayouts/service.ts +11 -0
  83. package/src/components/Business/BsLayouts/utils.tsx +205 -0
  84. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +566 -0
  85. package/src/components/Business/BsSulaQueryTable/bssulaquerytable.less +5 -0
  86. package/src/components/Business/BsSulaQueryTable/index.less +228 -0
  87. package/src/components/Business/BsSulaQueryTable/index.tsx +817 -0
  88. package/src/components/Business/BsSulaQueryTable/setting.tsx +937 -0
  89. package/src/components/Business/BsSulaQueryTable/utils.less +65 -0
  90. package/src/components/Business/BsSulaQueryTable/utils.tsx +709 -0
  91. package/src/components/Business/CommodityEntry/index.md +84 -0
  92. package/src/components/Business/CommodityEntry/index.tsx +82 -0
  93. package/src/components/Business/CommonAlert/index.less +0 -0
  94. package/src/components/Business/CommonAlert/index.tsx +23 -0
  95. package/src/components/Business/CommonGuideWrapper/index.less +156 -0
  96. package/src/components/Business/CommonGuideWrapper/index.md +61 -0
  97. package/src/components/Business/CommonGuideWrapper/index.tsx +108 -0
  98. package/src/components/Business/DetailPageWrapper/index.less +89 -0
  99. package/src/components/Business/DetailPageWrapper/index.tsx +306 -0
  100. package/src/components/Business/DetailPageWrapper/utils.tsx +166 -0
  101. package/src/components/Business/HomePageWrapper/index.less +36 -0
  102. package/src/components/Business/HomePageWrapper/index.md +45 -0
  103. package/src/components/Business/HomePageWrapper/index.tsx +130 -0
  104. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +823 -0
  105. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +206 -0
  106. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -0
  107. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -0
  108. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -0
  109. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -0
  110. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -0
  111. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -0
  112. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -0
  113. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -0
  114. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -0
  115. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -0
  116. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -0
  117. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -0
  118. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -0
  119. package/src/components/Business/JsonQueryTable/function.ts +62 -0
  120. package/src/components/Business/JsonQueryTable/index.less +17 -0
  121. package/src/components/Business/JsonQueryTable/index.md +328 -0
  122. package/src/components/Business/JsonQueryTable/index.tsx +534 -0
  123. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -0
  124. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -0
  125. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -0
  126. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -0
  127. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -0
  128. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -0
  129. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -0
  130. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -0
  131. package/src/components/Business/JsonQueryTable/static.ts +450 -0
  132. package/src/components/Business/SearchSelect/BusinessUtils.tsx +2207 -0
  133. package/src/components/Business/SearchSelect/common.ts +134 -0
  134. package/src/components/Business/SearchSelect/index.md +1570 -0
  135. package/src/components/Business/SearchSelect/index.tsx +55 -0
  136. package/src/components/Business/SearchSelect/utils.ts +125 -0
  137. package/src/components/Business/StateFlow/index.less +131 -0
  138. package/src/components/Business/StateFlow/index.md +60 -0
  139. package/src/components/Business/StateFlow/index.tsx +30 -0
  140. package/src/components/Business/TreeSearchSelect/index.md +239 -0
  141. package/src/components/Business/TreeSearchSelect/index.tsx +33 -0
  142. package/src/components/Business/TreeSearchSelect/utils.ts +115 -0
  143. package/src/components/Business/columnSettingTable/columnSetting.tsx +869 -0
  144. package/src/components/Business/columnSettingTable/index.less +253 -0
  145. package/src/components/Business/columnSettingTable/index.md +373 -0
  146. package/src/components/Business/columnSettingTable/index.tsx +235 -0
  147. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +232 -0
  148. package/src/components/Business/columnSettingTable/utils.tsx +88 -0
  149. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -0
  150. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -0
  151. package/src/components/Business/moreTreeTable/index.less +100 -0
  152. package/src/components/Business/moreTreeTable/index.md +448 -0
  153. package/src/components/Business/moreTreeTable/index.tsx +387 -0
  154. package/src/components/Business/moreTreeTable/utils.ts +127 -0
  155. package/src/components/Common/ExtendedCollapse/ExtendedPanel.tsx +51 -0
  156. package/src/components/Common/ExtendedCollapse/index.less +33 -0
  157. package/src/components/Common/ExtendedCollapse/index.md +136 -0
  158. package/src/components/Common/ExtendedCollapse/index.tsx +25 -0
  159. package/src/components/Common/ParagraphCopier/index.md +81 -0
  160. package/src/components/Common/ParagraphCopier/index.tsx +56 -0
  161. package/src/components/Common/Section/index.md +120 -0
  162. package/src/components/Common/Section/index.module.less +16 -0
  163. package/src/components/Common/Section/index.tsx +70 -0
  164. package/src/components/Functional/AccessWrapper/index.tsx +34 -0
  165. package/src/components/Functional/AddSelect/helps.ts +81 -0
  166. package/src/components/Functional/AddSelect/index.less +367 -0
  167. package/src/components/Functional/AddSelect/index.md +155 -0
  168. package/src/components/Functional/AddSelect/index.tsx +1072 -0
  169. package/src/components/Functional/AuthButton/index.tsx +15 -0
  170. package/src/components/Functional/BillEntry/index.less +371 -0
  171. package/src/components/Functional/BillEntry/index.md +39 -0
  172. package/src/components/Functional/BillEntry/index.tsx +771 -0
  173. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -0
  174. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -0
  175. package/src/components/Functional/BsAntdSula/index.ts +2 -0
  176. package/src/components/Functional/DataImport/index.less +63 -0
  177. package/src/components/Functional/DataImport/index.md +44 -0
  178. package/src/components/Functional/DataImport/index.tsx +782 -0
  179. package/src/components/Functional/DataValidation/index.less +63 -0
  180. package/src/components/Functional/DataValidation/index.md +52 -0
  181. package/src/components/Functional/DataValidation/index.tsx +788 -0
  182. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -0
  183. package/src/components/Functional/EllipsisTooltip/index.js +36 -0
  184. package/src/components/Functional/EllipsisTooltip/index.md +30 -0
  185. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -0
  186. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +65 -0
  187. package/src/components/Functional/QueryMutipleInput/index.less +37 -0
  188. package/src/components/Functional/QueryMutipleInput/index.md +33 -0
  189. package/src/components/Functional/QueryMutipleInput/index.tsx +129 -0
  190. package/src/components/Functional/SearchSelect/index.less +121 -0
  191. package/src/components/Functional/SearchSelect/index.md +141 -0
  192. package/src/components/Functional/SearchSelect/index.tsx +1041 -0
  193. package/src/components/Functional/SearchSelect/utils.ts +3 -0
  194. package/src/components/Functional/TreeSearchSelect/index.md +47 -0
  195. package/src/components/Functional/TreeSearchSelect/index.tsx +224 -0
  196. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.tsx +358 -0
  197. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/function.js +255 -0
  198. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.tsx +58 -0
  199. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.tsx +129 -0
  200. package/src/components/Solution/RuleComponent/Formula.tsx +335 -0
  201. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -0
  202. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +743 -0
  203. package/src/components/Solution/RuleComponent/index.d.ts +29 -0
  204. package/src/components/Solution/RuleComponent/index.js +1614 -0
  205. package/src/components/Solution/RuleComponent/index.less +247 -0
  206. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -0
  207. package/src/components/Solution/RuleComponent/ruleFiled.js +2587 -0
  208. package/src/components/Solution/RuleComponent/services.ts +13 -0
  209. package/src/components/Solution/RuleComponent/util.js +143 -0
  210. package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -0
  211. package/src/components/Solution/RuleSetter/baseRule.tsx +394 -0
  212. package/src/components/Solution/RuleSetter/function.ts +437 -0
  213. package/src/components/Solution/RuleSetter/index.less +221 -0
  214. package/src/components/Solution/RuleSetter/index.tsx +208 -0
  215. package/src/components/Solution/RuleSetter/service.js +276 -0
  216. package/src/index.ts +46 -0
  217. package/src/plugin/TableColumnSetting/index.less +247 -0
  218. package/src/plugin/TableColumnSetting/index.md +50 -0
  219. package/src/plugin/TableColumnSetting/index.tsx +725 -0
  220. package/src/plugin/TableColumnSetting/utils.ts +19 -0
  221. package/src/styles/bsDefault.less +32 -12
  222. package/src/utils/CheckOneUser/index.md +39 -0
  223. package/src/utils/CheckOneUser/index.ts +52 -0
  224. package/src/utils/CustomLoginInfo.ts +55 -0
  225. package/src/utils/LocalstorageUtils.ts +134 -0
  226. package/src/utils/TableUtils.less +52 -0
  227. package/src/utils/TableUtils.tsx +691 -0
  228. package/src/utils/auth.ts +39 -0
  229. package/src/utils/businessUtils.ts +434 -0
  230. package/src/utils/checkUtils.ts +39 -0
  231. package/src/utils/constant.ts +38 -0
  232. package/src/utils/enumConfig.ts +17 -0
  233. package/src/utils/getFormMode.js +12 -0
  234. package/src/utils/index.ts +19 -0
  235. package/src/utils/request.ts +53 -0
  236. package/src/utils/requestUtils.ts +197 -0
  237. package/src/utils/serialize.js +7 -0
  238. package/src/utils/utils.ts +267 -0
  239. package/src/utils/xlsxUtil.tsx +146 -0
  240. package/tsconfig.json +29 -0
  241. package/typings.d.ts +5 -0
@@ -0,0 +1,534 @@
1
+ // @ts-nocheck
2
+ import React, { useState, useRef, useEffect, Fragment } from 'react';
3
+ import { message, Button, Table, Tabs } from 'antd';
4
+ import Drawer from './drawer';
5
+ import ConfigButton from './configButton';
6
+ import Editor from './jsonEditor';
7
+ import request from '@/utils/request';
8
+ import FieldsSettingsTable from './components/FieldsSettingsTable';
9
+ import { isEmpty } from "lodash"
10
+ import './index.less';
11
+ import { getUserId } from '@/utils/LocalstorageUtils';
12
+
13
+ function iterFileds (fields) {
14
+ let filedsValue = [];
15
+
16
+ function iter(field) {
17
+ if(Array.isArray(field.fields)) {
18
+ field.fields.forEach(item => {
19
+ const targetValue = iterFileds(item);
20
+ if(targetValue){
21
+ filedsValue.push(targetValue);
22
+ }
23
+ })
24
+ } else {
25
+ return {
26
+ name: field.name,
27
+ isStaticCode: true,
28
+ label: field.label,
29
+ }
30
+ }
31
+
32
+ return {
33
+ container: {
34
+ name: field?.container?.props?.name,
35
+ title: field?.container?.props?.title
36
+ },
37
+ isStaticCode: true,
38
+ fields: filedsValue,
39
+ };
40
+ }
41
+
42
+ filedsValue = iter(fields)
43
+
44
+ return filedsValue;
45
+ }
46
+
47
+ function flatFileds (fields) {
48
+ let filedsValue = {
49
+ };
50
+ function iter(field, containerName) {
51
+ if(Array.isArray(field.fields)) {
52
+ if (field?.container?.props?.name) {
53
+ filedsValue[field?.container?.props?.name] = {
54
+ ...field,
55
+ fields: []
56
+ }
57
+ }
58
+ field.fields.forEach(item => {
59
+ iter(item, field?.container?.props?.name)
60
+ })
61
+ } else {
62
+ filedsValue[containerName ? (containerName + field.name) : field.name] = field
63
+ }
64
+ }
65
+
66
+ iter(fields)
67
+
68
+ return filedsValue;
69
+ }
70
+
71
+ function convertFileds (fields, falltValue, faltFieldRange, containerName) {
72
+ let filedsValue = [];
73
+
74
+ function iter(field) {
75
+ if(Array.isArray(field.fields)) {
76
+ field.fields.forEach(item => {
77
+ const targetValue = convertFileds(item, falltValue, faltFieldRange, field?.container?.name);
78
+ if(targetValue){
79
+ if(item.dependency) {
80
+ targetValue.dependency = {
81
+ visible: {
82
+ ...item.dependency.visible,
83
+ type: (new Function('request','ctx', item.dependency.visible.type)).bind(null, request)
84
+ }
85
+ }
86
+ }
87
+ filedsValue.push(targetValue)
88
+ }
89
+ })
90
+ } else {
91
+ const returnField = field.isStaticCode ? falltValue[containerName ? (containerName + field.name) : field.name] : faltFieldRange[field.name];
92
+ if (returnField) {
93
+ returnField.label = field?.label;
94
+ if(field?.disabled){ // 字段设置只读属性
95
+ returnField.field.props.disabled = true;
96
+ }
97
+ if(field?.invisible){ // 字段设置不可见属性
98
+ returnField.initialVisible = false;
99
+ }
100
+
101
+ if(Array.isArray(returnField.name)&&returnField.name?.includes("extensionFields")){
102
+ returnField.notShowLabel = true;
103
+ }
104
+ } else {
105
+ }
106
+ return returnField;
107
+ }
108
+
109
+ return {...falltValue[field?.container?.name], fields: filedsValue};
110
+ }
111
+
112
+ filedsValue = iter(fields)
113
+
114
+ return filedsValue;
115
+ }
116
+
117
+ function faltColumns(columns) {
118
+ let columnsValue = {}
119
+
120
+ columns.forEach(item => {
121
+ columnsValue[item.key] = {...item}
122
+ })
123
+
124
+ return columnsValue;
125
+ }
126
+
127
+ function faltCustomerFieldRange(fileds) {
128
+ let columnsValue = {}
129
+
130
+ fileds.forEach(item => {
131
+ columnsValue[item.name] = {...item}
132
+ })
133
+
134
+ return columnsValue;
135
+ }
136
+
137
+ //form存在新加container属性分组得情况 组合操作
138
+ function combineContainer(originFields, currentFields){
139
+ let newCurrentFields = [...originFields];
140
+ currentFields.map((item: any) => {
141
+ if(!originFields.find((i: any) => i?.container?.props?.name == item?.container?.name)){
142
+ newCurrentFields = [...newCurrentFields, {
143
+ container: {
144
+ type: 'card',
145
+ props: {
146
+ title: item?.container?.title,
147
+ level: 1,
148
+ id: Math.random(),
149
+ isWhiteCard: true,
150
+ bordered: false,
151
+ name: item?.container?.name,
152
+ },
153
+ },
154
+ fields: item?.fields || []
155
+ }];
156
+ }
157
+ })
158
+ return newCurrentFields;
159
+ }
160
+
161
+ function hanleCallbackValue(codeProps, value, customerFields, cacheColumns = []) {
162
+ const faltFieldRange = faltCustomerFieldRange(customerFields);
163
+ // const falltValue = flatFileds({fields: codeProps.fields})
164
+ const falltValue = flatFileds({fields: combineContainer(codeProps.fields, value?.fields)})
165
+ let newCodeProps = {...codeProps};
166
+ newCodeProps.fields = convertFileds({fields: value.fields}, falltValue, faltFieldRange).fields;
167
+ if (codeProps.columns) {
168
+ const faltColumnsValue = faltColumns(codeProps.columns)
169
+ newCodeProps.columns = value.columns.map(item => {
170
+ if (item.isStaticCode) {
171
+ const cacheFieldProperty = cacheColumns.find(k => (k.key||k.dataIndex) == (item.key||item.dataIndex));
172
+ return {
173
+ ...faltColumnsValue[item.key],
174
+ ...cacheFieldProperty
175
+ }
176
+ } else {
177
+ //自定义字段-列字段
178
+ if(item?.key&&item?.key.includes('extensionFields')&&item?.key.includes(',')){
179
+ return {
180
+ ...item,
181
+ render: ({ record }: any) => {
182
+ try{
183
+ const { extensionFields = {} } = record;
184
+ const fieldName1= item?.key.split(',')[1]; //兼容没有fieldName的情况
185
+ const fieldName2 = `${fieldName1}Name`;
186
+ if(customerFields.length){
187
+ const targetField = customerFields.find(k => k.name.includes(fieldName1));
188
+ if(targetField){
189
+ const { initialSource = [] } = targetField
190
+ if(initialSource.length){
191
+ return initialSource.find((d => d.value == extensionFields[fieldName1]))?.text || extensionFields[fieldName1];
192
+ }
193
+ }
194
+ }
195
+ return extensionFields[fieldName2] || extensionFields[fieldName1] || '';
196
+ }catch(e){
197
+ console.log('e',e);
198
+ }
199
+ }
200
+ }
201
+ }else{
202
+ return {
203
+ ...item
204
+ }
205
+ }
206
+ }
207
+ });
208
+
209
+ //进行列表搜索项自定义字段name替换 (排除是编辑表单的fields)
210
+ newCodeProps.fields = newCodeProps.fields.map(item => {
211
+ if(Array.isArray(item?.name)){
212
+ return {
213
+ ...item,
214
+ name: item?.realSearchName || item?.name
215
+ }
216
+ }
217
+ return item;
218
+ });
219
+
220
+ }
221
+
222
+ return newCodeProps;
223
+ }
224
+
225
+ function isAdmin() {
226
+ const username = getUserId();
227
+
228
+ return username === 'admin' || username === 'uiuiui'
229
+ }
230
+
231
+ const tableStyleList = [
232
+ {
233
+ type: '快速搜索',
234
+ img: 'https://img.alicdn.com/tfs/TB1al1JqHr1gK0jSZR0XXbP8XXa-40-40.svg',
235
+ url: '/list/singlesearch',
236
+ },
237
+ {
238
+ type: '高级搜索',
239
+ img: 'https://img.alicdn.com/tfs/TB1QgKIqQL0gK0jSZFtXXXQCXXa-40-40.svg',
240
+ url: '/list/advancedsearch',
241
+ },
242
+ {
243
+ type: '一般搜索',
244
+ img: 'https://img.alicdn.com/tfs/TB1xHCPqRr0gK0jSZFnXXbRRXXa-40-40.svg',
245
+ url: '/list/basic',
246
+ },
247
+ {
248
+ type: '无分页表格',
249
+ img: 'https://img.alicdn.com/tfs/TB1txuMqQL0gK0jSZFxXXXWHVXa-40-40.svg',
250
+ url: '/list/nopagination',
251
+ },
252
+ {
253
+ type: '分步查询表格',
254
+ img: 'https://img.alicdn.com/tfs/TB10IOmGkL0gK0jSZFAXXcA9pXa-53-46.svg',
255
+ url: '/list/stepquerytable',
256
+ },
257
+ ];
258
+ const JsonQueryTable = React.memo(props => {
259
+ const {
260
+ callBack, // 主保存函数回调
261
+ codeProps, // 整体的配置数据
262
+ customerFields, //可选的配置字段
263
+ initialSetting, //上一次添加自定义字段后保存的数据
264
+ pageType, //页面权限code
265
+ detailTablesSetting = [], //详情明细表格列配置数据
266
+ saveTableCallBack, //详情明细保存函数回调
267
+ } = props;
268
+
269
+ let codeFilter = {};
270
+ if (codeProps.columns) { // table
271
+ codeFilter.columns = codeProps.columns.map(item => ({
272
+ key: item.key,
273
+ isStaticCode: true,
274
+ title: item.title
275
+ }))
276
+
277
+ codeFilter.fields = codeProps.fields.map(item => ({
278
+ name: item.name,
279
+ isStaticCode: true,
280
+ label: item.label,
281
+ notShowLabel: item.notShowLabel || false
282
+ }))
283
+ } else {
284
+ codeFilter.fields = iterFileds({fields: codeProps.fields}).fields
285
+ }
286
+
287
+ const styleRef = useRef(null);
288
+
289
+ const [visible, setVisible] = useState(false)
290
+ const [code, setCode] = useState(codeProps);
291
+ const [init, setInit] = useState(true);
292
+ const [jsonEditorVal, setJsonEditorVal] = useState(initialSetting || codeFilter);
293
+ const [moduleParams, setModuleParams] = useState({});
294
+ const [activeKey, setActiveKey] = useState('main'); //默认详情页配置
295
+ const [tablesConfigParams, setTablesConfigParams] = useState({});
296
+ const [tableJsonEditorValsArr, setTableJsonEditorValsArr] = useState([]);
297
+
298
+ useEffect(()=>{
299
+ Promise.all([
300
+ request.get(`/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=${pageType}`),
301
+ ]).then(([res] )=> {
302
+ const { code, data } = res?.data || {};
303
+ if (code === '000000') {
304
+ if(data){
305
+ const { businessType, code:fieldGroup, moduleType, moduleRelationId } = data;
306
+ setModuleParams({
307
+ businessType,
308
+ fieldGroup,
309
+ moduleType,
310
+ moduleRelationId
311
+ });
312
+ }
313
+ }
314
+ })
315
+ },[]);
316
+
317
+ useEffect(()=>{
318
+ //明细表的配置数据
319
+ const axiosArr = detailTablesSetting.map((item:any) => request.get(`/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=${item.tableCode}`));
320
+ Promise.all(axiosArr).then(([...resArr])=> {
321
+ let configParams = {};
322
+ detailTablesSetting.map((item:any, index:number)=>{
323
+ const { code, data } = resArr[index]?.data || {};
324
+ if(data){
325
+ const { businessType, code:fieldGroup, moduleType } = data;
326
+ configParams [item.tableCode] = {
327
+ businessType,
328
+ fieldGroup,
329
+ moduleType,
330
+ tableFlag: true
331
+ }
332
+ }
333
+ })
334
+ setTablesConfigParams({
335
+ ...configParams,
336
+ });
337
+ })
338
+
339
+ const detailTableCodeFilter = detailTablesSetting.map(item => {
340
+ if(item?.initialSetting && item?.initialSetting.length){
341
+ return {
342
+ ...item,
343
+ columns: item?.initialSetting
344
+ }
345
+ }
346
+ return {
347
+ ...item,
348
+ columns: item?.columns.map(childItem => ({
349
+ key: childItem.key || childItem.dataIndex,
350
+ dataIndex: childItem.dataIndex || childItem.key,
351
+ isStaticCode: true,
352
+ title: childItem.title
353
+ }))
354
+ }
355
+ });
356
+ setTableJsonEditorValsArr([...detailTableCodeFilter]);
357
+ const lastRes = detailTableCodeFilter.map(item => {
358
+ if(item?.initialSetting && item?.initialSetting.length){
359
+ const codeProps = {
360
+ fields: [],
361
+ columns: item?.columns,
362
+ };
363
+ const newValue = {
364
+ fields: [],
365
+ columns: item.initialSetting
366
+ };
367
+ const result = hanleCallbackValue(codeProps, newValue, item?.customerFields, item?.cacheColumns);
368
+ return {
369
+ ...item,
370
+ columns: result?.columns
371
+ }
372
+ }
373
+ return item;
374
+ });
375
+ if(lastRes.length){
376
+ saveTableCallBack(lastRes, false);
377
+ }
378
+ },[detailTablesSetting.length]);
379
+
380
+ const onClickRun = (value, isSave) => {
381
+ setJsonEditorVal(value);
382
+
383
+ try {
384
+ setCode(value);
385
+ callBack(hanleCallbackValue(codeProps, value, customerFields), isSave, value);
386
+ } catch (e) {
387
+ message.error(e);
388
+ }
389
+ };
390
+
391
+ //明细表保存
392
+ const onClickRunDetailTables = (value, isSave, tableCode, tableSouce) =>{
393
+ const targetCode = tableCode || activeKey;
394
+ const targetTableSource = tableSouce || tableJsonEditorValsArr;
395
+ const newArr = targetTableSource.map(item => {
396
+ if(item.tableCode == targetCode){
397
+ return {
398
+ ...item,
399
+ columns: value
400
+ }
401
+ }
402
+ return item
403
+ });
404
+ setTableJsonEditorValsArr([...newArr]);
405
+
406
+ try {
407
+ const target = targetTableSource.find(item=>item.tableCode == targetCode);
408
+ const codeProps = {
409
+ fields: [],
410
+ columns: target?.columns,
411
+ };
412
+ const newValue = {
413
+ fields: [],
414
+ columns: value
415
+ };
416
+ const result = hanleCallbackValue(codeProps, newValue, target?.customerFields, target?.cacheColumns);
417
+ saveTableCallBack({ columns: result.columns, tableCode: targetCode }, isSave, value);
418
+ } catch (e) {
419
+ message.error(e);
420
+ }
421
+ }
422
+
423
+ React.useEffect(() => {
424
+ localStorage.setItem('jsonEditorVal',JSON.stringify(jsonEditorVal||{}))
425
+ }, [jsonEditorVal]);
426
+
427
+ React.useEffect(() => {
428
+ if (initialSetting) {
429
+ onClickRun(initialSetting);
430
+ setJsonEditorVal(initialSetting)
431
+ }
432
+ }, [initialSetting]);
433
+
434
+ const height =
435
+ styleRef?.current?.clientHeight || styleRef?.current?.offsetHeight;
436
+
437
+ const tableParams = {
438
+ ...moduleParams,
439
+ jsonEditorVal,
440
+ codeProps,
441
+ };
442
+
443
+ return (
444
+ <div>
445
+ <Drawer visible={visible} width={1400} onClose={() => setVisible(false)} className={'customFieldsDrawer'}>
446
+ {
447
+ detailTablesSetting.length == 0 &&(
448
+ <div style={{display: 'flex'}}>
449
+ <div style={{flex: 1, width: 500}}>
450
+ {
451
+ isEmpty(moduleParams)?(
452
+ <div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
453
+ 提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
454
+ </div>
455
+ ):(
456
+ <FieldsSettingsTable {...tableParams}/>
457
+ )
458
+ }
459
+ </div>
460
+ <div style={{flex: 1}}>
461
+ <Editor
462
+ type="table"
463
+ onRun={onClickRun}
464
+ value={jsonEditorVal}
465
+ shallowHeight={height}
466
+ />
467
+ </div>
468
+ </div>
469
+ )
470
+ }
471
+ {
472
+ detailTablesSetting.length > 0 && (
473
+ <Tabs defaultActiveKey={activeKey} onChange={(v: any) => setActiveKey(v)}>
474
+ <Tabs.TabPane tab="详情页配置" key="main">
475
+ <div style={{display: 'flex'}}>
476
+ <div style={{flex: 1, width: 500}}>
477
+ {
478
+ isEmpty(moduleParams)?(
479
+ <div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
480
+ 提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
481
+ </div>
482
+ ):(
483
+ <FieldsSettingsTable {...tableParams}/>
484
+ )
485
+ }
486
+ </div>
487
+ <div style={{flex: 1}}>
488
+ <Editor
489
+ type="table"
490
+ onRun={onClickRun}
491
+ value={jsonEditorVal}
492
+ shallowHeight={height}
493
+ />
494
+ </div>
495
+ </div>
496
+ </Tabs.TabPane>
497
+ {
498
+ tableJsonEditorValsArr.map((k:any)=>(
499
+ <Tabs.TabPane tab={k.title} key={k.tableCode}>
500
+ <div style={{display: 'flex'}}>
501
+ <div style={{flex: 1, width: 500}}>
502
+ {
503
+ !tablesConfigParams[k.tableCode]?(
504
+ <div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
505
+ 提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
506
+ </div>
507
+ ):(
508
+ <FieldsSettingsTable {...tablesConfigParams[k.tableCode]}/>
509
+ )
510
+ }
511
+ </div>
512
+ <div style={{flex: 1}}>
513
+ <Editor
514
+ type="table"
515
+ onRun={onClickRunDetailTables}
516
+ value={k.columns}
517
+ shallowHeight={height}
518
+ />
519
+ </div>
520
+ </div>
521
+ </Tabs.TabPane>
522
+ ))
523
+ }
524
+ </Tabs>
525
+ )
526
+ }
527
+ </Drawer>
528
+
529
+ {!visible && isAdmin() && <ConfigButton type='primary' onClick={() => setVisible(true)}>setting</ConfigButton>}
530
+ </div>
531
+ );
532
+ });
533
+
534
+ export default JsonQueryTable;