@yilianjituan/yilian_dgerm 0.0.1-alpha.38 → 0.0.1-alpha.40

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 (148) hide show
  1. package/.eslintrc.js +0 -0
  2. package/LICENSE +0 -0
  3. package/README.md +0 -0
  4. package/dist/business/Entry/index.d.ts +0 -0
  5. package/dist/business/Entry/index.interface.d.ts +0 -0
  6. package/dist/business/Entry/index.interface.js +0 -0
  7. package/dist/business/Entry/index.js +0 -0
  8. package/dist/business/Entry/index.scss +0 -0
  9. package/dist/business/TestBtn/index.d.ts +0 -0
  10. package/dist/business/TestBtn/index.interface.d.ts +0 -0
  11. package/dist/business/TestBtn/index.interface.js +0 -0
  12. package/dist/business/TestBtn/index.js +0 -0
  13. package/dist/commonAxios/Axios.d.ts +0 -0
  14. package/dist/commonAxios/Axios.js +0 -0
  15. package/dist/commonAxios/http.d.ts +0 -0
  16. package/dist/commonAxios/http.js +0 -0
  17. package/dist/commonAxios/index.d.ts +0 -0
  18. package/dist/commonAxios/index.js +0 -0
  19. package/dist/commonAxios/juicer.d.ts +0 -0
  20. package/dist/commonAxios/juicer.js +0 -0
  21. package/dist/commonData/address.d.ts +0 -0
  22. package/dist/commonData/address.js +0 -0
  23. package/dist/commonImg/ic_im_no_archives_new.png +0 -0
  24. package/dist/commonType/globalEnum.d.ts +0 -0
  25. package/dist/commonType/globalEnum.js +0 -0
  26. package/dist/commonType/globalFun.d.ts +0 -0
  27. package/dist/commonType/globalFun.js +0 -0
  28. package/dist/components/BigImage/index.d.ts +0 -0
  29. package/dist/components/BigImage/index.interface.d.ts +0 -0
  30. package/dist/components/BigImage/index.interface.js +0 -0
  31. package/dist/components/BigImage/index.js +0 -0
  32. package/dist/components/CustomButtonModal/index.d.ts +0 -0
  33. package/dist/components/CustomButtonModal/index.interface.d.ts +0 -0
  34. package/dist/components/CustomButtonModal/index.interface.js +0 -0
  35. package/dist/components/CustomButtonModal/index.js +0 -0
  36. package/dist/components/DateTimePicker/index.d.ts +0 -0
  37. package/dist/components/DateTimePicker/index.interface.d.ts +0 -0
  38. package/dist/components/DateTimePicker/index.interface.js +0 -0
  39. package/dist/components/DateTimePicker/index.js +0 -0
  40. package/dist/components/DropDownSelect/index.d.ts +0 -0
  41. package/dist/components/DropDownSelect/index.interface.d.ts +6 -1
  42. package/dist/components/DropDownSelect/index.interface.js +0 -0
  43. package/dist/components/DropDownSelect/index.js +49 -20
  44. package/dist/components/EmptyDom/index.d.ts +0 -0
  45. package/dist/components/EmptyDom/index.interface.d.ts +0 -0
  46. package/dist/components/EmptyDom/index.interface.js +0 -0
  47. package/dist/components/EmptyDom/index.js +0 -0
  48. package/dist/components/Entry/index.d.ts +0 -0
  49. package/dist/components/Entry/index.interface.d.ts +0 -0
  50. package/dist/components/Entry/index.interface.js +0 -0
  51. package/dist/components/Entry/index.js +0 -0
  52. package/dist/components/Entry/index.scss +0 -0
  53. package/dist/components/ExportExcels/ExportExcels.scss +0 -0
  54. package/dist/components/ExportExcels/index.d.ts +0 -0
  55. package/dist/components/ExportExcels/index.interface.d.ts +0 -0
  56. package/dist/components/ExportExcels/index.interface.js +0 -0
  57. package/dist/components/ExportExcels/index.js +0 -0
  58. package/dist/components/FileUpload/fileUtil.d.ts +0 -0
  59. package/dist/components/FileUpload/fileUtil.js +0 -0
  60. package/dist/components/FileUpload/index.d.ts +0 -0
  61. package/dist/components/FileUpload/index.interface.d.ts +0 -0
  62. package/dist/components/FileUpload/index.interface.js +0 -0
  63. package/dist/components/FileUpload/index.js +0 -0
  64. package/dist/components/FileUpload/index.scss +0 -0
  65. package/dist/components/FilterRadio/index.d.ts +0 -0
  66. package/dist/components/FilterRadio/index.interface.d.ts +0 -0
  67. package/dist/components/FilterRadio/index.interface.js +0 -0
  68. package/dist/components/FilterRadio/index.js +0 -0
  69. package/dist/components/FilterRadio/index.scss +0 -0
  70. package/dist/components/MyBtn/index.d.ts +0 -0
  71. package/dist/components/MyBtn/index.interface.d.ts +0 -0
  72. package/dist/components/MyBtn/index.interface.js +0 -0
  73. package/dist/components/MyBtn/index.js +0 -0
  74. package/dist/components/NumberInput/index.d.ts +0 -0
  75. package/dist/components/NumberInput/index.interface.d.ts +0 -0
  76. package/dist/components/NumberInput/index.interface.js +0 -0
  77. package/dist/components/NumberInput/index.js +0 -0
  78. package/dist/components/NumberInput/index.scss +0 -0
  79. package/dist/components/OcrCommon/index.config.d.ts +0 -0
  80. package/dist/components/OcrCommon/index.config.js +0 -0
  81. package/dist/components/OcrCommon/index.d.ts +0 -0
  82. package/dist/components/OcrCommon/index.interface.d.ts +0 -0
  83. package/dist/components/OcrCommon/index.interface.js +0 -0
  84. package/dist/components/OcrCommon/index.js +0 -0
  85. package/dist/components/OcrCommon/index.scss +0 -0
  86. package/dist/components/PageTemplate/index.d.ts +0 -0
  87. package/dist/components/PageTemplate/index.interface.d.ts +0 -0
  88. package/dist/components/PageTemplate/index.interface.js +0 -0
  89. package/dist/components/PageTemplate/index.js +12 -2
  90. package/dist/components/PageTemplate/index.scss +0 -0
  91. package/dist/components/PageTemplate/resizable/index.d.ts +25 -0
  92. package/dist/components/PageTemplate/resizable/index.js +152 -0
  93. package/dist/components/PageTemplate/resizable/index.scss +14 -0
  94. package/dist/components/ReactEcharts/index.d.ts +0 -0
  95. package/dist/components/ReactEcharts/index.interface.d.ts +0 -0
  96. package/dist/components/ReactEcharts/index.interface.js +0 -0
  97. package/dist/components/ReactEcharts/index.js +0 -0
  98. package/dist/components/SelectMax/index.d.ts +0 -0
  99. package/dist/components/SelectMax/index.interface.d.ts +0 -0
  100. package/dist/components/SelectMax/index.interface.js +0 -0
  101. package/dist/components/SelectMax/index.js +0 -0
  102. package/dist/components/SelectPosition/index.d.ts +0 -0
  103. package/dist/components/SelectPosition/index.interface.d.ts +0 -0
  104. package/dist/components/SelectPosition/index.interface.js +0 -0
  105. package/dist/components/SelectPosition/index.js +0 -0
  106. package/dist/components/SelectPosition/index.scss +0 -0
  107. package/dist/components/SuperCascader/index.d.ts +0 -0
  108. package/dist/components/SuperCascader/index.interface.d.ts +0 -0
  109. package/dist/components/SuperCascader/index.interface.js +0 -0
  110. package/dist/components/SuperCascader/index.js +0 -0
  111. package/dist/components/SuperInput/index.d.ts +0 -0
  112. package/dist/components/SuperInput/index.interface.d.ts +0 -0
  113. package/dist/components/SuperInput/index.interface.js +0 -0
  114. package/dist/components/SuperInput/index.js +0 -0
  115. package/dist/components/TabsMode/index.d.ts +0 -0
  116. package/dist/components/TabsMode/index.interface.d.ts +0 -0
  117. package/dist/components/TabsMode/index.interface.js +0 -0
  118. package/dist/components/TabsMode/index.js +0 -0
  119. package/dist/components/TypographyText/index.d.ts +0 -0
  120. package/dist/components/TypographyText/index.interface.d.ts +0 -0
  121. package/dist/components/TypographyText/index.interface.js +0 -0
  122. package/dist/components/TypographyText/index.js +0 -0
  123. package/dist/components/TypographyText/index.scss +0 -0
  124. package/dist/components/VideoProgressModal/index.d.ts +0 -0
  125. package/dist/components/VideoProgressModal/index.interface.d.ts +0 -0
  126. package/dist/components/VideoProgressModal/index.interface.js +0 -0
  127. package/dist/components/VideoProgressModal/index.js +0 -0
  128. package/dist/components/VideoProgressModal/index.scss +0 -0
  129. package/dist/components/YLModal/drag.d.ts +0 -0
  130. package/dist/components/YLModal/drag.js +0 -0
  131. package/dist/components/YLModal/index.d.ts +0 -0
  132. package/dist/components/YLModal/index.interface.d.ts +0 -0
  133. package/dist/components/YLModal/index.interface.js +0 -0
  134. package/dist/components/YLModal/index.js +0 -0
  135. package/dist/index.d.ts +1 -0
  136. package/dist/index.js +1 -1
  137. package/dist/react-app-env.d.ts +2 -1
  138. package/dist/utils/common.d.ts +0 -0
  139. package/dist/utils/common.js +0 -0
  140. package/dist/utils/index.d.ts +0 -0
  141. package/dist/utils/index.js +0 -0
  142. package/dist/utils/notificationHelper.d.ts +0 -0
  143. package/dist/utils/notificationHelper.js +0 -0
  144. package/dist/utils/responseMessage.d.ts +0 -0
  145. package/dist/utils/responseMessage.js +0 -0
  146. package/dist/utils/userSessionActions.d.ts +0 -0
  147. package/dist/utils/userSessionActions.js +0 -0
  148. package/package.json +4 -3
package/.eslintrc.js CHANGED
File without changes
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { SelectProps } from "antd";
2
3
  export interface OptionItem {
3
4
  /**
@@ -11,7 +12,7 @@ export interface OptionItem {
11
12
  /**
12
13
  * @description list展示项
13
14
  */
14
- lable: (item: any) => string;
15
+ lable: (item: any) => string | React.ReactNode;
15
16
  }
16
17
  export interface DropDownSelectProps extends SelectProps {
17
18
  /**
@@ -71,4 +72,8 @@ export interface DropDownSelectProps extends SelectProps {
71
72
  * @description 是否开启搜索查询
72
73
  */
73
74
  changeNoSearch?: boolean;
75
+ /**
76
+ * @description 是否初始化搜索
77
+ */
78
+ isInitSearch?: boolean;
74
79
  }
File without changes
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["http", "url", "method", "handleSelect", "showValue", "customInput", "searchValue", "additionalParameters", "dynamicParameter", "beforeSearch", "filterOptionsCallback", "onChange", "changeNoSearch", "mode"];
2
+ var _excluded = ["http", "url", "method", "handleSelect", "showValue", "customInput", "searchValue", "additionalParameters", "dynamicParameter", "beforeSearch", "filterOptionsCallback", "onChange", "changeNoSearch", "mode", "isInitSearch"];
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -45,6 +45,8 @@ var Index = function Index(props) {
45
45
  changeNoSearch = _props$changeNoSearch === void 0 ? true : _props$changeNoSearch,
46
46
  _props$mode = props.mode,
47
47
  mode = _props$mode === void 0 ? undefined : _props$mode,
48
+ _props$isInitSearch = props.isInitSearch,
49
+ isInitSearch = _props$isInitSearch === void 0 ? false : _props$isInitSearch,
48
50
  prop = _objectWithoutProperties(props, _excluded);
49
51
  var id = showValue.id,
50
52
  value = showValue.value,
@@ -60,8 +62,14 @@ var Index = function Index(props) {
60
62
  var totalPagesRef = useRef(1); //总页数
61
63
  var pageRef = useRef(1); //当前页
62
64
  var paramsRef = useRef(''); //查询参数·
65
+ var selectValueRef = useRef(''); //当前选中的值
63
66
  var storeListRef = useRef([]); //列表
64
67
  var selectRef = useRef({});
68
+ var _useState5 = useState(true),
69
+ _useState6 = _slicedToArray(_useState5, 2),
70
+ isFetchedData = _useState6[0],
71
+ setIsFetchedData = _useState6[1]; // 是否需要获取数据
72
+ var _additionalParameters = dynamicParameter && beforeSearch ? beforeSearch(dynamicParameter) : additionalParameters;
65
73
 
66
74
  /**
67
75
  * 查询接口
@@ -89,7 +97,7 @@ var Index = function Index(props) {
89
97
  */
90
98
  var getStoreList = /*#__PURE__*/function () {
91
99
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(type) {
92
- var _additionalParameters, data, target, options;
100
+ var data, target, options;
93
101
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
94
102
  while (1) switch (_context2.prev = _context2.next) {
95
103
  case 0:
@@ -100,20 +108,20 @@ var Index = function Index(props) {
100
108
  return _context2.abrupt("return");
101
109
  case 2:
102
110
  setSelectState(true);
103
- _additionalParameters = dynamicParameter && beforeSearch ? beforeSearch(dynamicParameter) : additionalParameters;
104
- _context2.next = 6;
105
- return inquireDiseases(_objectSpread(_defineProperty(_defineProperty(_defineProperty({}, searchValue, paramsRef.current), "pageNo", pageRef.current), "pageSize", 10), _additionalParameters ? _additionalParameters : {}));
106
- case 6:
111
+ _context2.next = 5;
112
+ return inquireDiseases(_objectSpread(_defineProperty(_defineProperty(_defineProperty({}, searchValue, paramsRef.current), "pageNo", pageRef.current), "pageSize", 10), _additionalParameters || {}));
113
+ case 5:
107
114
  data = _context2.sent;
108
115
  if (data.code === "OK") {
109
116
  target = data.result;
110
117
  totalPagesRef.current = target.totalPages;
111
- options = filterOptionsCallback ? filterOptionsCallback(target.content) : target.content || target;
118
+ options = filterOptionsCallback ? filterOptionsCallback(target.content || target) : target.content || target;
112
119
  storeListRef.current = type === 'scoll' ? [].concat(_toConsumableArray(storeListRef.current), _toConsumableArray(options)) : options;
113
120
  setStoreList(storeListRef.current || []);
121
+ setIsFetchedData(false); // 设置不需要获取数据
114
122
  setSelectState(false);
115
123
  }
116
- case 8:
124
+ case 7:
117
125
  case "end":
118
126
  return _context2.stop();
119
127
  }
@@ -124,8 +132,14 @@ var Index = function Index(props) {
124
132
  };
125
133
  }();
126
134
  useEffect(function () {
127
- getStoreList();
128
- }, []);
135
+ if (isInitSearch) {
136
+ getStoreList();
137
+ }
138
+ }, [isInitSearch]);
139
+ useEffect(function () {
140
+ setIsFetchedData(true); // 设置需要获取数据
141
+ }, [_additionalParameters]);
142
+
129
143
  // 搜索
130
144
  var onFilterChange = _.debounce(function (e) {
131
145
  if (typeof e === 'string') {
@@ -134,15 +148,17 @@ var Index = function Index(props) {
134
148
  getStoreList();
135
149
  }
136
150
  }, 300);
151
+
137
152
  // 选择
138
153
  var onChangeSelect = function onChangeSelect(value, option) {
139
154
  var _selectRef$current;
140
155
  if (changeNoSearch && typeof value === 'string') {
141
- paramsRef.current = value;
156
+ selectValueRef.current = value;
142
157
  }
143
158
  mode === undefined && ((_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.blur());
144
159
  handleSelect === null || handleSelect === void 0 || handleSelect(value, option);
145
160
  };
161
+
146
162
  // 下拉加载
147
163
  var companyScroll = function companyScroll(e) {
148
164
  var target = e.target;
@@ -150,22 +166,34 @@ var Index = function Index(props) {
150
166
  scrollHeight = target.scrollHeight,
151
167
  scrollTop = target.scrollTop;
152
168
  if (Math.ceil(scrollTop + offsetHeight) === scrollHeight) {
153
- pageRef.current = pageRef.current + 1;
154
- if (pageRef.current <= totalPagesRef.current) {
155
- getStoreList('scoll');
169
+ if (pageRef.current < totalPagesRef.current) {
170
+ // 检查当前页是否小于总页数
171
+ pageRef.current += 1; // 增加当前页码
172
+ getStoreList('scoll'); // 获取下一页数据
156
173
  }
157
174
  }
158
175
  };
176
+
159
177
  // 失焦
160
178
  var onBlurSelect = function onBlurSelect() {
161
- return !!paramsRef.current && handleSelect && handleSelect(paramsRef.current);
179
+ paramsRef.current && setIsFetchedData(true); // 如果有搜索内容,则需要获取数据
180
+ if (!!selectValueRef.current) {
181
+ handleSelect === null || handleSelect === void 0 || handleSelect(selectValueRef.current);
182
+ }
162
183
  };
184
+
185
+ // 聚焦
163
186
  var onFocusSelect = function onFocusSelect() {
164
- paramsRef.current = '';
165
- pageRef.current = 1;
166
- setStoreList([]); // 获取焦点时重置列表,否则会偶现没有滚动条
167
- getStoreList();
187
+ if (isFetchedData) {
188
+ // 需要获取数据
189
+ paramsRef.current = '';
190
+ pageRef.current = 1; // 重置当前页码
191
+ setStoreList([]); // 获取焦点时重置列表,否则会偶现没有滚动条
192
+ getStoreList();
193
+ }
168
194
  };
195
+
196
+ // 下拉框渲染
169
197
  var renderCom = function renderCom() {
170
198
  var dropdownRender = function dropdownRender(menu) {
171
199
  return /*#__PURE__*/React.createElement("div", null, menu, /*#__PURE__*/React.createElement("div", {
@@ -210,7 +238,8 @@ var Index = function Index(props) {
210
238
  }
211
239
  });
212
240
  return /*#__PURE__*/React.createElement(Select, _extends({}, commonProps, {
213
- ref: selectRef
241
+ ref: selectRef,
242
+ filterOption: false
214
243
  }), options);
215
244
  };
216
245
  return renderCom();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -35,6 +35,7 @@ import { exportCompile } from "../../utils/common";
35
35
  import React from 'react';
36
36
  import { DropDownSelect } from "../..";
37
37
  import dayjs from 'dayjs';
38
+ import { mergedColumns, ResizableTitle } from "./resizable";
38
39
  var FormItem = Form.Item;
39
40
  var RangePicker = DatePicker.RangePicker;
40
41
  var PageTemplate = function PageTemplate(props, ref) {
@@ -91,6 +92,7 @@ var PageTemplate = function PageTemplate(props, ref) {
91
92
  _useState16 = _slicedToArray(_useState15, 2),
92
93
  additionalExport = _useState16[0],
93
94
  setAdditionalExport = _useState16[1]; // 额外的按钮
95
+ var tableRef = useRef(null); // 引用 Table 外层容器
94
96
 
95
97
  useImperativeHandle(ref, function () {
96
98
  return {
@@ -392,7 +394,8 @@ var PageTemplate = function PageTemplate(props, ref) {
392
394
  }, /*#__PURE__*/React.createElement("div", {
393
395
  className: "page-template__filter"
394
396
  }, renderFilter()), /*#__PURE__*/React.createElement("div", {
395
- className: "page-template__content"
397
+ className: "page-template__content",
398
+ ref: tableRef
396
399
  }, /*#__PURE__*/React.createElement("div", {
397
400
  className: "page-template__toolbar"
398
401
  }, toolbar), /*#__PURE__*/React.createElement(Table, _extends({
@@ -420,7 +423,14 @@ var PageTemplate = function PageTemplate(props, ref) {
420
423
  bordered: true,
421
424
  dataSource: dataSource
422
425
  }, tableProps, {
423
- columns: columns
426
+ components: {
427
+ header: {
428
+ cell: ResizableTitle
429
+ }
430
+ },
431
+ columns: mergedColumns(columns, tableRef, function (_columns) {
432
+ return setColumns(_columns);
433
+ })
424
434
  }))), isSpinLoading && /*#__PURE__*/React.createElement(ExportExcels, exportProps));
425
435
  };
426
436
  export default /*#__PURE__*/forwardRef(PageTemplate);
File without changes
@@ -0,0 +1,25 @@
1
+ import { TableProps, type TableColumnsType } from 'antd';
2
+ import React, { RefObject } from 'react';
3
+ import './index.scss';
4
+ interface DataType {
5
+ [key: string]: any;
6
+ }
7
+ interface TitlePropsType {
8
+ width: number;
9
+ onResize: (e: React.SyntheticEvent<Element>, data: any) => void;
10
+ isEnd?: boolean;
11
+ }
12
+ /**
13
+ * 设置表格列宽的初始化值
14
+ * ^判断初始columns中设置的width是否为number
15
+ * ^使用ref获取所有的列宽,存储在widthsList,如果width不为number,则取获取的dom宽或者默认为150
16
+ *
17
+ * @param columns - 初始化的columns.
18
+ * @param tableRef - table外层的div的ref,用于获取table的dom的列宽.
19
+ * @param newColumnsVoid - callback,传出新的columns.
20
+ * @return 给columns里的增加onResize属性,用于在Resizable进行控制.
21
+ */
22
+ declare const mergedColumns: (columns: TableColumnsType<DataType>, tableRef: RefObject<HTMLDivElement>, newColumnsVoid: (columns: any) => void) => (import("antd").TableColumnGroupType<DataType> | import("antd").TableColumnType<DataType>)[];
23
+ declare const ResizableTitle: React.FC<Readonly<React.HTMLAttributes<HTMLTableCellElement> & TitlePropsType>>;
24
+ declare const CustomTable: React.FC<TableProps<any>>;
25
+ export { mergedColumns, ResizableTitle, CustomTable };
@@ -0,0 +1,152 @@
1
+ var _excluded = ["onResize", "width", "isEnd"],
2
+ _excluded2 = ["components", "columns", "dataSource"];
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ import { Table } from 'antd';
19
+ import React, { useEffect, useRef } from 'react';
20
+ import { Resizable } from 'react-resizable';
21
+ import "./index.scss";
22
+ /**
23
+ * 处理单元格大小
24
+ *
25
+ * @param index 当前列的索引,用于标识是哪一列的宽度发生了变化
26
+ * @param columns 表格的列配置数组,包含了所有列的配置信息
27
+ * @param newColumnsVoid 一个回调函数,用于应用新的列配置
28
+ */
29
+ var handleResize = function handleResize(index, columns, newColumnsVoid) {
30
+ return function (_, _ref) {
31
+ var size = _ref.size;
32
+ try {
33
+ // 检查索引是否超出范围
34
+ if (index < 0 || index >= columns.length) {
35
+ console.error('Index out of bounds:', index);
36
+ return;
37
+ }
38
+
39
+ // 更新指定列的宽度
40
+ var newColumns = columns.map(function (column, i) {
41
+ return i === index ? _objectSpread(_objectSpread({}, column), {}, {
42
+ width: size.width
43
+ }) : column;
44
+ });
45
+
46
+ // 返回新的列配置
47
+ newColumnsVoid(newColumns);
48
+ } catch (error) {
49
+ console.error('Error in handleResize:', error);
50
+ }
51
+ };
52
+ };
53
+ /**
54
+ * 设置表格列宽的初始化值
55
+ * ^判断初始columns中设置的width是否为number
56
+ * ^使用ref获取所有的列宽,存储在widthsList,如果width不为number,则取获取的dom宽或者默认为150
57
+ *
58
+ * @param columns - 初始化的columns.
59
+ * @param tableRef - table外层的div的ref,用于获取table的dom的列宽.
60
+ * @param newColumnsVoid - callback,传出新的columns.
61
+ * @return 给columns里的增加onResize属性,用于在Resizable进行控制.
62
+ */
63
+ var mergedColumns = function mergedColumns(columns, tableRef, newColumnsVoid) {
64
+ if (!columns || columns.length === 0) {
65
+ return []; // 处理columns为空或长度为0的情况
66
+ }
67
+ var widthsList = {};
68
+ var headerCells = null; // 缓存headerCells以减少DOM查询
69
+
70
+ if (tableRef.current) {
71
+ try {
72
+ if (!headerCells) {
73
+ headerCells = tableRef.current.querySelectorAll('th'); // 缓存headerCells以减少DOM查询
74
+ }
75
+ headerCells.forEach(function (cell, index) {
76
+ widthsList[index] = cell.clientWidth;
77
+ });
78
+ } catch (error) {
79
+ console.log('Error while fetching header cells:', error); // 异常处理
80
+ }
81
+ }
82
+ return columns === null || columns === void 0 ? void 0 : columns.map(function (col, index) {
83
+ return _objectSpread(_objectSpread({}, col), {}, {
84
+ onHeaderCell: function onHeaderCell(column) {
85
+ return {
86
+ width: typeof column.width === 'number' ? column.width : widthsList[index] || 150,
87
+ // 设置默认宽度
88
+ isEnd: index === columns.length - 1,
89
+ // 判断是否是最后一个
90
+ onResize: handleResize(index, columns, newColumnsVoid)
91
+ };
92
+ }
93
+ });
94
+ });
95
+ };
96
+ var ResizableTitle = function ResizableTitle(props) {
97
+ var _onResize = props.onResize,
98
+ width = props.width,
99
+ isEnd = props.isEnd,
100
+ restProps = _objectWithoutProperties(props, _excluded);
101
+ return /*#__PURE__*/React.createElement(Resizable, {
102
+ width: width,
103
+ height: 0,
104
+ handle: /*#__PURE__*/React.createElement("span", _extends({
105
+ className: "react-resizable-handle"
106
+ }, isEnd ? {
107
+ style: {
108
+ width: '5px',
109
+ insetInlineEnd: '0'
110
+ }
111
+ } : {}, {
112
+ onClick: function onClick(e) {
113
+ return e.stopPropagation();
114
+ }
115
+ })),
116
+ onResize: function onResize(event, data) {
117
+ return _onResize === null || _onResize === void 0 ? void 0 : _onResize(event, data);
118
+ },
119
+ draggableOpts: {
120
+ enableUserSelectHack: false
121
+ }
122
+ }, /*#__PURE__*/React.createElement("th", restProps));
123
+ };
124
+ var CustomTable = function CustomTable(props) {
125
+ var components = props.components,
126
+ columns = props.columns,
127
+ dataSource = props.dataSource,
128
+ restProps = _objectWithoutProperties(props, _excluded2);
129
+ var tableRef = useRef(null); // 引用 Table 外层容器
130
+ var _React$useState = React.useState(columns),
131
+ _React$useState2 = _slicedToArray(_React$useState, 2),
132
+ column = _React$useState2[0],
133
+ setColumn = _React$useState2[1];
134
+ useEffect(function () {
135
+ setColumn(columns);
136
+ }, [dataSource]);
137
+ var customComponents = _objectSpread({
138
+ header: _objectSpread({
139
+ cell: ResizableTitle
140
+ }, components === null || components === void 0 ? void 0 : components.header)
141
+ }, components);
142
+ return /*#__PURE__*/React.createElement("div", {
143
+ ref: tableRef
144
+ }, /*#__PURE__*/React.createElement(Table, _extends({}, restProps, {
145
+ columns: mergedColumns(column, tableRef, function (_columns) {
146
+ return setColumn(_columns);
147
+ }),
148
+ components: customComponents,
149
+ dataSource: dataSource || []
150
+ })));
151
+ };
152
+ export { mergedColumns, ResizableTitle, CustomTable };
@@ -0,0 +1,14 @@
1
+ .react-resizable {
2
+ position: relative;
3
+ background-clip: padding-box;
4
+ }
5
+
6
+ .react-resizable-handle {
7
+ position: absolute;
8
+ inset-inline-end: -5px;
9
+ bottom: 0;
10
+ z-index: 1;
11
+ width: 10px;
12
+ height: 100%;
13
+ cursor: col-resize;
14
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/index.d.ts CHANGED
@@ -19,4 +19,5 @@ export { default as SuperInput } from './components/SuperInput';
19
19
  export { default as TabsMode } from './components/TabsMode';
20
20
  export { default as VideoProgressModal } from './components/VideoProgressModal';
21
21
  export { default as YLModal } from './components/YLModal';
22
+ export { mergedColumns, ResizableTitle, CustomTable } from './components/PageTemplate/resizable';
22
23
  export { default as TestBtn } from './business/TestBtn';
package/dist/index.js CHANGED
@@ -20,6 +20,6 @@ export { default as SuperInput } from "./components/SuperInput";
20
20
  export { default as TabsMode } from "./components/TabsMode";
21
21
  export { default as VideoProgressModal } from "./components/VideoProgressModal";
22
22
  export { default as YLModal } from "./components/YLModal";
23
-
23
+ export { mergedColumns, ResizableTitle, CustomTable } from "./components/PageTemplate/resizable"; // 用于单个table的列宽拖拽
24
24
  // 业务组件
25
25
  export { default as TestBtn } from "./business/TestBtn";
@@ -15,4 +15,5 @@ declare module "lodash/throttle";
15
15
 
16
16
  declare module "lodash/omit";
17
17
  declare module "qs";
18
- declare module "@hanyk/rc-viewer";
18
+ declare module "@hanyk/rc-viewer";
19
+ declare module "react-resizable";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yilianjituan/yilian_dgerm",
3
- "version": "0.0.1-alpha.38",
3
+ "version": "0.0.1-alpha.40",
4
4
  "description": "A react library developed with dumi",
5
5
  "keywords": [
6
6
  "React",
@@ -59,7 +59,7 @@
59
59
  "@ant-design/icons": "^5.5.1",
60
60
  "@hanyk/rc-viewer": "^0.0.3",
61
61
  "ahooks": "^3.7.2",
62
- "antd": "^5.18.0",
62
+ "antd": "^5.21.6",
63
63
  "axios": "^1.7.7",
64
64
  "copy-to-clipboard": "^3.3.3",
65
65
  "dayjs": "^1.11.11",
@@ -69,7 +69,8 @@
69
69
  "lodash": "^4.17.20",
70
70
  "qs": "^6.9.7",
71
71
  "react": ">=16.9.0",
72
- "react-dom": ">=16.9.0"
72
+ "react-dom": ">=16.9.0",
73
+ "react-resizable": "^3.0.5"
73
74
  },
74
75
  "devDependencies": {
75
76
  "@commitlint/cli": "^17.1.2",