@bit-sun/business-component 2.2.13 → 2.2.14

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 (177) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/index.esm.js +2 -1
  9. package/dist/index.js +2 -1
  10. package/docs/index.md +21 -21
  11. package/lib/assets/drag.svg +17 -17
  12. package/lib/assets/exportFail.svg +37 -37
  13. package/lib/assets/exportProcessing.svg +28 -28
  14. package/lib/assets/exportSuccess.svg +34 -34
  15. package/lib/assets/label_icon_bottom.svg +25 -25
  16. package/lib/assets/upExport.svg +22 -22
  17. package/package.json +77 -77
  18. package/src/assets/32.svg +27 -27
  19. package/src/assets/addIcon.svg +17 -17
  20. package/src/assets/allfunc.svg +27 -27
  21. package/src/assets/arrowRight.svg +24 -24
  22. package/src/assets/btn-delete.svg +29 -29
  23. package/src/assets/btn-edit.svg +19 -19
  24. package/src/assets/btn-more.svg +17 -17
  25. package/src/assets/btn-submit.svg +19 -19
  26. package/src/assets/caidan.svg +11 -11
  27. package/src/assets/close.svg +26 -26
  28. package/src/assets/drag.svg +17 -17
  29. package/src/assets/exportFail.svg +37 -37
  30. package/src/assets/exportProcessing.svg +28 -28
  31. package/src/assets/exportSuccess.svg +34 -34
  32. package/src/assets/fixed-left-active.svg +11 -11
  33. package/src/assets/fixed-left.svg +15 -15
  34. package/src/assets/fixed-right-active.svg +11 -11
  35. package/src/assets/fixed-right.svg +15 -15
  36. package/src/assets/guanbi.svg +15 -15
  37. package/src/assets/icon-quanping.svg +15 -15
  38. package/src/assets/icon-shezhi.svg +17 -17
  39. package/src/assets/label_icon_bottom.svg +25 -25
  40. package/src/assets/list-no-img.svg +21 -21
  41. package/src/assets/morentouxiang-32.svg +23 -23
  42. package/src/assets/scanning.svg +24 -24
  43. package/src/assets/upExport.svg +22 -22
  44. package/src/components/Business/AddSelectBusiness/index.md +93 -93
  45. package/src/components/Business/AddSelectBusiness/index.tsx +602 -601
  46. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  47. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  48. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  49. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  50. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  51. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  52. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  58. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  59. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  60. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  61. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  62. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -156
  63. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  64. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  65. package/src/components/Business/BsLayouts/index.less +79 -79
  66. package/src/components/Business/BsLayouts/index.tsx +1479 -1479
  67. package/src/components/Business/BsLayouts/service.ts +10 -10
  68. package/src/components/Business/BsLayouts/utils.tsx +225 -225
  69. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +538 -538
  70. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  71. package/src/components/Business/BsSulaQueryTable/index.tsx +527 -527
  72. package/src/components/Business/BsSulaQueryTable/setting.tsx +802 -802
  73. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  74. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  75. package/src/components/Business/CommodityEntry/index.md +70 -70
  76. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  77. package/src/components/Business/CommonAlert/index.tsx +23 -23
  78. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  79. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  80. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  81. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  82. package/src/components/Business/DetailPageWrapper/index.tsx +313 -313
  83. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  84. package/src/components/Business/HomePageWrapper/index.less +33 -33
  85. package/src/components/Business/HomePageWrapper/index.md +45 -45
  86. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  87. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  88. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -201
  89. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  90. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  91. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  92. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  93. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  94. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  95. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  96. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  97. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  98. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  99. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  100. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  101. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  102. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  103. package/src/components/Business/JsonQueryTable/index.less +16 -16
  104. package/src/components/Business/JsonQueryTable/index.md +328 -328
  105. package/src/components/Business/JsonQueryTable/index.tsx +320 -320
  106. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  107. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  108. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  109. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  110. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  111. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  112. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  113. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  114. package/src/components/Business/JsonQueryTable/static.ts +356 -356
  115. package/src/components/Business/SearchSelect/BusinessUtils.ts +1723 -1723
  116. package/src/components/Business/SearchSelect/common.ts +53 -53
  117. package/src/components/Business/SearchSelect/index.md +1310 -1310
  118. package/src/components/Business/SearchSelect/index.tsx +51 -51
  119. package/src/components/Business/SearchSelect/utils.ts +100 -100
  120. package/src/components/Business/StateFlow/index.less +130 -130
  121. package/src/components/Business/StateFlow/index.md +60 -60
  122. package/src/components/Business/StateFlow/index.tsx +29 -29
  123. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  124. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  125. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  126. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  127. package/src/components/Business/columnSettingTable/index.less +247 -247
  128. package/src/components/Business/columnSettingTable/index.md +357 -357
  129. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  130. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  131. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  132. package/src/components/Business/moreTreeTable/index.less +99 -99
  133. package/src/components/Business/moreTreeTable/index.md +508 -508
  134. package/src/components/Business/moreTreeTable/index.tsx +315 -315
  135. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  136. package/src/components/Functional/AddSelect/index.less +367 -367
  137. package/src/components/Functional/AddSelect/index.md +155 -155
  138. package/src/components/Functional/AddSelect/index.tsx +1165 -1165
  139. package/src/components/Functional/BillEntry/index.less +371 -371
  140. package/src/components/Functional/BillEntry/index.md +39 -39
  141. package/src/components/Functional/BillEntry/index.tsx +766 -766
  142. package/src/components/Functional/DataImport/index.less +63 -63
  143. package/src/components/Functional/DataImport/index.md +44 -44
  144. package/src/components/Functional/DataImport/index.tsx +695 -695
  145. package/src/components/Functional/DataValidation/index.less +63 -63
  146. package/src/components/Functional/DataValidation/index.md +39 -39
  147. package/src/components/Functional/DataValidation/index.tsx +687 -687
  148. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  149. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  150. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  151. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  152. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  153. package/src/components/Functional/SearchSelect/index.less +115 -115
  154. package/src/components/Functional/SearchSelect/index.md +141 -141
  155. package/src/components/Functional/SearchSelect/index.tsx +813 -813
  156. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  157. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  158. package/src/components/Functional/TreeSearchSelect/index.tsx +160 -160
  159. package/src/index.ts +34 -34
  160. package/src/plugin/TableColumnSetting/index.less +247 -247
  161. package/src/plugin/TableColumnSetting/index.md +50 -50
  162. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  163. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  164. package/src/styles/bsDefault.less +1912 -1912
  165. package/src/utils/CheckOneUser/index.md +39 -39
  166. package/src/utils/CheckOneUser/index.ts +51 -51
  167. package/src/utils/LocalstorageUtils.ts +58 -58
  168. package/src/utils/TableUtils.tsx +18 -18
  169. package/src/utils/checkUtils.ts +39 -39
  170. package/src/utils/enumConfig.ts +11 -11
  171. package/src/utils/getFormMode.js +12 -12
  172. package/src/utils/index.ts +2 -2
  173. package/src/utils/requestUtils.ts +36 -36
  174. package/src/utils/serialize.js +7 -7
  175. package/src/utils/utils.ts +183 -183
  176. package/tsconfig.json +29 -29
  177. package/typings.d.ts +4 -4
@@ -1,1165 +1,1165 @@
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 axios from 'axios';
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 { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
17
-
18
- const loadSelectSource = (url: string, params?: any) => {
19
- return new Promise((resolve, reject) => {
20
- axios
21
- .get(`${url}?${stringify(params)}`)
22
- .then((result: any) => {
23
- result = result.data;
24
- if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
25
- message.error(result.msg);
26
- return;
27
- }
28
- resolve(result);
29
- })
30
- .catch((err) => {
31
- reject(err);
32
- });
33
- })
34
- };
35
-
36
- const ResizeableTitle = (props) => {
37
- const { onResize, width, ...restProps } = props;
38
-
39
- if (!width) {
40
- return <th {...restProps} />;
41
- }
42
- return (
43
- <Resizable
44
- width={width}
45
- height={0}
46
- onResize={onResize}
47
- draggableOpts={{ enableUserSelectHack: false }}
48
- >
49
- <th {...restProps} />
50
- </Resizable>
51
- );
52
- };
53
-
54
- const formatSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['code', 'name']) => {
55
- const data = reData && reData[position]?.data;
56
- const list = Array.isArray(data) ? data :(data?.items || data?.list || data?.children || []);
57
- const formatData = list?.length ? list.map((v: any) => ({ text: v[resKeyValue[1]], value: v[resKeyValue[0]] })) : [];
58
- changeSearchForm[changePosition] = {...changeSearchForm[changePosition], initialSource: formatData}
59
- }
60
-
61
- // 格式化树选择器数据源
62
- const mapSearchTree = (treeDataItem: any, resKeyValue: any) => {
63
- const haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0;
64
- return {
65
- title: treeDataItem[resKeyValue[1]],
66
- value: treeDataItem[resKeyValue[0]],
67
- parentId: treeDataItem.parent,
68
- data: { ...treeDataItem },
69
- isLeaf: !haveChildren,
70
- disabled: haveChildren,
71
- children: haveChildren ? treeDataItem.children.map((i: any) => mapSearchTree(i, resKeyValue)) : [],
72
- };
73
- };
74
- const formatTreeDataSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['id', 'name']) => {
75
- const data = reData && reData[position]?.data;
76
- const formatData = (data &&
77
- Array.isArray(data) &&
78
- data.length &&
79
- data.map((ites: any) => mapSearchTree(ites, resKeyValue))) ||
80
- []
81
- changeSearchForm[changePosition].field.props.treeData = formatData;
82
- }
83
-
84
- const { Option } = Select;
85
-
86
- const AddSelect = (props: any) => {
87
- const {
88
- value, // 必传
89
- onChange,
90
- selectProps = {},
91
- modalTableProps = {},
92
- labelInValue = false,
93
- requestConfig,
94
- ctx,
95
- sourceName,
96
- needModalTable = true,
97
- getPopupContainer = undefined,
98
- onSaveCallback,
99
- buttonText = '添加',
100
- buttonProps = {},
101
- beforeShowModal,
102
- tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
103
- businessType = 'sku',
104
- isAllowRepeatedSelect = false
105
- } = props;
106
- const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField = 'name', mappingTextShowKeyField, mappingValueField = 'code', mappingTextShowTextField } = requestConfig || {};
107
- const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
108
- const realButtonProps = {type: "primary", ...buttonProps};
109
- const selectRowKey = isAllowRepeatedSelect ? 'uuid' : mappingValueField
110
-
111
- const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
112
- const initVal = value || (selectMode ? [] : null);
113
- const pageSize = 100 // 下拉框默认分页 条数
114
- const tableInitPageSize = 10 // 弹框默认分页 条数
115
- const currentPage = 1
116
- const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
117
- const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
118
- const currentSelectProps = {
119
- ...selectProps,
120
- // 以下属性不可更改----设计配置项
121
- showSearch: false,
122
- filterOption: false,
123
- allowClear: true,
124
- listHeight: 160,
125
- optionLabelProp: "label",
126
- autoClearSearchValue: false
127
- }
128
- const [items, setItems] = useState([]);
129
- const [scrollPage, setScrollPage] = useState(1);
130
- const [itemsTotal, setItemsTotal] = useState(0);
131
- const [fetching, setFetching] = useState(false);
132
- const [searchValue, setSearchValue] = useState('');
133
- const [isModalVisible, setIsModalVisible] = useState(false);
134
- const [popvalue, setPopValue] = useState(initVal);
135
- const [uniqueValue, setUniqueValue] = useState(sourceName)
136
- const { run } = useDebounceFn(
137
- (v?: any) => {
138
- // 优化搜索参数 支持传多个
139
- let searchParams = {};
140
- if (typeof selectParamsKey === 'string') {
141
- searchParams = v ? { [selectParamsInitKey]: initVal } : { [selectParamsKey]: searchValue }
142
- }
143
- if (Array.isArray(selectParamsKey)) {
144
- selectParamsKey.forEach((i: any) => {
145
- searchParams = { ...searchParams, [i]: searchValue }
146
- })
147
- }
148
- // 防抖函数 待定
149
- getData(searchParams)
150
- },
151
- {
152
- wait: 1000,
153
- },
154
- );
155
-
156
- const [form] = Form.useForm();
157
- const [tableSearchForm, setTableSearchForm] = useState(modalTableProps?.tableSearchForm)
158
- const [caretLeftFlag, setCaretLeftFlag] = useState(true);
159
- const [tableData, setTableData] = useState([]);
160
- const [tablePagination, setTablePagination] = useState({ total: 0, size: "small", current: 1, pageSize: tableInitPageSize })
161
- const [selectedRowKeys, setSelectedRowKeys] = useState([]);
162
- const [doubleArr, setDoubleArr] = useState([]); // 存放双数组的数组
163
- const [checkedAll, setCheckedAll] = useState(false)
164
- const [indeterminate, setIndeterminate] = useState(false)
165
- const [tableFormParams, setTableFormParams] = useState({});
166
- const [confirmLoading, setConfirmLoading] = useState(false);
167
- const [confirmContinueLoading, setConfirmContinueLoading] = useState(false);
168
-
169
- const [selectColumns, setSelectColumns] = useState([]);
170
- const [showColumns, setShowColumns] = useState([]);
171
- const [tableColumns, setTableColumns] = useState([]);
172
- const [showToChooseColumns, setShowToChooseColumns] = useState([]);
173
- const codeToChoose = tableCodeList[0] || 'skuSelect-tableOptionsToChoosePartCode';
174
- const codeSelected = tableCodeList[1] || 'skuSelect-tableSelectedItemPartCode';
175
-
176
- useEffect(() => {
177
- setTableColumns(modalTableProps?.tableColumns)
178
- }, [modalTableProps?.tableColumns])
179
-
180
- useEffect(() => {
181
- setSelectColumns([... modalTableProps.selectColumn.map(item => {
182
- const inputLength = modalTableProps.selectColumn.filter(item => item.isInputItem).length
183
- const currentIndex = inputIndex
184
-
185
- if (item.isInputItem) {
186
- inputIndex++;
187
- return {
188
- ...item,
189
- render: (text, record, index) => {
190
- // let
191
- if(record.needFocus === true && currentIndex === 0) {
192
-
193
- }
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
- value={text || ''}
220
- min={0}
221
- autoFocus={record.needFocus}
222
- keyboard={false}
223
- {...precisionObj}
224
- onChange={(value) => {
225
- record[item.dataIndex] = value
226
- const newPopValue = popvalue.map((i: any, innerIndex: number) => {
227
- if(innerIndex == index) {
228
- i[item.dataIndex] = record[item.dataIndex]
229
- }
230
- return i
231
- })
232
- setPopValue(newPopValue)
233
- }}
234
- // onFocus={(e)=> {
235
- // let dom1 = e.currentTarget;
236
- // dom1.setSelectionRange(100, 0);
237
- // dom1.select(text);
238
- // }}
239
- onKeyDown={(e) => {
240
- if(e.keyCode === 13 && e.ctrlKey) {
241
- handleOk(true)
242
- document.getElementById("first-query")?.focus()
243
- }
244
- if(e.keyCode === 8 && e.ctrlKey) {
245
- message.success('删除当前行')
246
- e.stopPropagation();
247
- e.preventDefault();
248
- let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
249
- if (dom) {
250
- dom.select();
251
- dom.focus();
252
- dom.scrollIntoView(false)
253
- }
254
- dom = null
255
- deleteRecord(record, popvalue);
256
- }
257
- if (e.keyCode === 37 && e.shiftKey) { // 左滑动
258
- e.stopPropagation();
259
- e.preventDefault();
260
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
261
- if (dom) {
262
- dom.select();
263
- dom.focus();
264
- dom.scrollIntoView(false)
265
- }
266
- dom = null
267
- }
268
- if (e.keyCode === 39 && e.shiftKey) { // 右滑
269
- e.stopPropagation();
270
- e.preventDefault();
271
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
272
- if (dom) {
273
- dom.select();
274
- dom.focus();
275
- dom.scrollIntoView(false)
276
- }
277
- dom = null
278
- }
279
- if (e.keyCode === 40) {
280
- e.stopPropagation();
281
- e.preventDefault();
282
- let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
283
- if (dom) {
284
- dom.select();
285
- dom.focus();
286
- dom.scrollIntoView(false)
287
- }
288
- dom = null
289
- } else if (e.keyCode === 38) {
290
- e.stopPropagation();
291
- e.preventDefault();
292
- let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
293
- if (dom1) {
294
- // dom1.value=""
295
- // dom1.setSelectionRange(100, 0);
296
- dom1.select();
297
- dom1.focus();
298
- dom1.scrollIntoViewIfNeeded(false)
299
- // dom1.value=record['count']
300
- }
301
- dom1 = null
302
- } else if (e.keyCode === 9 && index === selectedRowKeys.length - 1 && currentIndex === inputLength - 1) {
303
- e.stopPropagation();
304
- e.preventDefault();
305
- }
306
- }}
307
- />
308
- );
309
- },
310
- }
311
- }
312
-
313
- const selectLength = modalTableProps.selectColumn.filter(item => item.isSelectItem).length
314
- const currentSelectIndex = selectIndex
315
- if(item.isSelectItem) {
316
- selectIndex++;
317
- return {
318
- ...item,
319
- render: (text, record, index) => {
320
- if (item.dataSource?.length) {
321
- return (
322
- <Select
323
- value={text || null}
324
- onChange={(value) => {
325
- if(businessType == 'skc' && popvalue.some((i: any) => i.code == record.code && i[item.dataIndex] == value)) {
326
- message.warning('相同skc配码不可设置相同哦')
327
- record[item.dataIndex] = null;
328
- const newPopValue = popvalue.map((i: any, innerIndex: number) => {
329
- if(innerIndex == index) {
330
- i[item.dataIndex] = record[item.dataIndex]
331
- }
332
- return i
333
- })
334
- setPopValue(newPopValue)
335
- return false
336
- }
337
- record[item.dataIndex] = value
338
- const newPopValue = popvalue.map((i: any, innerIndex: number) => {
339
- if(innerIndex == index) {
340
- i[item.dataIndex] = record[item.dataIndex]
341
- }
342
- return i
343
- })
344
- setPopValue(newPopValue)
345
- }}
346
- style={{width: '160px'}}
347
- >
348
- {item.dataSource.map((item: any) => {
349
- return <Select.Option value={item.code}>{item.name}</Select.Option>
350
- })}
351
- </Select>
352
- )
353
- }
354
- return <></>
355
- },
356
- }
357
- }
358
-
359
- return item
360
- }), {
361
- title: '操作',
362
- width: 50,
363
- dataIndex: 'operation',
364
- fixed: 'right',
365
- render: (text, record, index) => {
366
- return (
367
- <span style={{cursor: 'pointer', color: '#005CFF' }} onClick={() => {
368
- deleteRecord(record)
369
- }} type={"text"}>删除</span>
370
- )
371
- }
372
- },])
373
- }, [modalTableProps?.selectColumn,popvalue])
374
-
375
- // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
376
- const getData = (params = {}, type = 1) => {
377
- if (!requestConfig) return;
378
-
379
- setFetching(true)
380
-
381
- // 处理dependence参数
382
- const fixedParam = {};
383
- if (fixedparameter && fieldValToParam && ctx) {
384
- fixedparameter.forEach((item: any, index: any) => {
385
- const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
386
- if (fixedParamVal) {
387
- fixedParam[item] = fixedParamVal;
388
- form.setFieldsValue({ ...form?.getFieldsValue(), [item]: fixedParamVal })
389
- }
390
- });
391
- }
392
-
393
- // 数组对象处理,对带有特殊标记的name进行处理
394
- for (const key in params) {
395
- if (Object.prototype.hasOwnProperty.call(params, key)) {
396
- const element = params[key];
397
- if (element && key.indexOf('*number*') >= 0) {
398
- const dataParams = key.split('*number*');
399
- dataParams.forEach((value, index) => {
400
- params[value] = element[index];
401
- });
402
- delete params[key];
403
- } else if (element && key.indexOf('*address*') >= 0) {
404
- const dataParams = key.split('*address*');
405
- dataParams.forEach((value, index) => {
406
- params[value] = element.PCDCode[index];
407
- });
408
- delete params[key];
409
- } else if (element && key.indexOf('*costType*') >= 0) {
410
- const dataParams = key.split('*costType*');
411
- // eslint-disable-next-line prefer-destructuring
412
- params[dataParams[0]] = element[1];
413
- delete params[key];
414
- } else if (element && key.indexOf('*fullDate*') >= 0) {
415
- const dataParams = key.split('*fullDate*');
416
- dataParams.forEach((value, index) => {
417
- if (index === 0) {
418
- params[value] = moment(element[index])
419
- .millisecond(0)
420
- .second(0)
421
- .minute(0)
422
- .hour(0)
423
- .format('YYYY-MM-DD HH:mm:ss');
424
- } else {
425
- params[value] = moment(element[index])
426
- .millisecond(59)
427
- .second(59)
428
- .minute(59)
429
- .hour(23)
430
- .format('YYYY-MM-DD HH:mm:ss');
431
- }
432
- });
433
- delete params[key];
434
- } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
435
- const dataParams = key.split('*checkBox*');
436
- if (element) {
437
- params[dataParams[0]] = 0
438
- }
439
- delete params[key];
440
- } else if (element && key.indexOf('*cascader*') >= 0) {
441
- const dataParams = key.split('*cascader*');
442
- params[dataParams[0]] = element[element.length - 1]
443
- delete params[key];
444
- } else if (element && key.indexOf('*date*') >= 0) {
445
- const dataParams = key.split('*date*')
446
- dataParams.forEach((value, index) => {
447
- if (index === 0) {
448
- params[value] = moment(element[index])
449
- .format('YYYY-MM-DD');
450
- } else {
451
- params[value] = moment(element[index])
452
- .format('YYYY-MM-DD');
453
- }
454
- });
455
- delete params[key];
456
- }
457
- else if (element && key.indexOf('*') >= 0) {
458
- const dataParams = key.split('*');
459
- dataParams.forEach((value, index) => {
460
- params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
461
- });
462
- delete params[key];
463
- } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
464
- const dataParams = key.split('_selectNumberRange')[0]
465
- if (params[key][0] === 'range') {
466
- if (params[key][1][0]) {
467
- params[`qp-${dataParams}-ge`] = params[key][1][0]
468
- }
469
- if (params[key][1][1]) {
470
- params[`qp-${dataParams}-le`] = params[key][1][1]
471
- }
472
- } else {
473
- params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
474
- }
475
- delete params[key]
476
- } else if (Array.isArray(element)) {
477
- params[key] = element.join(',');
478
- } else if (element == null || element === undefined || String(element).trim() === '') {
479
- delete params[key]
480
- }
481
- }
482
- }
483
-
484
- const queryParams = {
485
- pageSize,
486
- currentPage,
487
- ...otherParams, // 默认参数
488
- ...fixedParam,
489
- ...params,
490
- }
491
- axios
492
- .get(`${url}?${stringify(queryParams)}`)
493
- .then((result: any) => {
494
- setFetching(false)
495
- result = result.data;
496
- if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
497
- message.error(result.msg);
498
- return;
499
- }
500
- const res = result.data;
501
- let source = [];
502
- if (isMap) {
503
- source = Object.keys(res).map((d, i) => {
504
- return {
505
- text: Object.values(res)[i],
506
- value: d,
507
- };
508
- });
509
- } else {
510
- const keys = res.list ? 'list' : 'items';
511
- source = res
512
- ? res[keys]
513
- ? res[keys].map((item: any) => {
514
- let textShowText = item[mappingTextField]
515
- if (mappingTextShowTextField) {
516
- textShowText = []
517
- if (Array.isArray(mappingTextShowTextField)) {
518
- mappingTextShowTextField.forEach((r: any) => {
519
- textShowText.push(item[r])
520
- })
521
- } else {
522
- textShowText = item[mappingTextShowTextField]
523
- }
524
- }
525
- return {
526
- ...item,
527
- text: item[mappingTextField],
528
- textShowText,
529
- textShowKey: item[mappingTextShowKeyField || mappingValueField],
530
- value: item[mappingValueField],
531
- baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
532
- };
533
- })
534
- : Array.isArray(res) &&
535
- res?.map((item: Record<string, any>) => {
536
- let textShowText = item[mappingTextField]
537
- if (mappingTextShowTextField) {
538
- textShowText = []
539
- if (Array.isArray(mappingTextShowTextField)) {
540
- mappingTextShowTextField.forEach((r: any) => {
541
- textShowText.push(item[r])
542
- })
543
- } else {
544
- textShowText = item[mappingTextShowTextField]
545
- }
546
- }
547
- return {
548
- ...item,
549
- text: item[mappingTextField],
550
- textShowText,
551
- textShowKey: item[mappingTextShowKeyField || mappingValueField],
552
- value: item[mappingValueField],
553
- baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
554
- };
555
- })
556
- : [];
557
- }
558
- source = Array.isArray(source) ? source : []
559
- if (type === 1) {
560
- ctx?.form?.setFieldSource(resultSourceKey, source)
561
- setItems(source)
562
- setItemsTotal(Number(res?.total || res?.totalCount || source.length))
563
- } else {
564
- setTableData(source)
565
- 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)) })
566
- }
567
- })
568
- .catch((err) => { setFetching(false) });
569
- }
570
-
571
- const SelectScroll = e => {
572
- e.persist();
573
- const { target } = e;
574
- const totalPage = Math.ceil(itemsTotal / pageSize)
575
- // 判断是否滑动到底部
576
- const isTouchGround = target.scrollTop + target.offsetHeight === target.scrollHeight // >=scrollHeight
577
- // 判断数据是否还没有加载到了最后一页
578
- const canPageAdd = scrollPage < totalPage
579
- if (isTouchGround && canPageAdd) {
580
- const nextScrollPage = scrollPage + 1;
581
- setScrollPage(nextScrollPage);
582
- getData({ currentPage: nextScrollPage }); // 调用api方法
583
- }
584
-
585
- //判断是否滑动到顶部
586
- const isTouchTop = target.scrollTop === 0 // <=0
587
- // 判断数据是否到第一页
588
- const canPageJian = scrollPage > 1
589
- if (isTouchTop && canPageJian) {
590
- const preScrollPage = scrollPage - 1;
591
- setScrollPage(preScrollPage);
592
- getData({ currentPage: preScrollPage }); // 调用api方法
593
- }
594
- }
595
-
596
- useEffect(() => {
597
- if(businessType == 'sku') {
598
- Promise.all([
599
- loadSelectSource(`/items/brand/queryBrandList`, {
600
- pageSize: 5000,
601
- currentPage: 1,
602
- 'ctl-withAuth': true
603
- }),
604
- loadSelectSource(`/items/category/queryCategoryTree`, {
605
- pageSize: 5000,
606
- currentPage: 1,
607
- }),
608
- ]).then((x: any)=>{
609
- formatSource(x,0, 2, tableSearchForm,['id','name'])
610
- formatTreeDataSource(x,1, 3, tableSearchForm)
611
- })
612
- }
613
- if(businessType == 'skc') {
614
- Promise.all([
615
- loadSelectSource(`/items/item/propertyValue`, {
616
- pageSize: 5000,
617
- currentPage: 1,
618
- 'qp-propertyId-eq': '1467042217951883265'
619
- }),
620
- loadSelectSource(`/items/category/queryCategoryTree`, {
621
- pageSize: 5000,
622
- currentPage: 1,
623
- }),
624
- loadSelectSource(`/items/class/withProperty`, {
625
- pageSize: 5000,
626
- currentPage: 1,
627
- }),
628
- loadSelectSource(`/items/brand/queryBrandList`, {
629
- pageSize: 5000,
630
- currentPage: 1,
631
- 'ctl-withAuth': true
632
- }),
633
- ]).then((x: any)=>{
634
- formatSource(x,0, 3, tableSearchForm,['value','value'])
635
- formatTreeDataSource(x,1, 4, tableSearchForm)
636
- formatSource(x,2, 5, tableSearchForm,['id','name'])
637
- formatSource(x,3, 6, tableSearchForm,['id','name'])
638
- })
639
- }
640
- }, [businessType])
641
-
642
- useEffect(() => {
643
- if (value) {
644
- setPopValue(value);
645
- }
646
- }, [value]);
647
-
648
- useEffect(() => {
649
- makeUniqueValue();
650
- }, [sourceName])
651
-
652
- const showModal = () => {
653
- // getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
654
- setIsModalVisible(true);
655
- // 回显
656
- if (value) {
657
- if (selectMode) {
658
- setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
659
- setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
660
- setIndeterminate(!!value.length && value.length < itemsTotal);
661
- setCheckedAll(itemsTotal && value.length === itemsTotal);
662
- // 需清空数据
663
- if (!value.length) {
664
- setDoubleArr([])
665
- }
666
- } else {
667
- setSelectedRowKeys(labelInValue ? [value.key] : [value])
668
- setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
669
- }
670
- }
671
-
672
- setTimeout(() => {
673
- document.getElementById("first-query")?.focus()
674
- }, 50)
675
- };
676
-
677
- const handleShowModal = () => {
678
- if(beforeShowModal) {
679
- beforeShowModal(popvalue).then(res => {
680
- showModal()
681
- }).catch(Error => {
682
- message.warning(Error)
683
- })
684
- } else {
685
- showModal()
686
- }
687
- }
688
-
689
- const handleSelectOver = (selectedValue: any) => {
690
- if (selectedValue?.length) {
691
- formaData(selectedValue);
692
- // 解决选择最后1页的sku,返回后,不显示名称问题
693
- const source = _.uniqBy(items.concat(selectedValue), 'value')
694
- ctx?.form?.setFieldSource(resultSourceKey, source)
695
- setItems(source)
696
- }
697
- }
698
-
699
- const handleLoading = (isContinue,flag) => {
700
- isContinue ? setConfirmContinueLoading(flag) : setConfirmLoading(flag);
701
- }
702
-
703
- const handleOk = (isContinue) => {
704
- if(!popvalue.length) {
705
- message.warning('至少选中一条数据')
706
- return;
707
- }
708
- // handleSelectOver(popvalue)
709
- if(onSaveCallback) {
710
- handleLoading(isContinue,true)
711
- onSaveCallback(popvalue).then(res => {
712
- if(true) {
713
- message.success('保存成功')
714
- deleteSelectRows();
715
- document.getElementById('first-query')?.focus()
716
- !isContinue && handleCancel();
717
- } else {
718
- }
719
- handleLoading(isContinue,false)
720
- }).catch(Error => {
721
- message.error(Error);
722
- handleLoading(isContinue,false)
723
- })
724
- } else {
725
- !isContinue && handleCancel();
726
- }
727
- };
728
-
729
- const formaData = (value) => {
730
- if (labelInValue) {
731
- const formatResult = value.map((i: any) => ({ key: i[mappingValueField], label: i[mappingTextField], value: i[mappingValueField] }))
732
- onChange(selectMode ? formatResult : formatResult[0])
733
- } else {
734
- const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
735
- onChange(formatResult)
736
- }
737
- };
738
-
739
- const handleCancel = () => {
740
- form.resetFields();
741
- setTableFormParams({});
742
- setIsModalVisible(false);
743
- setTableData([])
744
- // if (selectMode) {
745
- // run();
746
- // }
747
- };
748
-
749
- const onSearchChange = (e) => {
750
- setSearchValue(e.target.value);
751
- run();
752
- }
753
-
754
- const onSearchBlur = () => {
755
- setSearchValue('')
756
- run();
757
- }
758
-
759
- const onSearchTable = () => {
760
- const params = form.getFieldsValue();
761
- setTableFormParams(params);
762
- getData({ ...params, pageSize: tableInitPageSize }, 2)
763
- if (selectMode) {
764
- getData(params)
765
- }
766
- }
767
-
768
- const onResetTable = () => {
769
- form.resetFields();
770
- setTableFormParams({});
771
- getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
772
- }
773
-
774
- const handleTableChange = (pagination) => {
775
- getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
776
- }
777
-
778
- // 扁平化二维数组的方法
779
- const mapRows = params => {
780
- var res = [];
781
- for (var i = 0; i < params.length; i++) {
782
- if (Array.isArray(params[i])) {
783
- // 去重
784
- res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
785
- } else {
786
- res.push(params[i]);
787
- // 去重
788
- res = _.uniqBy(res, 'value')
789
- }
790
- }
791
- return res.filter(Boolean); //去掉undefined的情况
792
- };
793
-
794
- const onChangeSelectedKeys = (selectKeys, selectRows) => {
795
- if(selectKeys.length - selectedRowKeys.length > 0) {
796
- if (selectKeys.length - selectedRowKeys.length === 1) {
797
- selectRows[selectRows.length -1]['needFocus'] = true;
798
- } else {
799
- selectRows[selectedRowKeys.length]['needFocus'] = true;
800
- }
801
- }
802
- if(isAllowRepeatedSelect) {
803
- const list = popvalue.concat(selectRows).map((i: any) => ({...i, uuid: i.uuid || uuid()}))
804
- setPopValue(list);
805
- setSelectedRowKeys([])
806
- } else {
807
- setPopValue(selectRows);
808
- setSelectedRowKeys(selectKeys)
809
- }
810
- // setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
811
- // setCheckedAll(filterRows.length === tablePagination?.total);
812
- }
813
-
814
- // 生成唯一值
815
- const makeUniqueValue = () => {
816
- const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
817
- setUniqueValue(generateUnitKey);
818
- return generateUnitKey;
819
- }
820
-
821
- const rowSelection = {
822
- type: 'checkbox',
823
- selectedRowKeys,
824
- preserveSelectedRowKeys: true,
825
- onChange: (sks, srs) => {
826
- onChangeSelectedKeys(sks, srs)
827
- },
828
- getCheckboxProps: () => ({
829
- disabled: selectProps?.disabled || props?.disabled,
830
- }),
831
- };
832
-
833
- const onDoubleClickSelect = (e, record) => {
834
- if (!selectMode) {
835
- const srs = [JSON.parse(JSON.stringify(record))]
836
- const sks = srs.map((i: any) => i.value)
837
- onChangeSelectedKeys(sks, srs)
838
- }
839
- }
840
-
841
- const themeColor = { color: '#005CFF' }
842
-
843
- const formItem = (list) => {
844
- if (isModalVisible && list?.length) {
845
- return list.map((i: any, index) => {
846
- if (i?.type === 'select' || i?.field?.type === 'select') {
847
- return (
848
- <Form.Item name={i.name} label={i.label} key={i.name}>
849
- <Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}>
850
- {i?.initialSource?.length && i?.initialSource.map((m: any) => (
851
- <Option value={m.value} key={m.value}>{m.text}</Option>
852
- ))}
853
- </Select>
854
- </Form.Item>
855
- )
856
- }
857
-
858
- if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
859
- return (
860
- <Form.Item name={i.name} label={i.label} key={i.name}>
861
- <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}></TreeSelect>
862
- </Form.Item>
863
- )
864
- }
865
-
866
- if (i?.type === 'BusinessSearchSelect' || i?.field?.type === 'BusinessSearchSelect') {
867
- return (
868
- <div>
869
- <Form.Item name={i.name} label={i.label} key={i.name}>
870
- <BusinessSearchSelect {...i.field.props} />
871
- </Form.Item>
872
- </div>
873
- )
874
- }
875
-
876
- if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
877
- return (
878
- <div>
879
- <Form.Item name={i.name} label={i.label} key={i.name}>
880
- <QueryMutipleInput onValueChange={(value) => {
881
- form.setFieldsValue({
882
- [i.name]: value
883
- })
884
- }} />
885
- </Form.Item>
886
- </div>
887
- );
888
- }
889
-
890
- // 默认type是input
891
- return (
892
- <Form.Item name={i.name} label={i.label} key={i.name}>
893
- <Input id={index === 0 ? "first-query" : 'index'} style={{ width: '100%' }} onKeyDown={(e) => {
894
- if (e.keyCode === 13) {
895
- onSearchTable()
896
- }
897
- }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} />
898
- </Form.Item>
899
- )
900
- })
901
- } else {
902
- return null
903
- }
904
- }
905
-
906
- const maxTagPlaceholder = (selectedValues) => {
907
- const onClose = (e: any, item: any) => {
908
- e.preventDefault();
909
- const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value) : JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
910
- onChange(newValue);
911
- }
912
- return (
913
- <Tooltip title={selectedValues.map((i: any) => (
914
- <Tag
915
- closable={true}
916
- onClose={(e) => onClose(e, i)}
917
- style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
918
- >
919
- {i.label}
920
- </Tag>
921
- ))}>
922
- {`+ ${selectedValues?.length}`}
923
- </Tooltip>
924
- )
925
- }
926
-
927
- const deleteSelectRows = () => {
928
- setPopValue([])
929
- setSelectedRowKeys([])
930
- }
931
-
932
- const deleteRecord = (record) => {
933
- if(isAllowRepeatedSelect) {
934
- setPopValue(popvalue.filter(item => item.uuid !== record.uuid))
935
- setSelectedRowKeys([])
936
- } else {
937
- setPopValue(popvalue.filter(item => item.skuCode !== record.skuCode))
938
- setSelectedRowKeys([...selectedRowKeys.filter(item => item !== record.skuCode)])
939
- }
940
- }
941
-
942
- let inputIndex = 0;
943
- let selectIndex = 0;
944
-
945
- useEffect(() => {
946
- setInitialShowColumn(codeSelected,selectColumns,(res) => {
947
- setShowColumnsCallback(res)
948
- })
949
- },[selectColumns])
950
- useEffect(() => {
951
- setInitialShowColumn(codeToChoose,tableColumns,(res) => {
952
- setShowToChooseColumnsCallback(res)
953
- })
954
- },[tableColumns])
955
-
956
- const handleResize = (arr,index: any, callback) => (_: any, { size }: any) => {
957
- let newColumns = arr.map((col: any) => ({ ...col }));
958
- const handleIndex = (arr: any, indexArr: any) => {
959
- let i = indexArr.shift();
960
- if (indexArr.length > 0) {
961
- handleIndex(arr[i].children, indexArr);
962
- } else {
963
- arr[i] = {
964
- ...arr[i],
965
- width: size.width,
966
- };
967
- handleAntdColumnsSpecialParams(arr[i]);
968
- }
969
- };
970
- handleIndex(newColumns, [...index]);
971
- callback(newColumns)
972
- };
973
-
974
- const setShowColumnsCallback = (newColumns: Array<any>) => {
975
- setShowColumns([...newColumns])
976
- }
977
- const setShowToChooseColumnsCallback = (newColumns: Array<any>) => {
978
- setShowToChooseColumns([...newColumns])
979
- }
980
-
981
- const handleColumns = (arr: any, indexArr: any[], callback: any) => {
982
- arr.forEach((item: any, index: any) => {
983
- let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
984
- if (noEmptyArray(item.children)) {
985
- handleColumns(item.children, indexArrInside);
986
- } else {
987
- item.width = item.width || getItemDefaultWidth(item);
988
- item.onHeaderCell = (column: any) => ({
989
- ...item,
990
- width:
991
- typeof column.width === 'number'
992
- ? column.width
993
- : parseInt(column.width.replace('px', '')),
994
- onResize: handleResize(arr,indexArrInside, callback),
995
- });
996
- }
997
- })
998
- };
999
- let showToChooseCol = showToChooseColumns.map((item: any) => {
1000
- handleAntdColumnsSpecialParams(item);
1001
- return ({ ...item })
1002
- })
1003
- handleColumns(showToChooseCol, [],(res)=> setShowToChooseColumnsCallback(res));
1004
- let showSelectedCol = showColumns.map((item: any) => {
1005
- handleAntdColumnsSpecialParams(item);
1006
- return ({ ...item })
1007
- })
1008
- handleColumns(showSelectedCol, [],(res)=> setShowColumnsCallback(res));
1009
-
1010
- const selectLength = isAllowRepeatedSelect ? (popvalue?.length || 0) : (selectedRowKeys?.length || 0)
1011
- return (
1012
- <div className={'add_select'}>
1013
- <div className="add_select_show" id={`add_select_div_${uniqueValue}`}>
1014
- <Button onClick={handleShowModal} {...realButtonProps}>
1015
- {buttonText}
1016
- </Button>
1017
- </div>
1018
- {needModalTable && isModalVisible && (
1019
- <Modal
1020
- width='1200px'
1021
- style={{ top: 20 }}
1022
- bodyStyle={{ padding: '0px' }}
1023
- // title={modalTableProps?.modalTableTitle}
1024
- visible={isModalVisible}
1025
- closable={false}
1026
- onCancel={handleCancel}
1027
- footer={selectMode ? [
1028
- <Button key="back" onClick={handleCancel}>
1029
- 取消
1030
- </Button>,
1031
- <Button
1032
- key="save-and-continue"
1033
- style={{color: '#005CFF', borderColor: '#005CFF'}}
1034
- onClick={() => {handleOk(true)}}
1035
- loading={confirmContinueLoading}
1036
- disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
1037
- >
1038
- 保存并继续
1039
- </Button>,
1040
- <Button
1041
- key="submit"
1042
- type="primary"
1043
- onClick={() => {handleOk(false)}}
1044
- loading={confirmLoading}
1045
- disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
1046
- >
1047
- 确定
1048
- </Button>,
1049
- ] : null}
1050
- >
1051
- <div>
1052
- <div className='add_select_header'>
1053
- {modalTableProps?.modalTableTitle}
1054
- <span><span>*</span> &nbsp;快捷键:【Tab】-跳格切换;【Shift+←、→】-当前行左、右移动;【 ↑、↓】-当前列上、下移动;【ctrl+Enter】-保存并继续;【ctrl+Delete】-删除当前行;</span>
1055
- <span className='add_select_header_close'><CloseCircleOutlined style={{fontSize: '20px'}} onClick={handleCancel} /></span>
1056
- </div>
1057
- <div className={'add_select_wrapper'}>
1058
- <div className={caretLeftFlag ? 'add_select_wrapper_left' : 'add_select_wrapper_left1'}>
1059
- <div className={'select_list_columns'}>
1060
- <div className={'select_list_columns_formItems'}>
1061
- <Form form={form} layout='vertical' key='modalForm'>
1062
- {formItem(tableSearchForm)}
1063
- </Form>
1064
- </div>
1065
- </div>
1066
- <div className={'select_list_searchButton'}>
1067
- <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
1068
- <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
1069
- </div>
1070
- </div>
1071
- <div className={caretLeftFlag ? 'add_select_wrapper_right' : 'add_select_wrapper_right1'}>
1072
- <div>
1073
- <div className={'select_list_selectTips'}>
1074
- <div style={{ marginLeft: 8 }}>搜索结果共&nbsp;<span style={themeColor}>{tablePagination?.total || 0}</span>&nbsp;项{selectMode ? <span>, 本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span> : ''}</div>
1075
- <div>
1076
- <span style={{ marginRight: 8 }}>
1077
- <TableColumnSetting
1078
- setShowColumns={setShowToChooseColumnsCallback}
1079
- showColumns={showToChooseColumns}
1080
- datasource={tableColumns || []}
1081
- tableCode={codeToChoose}
1082
- settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1083
- />
1084
- </span>
1085
- </div>
1086
- </div>
1087
- <Table
1088
- size='small'
1089
- rowSelection={rowSelection}
1090
- columns={showToChooseCol}
1091
- dataSource={tableData}
1092
- pagination={tablePagination}
1093
- loading={fetching}
1094
- onChange={handleTableChange}
1095
- rowKey={mappingValueField}
1096
- rowClassName={'row-class'}
1097
- scroll={{ y: 500 }}
1098
- components={{
1099
- header: {
1100
- cell: ResizeableTitle,
1101
- },
1102
- }}
1103
- />
1104
- </div>
1105
- </div>
1106
- {/* <div>
1107
- <Table
1108
- size='small'
1109
- columns={modalTableProps?.tableColumns}
1110
- dataSource={mapRows(doubleArr)}
1111
- rowKey={mappingValueField}
1112
- scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
1113
- onRow={record => {
1114
- return {
1115
- onDoubleClick: event => onDoubleClickSelect(event, record),
1116
- };
1117
- }}
1118
- />
1119
- </div> */}
1120
- </div>
1121
- <div className={'add_select_wrapper_select'}>
1122
- <div className={'select_list_selectTips'}>
1123
- <div style={{ marginLeft: 8 }}><span>本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span></div>
1124
- <div style={{ display: 'flex' }}>
1125
- <span style={{ marginRight: 8 }}>
1126
- <TableColumnSetting
1127
- setShowColumns={setShowColumnsCallback}
1128
- showColumns={showColumns}
1129
- datasource={selectColumns || []}
1130
- tableCode={codeSelected}
1131
- settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1132
- />
1133
- </span>
1134
- <div style={{ marginRight: 8 }}><span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>清空所选商品</span></div>
1135
- </div>
1136
- </div>
1137
- <Table
1138
- size='small'
1139
- columns={showSelectedCol}
1140
- dataSource={popvalue}
1141
- pagination={false}
1142
- // onChange={handleTableChange}
1143
- rowKey={selectRowKey}
1144
- rowClassName={'row-class'}
1145
- scroll={{ y: 500 }}
1146
- onRow={record => {
1147
- return {
1148
- onDoubleClick: event => onDoubleClickSelect(event, record),
1149
- };
1150
- }}
1151
- components={{
1152
- header: {
1153
- cell: ResizeableTitle,
1154
- },
1155
- }}
1156
- />
1157
- </div>
1158
- </div>
1159
- </Modal>
1160
- )}
1161
- </div>
1162
- );
1163
- };
1164
-
1165
- 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 axios from 'axios';
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 { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
17
+
18
+ const loadSelectSource = (url: string, params?: any) => {
19
+ return new Promise((resolve, reject) => {
20
+ axios
21
+ .get(`${url}?${stringify(params)}`)
22
+ .then((result: any) => {
23
+ result = result.data;
24
+ if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
25
+ message.error(result.msg);
26
+ return;
27
+ }
28
+ resolve(result);
29
+ })
30
+ .catch((err) => {
31
+ reject(err);
32
+ });
33
+ })
34
+ };
35
+
36
+ const ResizeableTitle = (props) => {
37
+ const { onResize, width, ...restProps } = props;
38
+
39
+ if (!width) {
40
+ return <th {...restProps} />;
41
+ }
42
+ return (
43
+ <Resizable
44
+ width={width}
45
+ height={0}
46
+ onResize={onResize}
47
+ draggableOpts={{ enableUserSelectHack: false }}
48
+ >
49
+ <th {...restProps} />
50
+ </Resizable>
51
+ );
52
+ };
53
+
54
+ const formatSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['code', 'name']) => {
55
+ const data = reData && reData[position]?.data;
56
+ const list = Array.isArray(data) ? data :(data?.items || data?.list || data?.children || []);
57
+ const formatData = list?.length ? list.map((v: any) => ({ text: v[resKeyValue[1]], value: v[resKeyValue[0]] })) : [];
58
+ changeSearchForm[changePosition] = {...changeSearchForm[changePosition], initialSource: formatData}
59
+ }
60
+
61
+ // 格式化树选择器数据源
62
+ const mapSearchTree = (treeDataItem: any, resKeyValue: any) => {
63
+ const haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0;
64
+ return {
65
+ title: treeDataItem[resKeyValue[1]],
66
+ value: treeDataItem[resKeyValue[0]],
67
+ parentId: treeDataItem.parent,
68
+ data: { ...treeDataItem },
69
+ isLeaf: !haveChildren,
70
+ disabled: haveChildren,
71
+ children: haveChildren ? treeDataItem.children.map((i: any) => mapSearchTree(i, resKeyValue)) : [],
72
+ };
73
+ };
74
+ const formatTreeDataSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['id', 'name']) => {
75
+ const data = reData && reData[position]?.data;
76
+ const formatData = (data &&
77
+ Array.isArray(data) &&
78
+ data.length &&
79
+ data.map((ites: any) => mapSearchTree(ites, resKeyValue))) ||
80
+ []
81
+ changeSearchForm[changePosition].field.props.treeData = formatData;
82
+ }
83
+
84
+ const { Option } = Select;
85
+
86
+ const AddSelect = (props: any) => {
87
+ const {
88
+ value, // 必传
89
+ onChange,
90
+ selectProps = {},
91
+ modalTableProps = {},
92
+ labelInValue = false,
93
+ requestConfig,
94
+ ctx,
95
+ sourceName,
96
+ needModalTable = true,
97
+ getPopupContainer = undefined,
98
+ onSaveCallback,
99
+ buttonText = '添加',
100
+ buttonProps = {},
101
+ beforeShowModal,
102
+ tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
103
+ businessType = 'sku',
104
+ isAllowRepeatedSelect = false
105
+ } = props;
106
+ const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField = 'name', mappingTextShowKeyField, mappingValueField = 'code', mappingTextShowTextField } = requestConfig || {};
107
+ const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
108
+ const realButtonProps = {type: "primary", ...buttonProps};
109
+ const selectRowKey = isAllowRepeatedSelect ? 'uuid' : mappingValueField
110
+
111
+ const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
112
+ const initVal = value || (selectMode ? [] : null);
113
+ const pageSize = 100 // 下拉框默认分页 条数
114
+ const tableInitPageSize = 10 // 弹框默认分页 条数
115
+ const currentPage = 1
116
+ const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
117
+ const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
118
+ const currentSelectProps = {
119
+ ...selectProps,
120
+ // 以下属性不可更改----设计配置项
121
+ showSearch: false,
122
+ filterOption: false,
123
+ allowClear: true,
124
+ listHeight: 160,
125
+ optionLabelProp: "label",
126
+ autoClearSearchValue: false
127
+ }
128
+ const [items, setItems] = useState([]);
129
+ const [scrollPage, setScrollPage] = useState(1);
130
+ const [itemsTotal, setItemsTotal] = useState(0);
131
+ const [fetching, setFetching] = useState(false);
132
+ const [searchValue, setSearchValue] = useState('');
133
+ const [isModalVisible, setIsModalVisible] = useState(false);
134
+ const [popvalue, setPopValue] = useState(initVal);
135
+ const [uniqueValue, setUniqueValue] = useState(sourceName)
136
+ const { run } = useDebounceFn(
137
+ (v?: any) => {
138
+ // 优化搜索参数 支持传多个
139
+ let searchParams = {};
140
+ if (typeof selectParamsKey === 'string') {
141
+ searchParams = v ? { [selectParamsInitKey]: initVal } : { [selectParamsKey]: searchValue }
142
+ }
143
+ if (Array.isArray(selectParamsKey)) {
144
+ selectParamsKey.forEach((i: any) => {
145
+ searchParams = { ...searchParams, [i]: searchValue }
146
+ })
147
+ }
148
+ // 防抖函数 待定
149
+ getData(searchParams)
150
+ },
151
+ {
152
+ wait: 1000,
153
+ },
154
+ );
155
+
156
+ const [form] = Form.useForm();
157
+ const [tableSearchForm, setTableSearchForm] = useState(modalTableProps?.tableSearchForm)
158
+ const [caretLeftFlag, setCaretLeftFlag] = useState(true);
159
+ const [tableData, setTableData] = useState([]);
160
+ const [tablePagination, setTablePagination] = useState({ total: 0, size: "small", current: 1, pageSize: tableInitPageSize })
161
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
162
+ const [doubleArr, setDoubleArr] = useState([]); // 存放双数组的数组
163
+ const [checkedAll, setCheckedAll] = useState(false)
164
+ const [indeterminate, setIndeterminate] = useState(false)
165
+ const [tableFormParams, setTableFormParams] = useState({});
166
+ const [confirmLoading, setConfirmLoading] = useState(false);
167
+ const [confirmContinueLoading, setConfirmContinueLoading] = useState(false);
168
+
169
+ const [selectColumns, setSelectColumns] = useState([]);
170
+ const [showColumns, setShowColumns] = useState([]);
171
+ const [tableColumns, setTableColumns] = useState([]);
172
+ const [showToChooseColumns, setShowToChooseColumns] = useState([]);
173
+ const codeToChoose = tableCodeList[0] || 'skuSelect-tableOptionsToChoosePartCode';
174
+ const codeSelected = tableCodeList[1] || 'skuSelect-tableSelectedItemPartCode';
175
+
176
+ useEffect(() => {
177
+ setTableColumns(modalTableProps?.tableColumns)
178
+ }, [modalTableProps?.tableColumns])
179
+
180
+ useEffect(() => {
181
+ setSelectColumns([... modalTableProps.selectColumn.map(item => {
182
+ const inputLength = modalTableProps.selectColumn.filter(item => item.isInputItem).length
183
+ const currentIndex = inputIndex
184
+
185
+ if (item.isInputItem) {
186
+ inputIndex++;
187
+ return {
188
+ ...item,
189
+ render: (text, record, index) => {
190
+ // let
191
+ if(record.needFocus === true && currentIndex === 0) {
192
+
193
+ }
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
+ value={text || ''}
220
+ min={0}
221
+ autoFocus={record.needFocus}
222
+ keyboard={false}
223
+ {...precisionObj}
224
+ onChange={(value) => {
225
+ record[item.dataIndex] = value
226
+ const newPopValue = popvalue.map((i: any, innerIndex: number) => {
227
+ if(innerIndex == index) {
228
+ i[item.dataIndex] = record[item.dataIndex]
229
+ }
230
+ return i
231
+ })
232
+ setPopValue(newPopValue)
233
+ }}
234
+ // onFocus={(e)=> {
235
+ // let dom1 = e.currentTarget;
236
+ // dom1.setSelectionRange(100, 0);
237
+ // dom1.select(text);
238
+ // }}
239
+ onKeyDown={(e) => {
240
+ if(e.keyCode === 13 && e.ctrlKey) {
241
+ handleOk(true)
242
+ document.getElementById("first-query")?.focus()
243
+ }
244
+ if(e.keyCode === 8 && e.ctrlKey) {
245
+ message.success('删除当前行')
246
+ e.stopPropagation();
247
+ e.preventDefault();
248
+ let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
249
+ if (dom) {
250
+ dom.select();
251
+ dom.focus();
252
+ dom.scrollIntoView(false)
253
+ }
254
+ dom = null
255
+ deleteRecord(record, popvalue);
256
+ }
257
+ if (e.keyCode === 37 && e.shiftKey) { // 左滑动
258
+ e.stopPropagation();
259
+ e.preventDefault();
260
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
261
+ if (dom) {
262
+ dom.select();
263
+ dom.focus();
264
+ dom.scrollIntoView(false)
265
+ }
266
+ dom = null
267
+ }
268
+ if (e.keyCode === 39 && e.shiftKey) { // 右滑
269
+ e.stopPropagation();
270
+ e.preventDefault();
271
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
272
+ if (dom) {
273
+ dom.select();
274
+ dom.focus();
275
+ dom.scrollIntoView(false)
276
+ }
277
+ dom = null
278
+ }
279
+ if (e.keyCode === 40) {
280
+ e.stopPropagation();
281
+ e.preventDefault();
282
+ let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
283
+ if (dom) {
284
+ dom.select();
285
+ dom.focus();
286
+ dom.scrollIntoView(false)
287
+ }
288
+ dom = null
289
+ } else if (e.keyCode === 38) {
290
+ e.stopPropagation();
291
+ e.preventDefault();
292
+ let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
293
+ if (dom1) {
294
+ // dom1.value=""
295
+ // dom1.setSelectionRange(100, 0);
296
+ dom1.select();
297
+ dom1.focus();
298
+ dom1.scrollIntoViewIfNeeded(false)
299
+ // dom1.value=record['count']
300
+ }
301
+ dom1 = null
302
+ } else if (e.keyCode === 9 && index === selectedRowKeys.length - 1 && currentIndex === inputLength - 1) {
303
+ e.stopPropagation();
304
+ e.preventDefault();
305
+ }
306
+ }}
307
+ />
308
+ );
309
+ },
310
+ }
311
+ }
312
+
313
+ const selectLength = modalTableProps.selectColumn.filter(item => item.isSelectItem).length
314
+ const currentSelectIndex = selectIndex
315
+ if(item.isSelectItem) {
316
+ selectIndex++;
317
+ return {
318
+ ...item,
319
+ render: (text, record, index) => {
320
+ if (item.dataSource?.length) {
321
+ return (
322
+ <Select
323
+ value={text || null}
324
+ onChange={(value) => {
325
+ if(businessType == 'skc' && popvalue.some((i: any) => i.code == record.code && i[item.dataIndex] == value)) {
326
+ message.warning('相同skc配码不可设置相同哦')
327
+ record[item.dataIndex] = null;
328
+ const newPopValue = popvalue.map((i: any, innerIndex: number) => {
329
+ if(innerIndex == index) {
330
+ i[item.dataIndex] = record[item.dataIndex]
331
+ }
332
+ return i
333
+ })
334
+ setPopValue(newPopValue)
335
+ return false
336
+ }
337
+ record[item.dataIndex] = value
338
+ const newPopValue = popvalue.map((i: any, innerIndex: number) => {
339
+ if(innerIndex == index) {
340
+ i[item.dataIndex] = record[item.dataIndex]
341
+ }
342
+ return i
343
+ })
344
+ setPopValue(newPopValue)
345
+ }}
346
+ style={{width: '160px'}}
347
+ >
348
+ {item.dataSource.map((item: any) => {
349
+ return <Select.Option value={item.code}>{item.name}</Select.Option>
350
+ })}
351
+ </Select>
352
+ )
353
+ }
354
+ return <></>
355
+ },
356
+ }
357
+ }
358
+
359
+ return item
360
+ }), {
361
+ title: '操作',
362
+ width: 50,
363
+ dataIndex: 'operation',
364
+ fixed: 'right',
365
+ render: (text, record, index) => {
366
+ return (
367
+ <span style={{cursor: 'pointer', color: '#005CFF' }} onClick={() => {
368
+ deleteRecord(record)
369
+ }} type={"text"}>删除</span>
370
+ )
371
+ }
372
+ },])
373
+ }, [modalTableProps?.selectColumn,popvalue])
374
+
375
+ // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
376
+ const getData = (params = {}, type = 1) => {
377
+ if (!requestConfig) return;
378
+
379
+ setFetching(true)
380
+
381
+ // 处理dependence参数
382
+ const fixedParam = {};
383
+ if (fixedparameter && fieldValToParam && ctx) {
384
+ fixedparameter.forEach((item: any, index: any) => {
385
+ const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
386
+ if (fixedParamVal) {
387
+ fixedParam[item] = fixedParamVal;
388
+ form.setFieldsValue({ ...form?.getFieldsValue(), [item]: fixedParamVal })
389
+ }
390
+ });
391
+ }
392
+
393
+ // 数组对象处理,对带有特殊标记的name进行处理
394
+ for (const key in params) {
395
+ if (Object.prototype.hasOwnProperty.call(params, key)) {
396
+ const element = params[key];
397
+ if (element && key.indexOf('*number*') >= 0) {
398
+ const dataParams = key.split('*number*');
399
+ dataParams.forEach((value, index) => {
400
+ params[value] = element[index];
401
+ });
402
+ delete params[key];
403
+ } else if (element && key.indexOf('*address*') >= 0) {
404
+ const dataParams = key.split('*address*');
405
+ dataParams.forEach((value, index) => {
406
+ params[value] = element.PCDCode[index];
407
+ });
408
+ delete params[key];
409
+ } else if (element && key.indexOf('*costType*') >= 0) {
410
+ const dataParams = key.split('*costType*');
411
+ // eslint-disable-next-line prefer-destructuring
412
+ params[dataParams[0]] = element[1];
413
+ delete params[key];
414
+ } else if (element && key.indexOf('*fullDate*') >= 0) {
415
+ const dataParams = key.split('*fullDate*');
416
+ dataParams.forEach((value, index) => {
417
+ if (index === 0) {
418
+ params[value] = moment(element[index])
419
+ .millisecond(0)
420
+ .second(0)
421
+ .minute(0)
422
+ .hour(0)
423
+ .format('YYYY-MM-DD HH:mm:ss');
424
+ } else {
425
+ params[value] = moment(element[index])
426
+ .millisecond(59)
427
+ .second(59)
428
+ .minute(59)
429
+ .hour(23)
430
+ .format('YYYY-MM-DD HH:mm:ss');
431
+ }
432
+ });
433
+ delete params[key];
434
+ } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
435
+ const dataParams = key.split('*checkBox*');
436
+ if (element) {
437
+ params[dataParams[0]] = 0
438
+ }
439
+ delete params[key];
440
+ } else if (element && key.indexOf('*cascader*') >= 0) {
441
+ const dataParams = key.split('*cascader*');
442
+ params[dataParams[0]] = element[element.length - 1]
443
+ delete params[key];
444
+ } else if (element && key.indexOf('*date*') >= 0) {
445
+ const dataParams = key.split('*date*')
446
+ dataParams.forEach((value, index) => {
447
+ if (index === 0) {
448
+ params[value] = moment(element[index])
449
+ .format('YYYY-MM-DD');
450
+ } else {
451
+ params[value] = moment(element[index])
452
+ .format('YYYY-MM-DD');
453
+ }
454
+ });
455
+ delete params[key];
456
+ }
457
+ else if (element && key.indexOf('*') >= 0) {
458
+ const dataParams = key.split('*');
459
+ dataParams.forEach((value, index) => {
460
+ params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
461
+ });
462
+ delete params[key];
463
+ } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
464
+ const dataParams = key.split('_selectNumberRange')[0]
465
+ if (params[key][0] === 'range') {
466
+ if (params[key][1][0]) {
467
+ params[`qp-${dataParams}-ge`] = params[key][1][0]
468
+ }
469
+ if (params[key][1][1]) {
470
+ params[`qp-${dataParams}-le`] = params[key][1][1]
471
+ }
472
+ } else {
473
+ params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
474
+ }
475
+ delete params[key]
476
+ } else if (Array.isArray(element)) {
477
+ params[key] = element.join(',');
478
+ } else if (element == null || element === undefined || String(element).trim() === '') {
479
+ delete params[key]
480
+ }
481
+ }
482
+ }
483
+
484
+ const queryParams = {
485
+ pageSize,
486
+ currentPage,
487
+ ...otherParams, // 默认参数
488
+ ...fixedParam,
489
+ ...params,
490
+ }
491
+ axios
492
+ .get(`${url}?${stringify(queryParams)}`)
493
+ .then((result: any) => {
494
+ setFetching(false)
495
+ result = result.data;
496
+ if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
497
+ message.error(result.msg);
498
+ return;
499
+ }
500
+ const res = result.data;
501
+ let source = [];
502
+ if (isMap) {
503
+ source = Object.keys(res).map((d, i) => {
504
+ return {
505
+ text: Object.values(res)[i],
506
+ value: d,
507
+ };
508
+ });
509
+ } else {
510
+ const keys = res.list ? 'list' : 'items';
511
+ source = res
512
+ ? res[keys]
513
+ ? res[keys].map((item: any) => {
514
+ let textShowText = item[mappingTextField]
515
+ if (mappingTextShowTextField) {
516
+ textShowText = []
517
+ if (Array.isArray(mappingTextShowTextField)) {
518
+ mappingTextShowTextField.forEach((r: any) => {
519
+ textShowText.push(item[r])
520
+ })
521
+ } else {
522
+ textShowText = item[mappingTextShowTextField]
523
+ }
524
+ }
525
+ return {
526
+ ...item,
527
+ text: item[mappingTextField],
528
+ textShowText,
529
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
530
+ value: item[mappingValueField],
531
+ baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
532
+ };
533
+ })
534
+ : Array.isArray(res) &&
535
+ res?.map((item: Record<string, any>) => {
536
+ let textShowText = item[mappingTextField]
537
+ if (mappingTextShowTextField) {
538
+ textShowText = []
539
+ if (Array.isArray(mappingTextShowTextField)) {
540
+ mappingTextShowTextField.forEach((r: any) => {
541
+ textShowText.push(item[r])
542
+ })
543
+ } else {
544
+ textShowText = item[mappingTextShowTextField]
545
+ }
546
+ }
547
+ return {
548
+ ...item,
549
+ text: item[mappingTextField],
550
+ textShowText,
551
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
552
+ value: item[mappingValueField],
553
+ baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
554
+ };
555
+ })
556
+ : [];
557
+ }
558
+ source = Array.isArray(source) ? source : []
559
+ if (type === 1) {
560
+ ctx?.form?.setFieldSource(resultSourceKey, source)
561
+ setItems(source)
562
+ setItemsTotal(Number(res?.total || res?.totalCount || source.length))
563
+ } else {
564
+ setTableData(source)
565
+ 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)) })
566
+ }
567
+ })
568
+ .catch((err) => { setFetching(false) });
569
+ }
570
+
571
+ const SelectScroll = e => {
572
+ e.persist();
573
+ const { target } = e;
574
+ const totalPage = Math.ceil(itemsTotal / pageSize)
575
+ // 判断是否滑动到底部
576
+ const isTouchGround = target.scrollTop + target.offsetHeight === target.scrollHeight // >=scrollHeight
577
+ // 判断数据是否还没有加载到了最后一页
578
+ const canPageAdd = scrollPage < totalPage
579
+ if (isTouchGround && canPageAdd) {
580
+ const nextScrollPage = scrollPage + 1;
581
+ setScrollPage(nextScrollPage);
582
+ getData({ currentPage: nextScrollPage }); // 调用api方法
583
+ }
584
+
585
+ //判断是否滑动到顶部
586
+ const isTouchTop = target.scrollTop === 0 // <=0
587
+ // 判断数据是否到第一页
588
+ const canPageJian = scrollPage > 1
589
+ if (isTouchTop && canPageJian) {
590
+ const preScrollPage = scrollPage - 1;
591
+ setScrollPage(preScrollPage);
592
+ getData({ currentPage: preScrollPage }); // 调用api方法
593
+ }
594
+ }
595
+
596
+ useEffect(() => {
597
+ if(businessType == 'sku') {
598
+ Promise.all([
599
+ loadSelectSource(`/items/brand/queryBrandList`, {
600
+ pageSize: 5000,
601
+ currentPage: 1,
602
+ 'ctl-withAuth': true
603
+ }),
604
+ loadSelectSource(`/items/category/queryCategoryTree`, {
605
+ pageSize: 5000,
606
+ currentPage: 1,
607
+ }),
608
+ ]).then((x: any)=>{
609
+ formatSource(x,0, 2, tableSearchForm,['id','name'])
610
+ formatTreeDataSource(x,1, 3, tableSearchForm)
611
+ })
612
+ }
613
+ if(businessType == 'skc') {
614
+ Promise.all([
615
+ loadSelectSource(`/items/item/propertyValue`, {
616
+ pageSize: 5000,
617
+ currentPage: 1,
618
+ 'qp-propertyId-eq': '1467042217951883265'
619
+ }),
620
+ loadSelectSource(`/items/category/queryCategoryTree`, {
621
+ pageSize: 5000,
622
+ currentPage: 1,
623
+ }),
624
+ loadSelectSource(`/items/class/withProperty`, {
625
+ pageSize: 5000,
626
+ currentPage: 1,
627
+ }),
628
+ loadSelectSource(`/items/brand/queryBrandList`, {
629
+ pageSize: 5000,
630
+ currentPage: 1,
631
+ 'ctl-withAuth': true
632
+ }),
633
+ ]).then((x: any)=>{
634
+ formatSource(x,0, 3, tableSearchForm,['value','value'])
635
+ formatTreeDataSource(x,1, 4, tableSearchForm)
636
+ formatSource(x,2, 5, tableSearchForm,['id','name'])
637
+ formatSource(x,3, 6, tableSearchForm,['id','name'])
638
+ })
639
+ }
640
+ }, [businessType])
641
+
642
+ useEffect(() => {
643
+ if (value) {
644
+ setPopValue(value);
645
+ }
646
+ }, [value]);
647
+
648
+ useEffect(() => {
649
+ makeUniqueValue();
650
+ }, [sourceName])
651
+
652
+ const showModal = () => {
653
+ // getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
654
+ setIsModalVisible(true);
655
+ // 回显
656
+ if (value) {
657
+ if (selectMode) {
658
+ setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
659
+ setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
660
+ setIndeterminate(!!value.length && value.length < itemsTotal);
661
+ setCheckedAll(itemsTotal && value.length === itemsTotal);
662
+ // 需清空数据
663
+ if (!value.length) {
664
+ setDoubleArr([])
665
+ }
666
+ } else {
667
+ setSelectedRowKeys(labelInValue ? [value.key] : [value])
668
+ setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
669
+ }
670
+ }
671
+
672
+ setTimeout(() => {
673
+ document.getElementById("first-query")?.focus()
674
+ }, 50)
675
+ };
676
+
677
+ const handleShowModal = () => {
678
+ if(beforeShowModal) {
679
+ beforeShowModal(popvalue).then(res => {
680
+ showModal()
681
+ }).catch(Error => {
682
+ message.warning(Error)
683
+ })
684
+ } else {
685
+ showModal()
686
+ }
687
+ }
688
+
689
+ const handleSelectOver = (selectedValue: any) => {
690
+ if (selectedValue?.length) {
691
+ formaData(selectedValue);
692
+ // 解决选择最后1页的sku,返回后,不显示名称问题
693
+ const source = _.uniqBy(items.concat(selectedValue), 'value')
694
+ ctx?.form?.setFieldSource(resultSourceKey, source)
695
+ setItems(source)
696
+ }
697
+ }
698
+
699
+ const handleLoading = (isContinue,flag) => {
700
+ isContinue ? setConfirmContinueLoading(flag) : setConfirmLoading(flag);
701
+ }
702
+
703
+ const handleOk = (isContinue) => {
704
+ if(!popvalue.length) {
705
+ message.warning('至少选中一条数据')
706
+ return;
707
+ }
708
+ // handleSelectOver(popvalue)
709
+ if(onSaveCallback) {
710
+ handleLoading(isContinue,true)
711
+ onSaveCallback(popvalue).then(res => {
712
+ if(true) {
713
+ message.success('保存成功')
714
+ deleteSelectRows();
715
+ document.getElementById('first-query')?.focus()
716
+ !isContinue && handleCancel();
717
+ } else {
718
+ }
719
+ handleLoading(isContinue,false)
720
+ }).catch(Error => {
721
+ message.error(Error);
722
+ handleLoading(isContinue,false)
723
+ })
724
+ } else {
725
+ !isContinue && handleCancel();
726
+ }
727
+ };
728
+
729
+ const formaData = (value) => {
730
+ if (labelInValue) {
731
+ const formatResult = value.map((i: any) => ({ key: i[mappingValueField], label: i[mappingTextField], value: i[mappingValueField] }))
732
+ onChange(selectMode ? formatResult : formatResult[0])
733
+ } else {
734
+ const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
735
+ onChange(formatResult)
736
+ }
737
+ };
738
+
739
+ const handleCancel = () => {
740
+ form.resetFields();
741
+ setTableFormParams({});
742
+ setIsModalVisible(false);
743
+ setTableData([])
744
+ // if (selectMode) {
745
+ // run();
746
+ // }
747
+ };
748
+
749
+ const onSearchChange = (e) => {
750
+ setSearchValue(e.target.value);
751
+ run();
752
+ }
753
+
754
+ const onSearchBlur = () => {
755
+ setSearchValue('')
756
+ run();
757
+ }
758
+
759
+ const onSearchTable = () => {
760
+ const params = form.getFieldsValue();
761
+ setTableFormParams(params);
762
+ getData({ ...params, pageSize: tableInitPageSize }, 2)
763
+ if (selectMode) {
764
+ getData(params)
765
+ }
766
+ }
767
+
768
+ const onResetTable = () => {
769
+ form.resetFields();
770
+ setTableFormParams({});
771
+ getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
772
+ }
773
+
774
+ const handleTableChange = (pagination) => {
775
+ getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
776
+ }
777
+
778
+ // 扁平化二维数组的方法
779
+ const mapRows = params => {
780
+ var res = [];
781
+ for (var i = 0; i < params.length; i++) {
782
+ if (Array.isArray(params[i])) {
783
+ // 去重
784
+ res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
785
+ } else {
786
+ res.push(params[i]);
787
+ // 去重
788
+ res = _.uniqBy(res, 'value')
789
+ }
790
+ }
791
+ return res.filter(Boolean); //去掉undefined的情况
792
+ };
793
+
794
+ const onChangeSelectedKeys = (selectKeys, selectRows) => {
795
+ if(selectKeys.length - selectedRowKeys.length > 0) {
796
+ if (selectKeys.length - selectedRowKeys.length === 1) {
797
+ selectRows[selectRows.length -1]['needFocus'] = true;
798
+ } else {
799
+ selectRows[selectedRowKeys.length]['needFocus'] = true;
800
+ }
801
+ }
802
+ if(isAllowRepeatedSelect) {
803
+ const list = popvalue.concat(selectRows).map((i: any) => ({...i, uuid: i.uuid || uuid()}))
804
+ setPopValue(list);
805
+ setSelectedRowKeys([])
806
+ } else {
807
+ setPopValue(selectRows);
808
+ setSelectedRowKeys(selectKeys)
809
+ }
810
+ // setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
811
+ // setCheckedAll(filterRows.length === tablePagination?.total);
812
+ }
813
+
814
+ // 生成唯一值
815
+ const makeUniqueValue = () => {
816
+ const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
817
+ setUniqueValue(generateUnitKey);
818
+ return generateUnitKey;
819
+ }
820
+
821
+ const rowSelection = {
822
+ type: 'checkbox',
823
+ selectedRowKeys,
824
+ preserveSelectedRowKeys: true,
825
+ onChange: (sks, srs) => {
826
+ onChangeSelectedKeys(sks, srs)
827
+ },
828
+ getCheckboxProps: () => ({
829
+ disabled: selectProps?.disabled || props?.disabled,
830
+ }),
831
+ };
832
+
833
+ const onDoubleClickSelect = (e, record) => {
834
+ if (!selectMode) {
835
+ const srs = [JSON.parse(JSON.stringify(record))]
836
+ const sks = srs.map((i: any) => i.value)
837
+ onChangeSelectedKeys(sks, srs)
838
+ }
839
+ }
840
+
841
+ const themeColor = { color: '#005CFF' }
842
+
843
+ const formItem = (list) => {
844
+ if (isModalVisible && list?.length) {
845
+ return list.map((i: any, index) => {
846
+ if (i?.type === 'select' || i?.field?.type === 'select') {
847
+ return (
848
+ <Form.Item name={i.name} label={i.label} key={i.name}>
849
+ <Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}>
850
+ {i?.initialSource?.length && i?.initialSource.map((m: any) => (
851
+ <Option value={m.value} key={m.value}>{m.text}</Option>
852
+ ))}
853
+ </Select>
854
+ </Form.Item>
855
+ )
856
+ }
857
+
858
+ if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
859
+ return (
860
+ <Form.Item name={i.name} label={i.label} key={i.name}>
861
+ <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}></TreeSelect>
862
+ </Form.Item>
863
+ )
864
+ }
865
+
866
+ if (i?.type === 'BusinessSearchSelect' || i?.field?.type === 'BusinessSearchSelect') {
867
+ return (
868
+ <div>
869
+ <Form.Item name={i.name} label={i.label} key={i.name}>
870
+ <BusinessSearchSelect {...i.field.props} />
871
+ </Form.Item>
872
+ </div>
873
+ )
874
+ }
875
+
876
+ if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
877
+ return (
878
+ <div>
879
+ <Form.Item name={i.name} label={i.label} key={i.name}>
880
+ <QueryMutipleInput onValueChange={(value) => {
881
+ form.setFieldsValue({
882
+ [i.name]: value
883
+ })
884
+ }} />
885
+ </Form.Item>
886
+ </div>
887
+ );
888
+ }
889
+
890
+ // 默认type是input
891
+ return (
892
+ <Form.Item name={i.name} label={i.label} key={i.name}>
893
+ <Input id={index === 0 ? "first-query" : 'index'} style={{ width: '100%' }} onKeyDown={(e) => {
894
+ if (e.keyCode === 13) {
895
+ onSearchTable()
896
+ }
897
+ }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} />
898
+ </Form.Item>
899
+ )
900
+ })
901
+ } else {
902
+ return null
903
+ }
904
+ }
905
+
906
+ const maxTagPlaceholder = (selectedValues) => {
907
+ const onClose = (e: any, item: any) => {
908
+ e.preventDefault();
909
+ const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value) : JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
910
+ onChange(newValue);
911
+ }
912
+ return (
913
+ <Tooltip title={selectedValues.map((i: any) => (
914
+ <Tag
915
+ closable={true}
916
+ onClose={(e) => onClose(e, i)}
917
+ style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
918
+ >
919
+ {i.label}
920
+ </Tag>
921
+ ))}>
922
+ {`+ ${selectedValues?.length}`}
923
+ </Tooltip>
924
+ )
925
+ }
926
+
927
+ const deleteSelectRows = () => {
928
+ setPopValue([])
929
+ setSelectedRowKeys([])
930
+ }
931
+
932
+ const deleteRecord = (record) => {
933
+ if(isAllowRepeatedSelect) {
934
+ setPopValue(popvalue.filter(item => item.uuid !== record.uuid))
935
+ setSelectedRowKeys([])
936
+ } else {
937
+ setPopValue(popvalue.filter(item => item.skuCode !== record.skuCode))
938
+ setSelectedRowKeys([...selectedRowKeys.filter(item => item !== record.skuCode)])
939
+ }
940
+ }
941
+
942
+ let inputIndex = 0;
943
+ let selectIndex = 0;
944
+
945
+ useEffect(() => {
946
+ setInitialShowColumn(codeSelected,selectColumns,(res) => {
947
+ setShowColumnsCallback(res)
948
+ })
949
+ },[selectColumns])
950
+ useEffect(() => {
951
+ setInitialShowColumn(codeToChoose,tableColumns,(res) => {
952
+ setShowToChooseColumnsCallback(res)
953
+ })
954
+ },[tableColumns])
955
+
956
+ const handleResize = (arr,index: any, callback) => (_: any, { size }: any) => {
957
+ let newColumns = arr.map((col: any) => ({ ...col }));
958
+ const handleIndex = (arr: any, indexArr: any) => {
959
+ let i = indexArr.shift();
960
+ if (indexArr.length > 0) {
961
+ handleIndex(arr[i].children, indexArr);
962
+ } else {
963
+ arr[i] = {
964
+ ...arr[i],
965
+ width: size.width,
966
+ };
967
+ handleAntdColumnsSpecialParams(arr[i]);
968
+ }
969
+ };
970
+ handleIndex(newColumns, [...index]);
971
+ callback(newColumns)
972
+ };
973
+
974
+ const setShowColumnsCallback = (newColumns: Array<any>) => {
975
+ setShowColumns([...newColumns])
976
+ }
977
+ const setShowToChooseColumnsCallback = (newColumns: Array<any>) => {
978
+ setShowToChooseColumns([...newColumns])
979
+ }
980
+
981
+ const handleColumns = (arr: any, indexArr: any[], callback: any) => {
982
+ arr.forEach((item: any, index: any) => {
983
+ let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
984
+ if (noEmptyArray(item.children)) {
985
+ handleColumns(item.children, indexArrInside);
986
+ } else {
987
+ item.width = item.width || getItemDefaultWidth(item);
988
+ item.onHeaderCell = (column: any) => ({
989
+ ...item,
990
+ width:
991
+ typeof column.width === 'number'
992
+ ? column.width
993
+ : parseInt(column.width.replace('px', '')),
994
+ onResize: handleResize(arr,indexArrInside, callback),
995
+ });
996
+ }
997
+ })
998
+ };
999
+ let showToChooseCol = showToChooseColumns.map((item: any) => {
1000
+ handleAntdColumnsSpecialParams(item);
1001
+ return ({ ...item })
1002
+ })
1003
+ handleColumns(showToChooseCol, [],(res)=> setShowToChooseColumnsCallback(res));
1004
+ let showSelectedCol = showColumns.map((item: any) => {
1005
+ handleAntdColumnsSpecialParams(item);
1006
+ return ({ ...item })
1007
+ })
1008
+ handleColumns(showSelectedCol, [],(res)=> setShowColumnsCallback(res));
1009
+
1010
+ const selectLength = isAllowRepeatedSelect ? (popvalue?.length || 0) : (selectedRowKeys?.length || 0)
1011
+ return (
1012
+ <div className={'add_select'}>
1013
+ <div className="add_select_show" id={`add_select_div_${uniqueValue}`}>
1014
+ <Button onClick={handleShowModal} {...realButtonProps}>
1015
+ {buttonText}
1016
+ </Button>
1017
+ </div>
1018
+ {needModalTable && isModalVisible && (
1019
+ <Modal
1020
+ width='1200px'
1021
+ style={{ top: 20 }}
1022
+ bodyStyle={{ padding: '0px' }}
1023
+ // title={modalTableProps?.modalTableTitle}
1024
+ visible={isModalVisible}
1025
+ closable={false}
1026
+ onCancel={handleCancel}
1027
+ footer={selectMode ? [
1028
+ <Button key="back" onClick={handleCancel}>
1029
+ 取消
1030
+ </Button>,
1031
+ <Button
1032
+ key="save-and-continue"
1033
+ style={{color: '#005CFF', borderColor: '#005CFF'}}
1034
+ onClick={() => {handleOk(true)}}
1035
+ loading={confirmContinueLoading}
1036
+ disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
1037
+ >
1038
+ 保存并继续
1039
+ </Button>,
1040
+ <Button
1041
+ key="submit"
1042
+ type="primary"
1043
+ onClick={() => {handleOk(false)}}
1044
+ loading={confirmLoading}
1045
+ disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
1046
+ >
1047
+ 确定
1048
+ </Button>,
1049
+ ] : null}
1050
+ >
1051
+ <div>
1052
+ <div className='add_select_header'>
1053
+ {modalTableProps?.modalTableTitle}
1054
+ <span><span>*</span> &nbsp;快捷键:【Tab】-跳格切换;【Shift+←、→】-当前行左、右移动;【 ↑、↓】-当前列上、下移动;【ctrl+Enter】-保存并继续;【ctrl+Delete】-删除当前行;</span>
1055
+ <span className='add_select_header_close'><CloseCircleOutlined style={{fontSize: '20px'}} onClick={handleCancel} /></span>
1056
+ </div>
1057
+ <div className={'add_select_wrapper'}>
1058
+ <div className={caretLeftFlag ? 'add_select_wrapper_left' : 'add_select_wrapper_left1'}>
1059
+ <div className={'select_list_columns'}>
1060
+ <div className={'select_list_columns_formItems'}>
1061
+ <Form form={form} layout='vertical' key='modalForm'>
1062
+ {formItem(tableSearchForm)}
1063
+ </Form>
1064
+ </div>
1065
+ </div>
1066
+ <div className={'select_list_searchButton'}>
1067
+ <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
1068
+ <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
1069
+ </div>
1070
+ </div>
1071
+ <div className={caretLeftFlag ? 'add_select_wrapper_right' : 'add_select_wrapper_right1'}>
1072
+ <div>
1073
+ <div className={'select_list_selectTips'}>
1074
+ <div style={{ marginLeft: 8 }}>搜索结果共&nbsp;<span style={themeColor}>{tablePagination?.total || 0}</span>&nbsp;项{selectMode ? <span>, 本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span> : ''}</div>
1075
+ <div>
1076
+ <span style={{ marginRight: 8 }}>
1077
+ <TableColumnSetting
1078
+ setShowColumns={setShowToChooseColumnsCallback}
1079
+ showColumns={showToChooseColumns}
1080
+ datasource={tableColumns || []}
1081
+ tableCode={codeToChoose}
1082
+ settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1083
+ />
1084
+ </span>
1085
+ </div>
1086
+ </div>
1087
+ <Table
1088
+ size='small'
1089
+ rowSelection={rowSelection}
1090
+ columns={showToChooseCol}
1091
+ dataSource={tableData}
1092
+ pagination={tablePagination}
1093
+ loading={fetching}
1094
+ onChange={handleTableChange}
1095
+ rowKey={mappingValueField}
1096
+ rowClassName={'row-class'}
1097
+ scroll={{ y: 500 }}
1098
+ components={{
1099
+ header: {
1100
+ cell: ResizeableTitle,
1101
+ },
1102
+ }}
1103
+ />
1104
+ </div>
1105
+ </div>
1106
+ {/* <div>
1107
+ <Table
1108
+ size='small'
1109
+ columns={modalTableProps?.tableColumns}
1110
+ dataSource={mapRows(doubleArr)}
1111
+ rowKey={mappingValueField}
1112
+ scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
1113
+ onRow={record => {
1114
+ return {
1115
+ onDoubleClick: event => onDoubleClickSelect(event, record),
1116
+ };
1117
+ }}
1118
+ />
1119
+ </div> */}
1120
+ </div>
1121
+ <div className={'add_select_wrapper_select'}>
1122
+ <div className={'select_list_selectTips'}>
1123
+ <div style={{ marginLeft: 8 }}><span>本次已选&nbsp;<span style={themeColor}>{selectLength}</span>&nbsp;项</span></div>
1124
+ <div style={{ display: 'flex' }}>
1125
+ <span style={{ marginRight: 8 }}>
1126
+ <TableColumnSetting
1127
+ setShowColumns={setShowColumnsCallback}
1128
+ showColumns={showColumns}
1129
+ datasource={selectColumns || []}
1130
+ tableCode={codeSelected}
1131
+ settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1132
+ />
1133
+ </span>
1134
+ <div style={{ marginRight: 8 }}><span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>清空所选商品</span></div>
1135
+ </div>
1136
+ </div>
1137
+ <Table
1138
+ size='small'
1139
+ columns={showSelectedCol}
1140
+ dataSource={popvalue}
1141
+ pagination={false}
1142
+ // onChange={handleTableChange}
1143
+ rowKey={selectRowKey}
1144
+ rowClassName={'row-class'}
1145
+ scroll={{ y: 500 }}
1146
+ onRow={record => {
1147
+ return {
1148
+ onDoubleClick: event => onDoubleClickSelect(event, record),
1149
+ };
1150
+ }}
1151
+ components={{
1152
+ header: {
1153
+ cell: ResizeableTitle,
1154
+ },
1155
+ }}
1156
+ />
1157
+ </div>
1158
+ </div>
1159
+ </Modal>
1160
+ )}
1161
+ </div>
1162
+ );
1163
+ };
1164
+
1165
+ export default AddSelect;