@yilianjituan/yilian_dgerm 0.0.1-alpha.39 → 0.0.1-alpha.41
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.
- package/dist/components/DropDownSelect/index.js +6 -6
- package/dist/components/PageTemplate/index.js +12 -2
- package/dist/components/PageTemplate/resizable/index.d.ts +25 -0
- package/dist/components/PageTemplate/resizable/index.js +152 -0
- package/dist/components/PageTemplate/resizable/index.scss +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/react-app-env.d.ts +2 -1
- package/package.json +3 -2
|
@@ -69,7 +69,6 @@ var Index = function Index(props) {
|
|
|
69
69
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
70
70
|
isFetchedData = _useState6[0],
|
|
71
71
|
setIsFetchedData = _useState6[1]; // 是否需要获取数据
|
|
72
|
-
var _additionalParameters = dynamicParameter && beforeSearch ? beforeSearch(dynamicParameter) : additionalParameters;
|
|
73
72
|
|
|
74
73
|
/**
|
|
75
74
|
* 查询接口
|
|
@@ -97,7 +96,7 @@ var Index = function Index(props) {
|
|
|
97
96
|
*/
|
|
98
97
|
var getStoreList = /*#__PURE__*/function () {
|
|
99
98
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(type) {
|
|
100
|
-
var data, target, options;
|
|
99
|
+
var _additionalParameters, data, target, options;
|
|
101
100
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
102
101
|
while (1) switch (_context2.prev = _context2.next) {
|
|
103
102
|
case 0:
|
|
@@ -107,10 +106,11 @@ var Index = function Index(props) {
|
|
|
107
106
|
}
|
|
108
107
|
return _context2.abrupt("return");
|
|
109
108
|
case 2:
|
|
109
|
+
_additionalParameters = dynamicParameter && beforeSearch ? beforeSearch(dynamicParameter) : additionalParameters;
|
|
110
110
|
setSelectState(true);
|
|
111
|
-
_context2.next =
|
|
111
|
+
_context2.next = 6;
|
|
112
112
|
return inquireDiseases(_objectSpread(_defineProperty(_defineProperty(_defineProperty({}, searchValue, paramsRef.current), "pageNo", pageRef.current), "pageSize", 10), _additionalParameters || {}));
|
|
113
|
-
case
|
|
113
|
+
case 6:
|
|
114
114
|
data = _context2.sent;
|
|
115
115
|
if (data.code === "OK") {
|
|
116
116
|
target = data.result;
|
|
@@ -121,7 +121,7 @@ var Index = function Index(props) {
|
|
|
121
121
|
setIsFetchedData(false); // 设置不需要获取数据
|
|
122
122
|
setSelectState(false);
|
|
123
123
|
}
|
|
124
|
-
case
|
|
124
|
+
case 8:
|
|
125
125
|
case "end":
|
|
126
126
|
return _context2.stop();
|
|
127
127
|
}
|
|
@@ -138,7 +138,7 @@ var Index = function Index(props) {
|
|
|
138
138
|
}, [isInitSearch]);
|
|
139
139
|
useEffect(function () {
|
|
140
140
|
setIsFetchedData(true); // 设置需要获取数据
|
|
141
|
-
}, [
|
|
141
|
+
}, [additionalParameters, dynamicParameter && (beforeSearch === null || beforeSearch === void 0 ? void 0 : beforeSearch(dynamicParameter))]);
|
|
142
142
|
|
|
143
143
|
// 搜索
|
|
144
144
|
var onFilterChange = _.debounce(function (e) {
|
|
@@ -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
|
-
|
|
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);
|
|
@@ -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 };
|
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";
|
package/dist/react-app-env.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yilianjituan/yilian_dgerm",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.41",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"React",
|
|
@@ -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",
|