@bit-sun/business-component 4.0.13-alpha.9 → 4.2.0-aiwei-alpha.1

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 (150) hide show
  1. package/.umirc.ts +21 -10
  2. package/dist/components/Business/AddSelectBusiness/index.d.ts +3 -4
  3. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -2
  4. package/dist/components/Business/BsLayouts/Components/ChooseStore/index.d.ts +1 -2
  5. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
  6. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +1 -1
  7. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +2 -2
  8. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +1 -2
  9. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +1 -2
  10. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
  11. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +1 -2
  12. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +1 -2
  13. package/dist/components/Business/BsLayouts/index.d.ts +1 -1
  14. package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +5 -5
  15. package/dist/components/Business/BsSulaQueryTable/index.d.ts +1 -2
  16. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +11 -8
  17. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +14 -15
  18. package/dist/components/Business/CommodityEntry/index.d.ts +1 -2
  19. package/dist/components/Business/CommonAlert/index.d.ts +1 -2
  20. package/dist/components/Business/CommonGuideWrapper/index.d.ts +3 -3
  21. package/dist/components/Business/DetailPageWrapper/index.d.ts +11 -6
  22. package/dist/components/Business/HomePageWrapper/index.d.ts +1 -2
  23. package/dist/components/Business/ItemPropertySelector/index.d.ts +2 -0
  24. package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +1 -2
  25. package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +1 -2
  26. package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +1 -2
  27. package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +1 -2
  28. package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +1 -2
  29. package/dist/components/Business/ModalUtils/index.d.ts +8 -0
  30. package/dist/components/Business/PropertyModal/index.d.ts +1 -2
  31. package/dist/components/Business/PropertyModal/propertyGroup.d.ts +1 -1
  32. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  33. package/dist/components/Business/SearchSelect/utils.d.ts +4 -2
  34. package/dist/components/Business/StateFlow/index.d.ts +1 -2
  35. package/dist/components/Business/SystemLog/index.d.ts +78 -0
  36. package/dist/components/Business/TreeSearchSelect/index.d.ts +1 -1
  37. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +9 -8
  38. package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +1 -2
  39. package/dist/components/Business/columnSettingTable/index.d.ts +21 -4
  40. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +22 -5
  41. package/dist/components/Business/columnSettingTable/utils.d.ts +1 -2
  42. package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
  43. package/dist/components/Common/ParagraphCopier/index.d.ts +1 -1
  44. package/dist/components/Common/Section/index.d.ts +1 -1
  45. package/dist/components/Functional/AddSelect/index.d.ts +1 -2
  46. package/dist/components/Functional/AuthButton/index.d.ts +1 -2
  47. package/dist/components/Functional/DataImport/index.d.ts +3 -3
  48. package/dist/components/Functional/DataValidation/index.d.ts +15 -5
  49. package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +1 -2
  50. package/dist/components/Functional/QueryMutipleInput/index.d.ts +3 -3
  51. package/dist/components/Functional/QueryMutipleSelect/index.d.ts +1 -2
  52. package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
  53. package/dist/components/Functional/SearchSelect/utils.d.ts +4 -4
  54. package/dist/components/Functional/TreeSearchSelect/index.d.ts +1 -2
  55. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +1 -1
  56. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +1 -2
  57. package/dist/components/Solution/RuleComponent/Formula.d.ts +1 -2
  58. package/dist/components/Solution/RuleComponent/InnerSelect.d.ts +1 -2
  59. package/dist/components/Solution/RuleComponent/RenderCompItem.d.ts +1 -2
  60. package/dist/components/Solution/RuleSetter/RuleInstance.d.ts +1 -2
  61. package/dist/components/Solution/RuleSetter/baseRule.d.ts +1 -1
  62. package/dist/components/Solution/RuleSetter/index.d.ts +1 -1
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.esm.js +4238 -2124
  65. package/dist/index.js +4247 -2122
  66. package/dist/plugin/TableColumnSetting/index.d.ts +6 -5
  67. package/dist/utils/RequestCacheManager.d.ts +82 -0
  68. package/dist/utils/TableUtils.d.ts +18 -19
  69. package/dist/utils/cachedRequest.d.ts +76 -0
  70. package/dist/utils/index.d.ts +1 -0
  71. package/dist/utils/utils.d.ts +41 -0
  72. package/package.json +16 -14
  73. package/src/assets/btn-cancel.svg +3 -0
  74. package/src/assets/btn-copy.svg +3 -0
  75. package/src/assets/btn-delete.svg +2 -29
  76. package/src/assets/btn-edit.svg +2 -19
  77. package/src/assets/btn-hangUp.svg +3 -0
  78. package/src/assets/btn-print.svg +3 -0
  79. package/src/assets/btn-refresh.svg +3 -0
  80. package/src/assets/btn-unhook.svg +3 -0
  81. package/src/components/Business/AddSelectBusiness/index.md +8 -2
  82. package/src/components/Business/AddSelectBusiness/index.tsx +4 -1
  83. package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +1 -1
  84. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +1 -1
  85. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +1 -1
  86. package/src/components/Business/BsLayouts/Components/RightContent/home.less +1 -1
  87. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +2 -2
  88. package/src/components/Business/BsLayouts/service.ts +1 -1
  89. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +6 -5
  90. package/src/components/Business/BsSulaQueryTable/bssulaquerytable.less +0 -4
  91. package/src/components/Business/BsSulaQueryTable/index.less +5 -3
  92. package/src/components/Business/BsSulaQueryTable/index.md +45 -32
  93. package/src/components/Business/BsSulaQueryTable/index.tsx +154 -76
  94. package/src/components/Business/BsSulaQueryTable/setting.tsx +47 -11
  95. package/src/components/Business/BsSulaQueryTable/utils.less +1 -1
  96. package/src/components/Business/BsSulaQueryTable/utils.tsx +15 -12
  97. package/src/components/Business/CommodityEntry/index.md +1 -1
  98. package/src/components/Business/CommodityEntry/index.tsx +11 -9
  99. package/src/components/Business/DetailPageWrapper/index.less +1 -1
  100. package/src/components/Business/DetailPageWrapper/index.tsx +24 -5
  101. package/src/components/Business/DetailPageWrapper/utils.tsx +7 -2
  102. package/src/components/Business/HomePageWrapper/index.less +1 -1
  103. package/src/components/Business/ItemPropertySelector/index.tsx +88 -0
  104. package/src/components/Business/JsonQueryTable/function.ts +1 -1
  105. package/src/components/Business/JsonQueryTable/index.tsx +1 -1
  106. package/src/components/Business/ModalUtils/index.tsx +45 -0
  107. package/src/components/Business/PropertyModal/index.tsx +1 -1
  108. package/src/components/Business/SearchSelect/BusinessUtils.tsx +625 -76
  109. package/src/components/Business/SearchSelect/index.md +4 -4
  110. package/src/components/Business/SearchSelect/utils.ts +27 -5
  111. package/src/components/Business/SystemLog/index.md +37 -0
  112. package/src/components/Business/SystemLog/index.tsx +87 -0
  113. package/src/components/Business/columnSettingTable/columnSetting.tsx +28 -12
  114. package/src/components/Business/columnSettingTable/index.less +5 -3
  115. package/src/components/Business/columnSettingTable/index.md +200 -136
  116. package/src/components/Business/columnSettingTable/index.tsx +168 -39
  117. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +188 -56
  118. package/src/components/Functional/AddSelect/helps.ts +1 -1
  119. package/src/components/Functional/AddSelect/index.tsx +132 -13
  120. package/src/components/Functional/BillEntry/index.less +3 -0
  121. package/src/components/Functional/BillEntry/index.tsx +1 -1
  122. package/src/components/Functional/DataImport/index.tsx +1 -1
  123. package/src/components/Functional/DataValidation/index.md +1 -0
  124. package/src/components/Functional/DataValidation/index.tsx +161 -27
  125. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +1 -1
  126. package/src/components/Functional/QueryMutipleInput/index.tsx +12 -3
  127. package/src/components/Functional/QueryMutipleSelect/index.tsx +3 -2
  128. package/src/components/Functional/SearchSelect/index.less +4 -0
  129. package/src/components/Functional/SearchSelect/index.tsx +68 -24
  130. package/src/components/Functional/SearchSelect/utils.tsx +17 -11
  131. package/src/components/Functional/TreeSearchSelect/index.tsx +3 -2
  132. package/src/components/Solution/RuleComponent/InnerSelect.tsx +1 -0
  133. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +11 -2
  134. package/src/components/Solution/RuleComponent/index.js +75 -4
  135. package/src/components/Solution/RuleComponent/ruleFiled.js +26 -2
  136. package/src/components/Solution/RuleComponent/services.ts +1 -1
  137. package/src/components/Solution/RuleSetter/service.js +1 -1
  138. package/src/index.ts +3 -0
  139. package/src/plugin/TableColumnSetting/index.less +5 -3
  140. package/src/plugin/TableColumnSetting/index.tsx +80 -13
  141. package/src/styles/bsDefault.less +9 -3
  142. package/src/utils/RequestCacheManager.ts +213 -0
  143. package/src/utils/RequestCache_Examples.md +137 -0
  144. package/src/utils/RequestCache_README.md +170 -0
  145. package/src/utils/TableUtils.less +1 -1
  146. package/src/utils/cachedRequest.ts +288 -0
  147. package/src/utils/index.ts +1 -0
  148. package/src/utils/request.ts +8 -4
  149. package/src/utils/requestUtils.ts +1 -1
  150. package/src/utils/utils.ts +52 -16
@@ -26,9 +26,9 @@ import {
26
26
  ProfileTwoTone,
27
27
  UnorderedListOutlined,
28
28
  } from '@ant-design/icons';
29
- import request from '@/utils/request';
29
+ import request from '@/utils/cachedRequest';
30
30
  import './index.less';
31
- import _ from "lodash"
31
+ import _, { ceil, isNumber } from "lodash"
32
32
  import { judgeIsRequestError } from '@/utils/requestUtils';
33
33
  import { readerXlsxToList } from '@/utils/xlsxUtil';
34
34
 
@@ -179,10 +179,26 @@ class DataValidation extends React.Component {
179
179
  }
180
180
 
181
181
  getCount = () => {
182
- const { resultData } = this.state;
182
+ const { resultData = [] } = this.state;
183
+ const totalQuantity = resultData.reduce((total, item) => {
184
+ total += Number(item.quantity || 0);
185
+ return total;
186
+ }, 0);
187
+ const totalSuccessQuantity = resultData.filter(item => item.flag).reduce((total, item) => {
188
+ total += Number(item.quantity || 0);
189
+ return total;
190
+ }, 0);
191
+ const totalErrorQuantity = resultData.filter(item => !item.flag).reduce((total, item) => {
192
+ total += Number(item.quantity || 0);
193
+ return total;
194
+ }, 0);
183
195
  return {
184
196
  total: resultData.length,
197
+ totalQuantity,
198
+ totalSuccessQuantity,
199
+ totalErrorQuantity,
185
200
  error: resultData.filter((item) => !item.flag).length,
201
+ success: resultData.filter((item) => item.flag).length,
186
202
  };
187
203
  };
188
204
 
@@ -191,7 +207,7 @@ class DataValidation extends React.Component {
191
207
  const { notValid } = this.props;
192
208
  return {
193
209
  container: 'luckysheet',
194
- showtoolbar: false,
210
+ // showtoolbar: false,
195
211
  hook: {
196
212
  columnTitleCellRenderBefore: function (columnAbc, postion, ctx) {
197
213
  if (columnAbc.name) {
@@ -233,18 +249,9 @@ class DataValidation extends React.Component {
233
249
  // console.info(data,sheetFile,ctx)
234
250
  },
235
251
  },
236
- // showtoolbarConfig: {
237
- // undoRedo: true, //撤销重做,注意撤消重做是两个按钮,由这一个配置决定显示还是隐藏
238
- // paintFormat: false, //格式刷
239
- // currencyFormat: false, //货币格式
240
- // percentageFormat: false, //百分比格式
241
- // numberDecrease: false, // '减少小数位数'
242
- // numberIncrease: false, // '增加小数位数
243
- // moreFormats: false, // '更多格式'
244
- // font: true, // '字体'
245
- // fontSize: true, // '字号大小'
246
-
247
- // },
252
+ showtoolbarConfig: {
253
+ sortAndFilter: true,
254
+ },
248
255
  data: [
249
256
  {
250
257
  name: 'Cell', //工作表名称
@@ -365,7 +372,7 @@ class DataValidation extends React.Component {
365
372
  showsheetbar: false,
366
373
  optionstate: false,
367
374
  showstatisticBarConfig: {
368
- count: false, // 计数栏
375
+ count: true, // 计数栏
369
376
  view: false, // 打印视图
370
377
  zoom: false, // 缩放
371
378
  },
@@ -422,9 +429,58 @@ class DataValidation extends React.Component {
422
429
  return data.filter(d => _.compact(Object.values(d)).length);
423
430
  };
424
431
 
425
- resetData = () => {
426
- const { validDataUrl, validDataParams, updateData, columns, isBrandAuth, isCheckStockNum = true, customerColumnsMapping } = this.props;
427
- const resultData = this.getData().filter(d => {
432
+ naturalCompare = (a, b) => {
433
+ const checkNumber = (value) => {
434
+ return /^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(value.trim())
435
+ };
436
+
437
+ if (checkNumber(a) && checkNumber(b)) {
438
+ return Number(a) - Number(b);
439
+ }
440
+ // 优先处理 "通过" 的情况
441
+ if (a === "通过" && b !== "通过") return -1;
442
+ if (b === "通过" && a !== "通过") return 1;
443
+
444
+ return a.localeCompare(b);
445
+
446
+ }
447
+
448
+ customSort = (a, b) => {
449
+
450
+ // 处理空值
451
+ const aEmpty = !a;
452
+
453
+ const bEmpty = !b;
454
+
455
+ if (aEmpty && bEmpty) return 0;
456
+
457
+ if (aEmpty) return 1; // a空,排后面
458
+
459
+ if (bEmpty) return -1; // b空,a排前面
460
+
461
+ return this.naturalCompare(a, b);
462
+
463
+ }
464
+
465
+ sortData = (sorterKey: string) => {
466
+ let sheetData = luckysheet.getSheetData();
467
+ let newData = JSON.parse(JSON.stringify(sheetData)).sort((cur, prev) => {
468
+ let cellIndex = itemsTemp.findIndex(item => item.code === sorterKey);
469
+ if (sorterKey === 'checkresult') {
470
+ cellIndex = itemsTemp.length;
471
+ }
472
+ return this.customSort(cur[cellIndex]?.v, prev[cellIndex]?.v);
473
+ })
474
+ luckysheet.create(this.setConfig(luckysheet.transToCellData(newData)));
475
+ this.setState({
476
+ data: luckysheet.transToCellData(newData),
477
+ });
478
+ }
479
+
480
+ resetData = async () => {
481
+ const { validDataUrl, validDataParams, updateData, columns, isBrandAuth, isCheckStockNum = true, customerColumnsMapping, checkSharedValue, beforeCheckCallback } = this.props;
482
+
483
+ let resultData = this.getData().filter(d => {
428
484
  return _.compact(Object.values(d)).length
429
485
  })
430
486
 
@@ -436,6 +492,24 @@ class DataValidation extends React.Component {
436
492
  otherParams = { brandAuth: 'ctl-withAuth' }
437
493
  }
438
494
 
495
+ // 处理校验参数,隐藏校验参数(公用的部分)
496
+ if(checkSharedValue){
497
+ resultData = resultData.map(d => {
498
+ return {
499
+ ...d,
500
+ ...checkSharedValue,
501
+ }
502
+ })
503
+ }
504
+
505
+ // 调用回调函数
506
+ if(beforeCheckCallback){
507
+ resultData = await beforeCheckCallback(resultData);
508
+ if(!resultData){
509
+ return;
510
+ }
511
+ }
512
+
439
513
  request
440
514
  .post(validDataUrl, {
441
515
  ...otherParams,
@@ -523,7 +597,6 @@ class DataValidation extends React.Component {
523
597
 
524
598
  toggleData = () => {
525
599
  const { showErrorData, data } = this.state;
526
-
527
600
  if (showErrorData) {
528
601
  luckysheet.create(this.setConfig(data));
529
602
  } else {
@@ -615,6 +688,44 @@ class DataValidation extends React.Component {
615
688
  </div>
616
689
  </Menu>
617
690
  );
691
+
692
+
693
+ getSortList = () => {
694
+ let sortList = []
695
+ if (this.props?.customerColumnsMapping?.length) {
696
+ sortList = this.props?.customerColumnsMapping?.map((item, index) => {
697
+ return createItem('item-0', index, item.title, item.name, this.format);
698
+ })||[]
699
+ } else {
700
+ sortList = this.props?.columns?.map((item, index) => {
701
+ if (!mapping.get(item))
702
+ throw Error(
703
+ `${item} is not in DataValidation component, please fix this error`,
704
+ );
705
+ return createItem('item-0', index, mapping.get(item), item, this.format);
706
+ })||[];
707
+ }
708
+
709
+ return (
710
+ <Menu>
711
+ {
712
+ (sortList || []).map((item, index) =>{
713
+ return (
714
+ <>
715
+ <Menu.Item key={index} className="sheet_table-menu_item_text">
716
+ <a onClick={() => this.sortData(item.code)}>{item.content}</a>
717
+ </Menu.Item>
718
+ <Menu.Divider />
719
+ </>
720
+ )
721
+ })
722
+ }
723
+ <Menu.Item key="checkresult" className="sheet_table-menu_item_text">
724
+ <a onClick={() => this.sortData('checkresult')}>校验结果</a>
725
+ </Menu.Item>
726
+ </Menu>
727
+ )
728
+ }
618
729
 
619
730
  getSheetMap = () => {
620
731
  const { customerColumnsMapping, columns } = this.props;
@@ -653,7 +764,7 @@ class DataValidation extends React.Component {
653
764
 
654
765
  render() {
655
766
  const { errorListCheck } = this.state;
656
- const { title, notValid, notExcelImport, excelImportConfig } = this.props;
767
+ const { title, notValid, notExcelImport, excelImportConfig, getTemplate } = this.props;
657
768
  const { size, accept, suffixRule } = excelImportConfig || {}
658
769
 
659
770
  let totalSummary = this.getCount();
@@ -708,6 +819,8 @@ class DataValidation extends React.Component {
708
819
  left: '0px',
709
820
  top: '0px',
710
821
  };
822
+
823
+ console.log('itemsTemp', itemsTemp)
711
824
  return (
712
825
  <>
713
826
  <div className="sheet_table_top">
@@ -745,9 +858,16 @@ class DataValidation extends React.Component {
745
858
  </Space>
746
859
  <Space>
747
860
  {!notExcelImport && (
748
- <Upload {...uploadProps}>
749
- <Button>导入</Button>
750
- </Upload>
861
+ <>
862
+ {
863
+ getTemplate && (
864
+ <Button onClick={getTemplate}>下载模板</Button>
865
+ )
866
+ }
867
+ <Upload {...uploadProps}>
868
+ <Button>导入</Button>
869
+ </Upload>
870
+ </>
751
871
  )}
752
872
  <Dropdown
753
873
  trigger={['click']}
@@ -759,6 +879,16 @@ class DataValidation extends React.Component {
759
879
  <DownOutlined />
760
880
  </Button>
761
881
  </Dropdown>
882
+ <Dropdown
883
+ trigger={['click']}
884
+ overlay={this.getSortList()}
885
+ placement="bottomRight"
886
+ >
887
+ <Button>
888
+ 排序
889
+ <DownOutlined />
890
+ </Button>
891
+ </Dropdown>
762
892
 
763
893
  {!notValid && <Button type="primary" onClick={this.resetData}>
764
894
  识别
@@ -769,9 +899,13 @@ class DataValidation extends React.Component {
769
899
  <div style={{ position: 'relative', height: '400px' }}>
770
900
  <div id="luckysheet" style={luckyCss}></div>
771
901
  </div>
772
- {!this.props.notValid && <div className="sheet_table_footer">
902
+ {!this.props.notValid && !!totalSummary.total && <div className="sheet_table_footer">
773
903
  <span className="sheet_table_footer_l">
774
- 共 {totalSummary.total} 条数据{!notValid && `, 其中错误 ${totalSummary.error} 项`}
904
+ 共 {totalSummary.total} 条数据:
905
+ <span style={{color: 'green', marginLeft: '5px'}}> 成功条数:</span>{totalSummary.success}
906
+ <span style={{color: 'green', marginLeft: '5px'}}> 成功数量:</span>{totalSummary.totalSuccessQuantity || 0}
907
+ <span style={{color: 'red', marginLeft: '5px'}}> 失败条数:</span>{totalSummary.error || 0}
908
+ <span style={{color: 'red', marginLeft: '5px'}}> 失败数量:</span>{totalSummary.totalErrorQuantity || 0}
775
909
  </span>
776
910
  {!notValid && <Space className="sheet_table_footer_r">
777
911
  <Checkbox
@@ -1,7 +1,7 @@
1
1
  // @ts-nocheck
2
2
  import React, {Ref} from 'react'
3
3
  import {message, Popconfirm, Tooltip} from "antd";
4
- import request from '@/utils/request';
4
+ import request from '@/utils/cachedRequest';
5
5
  import exportlogo from '../../../../assets/exportlogo.png'
6
6
  import {omit} from 'lodash'
7
7
  import { judgeIsRequestError } from '@/utils/requestUtils';
@@ -11,9 +11,9 @@ import { useDebounceFn } from 'ahooks';
11
11
  import { Input, Button, Modal, ConfigProvider } from 'antd';
12
12
  import './index.less';
13
13
 
14
- const QueryMutipleInput = ({ onValueChange,onPressEnter }) => {
14
+ const QueryMutipleInput = ({ onValueChange,onPressEnter, value: initialValue }) => {
15
15
  const [isModalVisible, setIsModalVisible] = useState(false);
16
- const [value, setValue] = useState('');
16
+ const [value, setValue] = useState(initialValue);
17
17
  const [popvalue, setPopValue] = useState('');
18
18
  const { run } = useDebounceFn(
19
19
  () => {
@@ -24,6 +24,14 @@ const QueryMutipleInput = ({ onValueChange,onPressEnter }) => {
24
24
  },
25
25
  );
26
26
 
27
+ /**
28
+ * 初始化参数
29
+ * 处理参数不展示和清空不同步的问题
30
+ */
31
+ useEffect(() => {
32
+ setValue(initialValue);
33
+ }, [initialValue]);
34
+
27
35
  useEffect(() => {
28
36
  setPopValue(value);
29
37
  onValueChange(value);
@@ -32,7 +40,7 @@ const QueryMutipleInput = ({ onValueChange,onPressEnter }) => {
32
40
  const showModal = () => {
33
41
  setIsModalVisible(true);
34
42
  //弹窗打开时 默认搜索内容换行显示
35
- setPopValue(data => data.replace(/,/g, '\n'));
43
+ setPopValue(data => data?.replace?.(/,/g, '\n'));
36
44
  };
37
45
 
38
46
  const handleOk = () => {
@@ -67,6 +75,7 @@ const QueryMutipleInput = ({ onValueChange,onPressEnter }) => {
67
75
  <Input
68
76
  value={value}
69
77
  onChange={outerChange}
78
+ allowClear
70
79
  onBlur={(e) => {
71
80
  formaData(e.target.value);
72
81
  }}
@@ -3,7 +3,7 @@ import { useDebounceFn } from 'ahooks';
3
3
  import _, { isNil } from "lodash"
4
4
  import { Select, Input, Button, Modal, ConfigProvider, Spin, message } from 'antd';
5
5
  import { DashOutlined } from '@ant-design/icons';
6
- import request from '@/utils/request';
6
+ import request from '@/utils/cachedRequest';
7
7
  import { judgeIsRequestError } from '@/utils/requestUtils';
8
8
  import './index.less';
9
9
  import { convertUrlQueryParams, convertBodyParams, convertResData, handleSourceName, makeUniqueValue, LightHeightOption, handleSelectOptionsShowValue, maxTagPlaceholder } from '../SearchSelect/utils';
@@ -91,6 +91,7 @@ const QueryMutipleSearchSelect = ({ onValueChange, requestConfig={}, selectProps
91
91
  const getData = (params: any = {}, callback?: any) => {
92
92
  if (!requestConfig) return;
93
93
  if (!url) return;
94
+ if(!searchValue?.length) return; // 空值默认不查询
94
95
 
95
96
  setFetching(true)
96
97
 
@@ -105,7 +106,7 @@ const QueryMutipleSearchSelect = ({ onValueChange, requestConfig={}, selectProps
105
106
  let getRequest;
106
107
  const methodName = method?.toLocaleLowerCase();
107
108
  if(['post','patch','put'].includes(methodName)) {
108
- getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams))
109
+ getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams),{headers: { ...extralHeaders }})
109
110
  } else {
110
111
  getRequest = request.get( `${url}${convertUrlQueryParams(queryParams)}`,{headers: { ...extralHeaders }})
111
112
  }
@@ -249,6 +249,10 @@
249
249
  &_wrapLeft1, &_wrapLeft2, &_wrapRight{
250
250
  background: #fff;
251
251
  width: calc(50% - 5px);
252
+ // 解决全选按钮位置偏左问题
253
+ .ant-table.ant-table-bordered > .ant-table-container > .ant-table-header > table .ant-table-thead .ant-table-selection .ant-checkbox-wrapper {
254
+ justify-content: center;
255
+ }
252
256
  }
253
257
  &_wrapLeft1 {
254
258
  width: 100%;
@@ -1,16 +1,17 @@
1
1
  // @ts-nocheck
2
2
  import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
3
3
  import { useDebounceFn } from 'ahooks';
4
- import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag, Row, Col, Space, Tabs } from 'antd';
4
+ import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag, Row, Col, Space, Tabs, Empty, DatePicker } from 'antd';
5
5
  import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
6
- import request from '@/utils/request';
6
+ import request from '@/utils/cachedRequest';
7
7
  import _, { escapeRegExp, isNil, values } from "lodash"
8
8
  import './index.less';
9
9
  import { BusinessSearchSelect, QueryMutipleInput, QueryMutipleSearchSelect } from '@/index';
10
- import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth, getCurrentSRKs, getRenderSource, handleParams, convertUrlQueryParams, convertBodyParams, formatSelectedValue, convertResData, makeUniqueValue, handleSelectOptionsShowValue, LightHeightOption, maxTagPlaceholder, getShowStr, handleTableColumns } from './utils';
10
+ import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, getTableHeigth, getCurrentSRKs, getRenderSource, handleParams, convertUrlQueryParams, convertBodyParams, formatSelectedValue, convertResData, makeUniqueValue, handleSelectOptionsShowValue, LightHeightOption, maxTagPlaceholder, getShowStr, handleTableColumns } from './utils';
11
11
  import { judgeIsRequestError } from '@/utils/requestUtils';
12
12
  import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
13
13
  import PropertySelector from '@/components/Business/PropertyModal';
14
+ import ItemPropertySelector from '@/components/Business/ItemPropertySelector';
14
15
 
15
16
  const { Option } = Select;
16
17
 
@@ -31,6 +32,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
31
32
  highestPopContainer = undefined,
32
33
  fieldComponent,
33
34
  onSaveCallback,
35
+ returnFormat = [],
34
36
  selectBusinessType,
35
37
  } = props;
36
38
  const {
@@ -52,6 +54,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
52
54
  noOperate, // 级联禁用按钮设置字段
53
55
  viewShowValueStr, // 详情展示值,不传展示组件处理的默认值
54
56
  searchStartLength, // 默认不校验长度去搜索,如果配置了,则按照配置项长度进行处理搜索
57
+ isQuery = false, // 是否是查询条件
55
58
  } = rCTemp || {};
56
59
  const requestConfig = {url,method,otherParams,isMap,fixedparameter,fieldValToParam,fixedparamsDisabled,mappingTextField,mappingTextShowKeyField,mappingValueField,mappingTextShowTextField,init,extralHeaders,specialBracket,noNeedSplit,noOperate,viewShowValueStr,searchStartLength,...rCTemp};
57
60
  const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || ctx?.name || 'supplierCode')
@@ -64,6 +67,8 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
64
67
  const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
65
68
  const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
66
69
  const currentSelectProps = {
70
+ // 回显字段可自定义
71
+ optionLabelProp: "label",
67
72
  ...selectProps,
68
73
  // 以下属性不可更改----设计配置项
69
74
  showArrow: true,
@@ -71,7 +76,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
71
76
  filterOption: false,
72
77
  allowClear: true,
73
78
  listHeight: 160,
74
- optionLabelProp: "label",
75
79
  autoClearSearchValue: false,
76
80
  placement: 'bottomRight'
77
81
  }
@@ -81,7 +85,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
81
85
  const isFormPage = pathname.match(pattern)?.length > 0;
82
86
 
83
87
  const initPagination = { showQuickJumper: true, showSizeChanger: true, showTotal: (total: any) => `共 ${total} 条`, pageSize: tableInitPageSize }
84
- const tableInitPagination = { ...initPagination, total: 0, current: 1 }
88
+ const tableInitPagination = { ...initPagination, total: 0, current: 1, pageSizeOptions: [10, 20, 50, 100, 500, 1000] }
85
89
  const disabled = !!noOperate || selectProps?.disabled || props?.disabled;
86
90
  const isHaveDependency = fixedparameter && fieldValToParam && ctx;
87
91
  const isHaveDValue = () => {
@@ -92,7 +96,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
92
96
  });
93
97
  return formValueList.filter((item: any) => item).length > 0
94
98
  }
95
- const sDisabled = disabled || (isHaveDependency && !!!isHaveDValue());
99
+ const sDisabled = disabled || (isHaveDependency && !!!isHaveDValue() && !isQuery);
96
100
 
97
101
  const [items, setItems] = useState([]);
98
102
  const [selectOpen, setSelectOpen] = useState(false);
@@ -230,14 +234,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
230
234
  ...fixedParam,
231
235
  ...params,
232
236
  };
233
- if (isNil(queryParams[selectParamsKey])) {
234
- queryParams[selectParamsKey] = searchValue;
237
+ if (isNil(queryParams[selectParamsKey])&&searchValue?.length) {
238
+ queryParams[selectParamsKey] = searchValue?.trim?.();
235
239
  }
236
240
 
237
241
  let getRequest;
238
242
  const methodName = method?.toLocaleLowerCase?.();
239
243
  if(['post','patch','put'].includes(methodName)) {
240
- getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams))
244
+ getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams), { headers: { ...extralHeaders }})
241
245
  } else {
242
246
  getRequest = request.get( `${url}${convertUrlQueryParams(queryParams)}`,{headers: { ...extralHeaders }})
243
247
  }
@@ -335,8 +339,8 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
335
339
 
336
340
  // 处理键盘事件
337
341
  const handleKeyPress = (event) => {
338
- if ((event.metaKey || event.ctrlKey) && (event.key === 'U' || event.keyCode == 85)) {
339
- // ctrl + U 键 重置
342
+ if ((event.metaKey || event.ctrlKey) && (event.key === 'I' || event.keyCode == 73)) {
343
+ // ctrl + I 键 重置
340
344
  onResetTable()
341
345
  } else if (event.key === 'Enter' || event.keyCode == 13) {
342
346
  // Enter 键 查询
@@ -429,7 +433,8 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
429
433
 
430
434
  const formaData = (value: any, source: any) => {
431
435
  if (labelInValue) {
432
- const formatResult = value.map((i: any) => ({ key: i[mappingValueField] || i.key, label: i[mappingTextField] || i.label, value: i[mappingValueField] || i.value }))
436
+ const getFromat = (format, val) => format.map(({key,value})=> ({[key]:val[value]}))
437
+ const formatResult = value.map((i: any) => (Object.assign({ key: i[mappingValueField] || i.key, label: i[mappingTextField] || i.label, value: i[mappingValueField] || i.value }, ...getFromat(returnFormat, i))))
433
438
  onChange(selectMode ? formatResult : formatResult[0], value,source)
434
439
  } else {
435
440
  const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
@@ -456,7 +461,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
456
461
  const refreshItems = () => {
457
462
  // 查看是否存在关联值 如果有关联值 就查询 没有就不能查询
458
463
  if (fieldValToParam && ctx && fixedparamsDisabled) {
459
- if (!!isHaveDValue()) {
464
+ if (!!isHaveDValue() || isQuery) {
460
465
  run();
461
466
  } else {
462
467
  clearSelectDataSource();
@@ -467,7 +472,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
467
472
  }
468
473
 
469
474
  const onSearchChange = (v) => {
470
- setSearchValue(v);
475
+ setSearchValue(v?.trim?.()||'');
471
476
  if(!!searchStartLength && v?.length < searchStartLength) return;
472
477
  refreshItems();
473
478
  }
@@ -573,9 +578,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
573
578
  }
574
579
  };
575
580
 
576
- const { emptyArray } = getFormRowInfo(list);
581
+ const { emptyArray, ColSpan } = getFormRowInfo(list, modalTableProps?.tableSearchColSpan);
577
582
  const addKong = emptyArray?.map((i: any) =>({ type: 'kong'}))||[];
578
- return list?.concat(addKong)?.map((i: any, index: number) => {
583
+ const searchList = modalTableProps?.noEmptySearchField ? list : list?.concat(addKong);
584
+ return searchList.map((i: any, index: number) => {
579
585
  if(i?.type === 'kong') return <Col span={ColSpan} key={i}></Col>;
580
586
 
581
587
  if (i?.type === 'select' || i?.field?.type === 'select') {
@@ -602,6 +608,25 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
602
608
  )
603
609
  }
604
610
 
611
+ if (i?.type === 'rangepicker' || i?.field?.type === 'rangepicker') {
612
+ return (
613
+ <Col span={ColSpan} key={i.name}>
614
+ <Form.Item name={i.name} label={i.label} key={i.name} initialValue={i?.initialValue ?? []}>
615
+ <DatePicker.RangePicker style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></DatePicker.RangePicker>
616
+ </Form.Item>
617
+ </Col>
618
+ )
619
+ }
620
+ if (i?.type === 'datepicker' || i?.field?.type === 'datepicker') {
621
+ return (
622
+ <Col span={ColSpan} key={i.name}>
623
+ <Form.Item name={i.name} label={i.label} key={i.name}>
624
+ <DatePicker style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></DatePicker>
625
+ </Form.Item>
626
+ </Col>
627
+ )
628
+ }
629
+
605
630
  if (i?.type === 'businessSearchSelect' || i?.field?.type === 'businessSearchSelect') {
606
631
  return (
607
632
  <Col span={ColSpan} key={i.name}>
@@ -635,6 +660,19 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
635
660
  </Col>
636
661
  );
637
662
  }
663
+ if (i?.type === 'itemPropertySelector' || i?.field?.type === 'itemPropertySelector') {
664
+ return (
665
+ <Col span={ColSpan} key={i.name}>
666
+ <Form.Item name={i.name} label={i.label} key={i.name}>
667
+ <ItemPropertySelector
668
+ style={{ width: '100%' }}
669
+ placeholder="请选择"
670
+ {...i?.field?.props}
671
+ ></ItemPropertySelector>
672
+ </Form.Item>
673
+ </Col>
674
+ );
675
+ }
638
676
  if (i?.field?.type === 'multipleQuerySearchSelect') {
639
677
  return (
640
678
  <Col span={ColSpan} key={i.name}>
@@ -667,9 +705,15 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
667
705
  return collapsed ? formItem(list?.slice(0,viCount)) : formItem(list)
668
706
  }
669
707
 
708
+ const renderEmptyText = (text: string,x: string) => {
709
+ return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={text} style={{ margin: `${x} 0px`}} />
710
+ }
711
+
670
712
  const renderShowTable = (tableList, type) => {
671
713
  const tableBoxHeighth = getTableHeigth(modalTableProps?.tableSearchForm);
672
- const oSY = `calc(100vh - ${tableBoxHeighth}px - 82px)`; // 分页 24+16*2+10 「高 + margin * 2 + paddingBottom 10 」
714
+ const x = tableList?.length ? 82 : 28; // 无数据没有分页,有数据计算减去:分页 24+16*2+10 「高 + margin * 2 + paddingBottom 10 」
715
+ const oSY = `calc(100vh - ${tableBoxHeighth}px - ${x}px)`;
716
+ const mTB = `calc(50vh - ${tableBoxHeighth/2}px - ${x/2}px - 40px)`
673
717
  return (
674
718
  <div style={{ height: `calc(100vh - ${tableBoxHeighth}px)` }}>
675
719
  <Table
@@ -681,14 +725,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
681
725
  {...type=='noPage'?{
682
726
  pagination: { ...initPagination,showSizeChanger: false },
683
727
  locale: {
684
- emptyText: '暂无已选结果',
728
+ emptyText: renderEmptyText('暂无已选结果',mTB),
685
729
  }
686
730
  }:{
687
731
  pagination: tablePagination,
688
732
  onChange: handleTableChange,
689
733
  loading: fetching,
690
734
  locale: {
691
- emptyText: modalSearched? '无匹配结果,请更换其他内容再试' : '请输入搜索条件',
735
+ emptyText: modalSearched? renderEmptyText('匹配结果,请更换其他内容再试',mTB) : renderEmptyText('请输入搜索条件',mTB),
692
736
  }
693
737
  }}
694
738
  rowKey={mappingValueField}
@@ -881,7 +925,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
881
925
  <Modal
882
926
  maskClosable={false}
883
927
  destroyOnClose
884
- width="80%"
928
+ width={`calc(100% - 320px)`}
885
929
  title={modalTableProps?.modalTableTitle}
886
930
  visible={isModalVisible}
887
931
  confirmLoading={confirmLoading}
@@ -916,14 +960,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
916
960
  {renderFormItem(modalTableProps?.tableSearchForm)}
917
961
  <Col span={6}>
918
962
  <Space>
919
- <Button key="search" type="primary" onClick={onSearchTable}>
963
+ <Button key="search" type="primary" onClick={onSearchTable} disabled={fetching}>
920
964
  查询 Enter
921
965
  </Button>
922
- <Button key="reset" onClick={onResetTable}>
923
- 重置 ctrl+U
966
+ <Button key="reset" onClick={onResetTable} disabled={fetching}>
967
+ 重置 ctrl+I
924
968
  </Button>
925
969
  <div style={{position: 'absolute',top: 0,right: 0}}>
926
- {hasMoreQueryFields(modalTableProps) && modalTableProps?.isHorizontally
970
+ {hasMoreQueryFields(modalTableProps)
927
971
  ? <img onClick={() => {toggleCollapsed()}} style={{
928
972
  cursor: 'pointer',
929
973
  fontSize: '10px',