@guo514360255/antd-lib 1.4.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.
- package/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/CustomDetailModal/detailModal.d.ts +72 -0
- package/dist/CustomDetailModal/index.d.ts +5 -0
- package/dist/CustomDetailModal/index.js +183 -0
- package/dist/CustomDetailModal/index.less +6 -0
- package/dist/CustomFormModal/formModal.d.ts +78 -0
- package/dist/CustomFormModal/index.d.ts +5 -0
- package/dist/CustomFormModal/index.js +293 -0
- package/dist/CustomFormModal/index.less +29 -0
- package/dist/CustomTable/index.d.ts +5 -0
- package/dist/CustomTable/index.js +412 -0
- package/dist/CustomTable/index.less +69 -0
- package/dist/CustomTable/table.d.ts +143 -0
- package/dist/CustomTag/index.d.ts +3 -0
- package/dist/CustomTag/index.js +27 -0
- package/dist/CustomTag/tag.d.ts +19 -0
- package/dist/CustomUpload/index.d.ts +22 -0
- package/dist/CustomUpload/index.js +197 -0
- package/dist/DynamicIcon/index.d.ts +9 -0
- package/dist/DynamicIcon/index.js +34 -0
- package/dist/FormItem/index.d.ts +9 -0
- package/dist/FormItem/index.js +47 -0
- package/dist/compontent.d.ts +86 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useFullscreen.d.ts +6 -0
- package/dist/hooks/useFullscreen.js +77 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +9 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/rememberPwd.d.ts +34 -0
- package/dist/utils/rememberPwd.js +112 -0
- package/dist/utils/util.d.ts +54 -0
- package/dist/utils/util.js +119 -0
- package/package.json +90 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
5
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
7
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
|
+
var _excluded = ["isIndex", "isDelete", "isUpdateState", "isDetail", "isUpdate", "isCreate", "createText", "columns", "rowKey", "request", "title", "defaultQueryParams", "toolBarRender", "dataSource", "deleteRequest", "detailRequest", "saveRequest", "updateRequest", "updateStateRequest", "handleModalData", "formProps", "detailProps"],
|
|
9
|
+
_excluded2 = ["list"];
|
|
10
|
+
/*
|
|
11
|
+
* @Author: 郭郭
|
|
12
|
+
* @Date: 2025/8/11
|
|
13
|
+
* @Description:
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { ProTable } from '@ant-design/pro-table';
|
|
17
|
+
import CustomFormModal from "../CustomFormModal";
|
|
18
|
+
import { Button, message, Popconfirm, Progress } from 'antd';
|
|
19
|
+
import { cloneDeep, debounce } from 'lodash';
|
|
20
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
21
|
+
import CustomDetailModal from "../CustomDetailModal";
|
|
22
|
+
import "./index.less";
|
|
23
|
+
var CustomTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
24
|
+
var _props$isIndex = props.isIndex,
|
|
25
|
+
isIndex = _props$isIndex === void 0 ? true : _props$isIndex,
|
|
26
|
+
_props$isDelete = props.isDelete,
|
|
27
|
+
isDelete = _props$isDelete === void 0 ? true : _props$isDelete,
|
|
28
|
+
_props$isUpdateState = props.isUpdateState,
|
|
29
|
+
isUpdateState = _props$isUpdateState === void 0 ? false : _props$isUpdateState,
|
|
30
|
+
_props$isDetail = props.isDetail,
|
|
31
|
+
isDetail = _props$isDetail === void 0 ? true : _props$isDetail,
|
|
32
|
+
_props$isUpdate = props.isUpdate,
|
|
33
|
+
isUpdate = _props$isUpdate === void 0 ? true : _props$isUpdate,
|
|
34
|
+
_props$isCreate = props.isCreate,
|
|
35
|
+
isCreate = _props$isCreate === void 0 ? true : _props$isCreate,
|
|
36
|
+
createText = props.createText,
|
|
37
|
+
columns = props.columns,
|
|
38
|
+
rowKey = props.rowKey,
|
|
39
|
+
request = props.request,
|
|
40
|
+
title = props.title,
|
|
41
|
+
_props$defaultQueryPa = props.defaultQueryParams,
|
|
42
|
+
defaultQueryParams = _props$defaultQueryPa === void 0 ? {} : _props$defaultQueryPa,
|
|
43
|
+
_props$toolBarRender = props.toolBarRender,
|
|
44
|
+
_toolBarRender = _props$toolBarRender === void 0 ? [] : _props$toolBarRender,
|
|
45
|
+
_props$dataSource = props.dataSource,
|
|
46
|
+
dataSource = _props$dataSource === void 0 ? null : _props$dataSource,
|
|
47
|
+
deleteRequest = props.deleteRequest,
|
|
48
|
+
detailRequest = props.detailRequest,
|
|
49
|
+
saveRequest = props.saveRequest,
|
|
50
|
+
updateRequest = props.updateRequest,
|
|
51
|
+
updateStateRequest = props.updateStateRequest,
|
|
52
|
+
handleModalData = props.handleModalData,
|
|
53
|
+
formProps = props.formProps,
|
|
54
|
+
detailProps = props.detailProps,
|
|
55
|
+
tableProps = _objectWithoutProperties(props, _excluded);
|
|
56
|
+
var formRef = useRef();
|
|
57
|
+
var actionRef = useRef();
|
|
58
|
+
var detailRef = useRef();
|
|
59
|
+
var formModalRef = useRef();
|
|
60
|
+
var _message$useMessage = message.useMessage(),
|
|
61
|
+
_message$useMessage2 = _slicedToArray(_message$useMessage, 2),
|
|
62
|
+
messageApi = _message$useMessage2[0],
|
|
63
|
+
messageHolder = _message$useMessage2[1];
|
|
64
|
+
var _useState = useState(false),
|
|
65
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
66
|
+
loading = _useState2[0],
|
|
67
|
+
setLoading = _useState2[1];
|
|
68
|
+
var _useState3 = useState(false),
|
|
69
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
70
|
+
scrollBar = _useState4[0],
|
|
71
|
+
setScrollBar = _useState4[1];
|
|
72
|
+
var tableContainerRef = useRef(null);
|
|
73
|
+
var delEvent = /*#__PURE__*/function () {
|
|
74
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(id) {
|
|
75
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
76
|
+
while (1) switch (_context.prev = _context.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
setLoading(true);
|
|
79
|
+
_context.prev = 1;
|
|
80
|
+
if (!deleteRequest) {
|
|
81
|
+
_context.next = 9;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
_context.next = 5;
|
|
85
|
+
return deleteRequest(id);
|
|
86
|
+
case 5:
|
|
87
|
+
messageApi.success('删除成功');
|
|
88
|
+
setTimeout(function () {
|
|
89
|
+
var _actionRef$current;
|
|
90
|
+
(_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 || _actionRef$current.reload();
|
|
91
|
+
}, 0);
|
|
92
|
+
_context.next = 10;
|
|
93
|
+
break;
|
|
94
|
+
case 9:
|
|
95
|
+
messageApi.error('删除接口未传入');
|
|
96
|
+
case 10:
|
|
97
|
+
_context.next = 16;
|
|
98
|
+
break;
|
|
99
|
+
case 12:
|
|
100
|
+
_context.prev = 12;
|
|
101
|
+
_context.t0 = _context["catch"](1);
|
|
102
|
+
messageApi.error('删除失败');
|
|
103
|
+
console.log(_context.t0);
|
|
104
|
+
case 16:
|
|
105
|
+
_context.prev = 16;
|
|
106
|
+
setLoading(false);
|
|
107
|
+
return _context.finish(16);
|
|
108
|
+
case 19:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context.stop();
|
|
111
|
+
}
|
|
112
|
+
}, _callee, null, [[1, 12, 16, 19]]);
|
|
113
|
+
}));
|
|
114
|
+
return function delEvent(_x) {
|
|
115
|
+
return _ref.apply(this, arguments);
|
|
116
|
+
};
|
|
117
|
+
}();
|
|
118
|
+
var updateState = /*#__PURE__*/function () {
|
|
119
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
|
|
120
|
+
var id, isActive, _formRef$current;
|
|
121
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
122
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
123
|
+
case 0:
|
|
124
|
+
id = _ref2.id, isActive = _ref2.isActive;
|
|
125
|
+
setLoading(true);
|
|
126
|
+
_context2.prev = 2;
|
|
127
|
+
if (!updateStateRequest) {
|
|
128
|
+
_context2.next = 10;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
_context2.next = 6;
|
|
132
|
+
return updateStateRequest({
|
|
133
|
+
id: id,
|
|
134
|
+
isActive: isActive === 0 ? 1 : 0
|
|
135
|
+
});
|
|
136
|
+
case 6:
|
|
137
|
+
messageApi.success('状态修改成功');
|
|
138
|
+
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.submit();
|
|
139
|
+
_context2.next = 11;
|
|
140
|
+
break;
|
|
141
|
+
case 10:
|
|
142
|
+
messageApi.error('状态修改接口未传入');
|
|
143
|
+
case 11:
|
|
144
|
+
_context2.next = 17;
|
|
145
|
+
break;
|
|
146
|
+
case 13:
|
|
147
|
+
_context2.prev = 13;
|
|
148
|
+
_context2.t0 = _context2["catch"](2);
|
|
149
|
+
messageApi.error('状态修改失败');
|
|
150
|
+
console.log(_context2.t0);
|
|
151
|
+
case 17:
|
|
152
|
+
_context2.prev = 17;
|
|
153
|
+
setLoading(false);
|
|
154
|
+
return _context2.finish(17);
|
|
155
|
+
case 20:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context2.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee2, null, [[2, 13, 17, 20]]);
|
|
160
|
+
}));
|
|
161
|
+
return function updateState(_x2) {
|
|
162
|
+
return _ref3.apply(this, arguments);
|
|
163
|
+
};
|
|
164
|
+
}();
|
|
165
|
+
useImperativeHandle(ref, function () {
|
|
166
|
+
return {
|
|
167
|
+
reload: function reload() {
|
|
168
|
+
var _actionRef$current2;
|
|
169
|
+
(_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 || _actionRef$current2.reload();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
var totalWidth = columns === null || columns === void 0 ? void 0 : columns.reduce(function (sum, col) {
|
|
174
|
+
return sum + (col.width || 100);
|
|
175
|
+
}, 0);
|
|
176
|
+
var openModal = function openModal() {
|
|
177
|
+
var _formModalRef$current;
|
|
178
|
+
var record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
(_formModalRef$current = formModalRef.current) === null || _formModalRef$current === void 0 || _formModalRef$current.open(handleModalData ? handleModalData(record) : record);
|
|
181
|
+
};
|
|
182
|
+
var handleColumns = function handleColumns() {
|
|
183
|
+
var _newColumns$;
|
|
184
|
+
var newColumns = cloneDeep(columns);
|
|
185
|
+
if (isIndex && Array.isArray(newColumns) && ((_newColumns$ = newColumns[0]) === null || _newColumns$ === void 0 ? void 0 : _newColumns$.dataIndex) !== 'index') {
|
|
186
|
+
newColumns.unshift({
|
|
187
|
+
title: '序号',
|
|
188
|
+
dataIndex: 'index',
|
|
189
|
+
valueType: 'index',
|
|
190
|
+
hideInSearch: true,
|
|
191
|
+
hideInForm: true,
|
|
192
|
+
fixed: 'left',
|
|
193
|
+
width: 70
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
newColumns === null || newColumns === void 0 || newColumns.forEach(function (item) {
|
|
197
|
+
// 所有select/treeSelect都附加搜索功能
|
|
198
|
+
if (['select', 'treeSelect'].includes(item.valueType)) {
|
|
199
|
+
item.fieldProps = _objectSpread({
|
|
200
|
+
showSearch: true
|
|
201
|
+
}, item.fieldProps || {});
|
|
202
|
+
}
|
|
203
|
+
return item;
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// progress
|
|
207
|
+
var progress = newColumns === null || newColumns === void 0 ? void 0 : newColumns.find(function (item) {
|
|
208
|
+
return item.type === 'progress';
|
|
209
|
+
});
|
|
210
|
+
if (progress && !progress.render) {
|
|
211
|
+
progress.render = function (_, record) {
|
|
212
|
+
var percent = record[progress.dataIndex];
|
|
213
|
+
return /*#__PURE__*/React.createElement(Progress, {
|
|
214
|
+
percent: percent,
|
|
215
|
+
format: function format(percent) {
|
|
216
|
+
return "".concat(percent, "%");
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 操作列
|
|
223
|
+
var operation = newColumns === null || newColumns === void 0 ? void 0 : newColumns.find(function (item) {
|
|
224
|
+
return item.dataIndex === 'operation' || item.valueType === 'option';
|
|
225
|
+
});
|
|
226
|
+
if (operation && !operation.render) {
|
|
227
|
+
operation.hideInSearch = true;
|
|
228
|
+
operation.hideInDetail = true;
|
|
229
|
+
if (!operation.width) {
|
|
230
|
+
operation.width = [isDetail, isDelete, isUpdateState, isUpdate].filter(Boolean).length * 65;
|
|
231
|
+
}
|
|
232
|
+
operation.render = function (_, record) {
|
|
233
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
234
|
+
style: {
|
|
235
|
+
display: 'flex'
|
|
236
|
+
}
|
|
237
|
+
}, isDetail && /*#__PURE__*/React.createElement(Button, {
|
|
238
|
+
type: "link"
|
|
239
|
+
// @ts-ignore
|
|
240
|
+
,
|
|
241
|
+
onClick: function onClick() {
|
|
242
|
+
var _detailRef$current;
|
|
243
|
+
return (_detailRef$current = detailRef.current) === null || _detailRef$current === void 0 ? void 0 : _detailRef$current.open(record);
|
|
244
|
+
}
|
|
245
|
+
}, "\u8BE6\u60C5"), isUpdate && /*#__PURE__*/React.createElement(Button, {
|
|
246
|
+
type: "link",
|
|
247
|
+
onClick: function onClick() {
|
|
248
|
+
return openModal(record);
|
|
249
|
+
}
|
|
250
|
+
}, "\u7F16\u8F91"), isDelete && /*#__PURE__*/React.createElement(Popconfirm, {
|
|
251
|
+
title: "\u786E\u5B9A\u5220\u9664\u5F53\u524D\u6570\u636E\uFF1F",
|
|
252
|
+
onConfirm: function onConfirm() {
|
|
253
|
+
return delEvent(record.id);
|
|
254
|
+
}
|
|
255
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
256
|
+
type: "link",
|
|
257
|
+
danger: true
|
|
258
|
+
}, "\u5220\u9664")), isUpdateState && /*#__PURE__*/React.createElement(Button, {
|
|
259
|
+
type: "link",
|
|
260
|
+
danger: record.isActive === 1,
|
|
261
|
+
onClick: function onClick() {
|
|
262
|
+
return updateState(record);
|
|
263
|
+
}
|
|
264
|
+
}, record.isActive === 0 ? '启用' : '禁用'), operation.buttons && operation.buttons(record));
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return newColumns === null || newColumns === void 0 ? void 0 : newColumns.map(function (item) {
|
|
268
|
+
return item.dataIndex === 'operation' || item.valueType === 'option' ? _objectSpread(_objectSpread({}, item), {}, {
|
|
269
|
+
fixed: 'right'
|
|
270
|
+
}) : item;
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
var getAntTableContainer = function getAntTableContainer() {
|
|
274
|
+
var tableContainer = tableContainerRef.current;
|
|
275
|
+
var tableBody = tableContainer === null || tableContainer === void 0 ? void 0 : tableContainer.querySelector('.ant-table-body');
|
|
276
|
+
setTimeout(function () {
|
|
277
|
+
if (tableBody) {
|
|
278
|
+
var _tableContainerRef$cu;
|
|
279
|
+
var hasVerticalScrollbar = tableBody.scrollHeight > tableBody.clientHeight;
|
|
280
|
+
setScrollBar(hasVerticalScrollbar);
|
|
281
|
+
var container = (_tableContainerRef$cu = tableContainerRef.current) === null || _tableContainerRef$cu === void 0 ? void 0 : _tableContainerRef$cu.querySelector('.ant-table-container');
|
|
282
|
+
container.style.transform = 'translateZ(0)';
|
|
283
|
+
requestAnimationFrame(function () {
|
|
284
|
+
container.style.transform = '';
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}, 10);
|
|
288
|
+
};
|
|
289
|
+
useEffect(function () {
|
|
290
|
+
// 初始检测
|
|
291
|
+
var timer = setTimeout(getAntTableContainer, 50);
|
|
292
|
+
|
|
293
|
+
// 创建防抖后的 resize 处理函数
|
|
294
|
+
var handleResize = debounce(getAntTableContainer, 100);
|
|
295
|
+
|
|
296
|
+
// 监听窗口 resize
|
|
297
|
+
window.addEventListener('resize', handleResize);
|
|
298
|
+
|
|
299
|
+
// 清理函数:移除监听器 + 清除定时器
|
|
300
|
+
return function () {
|
|
301
|
+
clearTimeout(timer);
|
|
302
|
+
window.removeEventListener('resize', handleResize);
|
|
303
|
+
};
|
|
304
|
+
}, [dataSource]);
|
|
305
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
306
|
+
className: "custom-table-container",
|
|
307
|
+
ref: tableContainerRef
|
|
308
|
+
}, messageHolder, /*#__PURE__*/React.createElement(ProTable, _extends({
|
|
309
|
+
className: "ant-table-container ".concat(scrollBar ? '' : 'customer-pro-table-container'),
|
|
310
|
+
scroll: {
|
|
311
|
+
x: totalWidth,
|
|
312
|
+
y: 5000
|
|
313
|
+
},
|
|
314
|
+
loading: loading,
|
|
315
|
+
bordered: true,
|
|
316
|
+
pagination: _objectSpread({
|
|
317
|
+
showSizeChanger: true,
|
|
318
|
+
showQuickJumper: true,
|
|
319
|
+
defaultPageSize: 10
|
|
320
|
+
}, Array.isArray(dataSource) ? {
|
|
321
|
+
onChange: function onChange() {
|
|
322
|
+
setTimeout(function () {
|
|
323
|
+
getAntTableContainer();
|
|
324
|
+
}, 50);
|
|
325
|
+
}
|
|
326
|
+
} : {}),
|
|
327
|
+
actionRef: actionRef,
|
|
328
|
+
formRef: formRef,
|
|
329
|
+
columns: handleColumns() || [],
|
|
330
|
+
request: ( /*#__PURE__*/function () {
|
|
331
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params, sort, filter) {
|
|
332
|
+
var pageNo, _yield$request, list, data;
|
|
333
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
334
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
335
|
+
case 0:
|
|
336
|
+
if (!(request && !dataSource)) {
|
|
337
|
+
_context3.next = 20;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
setLoading(true);
|
|
341
|
+
_context3.prev = 2;
|
|
342
|
+
pageNo = params.current;
|
|
343
|
+
delete params.current;
|
|
344
|
+
_context3.next = 7;
|
|
345
|
+
return request(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
346
|
+
pageNo: pageNo
|
|
347
|
+
}, sort), filter), defaultQueryParams));
|
|
348
|
+
case 7:
|
|
349
|
+
_yield$request = _context3.sent;
|
|
350
|
+
list = _yield$request.list;
|
|
351
|
+
data = _objectWithoutProperties(_yield$request, _excluded2);
|
|
352
|
+
getAntTableContainer();
|
|
353
|
+
return _context3.abrupt("return", _objectSpread({
|
|
354
|
+
data: list
|
|
355
|
+
}, data));
|
|
356
|
+
case 14:
|
|
357
|
+
_context3.prev = 14;
|
|
358
|
+
_context3.t0 = _context3["catch"](2);
|
|
359
|
+
console.log(_context3.t0);
|
|
360
|
+
case 17:
|
|
361
|
+
_context3.prev = 17;
|
|
362
|
+
setLoading(false);
|
|
363
|
+
return _context3.finish(17);
|
|
364
|
+
case 20:
|
|
365
|
+
return _context3.abrupt("return", {
|
|
366
|
+
data: [],
|
|
367
|
+
total: 0
|
|
368
|
+
});
|
|
369
|
+
case 21:
|
|
370
|
+
case "end":
|
|
371
|
+
return _context3.stop();
|
|
372
|
+
}
|
|
373
|
+
}, _callee3, null, [[2, 14, 17, 20]]);
|
|
374
|
+
}));
|
|
375
|
+
return function (_x3, _x4, _x5) {
|
|
376
|
+
return _ref4.apply(this, arguments);
|
|
377
|
+
};
|
|
378
|
+
}()),
|
|
379
|
+
rowKey: rowKey || 'id',
|
|
380
|
+
dateFormatter: "string"
|
|
381
|
+
}, Array.isArray(dataSource) ? {
|
|
382
|
+
dataSource: dataSource
|
|
383
|
+
} : {}, {
|
|
384
|
+
toolBarRender: function toolBarRender() {
|
|
385
|
+
return [].concat(_toConsumableArray(_toolBarRender || []), _toConsumableArray(isCreate ? [/*#__PURE__*/React.createElement(Button, {
|
|
386
|
+
type: "primary",
|
|
387
|
+
key: "create"
|
|
388
|
+
// @ts-ignore
|
|
389
|
+
,
|
|
390
|
+
onClick: function onClick() {
|
|
391
|
+
return openModal({});
|
|
392
|
+
}
|
|
393
|
+
}, createText || '创建')] : []));
|
|
394
|
+
}
|
|
395
|
+
}, tableProps)), /*#__PURE__*/React.createElement(CustomDetailModal, _extends({
|
|
396
|
+
title: title,
|
|
397
|
+
ref: detailRef,
|
|
398
|
+
detailRequest: detailRequest,
|
|
399
|
+
columns: columns.filter(function (item) {
|
|
400
|
+
return !item.hideInDetail && item.dataIndex !== 'operation' && item.valueType !== 'option';
|
|
401
|
+
})
|
|
402
|
+
}, detailProps || {})), /*#__PURE__*/React.createElement(CustomFormModal, _extends({
|
|
403
|
+
title: title,
|
|
404
|
+
ref: formModalRef,
|
|
405
|
+
saveRequest: saveRequest,
|
|
406
|
+
updateRequest: updateRequest,
|
|
407
|
+
columns: columns.filter(function (item) {
|
|
408
|
+
return !item.hideInForm && item.dataIndex !== 'operation' && item.valueType !== 'option';
|
|
409
|
+
})
|
|
410
|
+
}, formProps || {})));
|
|
411
|
+
});
|
|
412
|
+
export default CustomTable;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
.customer-pro-table-container{
|
|
2
|
+
.ant-table-container{
|
|
3
|
+
.ant-table-cell-fix-right{
|
|
4
|
+
right: 0 !important;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
.ant-table-cell-fix-right{
|
|
9
|
+
.ant-btn{
|
|
10
|
+
padding: 0 5px !important;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
.ant-pro-layout-container{
|
|
14
|
+
height: 100vh;
|
|
15
|
+
> .ant-pro-layout-content{
|
|
16
|
+
flex: 1;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
> .custom-table-container {
|
|
19
|
+
width: 100%;
|
|
20
|
+
flex: 1;
|
|
21
|
+
height: 100%;
|
|
22
|
+
display: flex;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
> .ant-pro-table{
|
|
25
|
+
height: 100%;
|
|
26
|
+
width: 100%;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
>.ant-pro-card:not(.ant-pro-table-search){
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
>.ant-pro-card-body{
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
>.ant-table-wrapper{
|
|
36
|
+
flex: 1;
|
|
37
|
+
overflow-y: hidden;
|
|
38
|
+
>.ant-spin-nested-loading{
|
|
39
|
+
height: 100%;
|
|
40
|
+
>.ant-spin-container{
|
|
41
|
+
height: 100%;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
>.ant-table{
|
|
45
|
+
flex: 1;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
>.ant-table-container{
|
|
48
|
+
height: 100%;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
>.ant-table-body{
|
|
52
|
+
flex: 1;
|
|
53
|
+
overflow: auto !important;
|
|
54
|
+
}
|
|
55
|
+
>.ant-table-content{
|
|
56
|
+
height: 100%;
|
|
57
|
+
overflow: auto !important;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 郭郭
|
|
3
|
+
* @Date: 2025/11/5
|
|
4
|
+
* @Description:
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ProColumns } from '@ant-design/pro-table';
|
|
8
|
+
|
|
9
|
+
interface CustomTableProps {
|
|
10
|
+
/**
|
|
11
|
+
* 表格标题
|
|
12
|
+
*/
|
|
13
|
+
title?: string | undefined;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 是否有序号
|
|
17
|
+
*/
|
|
18
|
+
isIndex?: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 是否有详情
|
|
22
|
+
*/
|
|
23
|
+
isDetail?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 是否有删除按钮
|
|
27
|
+
*/
|
|
28
|
+
isDelete?: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 是否有编辑按钮
|
|
32
|
+
*/
|
|
33
|
+
isUpdate?: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 是否创建按钮
|
|
37
|
+
*/
|
|
38
|
+
isCreate?: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 创建按钮文案
|
|
42
|
+
*/
|
|
43
|
+
createText?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 提交按钮文案
|
|
47
|
+
*/
|
|
48
|
+
okText?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 取消按钮文案
|
|
52
|
+
*/
|
|
53
|
+
cancelText?: string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 是否有编辑状态按钮
|
|
57
|
+
*/
|
|
58
|
+
isUpdateState?: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 字段列表
|
|
62
|
+
*/
|
|
63
|
+
columns: ProColumns[];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* record key
|
|
67
|
+
*/
|
|
68
|
+
rowKey?: string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 请求api
|
|
72
|
+
* @param data
|
|
73
|
+
*/
|
|
74
|
+
request?: (data?: any) => any;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 删除api
|
|
78
|
+
* @param data
|
|
79
|
+
*/
|
|
80
|
+
deleteRequest?: (data?: any) => any;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 修改状态api
|
|
84
|
+
* @param data
|
|
85
|
+
*/
|
|
86
|
+
updateStateRequest?: (data?: any) => any;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 详情
|
|
90
|
+
* @param data
|
|
91
|
+
*/
|
|
92
|
+
detailRequest?: (data: any) => any;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 保存
|
|
96
|
+
* @param data
|
|
97
|
+
*/
|
|
98
|
+
saveRequest?: (data: any) => any;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 编辑
|
|
102
|
+
* @param data
|
|
103
|
+
*/
|
|
104
|
+
updateRequest?: (data: any) => any;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 处理弹窗的数据
|
|
108
|
+
* @param data
|
|
109
|
+
*/
|
|
110
|
+
handleModalData?: (data: any) => any;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 数据源
|
|
114
|
+
*/
|
|
115
|
+
dataSource?: { [key: string]: any }[] | null;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
defaultQueryParams?: {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 工具栏渲染
|
|
126
|
+
*/
|
|
127
|
+
toolBarRender?: any[];
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* form props
|
|
131
|
+
*/
|
|
132
|
+
formProps?: { [key: string]: any };
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* detail props
|
|
136
|
+
*/
|
|
137
|
+
detailProps?: { [key: string]: any };
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 其它参数
|
|
141
|
+
*/
|
|
142
|
+
[key: string]: any;
|
|
143
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 郭郭
|
|
3
|
+
* @Date: 2025/11/11
|
|
4
|
+
* @Description:
|
|
5
|
+
*/
|
|
6
|
+
import { Tag } from 'antd';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
var CustomTag = function CustomTag(_ref, record, __, ___, column) {
|
|
9
|
+
var value = _ref.value,
|
|
10
|
+
valueEnum = _ref.valueEnum;
|
|
11
|
+
if (column) {
|
|
12
|
+
var _ref2 = column.valueEnum[record.status] || {},
|
|
13
|
+
_color = _ref2.color,
|
|
14
|
+
_text = _ref2.text;
|
|
15
|
+
return /*#__PURE__*/React.createElement(Tag, {
|
|
16
|
+
color: _color
|
|
17
|
+
}, _text);
|
|
18
|
+
}
|
|
19
|
+
if (!value) return /*#__PURE__*/React.createElement(React.Fragment, null, value);
|
|
20
|
+
var _ref3 = valueEnum[value] || {},
|
|
21
|
+
color = _ref3.color,
|
|
22
|
+
text = _ref3.text;
|
|
23
|
+
return /*#__PURE__*/React.createElement(Tag, {
|
|
24
|
+
color: color
|
|
25
|
+
}, text);
|
|
26
|
+
};
|
|
27
|
+
export default CustomTag;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 郭郭
|
|
3
|
+
* @Date: 2025/11/11
|
|
4
|
+
* @Description:
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
interface CustomTagProps {
|
|
8
|
+
/**
|
|
9
|
+
* 标签名称
|
|
10
|
+
*/
|
|
11
|
+
value: string | number;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 枚举
|
|
15
|
+
*/
|
|
16
|
+
valueEnum: {
|
|
17
|
+
[key: stirng]: { text: string; status?: string; color?: string };
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UploadProps } from 'antd';
|
|
2
|
+
import { ImgCropProps } from 'antd-img-crop';
|
|
3
|
+
import type { UploadFile } from 'antd/es/upload/interface';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface CustomUploadProps {
|
|
6
|
+
value?: UploadFile[];
|
|
7
|
+
onChange?: (fileList: UploadFile[]) => void;
|
|
8
|
+
uploadProps?: Omit<UploadProps, 'fileList' | 'onChange'>;
|
|
9
|
+
imgCrop?: ImgCropProps;
|
|
10
|
+
isCrop?: boolean;
|
|
11
|
+
isDragger?: boolean;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
rest?: {
|
|
14
|
+
isDragger?: boolean;
|
|
15
|
+
isCrop?: boolean;
|
|
16
|
+
request?: (data: any) => any;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
declare const CustomUpload: ({ value, onChange, isDragger, children, ...rest }: CustomUploadProps) => JSX.Element;
|
|
22
|
+
export default CustomUpload;
|