@bit-sun/business-component 3.1.5 → 3.1.6

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 (218) 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/.yarnclean +45 -0
  8. package/README.md +27 -27
  9. package/dist/index.esm.js +2 -2
  10. package/dist/index.js +2 -2
  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 +566 -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 +772 -772
  79. package/src/components/Business/BsSulaQueryTable/setting.tsx +888 -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 +2162 -2162
  123. package/src/components/Business/SearchSelect/common.ts +134 -134
  124. package/src/components/Business/SearchSelect/index.md +1512 -1512
  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 +211 -211
  131. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  132. package/src/components/Business/TreeSearchSelect/utils.ts +104 -104
  133. package/src/components/Business/columnSettingTable/columnSetting.tsx +816 -816
  134. package/src/components/Business/columnSettingTable/index.less +253 -253
  135. package/src/components/Business/columnSettingTable/index.md +357 -357
  136. package/src/components/Business/columnSettingTable/index.tsx +226 -226
  137. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +233 -233
  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 +1065 -1065
  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 +772 -772
  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 +783 -783
  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 -787
  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 +1034 -1034
  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/Formula.tsx +335 -335
  178. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -62
  179. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +670 -670
  180. package/src/components/Solution/RuleComponent/index.d.ts +29 -29
  181. package/src/components/Solution/RuleComponent/index.js +1601 -1601
  182. package/src/components/Solution/RuleComponent/index.less +247 -247
  183. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  184. package/src/components/Solution/RuleComponent/ruleFiled.js +2293 -2293
  185. package/src/components/Solution/RuleComponent/services.ts +13 -13
  186. package/src/components/Solution/RuleComponent/util.js +143 -143
  187. package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -6
  188. package/src/components/Solution/RuleSetter/baseRule.tsx +394 -394
  189. package/src/components/Solution/RuleSetter/function.ts +437 -437
  190. package/src/components/Solution/RuleSetter/index.less +221 -221
  191. package/src/components/Solution/RuleSetter/index.tsx +208 -208
  192. package/src/components/Solution/RuleSetter/service.js +276 -276
  193. package/src/index.ts +41 -41
  194. package/src/plugin/TableColumnSetting/index.less +247 -247
  195. package/src/plugin/TableColumnSetting/index.md +50 -50
  196. package/src/plugin/TableColumnSetting/index.tsx +725 -725
  197. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  198. package/src/styles/bsDefault.less +1933 -1933
  199. package/src/utils/CheckOneUser/index.md +39 -39
  200. package/src/utils/CheckOneUser/index.ts +51 -51
  201. package/src/utils/CustomLoginInfo.ts +55 -55
  202. package/src/utils/LocalstorageUtils.ts +134 -134
  203. package/src/utils/TableUtils.less +51 -51
  204. package/src/utils/TableUtils.tsx +691 -691
  205. package/src/utils/auth.ts +38 -38
  206. package/src/utils/businessUtils.ts +434 -434
  207. package/src/utils/checkUtils.ts +39 -39
  208. package/src/utils/constant.ts +38 -38
  209. package/src/utils/enumConfig.ts +17 -17
  210. package/src/utils/getFormMode.js +12 -12
  211. package/src/utils/index.ts +19 -19
  212. package/src/utils/request.ts +53 -53
  213. package/src/utils/requestUtils.ts +193 -193
  214. package/src/utils/serialize.js +7 -7
  215. package/src/utils/utils.ts +238 -238
  216. package/src/utils/xlsxUtil.tsx +145 -145
  217. package/tsconfig.json +29 -29
  218. package/typings.d.ts +4 -4
@@ -1,1065 +1,1065 @@
1
- // @ts-nocheck
2
- import React, { useState, useEffect } from 'react';
3
- import { useDebounceFn } from 'ahooks';
4
- import { Input, Button, Modal, Select, InputNumber, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
5
- import { SearchOutlined, CopyOutlined, CloseCircleOutlined } from '@ant-design/icons';
6
- import request from '@/utils/request';
7
- import { stringify } from 'querystring';
8
- import _ from "lodash"
9
- import './index.less';
10
- import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
- import { Resizable } from 'react-resizable';
12
- import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
13
- import TableColumnSetting from '@/plugin/TableColumnSetting';
14
- import { setInitialShowColumn } from '@/plugin/TableColumnSetting/utils';
15
- import { handleAntdColumnsSpecialParams, uuid } from '@/utils/utils';
16
- import { judgeIsRequestError } from '@/utils/requestUtils';
17
- import { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
18
- import { getSelectDataList, loadSelectSource, formatFormSourceList } from './helps';
19
-
20
- interface SearchFormItem {
21
- name: string;
22
- label: string;
23
- filterFormItem?: FormItemProps;
24
- initialSource?: any[];
25
- field: any;
26
- type?: string;
27
- [formItemProps: string]: any;
28
- }
29
-
30
- const checkSpuMatchCode = (data: any) => {
31
- return new Promise((resolve, reject) => {
32
- request.post(`/stock/rwFrontRecordSkcDetail/checkSpuMatchCode`,data)
33
- .then((result: any) => {
34
- result = result.data;
35
- if (judgeIsRequestError(result)) {
36
- message.error(result.msg);
37
- reject(false);
38
- return;
39
- }
40
- resolve(result);
41
- })
42
- .catch((err: any) => {
43
- reject(err);
44
- });
45
- })
46
- }
47
-
48
- const ResizeableTitle = (props) => {
49
- const { onResize, width, ...restProps } = props;
50
-
51
- if (!width) {
52
- return <th {...restProps} />;
53
- }
54
- return (
55
- <Resizable
56
- width={width}
57
- height={0}
58
- onResize={onResize}
59
- draggableOpts={{ enableUserSelectHack: false }}
60
- >
61
- <th {...restProps} />
62
- </Resizable>
63
- );
64
- };
65
-
66
- const initTableCode = {
67
- 'sku': ['skuSelect-tableOptionsToChoosePartCode','skuSelect-tableSelectedItemPartCode'],
68
- 'skc': ['skcSelect-tableOptionsToChoosePartCode','skcSelect-tableSelectedItemPartCode'],
69
- 'spu': ['spuSelect-tableOptionsToChoosePartCode','spuSelect-tableSelectedItemPartCode']
70
- }
71
-
72
- const { Option } = Select;
73
-
74
- const AddSelect = (props: any) => {
75
- const {
76
- value, // 必传
77
- selectProps = {},
78
- modalTableProps = {},
79
- labelInValue = false,
80
- requestConfig,
81
- sourceName,
82
- onSaveCallback,
83
- onCancelCallback,
84
- buttonText = '添加',
85
- buttonProps = {},
86
- beforeShowModal,
87
- tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
88
- businessType = 'sku',
89
- isAllowRepeatedSelect = false,
90
- clearTitle
91
- } = props;
92
- const { url, otherParams, isMap, mappingValueField = 'code' } = requestConfig || {};
93
- const realButtonProps = {type: "primary", ...buttonProps};
94
- const selectRowKey = isAllowRepeatedSelect ? 'uuid' : mappingValueField
95
-
96
- const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
97
- const initVal = value || (selectMode ? [] : null);
98
- const pageSize = 100 // 下拉框默认分页 条数
99
- const tableInitPageSize = 10 // 弹框默认分页 条数
100
- const currentPage = 1
101
-
102
- const [fetching, setFetching] = useState(false);
103
- const [isModalVisible, setIsModalVisible] = useState(false);
104
- const [popvalue, setPopValue] = useState(initVal);
105
- const [uniqueValue, setUniqueValue] = useState(sourceName)
106
-
107
- const [form] = Form.useForm();
108
- const [tableSearchForm, setTableSearchForm] = useState<Array<SearchFormItem>>(modalTableProps?.tableSearchForm)
109
- const [caretLeftFlag, setCaretLeftFlag] = useState(true);
110
- const [tableData, setTableData] = useState([]);
111
- const [tablePagination, setTablePagination] = useState({ total: 0, size: "small", current: 1, pageSize: tableInitPageSize })
112
- const [selectedRowKeys, setSelectedRowKeys] = useState([]);
113
- const [tableFormParams, setTableFormParams] = useState({});
114
- const [confirmLoading, setConfirmLoading] = useState(false);
115
- const [confirmContinueLoading, setConfirmContinueLoading] = useState(false);
116
-
117
- const [selectColumns, setSelectColumns] = useState([]);
118
- const [showColumns, setShowColumns] = useState([]);
119
- const [tableColumns, setTableColumns] = useState([]);
120
- const [showToChooseColumns, setShowToChooseColumns] = useState([]);
121
- const codeToChoose = tableCodeList[0] || initTableCode[businessType][0];
122
- const codeSelected = tableCodeList[1] || initTableCode[businessType][1];
123
-
124
- // FIXME: 特殊业务逻辑
125
- const checkSelectChange = async (bType: string, tList: any, recordKey: string, recordItem: any, selectItem: any, changeValue: string) => {
126
- if(bType == 'skc' && tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i[selectItem.dataIndex] == changeValue)) {
127
- message.warning('相同skc配码不可设置相同哦')
128
- return false
129
- }
130
- if(bType == 'spu') {
131
- if(selectItem.dataIndex == 'colorName' && tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i.selectPropertyGroupCode == recordItem.selectPropertyGroupCode && i[selectItem.dataIndex] == changeValue)){
132
- message.warning('相同商品相同配码颜色不可设置相同哦')
133
- return false
134
- }
135
- if(selectItem.dataIndex == 'selectPropertyGroupCode' && !recordItem.colorName) {
136
- message.warning('请先选择颜色!')
137
- return false
138
- }
139
- if(selectItem.dataIndex == 'selectPropertyGroupCode'&& tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i.colorName == recordItem.colorName && i[selectItem.dataIndex] == changeValue)){
140
- message.warning('相同商品相同颜色配码不可设置相同哦')
141
- return false
142
- }
143
- if(selectItem.dataIndex == 'selectPropertyGroupCode') {
144
- let result = true
145
- try {
146
- result = await checkSpuMatchCode({ skcCode: recordItem[recordKey], matchingCode: changeValue, ext1: recordItem.colorName });
147
- result = true
148
- } catch (e) {
149
- result = typeof e == 'boolean' ? e : false
150
- }
151
- return result
152
- }
153
- }
154
- return true
155
- }
156
- const setBusinessDefaultValue = (list: any, recordList: any) => {
157
- let result = list;
158
- // FIXME: 特殊业务逻辑
159
- if(businessType == 'spu' && (recordList?.some((i: any) => i?.colorValues?.length == 1) || recordList?.some((i: any) => i?.defaultMatchingCode))) {
160
- result = list.map((i: any) => {
161
- recordList.forEach((record: any) => {
162
- if(i.uuid == record?.uuid) {
163
- if(record.colorValues?.length == 1) {
164
- i.colorName = record.colorValues[0]?.value;
165
- }
166
- i.selectPropertyGroupCode = record?.defaultMatchingCode;
167
- }
168
- })
169
- return i
170
- })
171
- }
172
- return result
173
- }
174
-
175
- useEffect(() => {
176
- setTableColumns(modalTableProps?.tableColumns)
177
- }, [modalTableProps?.tableColumns])
178
-
179
- useEffect(() => {
180
- setSelectColumns([... modalTableProps.selectColumn.map(item => {
181
- const inputLength = modalTableProps.selectColumn.filter(item => item.isInputItem).length
182
- const currentIndex = inputIndex
183
-
184
- if (item.isInputItem) {
185
- inputIndex++;
186
- return {
187
- ...item,
188
- render: (text, record, index) => {
189
- // let
190
- if(record.needFocus === true && currentIndex === 0) {
191
-
192
- }
193
- // FIXME: 特殊业务逻辑
194
- let precisionObj=businessType == 'skc'?{
195
- precision: 0
196
- }:{};
197
- const unitAccuracy = record.packingUnitList?.[0]?.unitAccuracy
198
- const isCountUnitAccuracyCheck = item.dataIndex =='count' && unitAccuracy !== undefined
199
- if(isCountUnitAccuracyCheck) {
200
- precisionObj = {
201
- onBlur: (e: any) => {
202
- const { target: { value } } = e;
203
- if(!checkQuantityAccuracy(value,Number(unitAccuracy))) {
204
- record[item.dataIndex] = precisionQuantity(value,Number(unitAccuracy))
205
- const newPopValue = popvalue.map((i: any, innerIndex: number) => {
206
- if(innerIndex == index) {
207
- i[item.dataIndex] = record[item.dataIndex]
208
- }
209
- return i
210
- })
211
- setPopValue(newPopValue)
212
- }
213
- }
214
- // precision: unitAccuracy
215
- }
216
- }
217
- return (
218
- <InputNumber
219
- {...item.inputProps}
220
- value={text || ''}
221
- min={0}
222
- autoFocus={record.needFocus}
223
- keyboard={false}
224
- {...precisionObj}
225
- onChange={(value) => {
226
- record[item.dataIndex] = value
227
- editRecord(record)
228
- }}
229
- // onFocus={(e)=> {
230
- // let dom1 = e.currentTarget;
231
- // dom1.setSelectionRange(100, 0);
232
- // dom1.select(text);
233
- // }}
234
- onKeyDown={(e) => {
235
- if(e.keyCode === 13 && e.ctrlKey) {
236
- handleOk(true)
237
- document.getElementById("first-query")?.focus()
238
- }
239
- if(e.keyCode === 8 && e.ctrlKey) {
240
- message.success('删除当前行')
241
- e.stopPropagation();
242
- e.preventDefault();
243
- let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
244
- if (dom) {
245
- dom.select();
246
- dom.focus();
247
- dom.scrollIntoView(false)
248
- }
249
- dom = null
250
- deleteRecord(record, popvalue);
251
- }
252
- if (e.keyCode === 37 && e.shiftKey) { // 左滑动
253
- e.stopPropagation();
254
- e.preventDefault();
255
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
256
- if (dom) {
257
- dom.select();
258
- dom.focus();
259
- dom.scrollIntoView(false)
260
- }
261
- dom = null
262
- }
263
- if (e.keyCode === 39 && e.shiftKey) { // 右滑
264
- e.stopPropagation();
265
- e.preventDefault();
266
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
267
- if (dom) {
268
- dom.select();
269
- dom.focus();
270
- dom.scrollIntoView(false)
271
- }
272
- dom = null
273
- }
274
- if (e.keyCode === 40) {
275
- e.stopPropagation();
276
- e.preventDefault();
277
- let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
278
- if (dom) {
279
- dom.select();
280
- dom.focus();
281
- dom.scrollIntoView(false)
282
- }
283
- dom = null
284
- } else if (e.keyCode === 38) {
285
- e.stopPropagation();
286
- e.preventDefault();
287
- let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
288
- if (dom1) {
289
- // dom1.value=""
290
- // dom1.setSelectionRange(100, 0);
291
- dom1.select();
292
- dom1.focus();
293
- dom1.scrollIntoViewIfNeeded(false)
294
- // dom1.value=record['count']
295
- }
296
- dom1 = null
297
- } else if (e.keyCode === 9 && index === selectedRowKeys.length - 1 && currentIndex === inputLength - 1) {
298
- e.stopPropagation();
299
- e.preventDefault();
300
- }
301
- }}
302
- />
303
- );
304
- },
305
- }
306
- }
307
-
308
- const selectLength = modalTableProps.selectColumn.filter(item => item.isSelectItem).length
309
- const currentSelectIndex = selectIndex
310
- if(item.isSelectItem) {
311
- selectIndex++;
312
- return {
313
- ...item,
314
- render: (text, record, index) => {
315
- if (item?.dataSource?.length || item?.dataSourceCode) {
316
- const selectKey = item?.dataSourceMapping?.[0] || 'code';
317
- const selectText = item?.dataSourceMapping?.[1] || 'name';
318
- const dataSourceList = getSelectDataList(record,item,selectKey);
319
- return (
320
- <Select
321
- {...item.selectProps}
322
- value={text || null}
323
- onChange={async (value) => {
324
- const dataSourceSelectItem = dataSourceList?.find(d => d[selectKey] == value)||{}
325
- if(item?.selectChangeCallback) {
326
- // 由使用者定义下拉框改变如何处理数据
327
- await item?.selectChangeCallback?.(popvalue,setPopValue,{ record, index, item, oldValue:text, changeValue:value, dataSourceSelectItem, editRecord })
328
- } else {
329
- // 更新当前行数据函数
330
- const changeValue = (v,dSSItem) => {
331
- record[item.dataIndex] = v
332
- // 下拉框带出需要回填的数据
333
- if(item?.dataSourceSelectBackData?.length) {
334
- item?.dataSourceSelectBackData.forEach(s => {
335
- record[s] = dSSItem ? dSSItem[s] : null;
336
- })
337
- }
338
- }
339
-
340
- // 处理校验,默认不校验
341
- let isCheckPass = true;
342
- try {
343
- if(item?.selectCheckCallback) {
344
- isCheckPass = await item?.selectCheckCallback(popvalue,{ record, index, item, oldValue:text, changeValue:value, dataSourceSelectItem })
345
- } else {
346
- // 兼容老代码
347
- const isConformToTheRules = await checkSelectChange(businessType,popvalue,mappingValueField,record,item,value)
348
- isCheckPass = !isConformToTheRules;
349
- }
350
- } catch (error) {
351
-
352
- }
353
-
354
- if(isCheckPass) {
355
- changeValue(value,dataSourceSelectItem)
356
- } else {
357
- changeValue(null)
358
- }
359
-
360
- // 更新已选表格函数
361
- editRecord(record)
362
- }
363
- }}
364
- style={{width: `${item?.width && (item?.width -20) || '160'}px`}}
365
- >
366
- {dataSourceList?.map((item: any) => {
367
- return <Select.Option value={item[selectKey]}>{item[selectText]}</Select.Option>
368
- })}
369
- </Select>
370
- )
371
- }
372
- return <></>
373
- },
374
- }
375
- }
376
-
377
- return item
378
- }), {
379
- title: '操作',
380
- width: 50,
381
- dataIndex: 'operation',
382
- fixed: 'right',
383
- render: (text, record, index) => {
384
- return (
385
- <span style={{cursor: 'pointer', color: '#005CFF' }} onClick={() => {
386
- deleteRecord(record)
387
- }} type={"text"}>删除</span>
388
- )
389
- }
390
- },])
391
- }, [modalTableProps?.selectColumn,popvalue])
392
-
393
- // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
394
- const getData = (params = {}, type = 1) => {
395
- if (!requestConfig) return;
396
-
397
- setFetching(true)
398
-
399
- // 处理dependence参数
400
- const fixedParam = {};
401
-
402
- // 数组对象处理,对带有特殊标记的name进行处理
403
- for (const key in params) {
404
- if (Object.prototype.hasOwnProperty.call(params, key)) {
405
- const element = params[key];
406
- if (element && key.indexOf('*number*') >= 0) {
407
- const dataParams = key.split('*number*');
408
- dataParams.forEach((value, index) => {
409
- params[value] = element[index];
410
- });
411
- delete params[key];
412
- } else if (element && key.indexOf('*address*') >= 0) {
413
- const dataParams = key.split('*address*');
414
- dataParams.forEach((value, index) => {
415
- params[value] = element.PCDCode[index];
416
- });
417
- delete params[key];
418
- } else if (element && key.indexOf('*costType*') >= 0) {
419
- const dataParams = key.split('*costType*');
420
- // eslint-disable-next-line prefer-destructuring
421
- params[dataParams[0]] = element[1];
422
- delete params[key];
423
- } else if (element && key.indexOf('*fullDate*') >= 0) {
424
- const dataParams = key.split('*fullDate*');
425
- dataParams.forEach((value, index) => {
426
- if (index === 0) {
427
- params[value] = moment(element[index])
428
- .millisecond(0)
429
- .second(0)
430
- .minute(0)
431
- .hour(0)
432
- .format('YYYY-MM-DD HH:mm:ss');
433
- } else {
434
- params[value] = moment(element[index])
435
- .millisecond(59)
436
- .second(59)
437
- .minute(59)
438
- .hour(23)
439
- .format('YYYY-MM-DD HH:mm:ss');
440
- }
441
- });
442
- delete params[key];
443
- } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
444
- const dataParams = key.split('*checkBox*');
445
- if (element) {
446
- params[dataParams[0]] = 0
447
- }
448
- delete params[key];
449
- } else if (element && key.indexOf('*cascader*') >= 0) {
450
- const dataParams = key.split('*cascader*');
451
- params[dataParams[0]] = element[element.length - 1]
452
- delete params[key];
453
- } else if (element && key.indexOf('*date*') >= 0) {
454
- const dataParams = key.split('*date*')
455
- dataParams.forEach((value, index) => {
456
- if (index === 0) {
457
- params[value] = moment(element[index])
458
- .format('YYYY-MM-DD');
459
- } else {
460
- params[value] = moment(element[index])
461
- .format('YYYY-MM-DD');
462
- }
463
- });
464
- delete params[key];
465
- } else if (element && key.indexOf('*multiInput') >= 0) {
466
- let name = '',
467
- value = element['value'];
468
- if (value.indexOf(',') >= 0) {
469
- name = `qp-${element['name']}-in`;
470
- } else {
471
- name = `qp-${element['name']}-like`;
472
- }
473
- params[name] = value;
474
- delete params[key];
475
- }
476
- else if (element && key.indexOf('*') >= 0) {
477
- const dataParams = key.split('*');
478
- dataParams.forEach((value, index) => {
479
- params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
480
- });
481
- delete params[key];
482
- } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
483
- const dataParams = key.split('_selectNumberRange')[0]
484
- if (params[key][0] === 'range') {
485
- if (params[key][1][0]) {
486
- params[`qp-${dataParams}-ge`] = params[key][1][0]
487
- }
488
- if (params[key][1][1]) {
489
- params[`qp-${dataParams}-le`] = params[key][1][1]
490
- }
491
- } else {
492
- params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
493
- }
494
- delete params[key]
495
- } else if (Array.isArray(element)) {
496
- params[key] = element.join(',');
497
- } else if (element == null || element === undefined || String(element).trim() === '') {
498
- delete params[key]
499
- }
500
- }
501
- }
502
-
503
- const queryParams = {
504
- pageSize,
505
- currentPage,
506
- ...otherParams, // 默认参数
507
- ...fixedParam,
508
- ...params,
509
- }
510
- //todo 为了满足单个使用like查询,多个含,的使用in查询
511
- if(!queryParams.unConvert){
512
- Object.keys(queryParams).forEach(key =>{
513
- if(String(queryParams[key]).includes(',')){
514
- if(key.includes('like')){
515
- queryParams[key.replace('like','in')]=queryParams[key];
516
- delete queryParams[key];
517
- }
518
- }
519
- })
520
- }
521
- request
522
- .get(`${url}${url.includes("?")?"&":"?"}${stringify(queryParams)}`)
523
- .then((result: any) => {
524
- setFetching(false)
525
- result = result.data;
526
- if (judgeIsRequestError(result)) {
527
- message.error(result.msg);
528
- return;
529
- }
530
- const res = result.data;
531
- let source = [];
532
- if (isMap) {
533
- source = Object.keys(res).map((d, i) => {
534
- return {
535
- text: Object.values(res)[i],
536
- value: d,
537
- };
538
- });
539
- } else {
540
- const keys = res.list ? 'list' : 'items';
541
- source = res
542
- ? res[keys]
543
- ? res[keys].map((item: any) => {
544
- return {
545
- ...item,
546
- value: item[mappingValueField],
547
- baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
548
- };
549
- })
550
- : Array.isArray(res) &&
551
- res?.map((item: Record<string, any>) => {
552
- return {
553
- ...item,
554
- value: item[mappingValueField],
555
- baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
556
- };
557
- })
558
- : [];
559
- }
560
- source = Array.isArray(source) ? source : []
561
-
562
- setTableData(source)
563
- setTablePagination({ ...tablePagination, total: Number(res?.total || res?.totalCount || source.length), pageSize: Number(res?.size || res?.pageSize || (params?.pageSize || pageSize)), current: Number(res?.page || res?.currentPage || (params?.currentPage || currentPage)) })
564
- })
565
- .catch((err: any) => { setFetching(false) });
566
- }
567
-
568
- useEffect(() => {
569
- const pList = modalTableProps?.promiseLoadList || []
570
- if(!pList?.length) return;
571
- const list = pList.map((i: any) => {
572
- return loadSelectSource(i.url, i.params)
573
- });
574
- Promise.all(list).then((x: any)=>{
575
- formatFormSourceList(x,pList,tableSearchForm)
576
- })
577
- }, [businessType])
578
-
579
- useEffect(() => {
580
- if (value) {
581
- setPopValue(value);
582
- }
583
- }, [value]);
584
-
585
- useEffect(() => {
586
- makeUniqueValue();
587
- }, [sourceName])
588
-
589
- const showModal = () => {
590
- // getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
591
- setIsModalVisible(true);
592
- // 回显
593
- if (value) {
594
- if (selectMode) {
595
- setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
596
- setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
597
- } else {
598
- setSelectedRowKeys(labelInValue ? [value.key] : [value])
599
- setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
600
- }
601
- }
602
-
603
- setTimeout(() => {
604
- document.getElementById("first-query")?.focus()
605
- }, 50)
606
- };
607
-
608
- const handleShowModal = () => {
609
- if(beforeShowModal) {
610
- beforeShowModal(popvalue).then(res => {
611
- showModal()
612
- }).catch(Error => {
613
- message.warning(Error)
614
- })
615
- } else {
616
- showModal()
617
- }
618
- }
619
-
620
- const handleLoading = (isContinue,flag) => {
621
- isContinue ? setConfirmContinueLoading(flag) : setConfirmLoading(flag);
622
- }
623
-
624
- const handleOk = (isContinue) => {
625
- if(!popvalue.length) {
626
- message.warning('至少选中一条数据')
627
- return;
628
- }
629
-
630
- if(onSaveCallback) {
631
- handleLoading(isContinue,true)
632
- onSaveCallback(popvalue).then(res => {
633
- if(true) {
634
- // 成功信息可以在调用处处理 即resolve({messageSuccessBackInfo: { needThrowSuccess: false } })、resolve({messageSuccessBackInfo: { needThrowSuccess: true, successMessage: '已保存' } })
635
- let initSuccessMessage = '保存成功'
636
- const rmsbi = res?.messageSuccessBackInfo || {};
637
- if(rmsbi && Object.keys(rmsbi)?.length){
638
- rmsbi?.needThrowSuccess ? message.success(rmsbi?.successMessage || initSuccessMessage) : null
639
- } else {
640
- message.success(initSuccessMessage)
641
- }
642
- deleteSelectRows();
643
- document.getElementById('first-query')?.focus()
644
- !isContinue && handleCancel();
645
- } else {
646
- }
647
- handleLoading(isContinue,false)
648
- }).catch(Error => {
649
- if(typeof Error === 'object') {
650
- !Error.needThrowError ? null : message.error(Error.message)
651
- } else {
652
- message.error(Error);
653
- }
654
- handleLoading(isContinue,false)
655
- })
656
- } else {
657
- !isContinue && handleCancel();
658
- }
659
- };
660
-
661
- const handleCancel = () => {
662
- form.resetFields();
663
- setTableFormParams({});
664
- setIsModalVisible(false);
665
- setTableData([])
666
- onCancelCallback && onCancelCallback();
667
- // if (selectMode) {
668
- // run();
669
- // }
670
- };
671
-
672
- const onSearchTable = () => {
673
- form.validateFields()
674
- .then(() => {
675
- const params = form.getFieldsValue();
676
- setTableFormParams(params);
677
- getData({ ...params, pageSize: tableInitPageSize }, 2)
678
- })
679
- }
680
-
681
- const onResetTable = () => {
682
- form.resetFields();
683
- setTableFormParams({});
684
- form.validateFields()
685
- .then(() => {
686
- getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
687
- })
688
- .catch(() => {
689
- setTableData([]);
690
- })
691
- }
692
-
693
- const handleTableChange = (pagination) => {
694
- getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
695
- }
696
-
697
- // 扁平化二维数组的方法
698
- const mapRows = params => {
699
- var res = [];
700
- for (var i = 0; i < params.length; i++) {
701
- if (Array.isArray(params[i])) {
702
- // 去重
703
- res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
704
- } else {
705
- res.push(params[i]);
706
- // 去重
707
- res = _.uniqBy(res, 'value')
708
- }
709
- }
710
- return res.filter(Boolean); //去掉undefined的情况
711
- };
712
-
713
- const onChangeSelectedKeys = (selectKeys, selectRows) => {
714
- if(selectKeys.length - selectedRowKeys.length > 0) {
715
- if (selectKeys.length - selectedRowKeys.length === 1) {
716
- selectRows[selectRows.length -1]['needFocus'] = true;
717
- } else {
718
- selectRows[selectedRowKeys.length]['needFocus'] = true;
719
- }
720
- }
721
- if(isAllowRepeatedSelect) {
722
- const handleSelectRows = selectRows.map((i: any) => {
723
- const newUuid = uuid();
724
- return {...i, uuid: newUuid}
725
- })
726
- const list = popvalue.concat(handleSelectRows);
727
- const recordList = handleSelectRows
728
- setPopValue(setBusinessDefaultValue(list,recordList));
729
- setSelectedRowKeys([])
730
- } else {
731
- setPopValue(selectRows);
732
- setSelectedRowKeys(selectKeys)
733
- }
734
- }
735
-
736
- // 生成唯一值
737
- const makeUniqueValue = () => {
738
- const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
739
- setUniqueValue(generateUnitKey);
740
- return generateUnitKey;
741
- }
742
-
743
- const rowSelection = {
744
- type: 'checkbox',
745
- selectedRowKeys,
746
- preserveSelectedRowKeys: true,
747
- onChange: (sks, srs) => {
748
- onChangeSelectedKeys(sks, srs)
749
- },
750
- getCheckboxProps: () => ({
751
- disabled: selectProps?.disabled || props?.disabled,
752
- }),
753
- };
754
-
755
- const onDoubleClickSelect = (e, record) => {
756
- if (!selectMode) {
757
- const srs = [JSON.parse(JSON.stringify(record))]
758
- const sks = srs.map((i: any) => i.value)
759
- onChangeSelectedKeys(sks, srs)
760
- }
761
- }
762
-
763
- const themeColor = { color: '#005CFF' }
764
-
765
- const formItem = (list: Array<SearchFormItem>) => {
766
- if (isModalVisible && list?.length) {
767
- return list.map((i: SearchFormItem, index) => {
768
- const {name, label, field, type='', filterFormItem, initialSource=[], ...restProps} = i;
769
-
770
- if (type === 'custom_filter_form_item') return filterFormItem;
771
-
772
- if (type === 'select' || field?.type === 'select') {
773
- return (
774
- <Form.Item name={name} label={label} key={name} {...restProps}>
775
- <Select style={{ width: '100%' }} placeholder='请选择' {...field?.props}>
776
- {initialSource.length && initialSource.map((m: any) => (
777
- <Option value={m.value} key={m.value}>{m.text}</Option>
778
- ))}
779
- </Select>
780
- </Form.Item>
781
- )
782
- }
783
-
784
- if (type === 'treeSelect' || field?.type === 'treeSelect') {
785
- return (
786
- <Form.Item name={name} label={label} key={name} {...restProps}>
787
- <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...field?.props}></TreeSelect>
788
- </Form.Item>
789
- )
790
- }
791
-
792
- if (type === 'BusinessSearchSelect' || field?.type === 'BusinessSearchSelect') {
793
- return (
794
- <div>
795
- <Form.Item name={name} label={label} key={name} {...restProps}>
796
- <BusinessSearchSelect {...field?.props} />
797
- </Form.Item>
798
- </div>
799
- )
800
- }
801
-
802
- if (type === 'multipleQueryInput' || field?.type === 'multipleQueryInput') {
803
- return (
804
- <div>
805
- <Form.Item name={name} label={label} key={name} {...restProps}>
806
- <QueryMutipleInput onValueChange={(value) => {
807
- form.setFieldsValue({
808
- [name]: value
809
- })
810
- }} />
811
- </Form.Item>
812
- </div>
813
- );
814
- }
815
-
816
- // 默认type是input
817
- return (
818
- <Form.Item name={name} label={label} key={name} {...restProps}>
819
- <Input id={index === 0 ? "first-query" : 'index'} style={{ width: '100%' }} onKeyDown={(e) => {
820
- if (e.keyCode === 13) {
821
- onSearchTable()
822
- }
823
- }} placeholder='请输入' allowClear maxLength={100} {...field?.props} />
824
- </Form.Item>
825
- )
826
- })
827
- } else {
828
- return null
829
- }
830
- }
831
-
832
- const deleteSelectRows = () => {
833
- setPopValue([])
834
- setSelectedRowKeys([])
835
- }
836
-
837
- const deleteRecord = (record) => {
838
- if(isAllowRepeatedSelect) {
839
- setPopValue(popvalue.filter(item => item.uuid !== record.uuid))
840
- setSelectedRowKeys([])
841
- } else {
842
- setPopValue(popvalue.filter(item => item[selectRowKey] !== record[selectRowKey]))
843
- setSelectedRowKeys([...selectedRowKeys.filter(item => item !== record[selectRowKey])])
844
- }
845
- }
846
-
847
- const editRecord = (record) => {
848
- const newPopValue = [...popvalue]
849
- const index = newPopValue.findIndex(item => record[selectRowKey] == item[selectRowKey]);
850
- const item = newPopValue[index]
851
- newPopValue.splice(index, 1, {
852
- ...item,
853
- ...record
854
- })
855
- setPopValue([...newPopValue])
856
- }
857
-
858
- let inputIndex = 0;
859
- let selectIndex = 0;
860
-
861
- useEffect(() => {
862
- setInitialShowColumn(codeSelected,selectColumns,(res) => {
863
- setShowColumnsCallback(res)
864
- })
865
- },[selectColumns])
866
- useEffect(() => {
867
- setInitialShowColumn(codeToChoose,tableColumns,(res) => {
868
- setShowToChooseColumnsCallback(res)
869
- })
870
- },[tableColumns])
871
-
872
- const handleResize = (arr,index: any, callback) => (_: any, { size }: any) => {
873
- let newColumns = arr.map((col: any) => ({ ...col }));
874
- const handleIndex = (arr: any, indexArr: any) => {
875
- let i = indexArr.shift();
876
- if (indexArr.length > 0) {
877
- handleIndex(arr[i].children, indexArr);
878
- } else {
879
- arr[i] = {
880
- ...arr[i],
881
- width: size.width,
882
- };
883
- handleAntdColumnsSpecialParams(arr[i]);
884
- }
885
- };
886
- handleIndex(newColumns, [...index]);
887
- callback(newColumns)
888
- };
889
-
890
- const setShowColumnsCallback = (newColumns: Array<any>) => {
891
- setShowColumns([...newColumns])
892
- }
893
- const setShowToChooseColumnsCallback = (newColumns: Array<any>) => {
894
- setShowToChooseColumns([...newColumns])
895
- }
896
-
897
- const handleColumns = (arr: any, indexArr: any[], callback: any) => {
898
- arr.forEach((item: any, index: any) => {
899
- let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
900
- if (noEmptyArray(item.children)) {
901
- handleColumns(item.children, indexArrInside);
902
- } else {
903
- item.width = item.width || getItemDefaultWidth(item);
904
- item.onHeaderCell = (column: any) => ({
905
- ...item,
906
- width:
907
- typeof column.width === 'number'
908
- ? column.width
909
- : parseInt(column.width.replace('px', '')),
910
- onResize: handleResize(arr,indexArrInside, callback),
911
- });
912
- }
913
- })
914
- };
915
- let showToChooseCol = showToChooseColumns.map((item: any) => {
916
- handleAntdColumnsSpecialParams(item);
917
- return ({ ...item })
918
- })
919
- handleColumns(showToChooseCol, [],(res)=> setShowToChooseColumnsCallback(res));
920
- let showSelectedCol = showColumns.map((item: any) => {
921
- handleAntdColumnsSpecialParams(item);
922
- return ({ ...item })
923
- })
924
- handleColumns(showSelectedCol, [],(res)=> setShowColumnsCallback(res));
925
-
926
- const selectLength = isAllowRepeatedSelect ? (popvalue?.length || 0) : (selectedRowKeys?.length || 0)
927
- return (
928
- <div className={'add_select'}>
929
- <div className="add_select_show" id={`add_select_div_${uniqueValue}`}>
930
- <Button onClick={handleShowModal} {...realButtonProps}>
931
- {buttonText}
932
- </Button>
933
- </div>
934
- {isModalVisible && (
935
- <Modal
936
- width='1200px'
937
- style={{ top: 20 }}
938
- bodyStyle={{ padding: '0px' }}
939
- visible={isModalVisible}
940
- closable={false}
941
- onCancel={handleCancel}
942
- footer={selectMode ? [
943
- <Button key="back" onClick={handleCancel}>
944
- 取消
945
- </Button>,
946
- <Button
947
- key="save-and-continue"
948
- style={{color: '#005CFF', borderColor: '#005CFF'}}
949
- onClick={() => {handleOk(true)}}
950
- loading={confirmContinueLoading}
951
- disabled={confirmLoading || !tableData.length || (selectProps?.disabled || props?.disabled)}
952
- >
953
- 保存并继续
954
- </Button>,
955
- <Button
956
- key="submit"
957
- type="primary"
958
- onClick={() => {handleOk(false)}}
959
- loading={confirmLoading}
960
- disabled={confirmContinueLoading || !tableData.length || (selectProps?.disabled || props?.disabled)}
961
- >
962
- 确定
963
- </Button>,
964
- ] : null}
965
- >
966
- <div>
967
- <div className='add_select_header'>
968
- {modalTableProps?.modalTableTitle}
969
- <span><span>*</span> &nbsp;快捷键:【Tab】-跳格切换;【Shift+←、→】-当前行左、右移动;【 ↑、↓】-当前列上、下移动;【ctrl+Enter】-保存并继续;【ctrl+Delete】-删除当前行;</span>
970
- <span className='add_select_header_close'><CloseCircleOutlined style={{fontSize: '20px'}} onClick={handleCancel} /></span>
971
- </div>
972
- <div className={'add_select_wrapper'}>
973
- <div className={caretLeftFlag ? 'add_select_wrapper_left' : 'add_select_wrapper_left1'}>
974
- <div className={'select_list_columns'}>
975
- <div className={'select_list_columns_formItems'}>
976
- <Form form={form} layout='vertical' key='modalForm'>
977
- {formItem(tableSearchForm)}
978
- </Form>
979
- </div>
980
- </div>
981
- <div className={'select_list_searchButton'}>
982
- <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
983
- <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
984
- </div>
985
- </div>
986
- <div className={caretLeftFlag ? 'add_select_wrapper_right' : 'add_select_wrapper_right1'}>
987
- <div>
988
- <div className={'select_list_selectTips'}>
989
- <div style={{ marginLeft: 8 }}>搜索结果共&nbsp;<span style={themeColor}>{tablePagination?.total || 0}</span>&nbsp;项{selectMode ? <span>, 本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span> : ''}</div>
990
- <div>
991
- <span style={{ marginRight: 8 }}>
992
- <TableColumnSetting
993
- setShowColumns={setShowToChooseColumnsCallback}
994
- showColumns={showToChooseColumns}
995
- datasource={tableColumns || []}
996
- tableCode={codeToChoose}
997
- settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
998
- />
999
- </span>
1000
- </div>
1001
- </div>
1002
- <Table
1003
- size='small'
1004
- rowSelection={rowSelection}
1005
- columns={showToChooseCol}
1006
- dataSource={tableData}
1007
- pagination={tablePagination}
1008
- loading={fetching}
1009
- onChange={handleTableChange}
1010
- rowKey={mappingValueField}
1011
- rowClassName={'row-class'}
1012
- scroll={{ y: 500 }}
1013
- components={{
1014
- header: {
1015
- cell: ResizeableTitle,
1016
- },
1017
- }}
1018
- />
1019
- </div>
1020
- </div>
1021
- </div>
1022
- <div className={'add_select_wrapper_select'}>
1023
- <div className={'select_list_selectTips'}>
1024
- <div style={{ marginLeft: 8 }}><span>本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span></div>
1025
- <div style={{ display: 'flex' }}>
1026
- <span style={{ marginRight: 8 }}>
1027
- <TableColumnSetting
1028
- setShowColumns={setShowColumnsCallback}
1029
- showColumns={showColumns}
1030
- datasource={selectColumns || []}
1031
- tableCode={codeSelected}
1032
- settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1033
- />
1034
- </span>
1035
- <div style={{ marginRight: 8 }}><span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>{clearTitle??'清空所选商品'}</span></div>
1036
- </div>
1037
- </div>
1038
- <Table
1039
- size='small'
1040
- columns={showSelectedCol}
1041
- dataSource={popvalue}
1042
- pagination={false}
1043
- rowKey={selectRowKey}
1044
- rowClassName={'row-class'}
1045
- scroll={{ y: 500 }}
1046
- onRow={record => {
1047
- return {
1048
- onDoubleClick: event => onDoubleClickSelect(event, record),
1049
- };
1050
- }}
1051
- components={{
1052
- header: {
1053
- cell: ResizeableTitle,
1054
- },
1055
- }}
1056
- />
1057
- </div>
1058
- </div>
1059
- </Modal>
1060
- )}
1061
- </div>
1062
- );
1063
- };
1064
-
1065
- export default AddSelect;
1
+ // @ts-nocheck
2
+ import React, { useState, useEffect } from 'react';
3
+ import { useDebounceFn } from 'ahooks';
4
+ import { Input, Button, Modal, Select, InputNumber, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
5
+ import { SearchOutlined, CopyOutlined, CloseCircleOutlined } from '@ant-design/icons';
6
+ import request from '@/utils/request';
7
+ import { stringify } from 'querystring';
8
+ import _ from "lodash"
9
+ import './index.less';
10
+ import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
+ import { Resizable } from 'react-resizable';
12
+ import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
13
+ import TableColumnSetting from '@/plugin/TableColumnSetting';
14
+ import { setInitialShowColumn } from '@/plugin/TableColumnSetting/utils';
15
+ import { handleAntdColumnsSpecialParams, uuid } from '@/utils/utils';
16
+ import { judgeIsRequestError } from '@/utils/requestUtils';
17
+ import { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
18
+ import { getSelectDataList, loadSelectSource, formatFormSourceList } from './helps';
19
+
20
+ interface SearchFormItem {
21
+ name: string;
22
+ label: string;
23
+ filterFormItem?: FormItemProps;
24
+ initialSource?: any[];
25
+ field: any;
26
+ type?: string;
27
+ [formItemProps: string]: any;
28
+ }
29
+
30
+ const checkSpuMatchCode = (data: any) => {
31
+ return new Promise((resolve, reject) => {
32
+ request.post(`/stock/rwFrontRecordSkcDetail/checkSpuMatchCode`,data)
33
+ .then((result: any) => {
34
+ result = result.data;
35
+ if (judgeIsRequestError(result)) {
36
+ message.error(result.msg);
37
+ reject(false);
38
+ return;
39
+ }
40
+ resolve(result);
41
+ })
42
+ .catch((err: any) => {
43
+ reject(err);
44
+ });
45
+ })
46
+ }
47
+
48
+ const ResizeableTitle = (props) => {
49
+ const { onResize, width, ...restProps } = props;
50
+
51
+ if (!width) {
52
+ return <th {...restProps} />;
53
+ }
54
+ return (
55
+ <Resizable
56
+ width={width}
57
+ height={0}
58
+ onResize={onResize}
59
+ draggableOpts={{ enableUserSelectHack: false }}
60
+ >
61
+ <th {...restProps} />
62
+ </Resizable>
63
+ );
64
+ };
65
+
66
+ const initTableCode = {
67
+ 'sku': ['skuSelect-tableOptionsToChoosePartCode','skuSelect-tableSelectedItemPartCode'],
68
+ 'skc': ['skcSelect-tableOptionsToChoosePartCode','skcSelect-tableSelectedItemPartCode'],
69
+ 'spu': ['spuSelect-tableOptionsToChoosePartCode','spuSelect-tableSelectedItemPartCode']
70
+ }
71
+
72
+ const { Option } = Select;
73
+
74
+ const AddSelect = (props: any) => {
75
+ const {
76
+ value, // 必传
77
+ selectProps = {},
78
+ modalTableProps = {},
79
+ labelInValue = false,
80
+ requestConfig,
81
+ sourceName,
82
+ onSaveCallback,
83
+ onCancelCallback,
84
+ buttonText = '添加',
85
+ buttonProps = {},
86
+ beforeShowModal,
87
+ tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
88
+ businessType = 'sku',
89
+ isAllowRepeatedSelect = false,
90
+ clearTitle
91
+ } = props;
92
+ const { url, otherParams, isMap, mappingValueField = 'code' } = requestConfig || {};
93
+ const realButtonProps = {type: "primary", ...buttonProps};
94
+ const selectRowKey = isAllowRepeatedSelect ? 'uuid' : mappingValueField
95
+
96
+ const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
97
+ const initVal = value || (selectMode ? [] : null);
98
+ const pageSize = 100 // 下拉框默认分页 条数
99
+ const tableInitPageSize = 10 // 弹框默认分页 条数
100
+ const currentPage = 1
101
+
102
+ const [fetching, setFetching] = useState(false);
103
+ const [isModalVisible, setIsModalVisible] = useState(false);
104
+ const [popvalue, setPopValue] = useState(initVal);
105
+ const [uniqueValue, setUniqueValue] = useState(sourceName)
106
+
107
+ const [form] = Form.useForm();
108
+ const [tableSearchForm, setTableSearchForm] = useState<Array<SearchFormItem>>(modalTableProps?.tableSearchForm)
109
+ const [caretLeftFlag, setCaretLeftFlag] = useState(true);
110
+ const [tableData, setTableData] = useState([]);
111
+ const [tablePagination, setTablePagination] = useState({ total: 0, size: "small", current: 1, pageSize: tableInitPageSize })
112
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
113
+ const [tableFormParams, setTableFormParams] = useState({});
114
+ const [confirmLoading, setConfirmLoading] = useState(false);
115
+ const [confirmContinueLoading, setConfirmContinueLoading] = useState(false);
116
+
117
+ const [selectColumns, setSelectColumns] = useState([]);
118
+ const [showColumns, setShowColumns] = useState([]);
119
+ const [tableColumns, setTableColumns] = useState([]);
120
+ const [showToChooseColumns, setShowToChooseColumns] = useState([]);
121
+ const codeToChoose = tableCodeList[0] || initTableCode[businessType][0];
122
+ const codeSelected = tableCodeList[1] || initTableCode[businessType][1];
123
+
124
+ // FIXME: 特殊业务逻辑
125
+ const checkSelectChange = async (bType: string, tList: any, recordKey: string, recordItem: any, selectItem: any, changeValue: string) => {
126
+ if(bType == 'skc' && tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i[selectItem.dataIndex] == changeValue)) {
127
+ message.warning('相同skc配码不可设置相同哦')
128
+ return false
129
+ }
130
+ if(bType == 'spu') {
131
+ if(selectItem.dataIndex == 'colorName' && tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i.selectPropertyGroupCode == recordItem.selectPropertyGroupCode && i[selectItem.dataIndex] == changeValue)){
132
+ message.warning('相同商品相同配码颜色不可设置相同哦')
133
+ return false
134
+ }
135
+ if(selectItem.dataIndex == 'selectPropertyGroupCode' && !recordItem.colorName) {
136
+ message.warning('请先选择颜色!')
137
+ return false
138
+ }
139
+ if(selectItem.dataIndex == 'selectPropertyGroupCode'&& tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i.colorName == recordItem.colorName && i[selectItem.dataIndex] == changeValue)){
140
+ message.warning('相同商品相同颜色配码不可设置相同哦')
141
+ return false
142
+ }
143
+ if(selectItem.dataIndex == 'selectPropertyGroupCode') {
144
+ let result = true
145
+ try {
146
+ result = await checkSpuMatchCode({ skcCode: recordItem[recordKey], matchingCode: changeValue, ext1: recordItem.colorName });
147
+ result = true
148
+ } catch (e) {
149
+ result = typeof e == 'boolean' ? e : false
150
+ }
151
+ return result
152
+ }
153
+ }
154
+ return true
155
+ }
156
+ const setBusinessDefaultValue = (list: any, recordList: any) => {
157
+ let result = list;
158
+ // FIXME: 特殊业务逻辑
159
+ if(businessType == 'spu' && (recordList?.some((i: any) => i?.colorValues?.length == 1) || recordList?.some((i: any) => i?.defaultMatchingCode))) {
160
+ result = list.map((i: any) => {
161
+ recordList.forEach((record: any) => {
162
+ if(i.uuid == record?.uuid) {
163
+ if(record.colorValues?.length == 1) {
164
+ i.colorName = record.colorValues[0]?.value;
165
+ }
166
+ i.selectPropertyGroupCode = record?.defaultMatchingCode;
167
+ }
168
+ })
169
+ return i
170
+ })
171
+ }
172
+ return result
173
+ }
174
+
175
+ useEffect(() => {
176
+ setTableColumns(modalTableProps?.tableColumns)
177
+ }, [modalTableProps?.tableColumns])
178
+
179
+ useEffect(() => {
180
+ setSelectColumns([... modalTableProps.selectColumn.map(item => {
181
+ const inputLength = modalTableProps.selectColumn.filter(item => item.isInputItem).length
182
+ const currentIndex = inputIndex
183
+
184
+ if (item.isInputItem) {
185
+ inputIndex++;
186
+ return {
187
+ ...item,
188
+ render: (text, record, index) => {
189
+ // let
190
+ if(record.needFocus === true && currentIndex === 0) {
191
+
192
+ }
193
+ // FIXME: 特殊业务逻辑
194
+ let precisionObj=businessType == 'skc'?{
195
+ precision: 0
196
+ }:{};
197
+ const unitAccuracy = record.packingUnitList?.[0]?.unitAccuracy
198
+ const isCountUnitAccuracyCheck = item.dataIndex =='count' && unitAccuracy !== undefined
199
+ if(isCountUnitAccuracyCheck) {
200
+ precisionObj = {
201
+ onBlur: (e: any) => {
202
+ const { target: { value } } = e;
203
+ if(!checkQuantityAccuracy(value,Number(unitAccuracy))) {
204
+ record[item.dataIndex] = precisionQuantity(value,Number(unitAccuracy))
205
+ const newPopValue = popvalue.map((i: any, innerIndex: number) => {
206
+ if(innerIndex == index) {
207
+ i[item.dataIndex] = record[item.dataIndex]
208
+ }
209
+ return i
210
+ })
211
+ setPopValue(newPopValue)
212
+ }
213
+ }
214
+ // precision: unitAccuracy
215
+ }
216
+ }
217
+ return (
218
+ <InputNumber
219
+ {...item.inputProps}
220
+ value={text || ''}
221
+ min={0}
222
+ autoFocus={record.needFocus}
223
+ keyboard={false}
224
+ {...precisionObj}
225
+ onChange={(value) => {
226
+ record[item.dataIndex] = value
227
+ editRecord(record)
228
+ }}
229
+ // onFocus={(e)=> {
230
+ // let dom1 = e.currentTarget;
231
+ // dom1.setSelectionRange(100, 0);
232
+ // dom1.select(text);
233
+ // }}
234
+ onKeyDown={(e) => {
235
+ if(e.keyCode === 13 && e.ctrlKey) {
236
+ handleOk(true)
237
+ document.getElementById("first-query")?.focus()
238
+ }
239
+ if(e.keyCode === 8 && e.ctrlKey) {
240
+ message.success('删除当前行')
241
+ e.stopPropagation();
242
+ e.preventDefault();
243
+ let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
244
+ if (dom) {
245
+ dom.select();
246
+ dom.focus();
247
+ dom.scrollIntoView(false)
248
+ }
249
+ dom = null
250
+ deleteRecord(record, popvalue);
251
+ }
252
+ if (e.keyCode === 37 && e.shiftKey) { // 左滑动
253
+ e.stopPropagation();
254
+ e.preventDefault();
255
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
256
+ if (dom) {
257
+ dom.select();
258
+ dom.focus();
259
+ dom.scrollIntoView(false)
260
+ }
261
+ dom = null
262
+ }
263
+ if (e.keyCode === 39 && e.shiftKey) { // 右滑
264
+ e.stopPropagation();
265
+ e.preventDefault();
266
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
267
+ if (dom) {
268
+ dom.select();
269
+ dom.focus();
270
+ dom.scrollIntoView(false)
271
+ }
272
+ dom = null
273
+ }
274
+ if (e.keyCode === 40) {
275
+ e.stopPropagation();
276
+ e.preventDefault();
277
+ let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
278
+ if (dom) {
279
+ dom.select();
280
+ dom.focus();
281
+ dom.scrollIntoView(false)
282
+ }
283
+ dom = null
284
+ } else if (e.keyCode === 38) {
285
+ e.stopPropagation();
286
+ e.preventDefault();
287
+ let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
288
+ if (dom1) {
289
+ // dom1.value=""
290
+ // dom1.setSelectionRange(100, 0);
291
+ dom1.select();
292
+ dom1.focus();
293
+ dom1.scrollIntoViewIfNeeded(false)
294
+ // dom1.value=record['count']
295
+ }
296
+ dom1 = null
297
+ } else if (e.keyCode === 9 && index === selectedRowKeys.length - 1 && currentIndex === inputLength - 1) {
298
+ e.stopPropagation();
299
+ e.preventDefault();
300
+ }
301
+ }}
302
+ />
303
+ );
304
+ },
305
+ }
306
+ }
307
+
308
+ const selectLength = modalTableProps.selectColumn.filter(item => item.isSelectItem).length
309
+ const currentSelectIndex = selectIndex
310
+ if(item.isSelectItem) {
311
+ selectIndex++;
312
+ return {
313
+ ...item,
314
+ render: (text, record, index) => {
315
+ if (item?.dataSource?.length || item?.dataSourceCode) {
316
+ const selectKey = item?.dataSourceMapping?.[0] || 'code';
317
+ const selectText = item?.dataSourceMapping?.[1] || 'name';
318
+ const dataSourceList = getSelectDataList(record,item,selectKey);
319
+ return (
320
+ <Select
321
+ {...item.selectProps}
322
+ value={text || null}
323
+ onChange={async (value) => {
324
+ const dataSourceSelectItem = dataSourceList?.find(d => d[selectKey] == value)||{}
325
+ if(item?.selectChangeCallback) {
326
+ // 由使用者定义下拉框改变如何处理数据
327
+ await item?.selectChangeCallback?.(popvalue,setPopValue,{ record, index, item, oldValue:text, changeValue:value, dataSourceSelectItem, editRecord })
328
+ } else {
329
+ // 更新当前行数据函数
330
+ const changeValue = (v,dSSItem) => {
331
+ record[item.dataIndex] = v
332
+ // 下拉框带出需要回填的数据
333
+ if(item?.dataSourceSelectBackData?.length) {
334
+ item?.dataSourceSelectBackData.forEach(s => {
335
+ record[s] = dSSItem ? dSSItem[s] : null;
336
+ })
337
+ }
338
+ }
339
+
340
+ // 处理校验,默认不校验
341
+ let isCheckPass = true;
342
+ try {
343
+ if(item?.selectCheckCallback) {
344
+ isCheckPass = await item?.selectCheckCallback(popvalue,{ record, index, item, oldValue:text, changeValue:value, dataSourceSelectItem })
345
+ } else {
346
+ // 兼容老代码
347
+ const isConformToTheRules = await checkSelectChange(businessType,popvalue,mappingValueField,record,item,value)
348
+ isCheckPass = !isConformToTheRules;
349
+ }
350
+ } catch (error) {
351
+
352
+ }
353
+
354
+ if(isCheckPass) {
355
+ changeValue(value,dataSourceSelectItem)
356
+ } else {
357
+ changeValue(null)
358
+ }
359
+
360
+ // 更新已选表格函数
361
+ editRecord(record)
362
+ }
363
+ }}
364
+ style={{width: `${item?.width && (item?.width -20) || '160'}px`}}
365
+ >
366
+ {dataSourceList?.map((item: any) => {
367
+ return <Select.Option value={item[selectKey]}>{item[selectText]}</Select.Option>
368
+ })}
369
+ </Select>
370
+ )
371
+ }
372
+ return <></>
373
+ },
374
+ }
375
+ }
376
+
377
+ return item
378
+ }), {
379
+ title: '操作',
380
+ width: 50,
381
+ dataIndex: 'operation',
382
+ fixed: 'right',
383
+ render: (text, record, index) => {
384
+ return (
385
+ <span style={{cursor: 'pointer', color: '#005CFF' }} onClick={() => {
386
+ deleteRecord(record)
387
+ }} type={"text"}>删除</span>
388
+ )
389
+ }
390
+ },])
391
+ }, [modalTableProps?.selectColumn,popvalue])
392
+
393
+ // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
394
+ const getData = (params = {}, type = 1) => {
395
+ if (!requestConfig) return;
396
+
397
+ setFetching(true)
398
+
399
+ // 处理dependence参数
400
+ const fixedParam = {};
401
+
402
+ // 数组对象处理,对带有特殊标记的name进行处理
403
+ for (const key in params) {
404
+ if (Object.prototype.hasOwnProperty.call(params, key)) {
405
+ const element = params[key];
406
+ if (element && key.indexOf('*number*') >= 0) {
407
+ const dataParams = key.split('*number*');
408
+ dataParams.forEach((value, index) => {
409
+ params[value] = element[index];
410
+ });
411
+ delete params[key];
412
+ } else if (element && key.indexOf('*address*') >= 0) {
413
+ const dataParams = key.split('*address*');
414
+ dataParams.forEach((value, index) => {
415
+ params[value] = element.PCDCode[index];
416
+ });
417
+ delete params[key];
418
+ } else if (element && key.indexOf('*costType*') >= 0) {
419
+ const dataParams = key.split('*costType*');
420
+ // eslint-disable-next-line prefer-destructuring
421
+ params[dataParams[0]] = element[1];
422
+ delete params[key];
423
+ } else if (element && key.indexOf('*fullDate*') >= 0) {
424
+ const dataParams = key.split('*fullDate*');
425
+ dataParams.forEach((value, index) => {
426
+ if (index === 0) {
427
+ params[value] = moment(element[index])
428
+ .millisecond(0)
429
+ .second(0)
430
+ .minute(0)
431
+ .hour(0)
432
+ .format('YYYY-MM-DD HH:mm:ss');
433
+ } else {
434
+ params[value] = moment(element[index])
435
+ .millisecond(59)
436
+ .second(59)
437
+ .minute(59)
438
+ .hour(23)
439
+ .format('YYYY-MM-DD HH:mm:ss');
440
+ }
441
+ });
442
+ delete params[key];
443
+ } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
444
+ const dataParams = key.split('*checkBox*');
445
+ if (element) {
446
+ params[dataParams[0]] = 0
447
+ }
448
+ delete params[key];
449
+ } else if (element && key.indexOf('*cascader*') >= 0) {
450
+ const dataParams = key.split('*cascader*');
451
+ params[dataParams[0]] = element[element.length - 1]
452
+ delete params[key];
453
+ } else if (element && key.indexOf('*date*') >= 0) {
454
+ const dataParams = key.split('*date*')
455
+ dataParams.forEach((value, index) => {
456
+ if (index === 0) {
457
+ params[value] = moment(element[index])
458
+ .format('YYYY-MM-DD');
459
+ } else {
460
+ params[value] = moment(element[index])
461
+ .format('YYYY-MM-DD');
462
+ }
463
+ });
464
+ delete params[key];
465
+ } else if (element && key.indexOf('*multiInput') >= 0) {
466
+ let name = '',
467
+ value = element['value'];
468
+ if (value.indexOf(',') >= 0) {
469
+ name = `qp-${element['name']}-in`;
470
+ } else {
471
+ name = `qp-${element['name']}-like`;
472
+ }
473
+ params[name] = value;
474
+ delete params[key];
475
+ }
476
+ else if (element && key.indexOf('*') >= 0) {
477
+ const dataParams = key.split('*');
478
+ dataParams.forEach((value, index) => {
479
+ params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
480
+ });
481
+ delete params[key];
482
+ } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
483
+ const dataParams = key.split('_selectNumberRange')[0]
484
+ if (params[key][0] === 'range') {
485
+ if (params[key][1][0]) {
486
+ params[`qp-${dataParams}-ge`] = params[key][1][0]
487
+ }
488
+ if (params[key][1][1]) {
489
+ params[`qp-${dataParams}-le`] = params[key][1][1]
490
+ }
491
+ } else {
492
+ params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
493
+ }
494
+ delete params[key]
495
+ } else if (Array.isArray(element)) {
496
+ params[key] = element.join(',');
497
+ } else if (element == null || element === undefined || String(element).trim() === '') {
498
+ delete params[key]
499
+ }
500
+ }
501
+ }
502
+
503
+ const queryParams = {
504
+ pageSize,
505
+ currentPage,
506
+ ...otherParams, // 默认参数
507
+ ...fixedParam,
508
+ ...params,
509
+ }
510
+ //todo 为了满足单个使用like查询,多个含,的使用in查询
511
+ if(!queryParams.unConvert){
512
+ Object.keys(queryParams).forEach(key =>{
513
+ if(String(queryParams[key]).includes(',')){
514
+ if(key.includes('like')){
515
+ queryParams[key.replace('like','in')]=queryParams[key];
516
+ delete queryParams[key];
517
+ }
518
+ }
519
+ })
520
+ }
521
+ request
522
+ .get(`${url}${url.includes("?")?"&":"?"}${stringify(queryParams)}`)
523
+ .then((result: any) => {
524
+ setFetching(false)
525
+ result = result.data;
526
+ if (judgeIsRequestError(result)) {
527
+ message.error(result.msg);
528
+ return;
529
+ }
530
+ const res = result.data;
531
+ let source = [];
532
+ if (isMap) {
533
+ source = Object.keys(res).map((d, i) => {
534
+ return {
535
+ text: Object.values(res)[i],
536
+ value: d,
537
+ };
538
+ });
539
+ } else {
540
+ const keys = res.list ? 'list' : 'items';
541
+ source = res
542
+ ? res[keys]
543
+ ? res[keys].map((item: any) => {
544
+ return {
545
+ ...item,
546
+ value: item[mappingValueField],
547
+ baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
548
+ };
549
+ })
550
+ : Array.isArray(res) &&
551
+ res?.map((item: Record<string, any>) => {
552
+ return {
553
+ ...item,
554
+ value: item[mappingValueField],
555
+ baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
556
+ };
557
+ })
558
+ : [];
559
+ }
560
+ source = Array.isArray(source) ? source : []
561
+
562
+ setTableData(source)
563
+ setTablePagination({ ...tablePagination, total: Number(res?.total || res?.totalCount || source.length), pageSize: Number(res?.size || res?.pageSize || (params?.pageSize || pageSize)), current: Number(res?.page || res?.currentPage || (params?.currentPage || currentPage)) })
564
+ })
565
+ .catch((err: any) => { setFetching(false) });
566
+ }
567
+
568
+ useEffect(() => {
569
+ const pList = modalTableProps?.promiseLoadList || []
570
+ if(!pList?.length) return;
571
+ const list = pList.map((i: any) => {
572
+ return loadSelectSource(i.url, i.params)
573
+ });
574
+ Promise.all(list).then((x: any)=>{
575
+ formatFormSourceList(x,pList,tableSearchForm)
576
+ })
577
+ }, [businessType])
578
+
579
+ useEffect(() => {
580
+ if (value) {
581
+ setPopValue(value);
582
+ }
583
+ }, [value]);
584
+
585
+ useEffect(() => {
586
+ makeUniqueValue();
587
+ }, [sourceName])
588
+
589
+ const showModal = () => {
590
+ // getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
591
+ setIsModalVisible(true);
592
+ // 回显
593
+ if (value) {
594
+ if (selectMode) {
595
+ setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
596
+ setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
597
+ } else {
598
+ setSelectedRowKeys(labelInValue ? [value.key] : [value])
599
+ setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
600
+ }
601
+ }
602
+
603
+ setTimeout(() => {
604
+ document.getElementById("first-query")?.focus()
605
+ }, 50)
606
+ };
607
+
608
+ const handleShowModal = () => {
609
+ if(beforeShowModal) {
610
+ beforeShowModal(popvalue).then(res => {
611
+ showModal()
612
+ }).catch(Error => {
613
+ message.warning(Error)
614
+ })
615
+ } else {
616
+ showModal()
617
+ }
618
+ }
619
+
620
+ const handleLoading = (isContinue,flag) => {
621
+ isContinue ? setConfirmContinueLoading(flag) : setConfirmLoading(flag);
622
+ }
623
+
624
+ const handleOk = (isContinue) => {
625
+ if(!popvalue.length) {
626
+ message.warning('至少选中一条数据')
627
+ return;
628
+ }
629
+
630
+ if(onSaveCallback) {
631
+ handleLoading(isContinue,true)
632
+ onSaveCallback(popvalue).then(res => {
633
+ if(true) {
634
+ // 成功信息可以在调用处处理 即resolve({messageSuccessBackInfo: { needThrowSuccess: false } })、resolve({messageSuccessBackInfo: { needThrowSuccess: true, successMessage: '已保存' } })
635
+ let initSuccessMessage = '保存成功'
636
+ const rmsbi = res?.messageSuccessBackInfo || {};
637
+ if(rmsbi && Object.keys(rmsbi)?.length){
638
+ rmsbi?.needThrowSuccess ? message.success(rmsbi?.successMessage || initSuccessMessage) : null
639
+ } else {
640
+ message.success(initSuccessMessage)
641
+ }
642
+ deleteSelectRows();
643
+ document.getElementById('first-query')?.focus()
644
+ !isContinue && handleCancel();
645
+ } else {
646
+ }
647
+ handleLoading(isContinue,false)
648
+ }).catch(Error => {
649
+ if(typeof Error === 'object') {
650
+ !Error.needThrowError ? null : message.error(Error.message)
651
+ } else {
652
+ message.error(Error);
653
+ }
654
+ handleLoading(isContinue,false)
655
+ })
656
+ } else {
657
+ !isContinue && handleCancel();
658
+ }
659
+ };
660
+
661
+ const handleCancel = () => {
662
+ form.resetFields();
663
+ setTableFormParams({});
664
+ setIsModalVisible(false);
665
+ setTableData([])
666
+ onCancelCallback && onCancelCallback();
667
+ // if (selectMode) {
668
+ // run();
669
+ // }
670
+ };
671
+
672
+ const onSearchTable = () => {
673
+ form.validateFields()
674
+ .then(() => {
675
+ const params = form.getFieldsValue();
676
+ setTableFormParams(params);
677
+ getData({ ...params, pageSize: tableInitPageSize }, 2)
678
+ })
679
+ }
680
+
681
+ const onResetTable = () => {
682
+ form.resetFields();
683
+ setTableFormParams({});
684
+ form.validateFields()
685
+ .then(() => {
686
+ getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
687
+ })
688
+ .catch(() => {
689
+ setTableData([]);
690
+ })
691
+ }
692
+
693
+ const handleTableChange = (pagination) => {
694
+ getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
695
+ }
696
+
697
+ // 扁平化二维数组的方法
698
+ const mapRows = params => {
699
+ var res = [];
700
+ for (var i = 0; i < params.length; i++) {
701
+ if (Array.isArray(params[i])) {
702
+ // 去重
703
+ res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
704
+ } else {
705
+ res.push(params[i]);
706
+ // 去重
707
+ res = _.uniqBy(res, 'value')
708
+ }
709
+ }
710
+ return res.filter(Boolean); //去掉undefined的情况
711
+ };
712
+
713
+ const onChangeSelectedKeys = (selectKeys, selectRows) => {
714
+ if(selectKeys.length - selectedRowKeys.length > 0) {
715
+ if (selectKeys.length - selectedRowKeys.length === 1) {
716
+ selectRows[selectRows.length -1]['needFocus'] = true;
717
+ } else {
718
+ selectRows[selectedRowKeys.length]['needFocus'] = true;
719
+ }
720
+ }
721
+ if(isAllowRepeatedSelect) {
722
+ const handleSelectRows = selectRows.map((i: any) => {
723
+ const newUuid = uuid();
724
+ return {...i, uuid: newUuid}
725
+ })
726
+ const list = popvalue.concat(handleSelectRows);
727
+ const recordList = handleSelectRows
728
+ setPopValue(setBusinessDefaultValue(list,recordList));
729
+ setSelectedRowKeys([])
730
+ } else {
731
+ setPopValue(selectRows);
732
+ setSelectedRowKeys(selectKeys)
733
+ }
734
+ }
735
+
736
+ // 生成唯一值
737
+ const makeUniqueValue = () => {
738
+ const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
739
+ setUniqueValue(generateUnitKey);
740
+ return generateUnitKey;
741
+ }
742
+
743
+ const rowSelection = {
744
+ type: 'checkbox',
745
+ selectedRowKeys,
746
+ preserveSelectedRowKeys: true,
747
+ onChange: (sks, srs) => {
748
+ onChangeSelectedKeys(sks, srs)
749
+ },
750
+ getCheckboxProps: () => ({
751
+ disabled: selectProps?.disabled || props?.disabled,
752
+ }),
753
+ };
754
+
755
+ const onDoubleClickSelect = (e, record) => {
756
+ if (!selectMode) {
757
+ const srs = [JSON.parse(JSON.stringify(record))]
758
+ const sks = srs.map((i: any) => i.value)
759
+ onChangeSelectedKeys(sks, srs)
760
+ }
761
+ }
762
+
763
+ const themeColor = { color: '#005CFF' }
764
+
765
+ const formItem = (list: Array<SearchFormItem>) => {
766
+ if (isModalVisible && list?.length) {
767
+ return list.map((i: SearchFormItem, index) => {
768
+ const {name, label, field, type='', filterFormItem, initialSource=[], ...restProps} = i;
769
+
770
+ if (type === 'custom_filter_form_item') return filterFormItem;
771
+
772
+ if (type === 'select' || field?.type === 'select') {
773
+ return (
774
+ <Form.Item name={name} label={label} key={name} {...restProps}>
775
+ <Select style={{ width: '100%' }} placeholder='请选择' {...field?.props}>
776
+ {initialSource.length && initialSource.map((m: any) => (
777
+ <Option value={m.value} key={m.value}>{m.text}</Option>
778
+ ))}
779
+ </Select>
780
+ </Form.Item>
781
+ )
782
+ }
783
+
784
+ if (type === 'treeSelect' || field?.type === 'treeSelect') {
785
+ return (
786
+ <Form.Item name={name} label={label} key={name} {...restProps}>
787
+ <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...field?.props}></TreeSelect>
788
+ </Form.Item>
789
+ )
790
+ }
791
+
792
+ if (type === 'BusinessSearchSelect' || field?.type === 'BusinessSearchSelect') {
793
+ return (
794
+ <div>
795
+ <Form.Item name={name} label={label} key={name} {...restProps}>
796
+ <BusinessSearchSelect {...field?.props} />
797
+ </Form.Item>
798
+ </div>
799
+ )
800
+ }
801
+
802
+ if (type === 'multipleQueryInput' || field?.type === 'multipleQueryInput') {
803
+ return (
804
+ <div>
805
+ <Form.Item name={name} label={label} key={name} {...restProps}>
806
+ <QueryMutipleInput onValueChange={(value) => {
807
+ form.setFieldsValue({
808
+ [name]: value
809
+ })
810
+ }} />
811
+ </Form.Item>
812
+ </div>
813
+ );
814
+ }
815
+
816
+ // 默认type是input
817
+ return (
818
+ <Form.Item name={name} label={label} key={name} {...restProps}>
819
+ <Input id={index === 0 ? "first-query" : 'index'} style={{ width: '100%' }} onKeyDown={(e) => {
820
+ if (e.keyCode === 13) {
821
+ onSearchTable()
822
+ }
823
+ }} placeholder='请输入' allowClear maxLength={100} {...field?.props} />
824
+ </Form.Item>
825
+ )
826
+ })
827
+ } else {
828
+ return null
829
+ }
830
+ }
831
+
832
+ const deleteSelectRows = () => {
833
+ setPopValue([])
834
+ setSelectedRowKeys([])
835
+ }
836
+
837
+ const deleteRecord = (record) => {
838
+ if(isAllowRepeatedSelect) {
839
+ setPopValue(popvalue.filter(item => item.uuid !== record.uuid))
840
+ setSelectedRowKeys([])
841
+ } else {
842
+ setPopValue(popvalue.filter(item => item[selectRowKey] !== record[selectRowKey]))
843
+ setSelectedRowKeys([...selectedRowKeys.filter(item => item !== record[selectRowKey])])
844
+ }
845
+ }
846
+
847
+ const editRecord = (record) => {
848
+ const newPopValue = [...popvalue]
849
+ const index = newPopValue.findIndex(item => record[selectRowKey] == item[selectRowKey]);
850
+ const item = newPopValue[index]
851
+ newPopValue.splice(index, 1, {
852
+ ...item,
853
+ ...record
854
+ })
855
+ setPopValue([...newPopValue])
856
+ }
857
+
858
+ let inputIndex = 0;
859
+ let selectIndex = 0;
860
+
861
+ useEffect(() => {
862
+ setInitialShowColumn(codeSelected,selectColumns,(res) => {
863
+ setShowColumnsCallback(res)
864
+ })
865
+ },[selectColumns])
866
+ useEffect(() => {
867
+ setInitialShowColumn(codeToChoose,tableColumns,(res) => {
868
+ setShowToChooseColumnsCallback(res)
869
+ })
870
+ },[tableColumns])
871
+
872
+ const handleResize = (arr,index: any, callback) => (_: any, { size }: any) => {
873
+ let newColumns = arr.map((col: any) => ({ ...col }));
874
+ const handleIndex = (arr: any, indexArr: any) => {
875
+ let i = indexArr.shift();
876
+ if (indexArr.length > 0) {
877
+ handleIndex(arr[i].children, indexArr);
878
+ } else {
879
+ arr[i] = {
880
+ ...arr[i],
881
+ width: size.width,
882
+ };
883
+ handleAntdColumnsSpecialParams(arr[i]);
884
+ }
885
+ };
886
+ handleIndex(newColumns, [...index]);
887
+ callback(newColumns)
888
+ };
889
+
890
+ const setShowColumnsCallback = (newColumns: Array<any>) => {
891
+ setShowColumns([...newColumns])
892
+ }
893
+ const setShowToChooseColumnsCallback = (newColumns: Array<any>) => {
894
+ setShowToChooseColumns([...newColumns])
895
+ }
896
+
897
+ const handleColumns = (arr: any, indexArr: any[], callback: any) => {
898
+ arr.forEach((item: any, index: any) => {
899
+ let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
900
+ if (noEmptyArray(item.children)) {
901
+ handleColumns(item.children, indexArrInside);
902
+ } else {
903
+ item.width = item.width || getItemDefaultWidth(item);
904
+ item.onHeaderCell = (column: any) => ({
905
+ ...item,
906
+ width:
907
+ typeof column.width === 'number'
908
+ ? column.width
909
+ : parseInt(column.width.replace('px', '')),
910
+ onResize: handleResize(arr,indexArrInside, callback),
911
+ });
912
+ }
913
+ })
914
+ };
915
+ let showToChooseCol = showToChooseColumns.map((item: any) => {
916
+ handleAntdColumnsSpecialParams(item);
917
+ return ({ ...item })
918
+ })
919
+ handleColumns(showToChooseCol, [],(res)=> setShowToChooseColumnsCallback(res));
920
+ let showSelectedCol = showColumns.map((item: any) => {
921
+ handleAntdColumnsSpecialParams(item);
922
+ return ({ ...item })
923
+ })
924
+ handleColumns(showSelectedCol, [],(res)=> setShowColumnsCallback(res));
925
+
926
+ const selectLength = isAllowRepeatedSelect ? (popvalue?.length || 0) : (selectedRowKeys?.length || 0)
927
+ return (
928
+ <div className={'add_select'}>
929
+ <div className="add_select_show" id={`add_select_div_${uniqueValue}`}>
930
+ <Button onClick={handleShowModal} {...realButtonProps}>
931
+ {buttonText}
932
+ </Button>
933
+ </div>
934
+ {isModalVisible && (
935
+ <Modal
936
+ width='1200px'
937
+ style={{ top: 20 }}
938
+ bodyStyle={{ padding: '0px' }}
939
+ visible={isModalVisible}
940
+ closable={false}
941
+ onCancel={handleCancel}
942
+ footer={selectMode ? [
943
+ <Button key="back" onClick={handleCancel}>
944
+ 取消
945
+ </Button>,
946
+ <Button
947
+ key="save-and-continue"
948
+ style={{color: '#005CFF', borderColor: '#005CFF'}}
949
+ onClick={() => {handleOk(true)}}
950
+ loading={confirmContinueLoading}
951
+ disabled={confirmLoading || !tableData.length || (selectProps?.disabled || props?.disabled)}
952
+ >
953
+ 保存并继续
954
+ </Button>,
955
+ <Button
956
+ key="submit"
957
+ type="primary"
958
+ onClick={() => {handleOk(false)}}
959
+ loading={confirmLoading}
960
+ disabled={confirmContinueLoading || !tableData.length || (selectProps?.disabled || props?.disabled)}
961
+ >
962
+ 确定
963
+ </Button>,
964
+ ] : null}
965
+ >
966
+ <div>
967
+ <div className='add_select_header'>
968
+ {modalTableProps?.modalTableTitle}
969
+ <span><span>*</span> &nbsp;快捷键:【Tab】-跳格切换;【Shift+←、→】-当前行左、右移动;【 ↑、↓】-当前列上、下移动;【ctrl+Enter】-保存并继续;【ctrl+Delete】-删除当前行;</span>
970
+ <span className='add_select_header_close'><CloseCircleOutlined style={{fontSize: '20px'}} onClick={handleCancel} /></span>
971
+ </div>
972
+ <div className={'add_select_wrapper'}>
973
+ <div className={caretLeftFlag ? 'add_select_wrapper_left' : 'add_select_wrapper_left1'}>
974
+ <div className={'select_list_columns'}>
975
+ <div className={'select_list_columns_formItems'}>
976
+ <Form form={form} layout='vertical' key='modalForm'>
977
+ {formItem(tableSearchForm)}
978
+ </Form>
979
+ </div>
980
+ </div>
981
+ <div className={'select_list_searchButton'}>
982
+ <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
983
+ <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
984
+ </div>
985
+ </div>
986
+ <div className={caretLeftFlag ? 'add_select_wrapper_right' : 'add_select_wrapper_right1'}>
987
+ <div>
988
+ <div className={'select_list_selectTips'}>
989
+ <div style={{ marginLeft: 8 }}>搜索结果共&nbsp;<span style={themeColor}>{tablePagination?.total || 0}</span>&nbsp;项{selectMode ? <span>, 本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span> : ''}</div>
990
+ <div>
991
+ <span style={{ marginRight: 8 }}>
992
+ <TableColumnSetting
993
+ setShowColumns={setShowToChooseColumnsCallback}
994
+ showColumns={showToChooseColumns}
995
+ datasource={tableColumns || []}
996
+ tableCode={codeToChoose}
997
+ settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
998
+ />
999
+ </span>
1000
+ </div>
1001
+ </div>
1002
+ <Table
1003
+ size='small'
1004
+ rowSelection={rowSelection}
1005
+ columns={showToChooseCol}
1006
+ dataSource={tableData}
1007
+ pagination={tablePagination}
1008
+ loading={fetching}
1009
+ onChange={handleTableChange}
1010
+ rowKey={mappingValueField}
1011
+ rowClassName={'row-class'}
1012
+ scroll={{ y: 500 }}
1013
+ components={{
1014
+ header: {
1015
+ cell: ResizeableTitle,
1016
+ },
1017
+ }}
1018
+ />
1019
+ </div>
1020
+ </div>
1021
+ </div>
1022
+ <div className={'add_select_wrapper_select'}>
1023
+ <div className={'select_list_selectTips'}>
1024
+ <div style={{ marginLeft: 8 }}><span>本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span></div>
1025
+ <div style={{ display: 'flex' }}>
1026
+ <span style={{ marginRight: 8 }}>
1027
+ <TableColumnSetting
1028
+ setShowColumns={setShowColumnsCallback}
1029
+ showColumns={showColumns}
1030
+ datasource={selectColumns || []}
1031
+ tableCode={codeSelected}
1032
+ settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1033
+ />
1034
+ </span>
1035
+ <div style={{ marginRight: 8 }}><span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>{clearTitle??'清空所选商品'}</span></div>
1036
+ </div>
1037
+ </div>
1038
+ <Table
1039
+ size='small'
1040
+ columns={showSelectedCol}
1041
+ dataSource={popvalue}
1042
+ pagination={false}
1043
+ rowKey={selectRowKey}
1044
+ rowClassName={'row-class'}
1045
+ scroll={{ y: 500 }}
1046
+ onRow={record => {
1047
+ return {
1048
+ onDoubleClick: event => onDoubleClickSelect(event, record),
1049
+ };
1050
+ }}
1051
+ components={{
1052
+ header: {
1053
+ cell: ResizeableTitle,
1054
+ },
1055
+ }}
1056
+ />
1057
+ </div>
1058
+ </div>
1059
+ </Modal>
1060
+ )}
1061
+ </div>
1062
+ );
1063
+ };
1064
+
1065
+ export default AddSelect;