ztxkui 4.2.23-2 → 4.2.23-21
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/DemoCom/PrintContainerDemo.js +223 -70
- package/dist/TableDemo/data.js +1 -1
- package/dist/UI/Basic/index.d.ts +2 -0
- package/dist/UI/Basic/index.js +18 -0
- package/dist/UI/Form/index.d.ts +3 -0
- package/dist/UI/Form/index.js +187 -0
- package/dist/UI/Modal/hooks.d.ts +15 -0
- package/dist/UI/Modal/hooks.js +172 -0
- package/dist/UI/Modal/index.d.ts +3 -0
- package/dist/UI/Modal/index.js +46 -0
- package/dist/UI/Table/DefaultTable.d.ts +2 -0
- package/dist/UI/Table/DefaultTable.js +49 -0
- package/dist/UI/Table/EditTable.d.ts +2 -0
- package/dist/UI/Table/EditTable.js +259 -0
- package/dist/UI/Table/data.d.ts +10 -0
- package/dist/UI/Table/data.js +14 -0
- package/dist/UI/Table/index.d.ts +2 -0
- package/dist/UI/Table/index.js +5 -0
- package/dist/UI/index.d.ts +2 -0
- package/dist/UI/index.js +26 -0
- package/dist/components/EnhanceSelect/index.js +4 -0
- package/dist/components/Input/input.js +38 -13
- package/dist/components/PrintContainer/print-container.js +70 -30
- package/dist/components/ProForm/hooks.d.ts +23 -0
- package/dist/components/ProForm/hooks.js +209 -0
- package/dist/components/ProForm/index.d.ts +6 -0
- package/dist/components/ProForm/index.js +87 -0
- package/dist/components/ProForm/interface.d.ts +116 -0
- package/dist/components/ProForm/interface.js +1 -0
- package/dist/components/ProForm/items.d.ts +5 -0
- package/dist/components/ProForm/items.js +136 -0
- package/dist/components/ProForm/search-drawer.d.ts +11 -0
- package/dist/components/ProForm/search-drawer.js +76 -0
- package/dist/components/ProForm/setting.d.ts +5 -0
- package/dist/components/ProForm/setting.js +13 -0
- package/dist/components/ProFormList/index.d.ts +12 -0
- package/dist/components/ProFormList/index.js +34 -0
- package/dist/components/ProModal/ModalForm.d.ts +8 -0
- package/dist/components/ProModal/ModalForm.js +32 -0
- package/dist/components/ProModal/ModalTable.d.ts +8 -0
- package/dist/components/ProModal/ModalTable.js +32 -0
- package/dist/components/ProModal/hooks.d.ts +33 -0
- package/dist/components/ProModal/hooks.js +193 -0
- package/dist/components/ProModal/index.d.ts +17 -0
- package/dist/components/ProModal/index.js +80 -0
- package/dist/components/ProModal/interface.d.ts +47 -0
- package/dist/components/ProModal/interface.js +1 -0
- package/dist/components/ProTable/hooks.d.ts +28 -0
- package/dist/components/ProTable/hooks.js +272 -0
- package/dist/components/ProTable/index.d.ts +8 -0
- package/dist/components/ProTable/index.js +76 -0
- package/dist/components/ProTable/interface.d.ts +51 -0
- package/dist/components/ProTable/interface.js +1 -0
- package/dist/components/Table/hooks/useColumns.d.ts +4 -4
- package/dist/components/Table/hooks/useColumns.js +227 -169
- package/dist/components/Table/hooks/useInnerPagination.js +1 -0
- package/dist/components/Table/table-adddel-column.d.ts +2 -1
- package/dist/components/Table/table-adddel-column.js +5 -3
- package/dist/components/Table/table-enhance-cell.d.ts +6 -3
- package/dist/components/Table/table-enhance-cell.js +119 -110
- package/dist/components/Table/table-enhance-row.d.ts +3 -4
- package/dist/components/Table/table-enhance-row.js +6 -10
- package/dist/components/Table/table-resizable-title.d.ts +4 -5
- package/dist/components/Table/table-resizable-title.js +31 -6
- package/dist/components/Table/table.d.ts +2 -0
- package/dist/components/Table/table.js +154 -150
- package/dist/components/Table/utils/shallowEqual.d.ts +2 -0
- package/dist/components/Table/utils/shallowEqual.js +34 -0
- package/dist/components/Table/utils/validate.js +0 -3
- package/dist/components/Tabs/DraggableTabNode.d.ts +7 -0
- package/dist/components/Tabs/DraggableTabNode.js +33 -0
- package/dist/components/Tabs/hooks.d.ts +3 -0
- package/dist/components/Tabs/hooks.js +59 -0
- package/dist/components/Tabs/tabs.d.ts +3 -0
- package/dist/components/Tabs/tabs.js +8 -2
- package/dist/components/business/Footer/index.d.ts +1 -0
- package/dist/components/business/Footer/index.js +18 -4
- package/dist/components/business/Signatures/components/QunjSeal.js +3 -2
- package/dist/components/business/Signatures/index.js +13 -14
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/index.css +327 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -1
- package/package.json +4 -4
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React, { useMemo } from 'react';
|
|
13
|
+
import { Input, EnhanceSelect, DatePicker } from '../../index';
|
|
14
|
+
import { Select } from 'antd';
|
|
15
|
+
import dayjs from 'dayjs';
|
|
16
|
+
var getLastMonth = function () {
|
|
17
|
+
var date = [];
|
|
18
|
+
var start = dayjs().subtract(1, 'month').format('YYYY-MM') + '-01';
|
|
19
|
+
var end = dayjs(start)
|
|
20
|
+
.subtract(-1, 'month')
|
|
21
|
+
.add(-1, 'days')
|
|
22
|
+
.format('YYYY-MM-DD');
|
|
23
|
+
date.push(dayjs(start));
|
|
24
|
+
date.push(dayjs(end));
|
|
25
|
+
return date;
|
|
26
|
+
};
|
|
27
|
+
export var RANGEPICKER_RANGES = {
|
|
28
|
+
此刻: [dayjs(), dayjs()],
|
|
29
|
+
最近7天: [dayjs().subtract(6, 'days'), dayjs().subtract(0, 'days')],
|
|
30
|
+
最近30天: [dayjs().subtract(29, 'days'), dayjs().subtract(0, 'days')],
|
|
31
|
+
上月: getLastMonth(),
|
|
32
|
+
本月: [dayjs().startOf('month'), dayjs().endOf('month')],
|
|
33
|
+
上季度: [
|
|
34
|
+
dayjs()
|
|
35
|
+
.quarter(dayjs().quarter() - 1)
|
|
36
|
+
.startOf('quarter'),
|
|
37
|
+
dayjs()
|
|
38
|
+
.quarter(dayjs().quarter() - 1)
|
|
39
|
+
.endOf('quarter'),
|
|
40
|
+
],
|
|
41
|
+
本季度: [dayjs().startOf('quarter'), dayjs().endOf('quarter')],
|
|
42
|
+
上一年: [
|
|
43
|
+
dayjs()
|
|
44
|
+
.year(dayjs().year() - 1)
|
|
45
|
+
.startOf('year'),
|
|
46
|
+
dayjs()
|
|
47
|
+
.year(dayjs().year() - 1)
|
|
48
|
+
.endOf('year'),
|
|
49
|
+
],
|
|
50
|
+
本年: [dayjs().startOf('year'), dayjs().endOf('year')],
|
|
51
|
+
};
|
|
52
|
+
export function useForm() {
|
|
53
|
+
var items = useMemo(function () {
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
name: 'test1',
|
|
57
|
+
label: '测试1',
|
|
58
|
+
render: function (itemProps) { return React.createElement(Input, __assign({}, itemProps, { allowClear: true })); },
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'test2',
|
|
62
|
+
label: '测试2',
|
|
63
|
+
render: function (itemProps) { return (React.createElement(Select, __assign({}, itemProps, { allowClear: true }),
|
|
64
|
+
React.createElement(Select.Option, { value: 1 }, "1"),
|
|
65
|
+
React.createElement(Select.Option, { value: 2 }, "2"))); },
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'companyId',
|
|
69
|
+
label: '公司',
|
|
70
|
+
render: function (itemProps) { return (React.createElement(EnhanceSelect, __assign({}, itemProps, { list: [
|
|
71
|
+
{ id: '1', name: '小明' },
|
|
72
|
+
{ id: '2', name: '小虎' },
|
|
73
|
+
], allowClear: true }))); },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'depId',
|
|
77
|
+
label: '部门',
|
|
78
|
+
render: function (itemProps) { return (React.createElement(EnhanceSelect, __assign({}, itemProps, { list: [
|
|
79
|
+
{ id: '1', name: '小明' },
|
|
80
|
+
{ id: '2', name: '小虎' },
|
|
81
|
+
], allowClear: true }))); },
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'createTime',
|
|
85
|
+
label: '时间',
|
|
86
|
+
render: function (itemProps) { return (React.createElement(DatePicker.RangePicker, __assign({}, itemProps, { ranges: RANGEPICKER_RANGES }))); },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'oneTime',
|
|
90
|
+
label: '时间1',
|
|
91
|
+
render: function (itemProps) { return React.createElement(DatePicker, __assign({}, itemProps)); },
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}, []);
|
|
95
|
+
// 时间转换
|
|
96
|
+
var dateTransformToString = useMemo(function () {
|
|
97
|
+
return {
|
|
98
|
+
fromKey: ['createTime', 'oneTime'],
|
|
99
|
+
toKey: [['startTime', 'endTime'], 'oneTimeEnd'],
|
|
100
|
+
format: ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD'],
|
|
101
|
+
type: 'string',
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
104
|
+
// 外部初始值
|
|
105
|
+
var outsideParams = useMemo(function () {
|
|
106
|
+
return {
|
|
107
|
+
test1: '22',
|
|
108
|
+
test2: 1,
|
|
109
|
+
createTime: [dayjs().subtract(30, 'days'), dayjs().subtract(0, 'days')],
|
|
110
|
+
};
|
|
111
|
+
}, []);
|
|
112
|
+
return {
|
|
113
|
+
items: items,
|
|
114
|
+
outsideParams: outsideParams,
|
|
115
|
+
dateTransformToString: dateTransformToString,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function useTable() {
|
|
119
|
+
var columns = [
|
|
120
|
+
{
|
|
121
|
+
title: '测试列3',
|
|
122
|
+
width: 100,
|
|
123
|
+
dataIndex: 'test3',
|
|
124
|
+
key: 'test3',
|
|
125
|
+
// 普通输入框配置
|
|
126
|
+
editable: true,
|
|
127
|
+
// 配置列的验证规则,这种是最普通的非空校验
|
|
128
|
+
validate: {},
|
|
129
|
+
shouldCellUpdate: function (record, preRecord) {
|
|
130
|
+
return record.test3 !== preRecord.test3;
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: '测试列2',
|
|
135
|
+
width: 100,
|
|
136
|
+
dataIndex: 'test2',
|
|
137
|
+
key: 'test2',
|
|
138
|
+
// 普通输入框配置
|
|
139
|
+
editable: true,
|
|
140
|
+
// 配置列的验证规则,这种是最普通的非空校验
|
|
141
|
+
validate: {},
|
|
142
|
+
shouldCellUpdate: function (record, preRecord) {
|
|
143
|
+
return record.test2 !== preRecord.test2;
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
title: '测试列1',
|
|
148
|
+
width: 100,
|
|
149
|
+
dataIndex: 'test1',
|
|
150
|
+
key: 'test1',
|
|
151
|
+
// 普通输入框配置
|
|
152
|
+
editable: true,
|
|
153
|
+
// 配置列的验证规则,这种是最普通的非空校验
|
|
154
|
+
validate: {},
|
|
155
|
+
shouldCellUpdate: function (record, preRecord) {
|
|
156
|
+
return record.test1 !== preRecord.test1;
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
var tablePropsReset = useMemo(function () {
|
|
161
|
+
return {
|
|
162
|
+
isEdit: true,
|
|
163
|
+
showColumnDynamic: true,
|
|
164
|
+
showColumnDynamicKey: 'modal-table-ui',
|
|
165
|
+
scroll: { x: 1000, y: 500 },
|
|
166
|
+
};
|
|
167
|
+
}, []);
|
|
168
|
+
return {
|
|
169
|
+
columns: columns,
|
|
170
|
+
tablePropsReset: tablePropsReset,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import ProModal, { useVisible } from 'components/ProModal';
|
|
3
|
+
import { Button } from '../../index';
|
|
4
|
+
import { data2 } from '../Table/data';
|
|
5
|
+
import { useForm, useTable } from './hooks';
|
|
6
|
+
function request(params) {
|
|
7
|
+
return new Promise(function (resolve) {
|
|
8
|
+
setTimeout(function () {
|
|
9
|
+
resolve(data2);
|
|
10
|
+
}, 2000);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
var Modal = function () {
|
|
14
|
+
var _a = useVisible(), visible = _a.visible, onClose = _a.onClose, onOpen = _a.onOpen;
|
|
15
|
+
// 表单配置相关信息
|
|
16
|
+
var _b = useForm(), items = _b.items, outsideParams = _b.outsideParams, dateTransformToString = _b.dateTransformToString;
|
|
17
|
+
// 已选中的选择项
|
|
18
|
+
var _c = useState(), selectedRowKeys = _c[0], setSelectedRowKeys = _c[1];
|
|
19
|
+
var _d = useState(), selectedRows = _d[0], setSelectedRows = _d[1];
|
|
20
|
+
var tablePropsChoiceFilterHandle = useCallback(function (record, selectedRowKeys, selectedRows) {
|
|
21
|
+
return {};
|
|
22
|
+
}, []);
|
|
23
|
+
// 选中后点击确认选择回调
|
|
24
|
+
var tablePropsOnSelectedRowChange = useCallback(function (selectedRowKeys, selectedRows) {
|
|
25
|
+
setSelectedRowKeys(selectedRowKeys);
|
|
26
|
+
setSelectedRows(selectedRows);
|
|
27
|
+
}, []);
|
|
28
|
+
// 当前选中项回调
|
|
29
|
+
var _e = useState(), childContent = _e[0], setChildContent = _e[1];
|
|
30
|
+
var tablePropsOnSelect = useCallback(function (record, selected, selectedRows) {
|
|
31
|
+
console.log(record, selected, selectedRows);
|
|
32
|
+
setChildContent(record);
|
|
33
|
+
}, []);
|
|
34
|
+
// 表格配置相关信息
|
|
35
|
+
var _f = useTable(), columns = _f.columns, tablePropsReset = _f.tablePropsReset;
|
|
36
|
+
return (React.createElement(React.Fragment, null,
|
|
37
|
+
React.createElement(Button, { onClick: function () { return onOpen(); } }, "\u5F00\u542F\u5F39\u6846"),
|
|
38
|
+
React.createElement(Button, { onClick: function () {
|
|
39
|
+
console.log(selectedRowKeys, selectedRows);
|
|
40
|
+
} }, "\u83B7\u53D6\u6570\u636E"),
|
|
41
|
+
React.createElement(ProModal, { title: "\u8BF7\u9009\u62E9", visible: visible, onClose: onClose, request: request, outsideParams: outsideParams, formPropsItems: items, formPropsDateTransform: dateTransformToString, tablePropsColumns: columns, tablePropsRowKey: "id", tablePropsReset: tablePropsReset, tablePropsIsChoice: true, tablePropsIsChoiceFilter: true, tablePropsSelectedRowKeys: selectedRowKeys, tablePropsSelectedRows: selectedRows, tablePropsChoiceFilterHandle: tablePropsChoiceFilterHandle, tablePropsOnSelectedRowChange: tablePropsOnSelectedRowChange, tablePropsOnSelect: tablePropsOnSelect, tablePropsIsRepeatChoice: true },
|
|
42
|
+
React.createElement("div", null,
|
|
43
|
+
"\u6211\u662F\u5B50\u8868",
|
|
44
|
+
JSON.stringify(childContent)))));
|
|
45
|
+
};
|
|
46
|
+
export default Modal;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// 普通的表格使用
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { ProTable } from '../../index';
|
|
4
|
+
import { data1 } from './data';
|
|
5
|
+
// 表格列配置相关逻辑
|
|
6
|
+
// 可以把columns定义成常量再最外面,或者state
|
|
7
|
+
function useColumns() {
|
|
8
|
+
var _a = useState([]), data = _a[0], setData = _a[1];
|
|
9
|
+
var columns = [
|
|
10
|
+
{
|
|
11
|
+
title: '序号',
|
|
12
|
+
width: 62,
|
|
13
|
+
fixed: 'left',
|
|
14
|
+
key: 'index',
|
|
15
|
+
render: function (_text, _record, index) { return "" + (index + 1); },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: '测试列1',
|
|
19
|
+
width: 100,
|
|
20
|
+
dataIndex: 'test1',
|
|
21
|
+
key: 'test1',
|
|
22
|
+
showCopy: true,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: '测试列2',
|
|
26
|
+
width: 100,
|
|
27
|
+
dataIndex: 'test2',
|
|
28
|
+
key: 'test2',
|
|
29
|
+
showCopy: true,
|
|
30
|
+
render: function (_text, _record, index) {
|
|
31
|
+
return _text + '自定义添加';
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
setTimeout(function () {
|
|
37
|
+
setData(data1);
|
|
38
|
+
}, 300);
|
|
39
|
+
}, []);
|
|
40
|
+
return { columns: columns, data: data };
|
|
41
|
+
}
|
|
42
|
+
export default function DefaultTable() {
|
|
43
|
+
var _a = useColumns(), columns = _a.columns, data = _a.data;
|
|
44
|
+
return (React.createElement(ProTable, { rowKey: "id", columns: columns, dataSource: data,
|
|
45
|
+
// 是否开启动态列配置
|
|
46
|
+
showColumnDynamic: true,
|
|
47
|
+
// 动态列配置必须参数,唯一的键值
|
|
48
|
+
showColumnDynamicKey: "single-local-key-001" }));
|
|
49
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
38
|
+
var t = {};
|
|
39
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
40
|
+
t[p] = s[p];
|
|
41
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
42
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
43
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
44
|
+
t[p[i]] = s[p[i]];
|
|
45
|
+
}
|
|
46
|
+
return t;
|
|
47
|
+
};
|
|
48
|
+
// 带编辑属性的表格使用
|
|
49
|
+
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
50
|
+
import { data2 } from './data';
|
|
51
|
+
import ProEditTable from 'components/ProTable';
|
|
52
|
+
import { Button, message, EnhanceSelect } from '../../index';
|
|
53
|
+
// 表格列配置相关逻辑
|
|
54
|
+
// 可以把columns定义成常量再最外面,或者state
|
|
55
|
+
// 编辑列的配置需要注意的点
|
|
56
|
+
// 1. 对于编辑想的scu配置,因为里面存在比较复杂的render
|
|
57
|
+
// 2. 如果是input 或者inputNumber可以通过配置实现
|
|
58
|
+
// 3. 可以通过配置校验规则 验证表格
|
|
59
|
+
// 4. 自定义render 需要调用表格提供的修改数据方法
|
|
60
|
+
function useColumns(tableHandleRef) {
|
|
61
|
+
var _a = useState([]), data = _a[0], setData = _a[1];
|
|
62
|
+
var columns = [
|
|
63
|
+
{
|
|
64
|
+
title: '序号',
|
|
65
|
+
width: 62,
|
|
66
|
+
fixed: 'left',
|
|
67
|
+
key: 'index',
|
|
68
|
+
render: function (_text, _record, index) { return "" + (index + 1); },
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: '测试列1',
|
|
72
|
+
width: 100,
|
|
73
|
+
dataIndex: 'test1',
|
|
74
|
+
key: 'test1',
|
|
75
|
+
showCopy: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: '测试列2',
|
|
79
|
+
width: 100,
|
|
80
|
+
dataIndex: 'test2',
|
|
81
|
+
key: 'test2',
|
|
82
|
+
showCopy: true,
|
|
83
|
+
render: function (_text, _record, index) {
|
|
84
|
+
return _text + '自定义添加';
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: '测试列3',
|
|
89
|
+
width: 100,
|
|
90
|
+
dataIndex: 'test3',
|
|
91
|
+
key: 'test3',
|
|
92
|
+
showCopy: true,
|
|
93
|
+
// 普通输入框配置
|
|
94
|
+
editable: true,
|
|
95
|
+
// 配置列的验证规则,这种是最普通的非空校验
|
|
96
|
+
validate: {},
|
|
97
|
+
shouldCellUpdate: function (record, preRecord) {
|
|
98
|
+
return record.test3 !== preRecord.test3;
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
title: '测试列4',
|
|
103
|
+
width: 100,
|
|
104
|
+
dataIndex: 'test4',
|
|
105
|
+
key: 'test4',
|
|
106
|
+
showCopy: true,
|
|
107
|
+
editable: true,
|
|
108
|
+
editableConfig: {
|
|
109
|
+
type: 'input',
|
|
110
|
+
placeholder: '输入',
|
|
111
|
+
},
|
|
112
|
+
// 配置列的验证规则,实现自定义校验
|
|
113
|
+
validate: {
|
|
114
|
+
validate: function (value, record, index, title) {
|
|
115
|
+
// value 当前输入值
|
|
116
|
+
// record 当前行数据
|
|
117
|
+
// index 当前行
|
|
118
|
+
// title 列头
|
|
119
|
+
if (value === '我是张飞') {
|
|
120
|
+
// 返回错误格式,为了迎合表单的校验
|
|
121
|
+
return Promise.reject({
|
|
122
|
+
errorFields: [
|
|
123
|
+
{
|
|
124
|
+
errors: "\u67D0\u67D0\u8868\u683C \u7B2C" + index + "\u884C " + title + " \u4E0D\u80FD\u4E3A\u5F20\u98DE\uFF01",
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return Promise.resolve();
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
shouldCellUpdate: function (record, preRecord) {
|
|
133
|
+
return record.test4 !== preRecord.test4;
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
title: '测试列5',
|
|
138
|
+
width: 100,
|
|
139
|
+
dataIndex: 'test5',
|
|
140
|
+
key: 'test5',
|
|
141
|
+
showCopy: true,
|
|
142
|
+
editable: true,
|
|
143
|
+
// 可以增加一些编辑列的配置,目前只建议使用 inputNumber 或者input
|
|
144
|
+
// input的话 可以不使用这个配置 默认就是input
|
|
145
|
+
editableConfig: {
|
|
146
|
+
type: 'inputNumber',
|
|
147
|
+
placeholder: '输入',
|
|
148
|
+
},
|
|
149
|
+
shouldCellUpdate: function (record, preRecord) {
|
|
150
|
+
return record.test5 !== preRecord.test5;
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title: '测试列6',
|
|
155
|
+
width: 100,
|
|
156
|
+
dataIndex: 'test6',
|
|
157
|
+
key: 'test6',
|
|
158
|
+
shouldCellUpdate: function (record, preRecord) {
|
|
159
|
+
return record.test6 !== preRecord.test6;
|
|
160
|
+
},
|
|
161
|
+
// 自定义render的话 需要手动调用表格的修改数据方法,只传递当前值
|
|
162
|
+
render: function (_text, _record, index) {
|
|
163
|
+
return (React.createElement(EnhanceSelect, { value: _text, list: [
|
|
164
|
+
{
|
|
165
|
+
id: '1',
|
|
166
|
+
name: '小明',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: '2',
|
|
170
|
+
name: '小李',
|
|
171
|
+
},
|
|
172
|
+
], onChange: function (value, option, fullData) {
|
|
173
|
+
var _a;
|
|
174
|
+
var newRecord = {
|
|
175
|
+
test6: value,
|
|
176
|
+
test6Name: fullData.name,
|
|
177
|
+
};
|
|
178
|
+
(_a = tableHandleRef.current) === null || _a === void 0 ? void 0 : _a.onEditableSaveHandle(newRecord, index);
|
|
179
|
+
} }));
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
useEffect(function () {
|
|
184
|
+
setTimeout(function () {
|
|
185
|
+
setData(data2);
|
|
186
|
+
}, 300);
|
|
187
|
+
}, []);
|
|
188
|
+
return { columns: columns, data: data, setData: setData };
|
|
189
|
+
}
|
|
190
|
+
export default function EditTable() {
|
|
191
|
+
var _this = this;
|
|
192
|
+
var tableHandleRef = useRef({});
|
|
193
|
+
var _a = useColumns(tableHandleRef), columns = _a.columns, data = _a.data, setData = _a.setData;
|
|
194
|
+
var _b = useState(1), num = _b[0], setNum = _b[1];
|
|
195
|
+
useEffect(function () {
|
|
196
|
+
setNum(2);
|
|
197
|
+
}, []);
|
|
198
|
+
// 触发onChange事件
|
|
199
|
+
var onChange = useCallback(function (dataSource, info) {
|
|
200
|
+
setData(dataSource);
|
|
201
|
+
}, [setData]);
|
|
202
|
+
// 选中相关
|
|
203
|
+
var _c = useState(), selectedRowKeys = _c[0], setSelectedRowKeys = _c[1];
|
|
204
|
+
var _d = useState(), setSelectedRows = _d[1];
|
|
205
|
+
var onSelectedRowChange = useCallback(function (selectedRowKeys, selectedRows) {
|
|
206
|
+
setSelectedRowKeys(selectedRowKeys);
|
|
207
|
+
setSelectedRows(selectedRows);
|
|
208
|
+
}, []);
|
|
209
|
+
return (React.createElement("div", null,
|
|
210
|
+
React.createElement(Button, { onClick: function () {
|
|
211
|
+
console.log(data, selectedRowKeys);
|
|
212
|
+
} },
|
|
213
|
+
"\u83B7\u53D6\u6570\u636E",
|
|
214
|
+
num),
|
|
215
|
+
React.createElement(Button, { onClick: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
216
|
+
var err_1, errorFields;
|
|
217
|
+
var _a;
|
|
218
|
+
return __generator(this, function (_b) {
|
|
219
|
+
switch (_b.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
_b.trys.push([0, 2, , 3]);
|
|
222
|
+
return [4 /*yield*/, ((_a = tableHandleRef.current) === null || _a === void 0 ? void 0 : _a.validate())];
|
|
223
|
+
case 1:
|
|
224
|
+
_b.sent();
|
|
225
|
+
return [3 /*break*/, 3];
|
|
226
|
+
case 2:
|
|
227
|
+
err_1 = _b.sent();
|
|
228
|
+
errorFields = err_1.errorFields;
|
|
229
|
+
if (errorFields) {
|
|
230
|
+
message.warning(errorFields[0].errors + '');
|
|
231
|
+
}
|
|
232
|
+
return [3 /*break*/, 3];
|
|
233
|
+
case 3: return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}); } }, "\u89E6\u53D1\u9A8C\u8BC1"),
|
|
237
|
+
React.createElement(ProEditTable, { rowKey: "id", columns: columns, dataSource: data,
|
|
238
|
+
// 调用表格内部提供的方法
|
|
239
|
+
tableHandleRef: tableHandleRef,
|
|
240
|
+
// 是否开启编辑,对于可编辑表格来说 这个属性很重要
|
|
241
|
+
isEdit: true,
|
|
242
|
+
// 是否开启拖拽
|
|
243
|
+
isMove: true,
|
|
244
|
+
// 是否可以批量复制,如果批量复制需要前置处理 或者后置处理 可通过提供方法处理
|
|
245
|
+
isPaste: true,
|
|
246
|
+
// 是否开启增减行
|
|
247
|
+
showDelIcon: true, showAddIcon: true,
|
|
248
|
+
// 增加数据的规则 是增加空白行 还是 复制一行
|
|
249
|
+
addDataMode: "blank", addDataReturnRecord: useCallback(function (record) {
|
|
250
|
+
var id = record.id, resetRecord = __rest(record, ["id"]);
|
|
251
|
+
return resetRecord;
|
|
252
|
+
}, []),
|
|
253
|
+
// 是否记录列宽,但是又不要显示那个按钮
|
|
254
|
+
showColumnDynamic: true, showColumnDynamicKey: "single-110011", hiddenColumnDynamicIcon: true,
|
|
255
|
+
// 开启内部分页
|
|
256
|
+
showInnerPagination: true, defaultInnerPageSize: 10,
|
|
257
|
+
// 是否选择
|
|
258
|
+
isChoice: true, selectedRowKeys: selectedRowKeys, onSelectedRowChange: onSelectedRowChange, onChange: onChange })));
|
|
259
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var data1 = new Array(50).fill(1).map(function (item, index) {
|
|
2
|
+
return {
|
|
3
|
+
id: "id-" + index,
|
|
4
|
+
test1: "test1-" + index,
|
|
5
|
+
test2: index + 100,
|
|
6
|
+
};
|
|
7
|
+
});
|
|
8
|
+
export var data2 = new Array(40).fill(1).map(function (item, index) {
|
|
9
|
+
return {
|
|
10
|
+
id: "id-" + index,
|
|
11
|
+
test1: "test1-" + index,
|
|
12
|
+
test2: index + 100,
|
|
13
|
+
};
|
|
14
|
+
});
|
package/dist/UI/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link, Switch, Route } from 'react-router-dom';
|
|
3
|
+
import DefaultTable from './Table/DefaultTable';
|
|
4
|
+
import EditTable from './Table/EditTable';
|
|
5
|
+
import Form from './Form';
|
|
6
|
+
import Modal from './Modal';
|
|
7
|
+
import Basic from './Basic';
|
|
8
|
+
export default function UIComponent() {
|
|
9
|
+
return (React.createElement("div", { style: { padding: '10px' } },
|
|
10
|
+
React.createElement(Link, { to: "/ui/default-table", style: { marginRight: '10px' } }, "\u7B80\u5355\u8868\u683C"),
|
|
11
|
+
React.createElement(Link, { to: "/ui/edit-table", style: { marginRight: '10px' } }, "\u53EF\u7F16\u8F91\u8868\u683C"),
|
|
12
|
+
React.createElement(Link, { to: "/ui/form", style: { marginRight: '10px' } }, "\u8868\u5355"),
|
|
13
|
+
React.createElement(Link, { to: "/ui/modal", style: { marginRight: '10px' } }, "\u5F39\u6846"),
|
|
14
|
+
React.createElement(Link, { to: "/ui/basic", style: { marginRight: '10px' } }, "\u57FA\u7840"),
|
|
15
|
+
React.createElement(Switch, null,
|
|
16
|
+
React.createElement(Route, { path: "/ui/default-table" },
|
|
17
|
+
React.createElement(DefaultTable, null)),
|
|
18
|
+
React.createElement(Route, { path: "/ui/edit-table" },
|
|
19
|
+
React.createElement(EditTable, null)),
|
|
20
|
+
React.createElement(Route, { path: "/ui/form" },
|
|
21
|
+
React.createElement(Form, null)),
|
|
22
|
+
React.createElement(Route, { path: "/ui/modal" },
|
|
23
|
+
React.createElement(Modal, null)),
|
|
24
|
+
React.createElement(Route, { path: "/ui/basic" },
|
|
25
|
+
React.createElement(Basic, null)))));
|
|
26
|
+
}
|
|
@@ -104,6 +104,7 @@ function getData(request, options) {
|
|
|
104
104
|
options.data = options.params;
|
|
105
105
|
Reflect.deleteProperty(options, 'params');
|
|
106
106
|
}
|
|
107
|
+
options.isCatch = true;
|
|
107
108
|
return request(options);
|
|
108
109
|
}
|
|
109
110
|
return Promise.resolve({
|
|
@@ -549,6 +550,8 @@ function EnhanceSelect(_a) {
|
|
|
549
550
|
var catchDataKey = params ? JSON.stringify(params) : 'single';
|
|
550
551
|
if (catchData[catchDataKey]) {
|
|
551
552
|
// 读取缓存数据
|
|
553
|
+
fetchId.current++; // fetchId +1 防止之前的请求覆盖之后的数据
|
|
554
|
+
setLoading(false);
|
|
552
555
|
setSelectList(catchData[catchDataKey]);
|
|
553
556
|
}
|
|
554
557
|
else {
|
|
@@ -601,6 +604,7 @@ function EnhanceSelect(_a) {
|
|
|
601
604
|
sendRequest,
|
|
602
605
|
setSelectList,
|
|
603
606
|
url,
|
|
607
|
+
setLoading,
|
|
604
608
|
]);
|
|
605
609
|
// 3、远程搜索,url必须传递
|
|
606
610
|
// 关于远程查询,最好的做法还是后台根据主键再去查一次详情数据,这样就能保证
|