zmdms-webui 0.0.4 → 0.0.6
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/README.md +22 -12
- package/dist/es/_virtual/_tslib.js +39 -1
- package/dist/es/button/button.d.ts +5 -3
- package/dist/es/button/button.js +7 -18
- package/dist/es/detaillist/index.d.ts +5 -0
- package/dist/es/detaillist/index.js +5 -0
- package/dist/es/detaillist/item.d.ts +21 -0
- package/dist/es/detaillist/item.js +26 -0
- package/dist/es/detaillist/list.d.ts +15 -0
- package/dist/es/detaillist/list.js +19 -0
- package/dist/es/dynamicsetting/dynamicSetting.d.ts +2 -2
- package/dist/es/dynamicsetting/interface.d.ts +6 -1
- package/dist/es/dynamicsetting/useDynamic.js +2 -0
- package/dist/es/footer/footer.js +1 -1
- package/dist/es/forgetpassword/forgetPassword.js +2 -2
- package/dist/es/form/detaultDom.js +11 -0
- package/dist/es/form/form.d.ts +1 -0
- package/dist/es/form/form.js +8 -5
- package/dist/es/form/formItems.js +4 -2
- package/dist/es/form/hooks.js +8 -8
- package/dist/es/form/interface.d.ts +5 -4
- package/dist/es/formitem/formItem.js +26 -9
- package/dist/es/login/index.d.ts +1 -0
- package/dist/es/login/index.js +2 -2
- package/dist/es/modal/index.d.ts +5 -0
- package/dist/es/modal/index.js +5 -0
- package/dist/es/modal/interface.d.ts +16 -0
- package/dist/es/modal/modal.d.ts +5 -0
- package/dist/es/modal/modal.js +34 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/MinusOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/MinusSquareOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/PicRightOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/PlusOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/MinusOutlined.js +5 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/MinusSquareOutlined.js +5 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/PicRightOutlined.js +5 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/PlusOutlined.js +5 -0
- package/dist/es/table/components/ColumnAddDel.js +21 -0
- package/dist/es/table/components/ColumnDynamic.js +14 -0
- package/dist/es/table/components/CopyIcon.js +4 -2
- package/dist/es/table/components/EnhanceCell.js +17 -6
- package/dist/es/table/components/EnhanceRow.js +12 -2
- package/dist/es/table/components/hooks.js +18 -2
- package/dist/es/table/components/useDragRef.js +56 -0
- package/dist/es/table/constant.js +6 -2
- package/dist/es/table/hooks.js +154 -5
- package/dist/es/table/interface.d.ts +51 -4
- package/dist/es/table/table.js +122 -16
- package/dist/es/table/useColumns.js +47 -4
- package/dist/es/table/useDynamicListByColumns.js +1 -1
- package/dist/es/table/useInnerPagination.js +60 -0
- package/dist/es/table/useSummary.js +286 -0
- package/dist/es/table/useTableValidate.js +208 -0
- package/dist/es/table/utils.js +4 -3
- package/dist/index.build.d.ts +3 -1
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/dist/index.es.js +3 -1
- package/dist/index.umd.js +2 -2
- package/package.json +5 -2
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
|
+
import { useRef, useCallback } from 'react';
|
|
3
|
+
import { ERROR_TD_CLASSNAME } from './constant.js';
|
|
4
|
+
|
|
5
|
+
function useTableValidate() {
|
|
6
|
+
var tableRef = useRef();
|
|
7
|
+
var getCurrentTable = useCallback(function () {
|
|
8
|
+
var _a;
|
|
9
|
+
var tableContent = domFind(tableRef.current, ".ant-table-content");
|
|
10
|
+
if (!tableContent) {
|
|
11
|
+
tableContent = domFind(tableRef.current, ".ant-table-container");
|
|
12
|
+
}
|
|
13
|
+
var tableBody = domFind(tableContent, ".ant-table-tbody");
|
|
14
|
+
var tr = tableBody === null || tableBody === void 0 ? void 0 : tableBody.children;
|
|
15
|
+
var arrTr = Array.prototype.slice.call(tr);
|
|
16
|
+
var resultTr = ((_a = arrTr === null || arrTr === void 0 ? void 0 : arrTr.filter) === null || _a === void 0 ? void 0 : _a.call(arrTr, function (item) { return item.className.includes("ant-table-row"); })) || [];
|
|
17
|
+
return { tableBody: tableBody, resultTr: resultTr };
|
|
18
|
+
}, []);
|
|
19
|
+
var clearErrorClass = useCallback(function (index) {
|
|
20
|
+
try {
|
|
21
|
+
var resultTr = getCurrentTable().resultTr;
|
|
22
|
+
if (typeof index === "number") {
|
|
23
|
+
var tds = resultTr[index].querySelectorAll("td");
|
|
24
|
+
for (var i = 0; i < tds.length; i++) {
|
|
25
|
+
tds[i].classList.remove(ERROR_TD_CLASSNAME);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
for (var i = 0; i < resultTr.length; i++) {
|
|
30
|
+
var tds = resultTr[i].querySelectorAll("td");
|
|
31
|
+
for (var j = 0; j < tds.length; j++) {
|
|
32
|
+
tds[j].classList.remove(ERROR_TD_CLASSNAME);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
console.log(err);
|
|
39
|
+
}
|
|
40
|
+
}, [getCurrentTable]);
|
|
41
|
+
return {
|
|
42
|
+
tableRef: tableRef,
|
|
43
|
+
getCurrentTable: getCurrentTable,
|
|
44
|
+
clearErrorClass: clearErrorClass,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// 获取当前表格
|
|
48
|
+
function domFind(el, selector) {
|
|
49
|
+
return el.querySelector(selector);
|
|
50
|
+
}
|
|
51
|
+
function tableValidate(dataSource, columns, restParams) {
|
|
52
|
+
var _a;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var getCurrentTable, rowSelection, expandable, tableName, isInnerPagination, setCurrent, pageSize, requiredFileds, i, item, _loop_1, j, state_1;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
getCurrentTable = restParams.getCurrentTable, rowSelection = restParams.rowSelection, expandable = restParams.expandable, tableName = restParams.tableName, isInnerPagination = restParams.isInnerPagination, setCurrent = restParams.setCurrent, pageSize = restParams.pageSize;
|
|
59
|
+
if (!Array.isArray(dataSource) || dataSource.length === 0) {
|
|
60
|
+
console.info("没有数据,无需验证!");
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
}
|
|
63
|
+
if (!Array.isArray(columns)) {
|
|
64
|
+
console.info("columns 不是数组!");
|
|
65
|
+
return [2 /*return*/];
|
|
66
|
+
}
|
|
67
|
+
requiredFileds = [];
|
|
68
|
+
if (Array.isArray(columns)) {
|
|
69
|
+
columns.forEach(function (column, index) {
|
|
70
|
+
if (column.validate) {
|
|
71
|
+
requiredFileds.push({
|
|
72
|
+
dataIndex: column.validate.dataIndex || column.dataIndex,
|
|
73
|
+
title: column.validate.title || column.title,
|
|
74
|
+
validate: column.validate.validate,
|
|
75
|
+
index: index + (rowSelection ? 1 : 0) + (expandable ? 1 : 0),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
i = 0;
|
|
81
|
+
_b.label = 1;
|
|
82
|
+
case 1:
|
|
83
|
+
if (!(i < dataSource.length)) return [3 /*break*/, 6];
|
|
84
|
+
item = dataSource[i];
|
|
85
|
+
_loop_1 = function (j) {
|
|
86
|
+
var _c, dataIndex, title, validate, index, value, setElementState, innerCurrentI, currentPage, err_1;
|
|
87
|
+
return __generator(this, function (_d) {
|
|
88
|
+
switch (_d.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
_c = requiredFileds[j], dataIndex = _c.dataIndex, title = _c.title, validate = _c.validate, index = _c.index;
|
|
91
|
+
if (!dataIndex) {
|
|
92
|
+
return [2 /*return*/, "break"];
|
|
93
|
+
}
|
|
94
|
+
value = item[dataIndex];
|
|
95
|
+
setElementState = function (i, index, className) {
|
|
96
|
+
var _a, _b, _c;
|
|
97
|
+
// 获取表格元素
|
|
98
|
+
var resultTr = getCurrentTable().resultTr;
|
|
99
|
+
var errorTr = resultTr[i];
|
|
100
|
+
var errorTds = Array.prototype.slice.call(errorTr === null || errorTr === void 0 ? void 0 : errorTr.children);
|
|
101
|
+
var errorTd = typeof index === "number" ? errorTds[index] : null;
|
|
102
|
+
(_b = (_a = errorTd === null || errorTd === void 0 ? void 0 : errorTd.classList) === null || _a === void 0 ? void 0 : _a.add) === null || _b === void 0 ? void 0 : _b.call(_a, className);
|
|
103
|
+
(_c = errorTd === null || errorTd === void 0 ? void 0 : errorTd.scrollIntoView) === null || _c === void 0 ? void 0 : _c.call(errorTd);
|
|
104
|
+
};
|
|
105
|
+
innerCurrentI = i;
|
|
106
|
+
currentPage = 1;
|
|
107
|
+
if (isInnerPagination) {
|
|
108
|
+
currentPage = Math.ceil((i + 1) / pageSize);
|
|
109
|
+
innerCurrentI = innerCurrentI - pageSize * (currentPage - 1);
|
|
110
|
+
}
|
|
111
|
+
if (!validate) return [3 /*break*/, 10];
|
|
112
|
+
if (!(typeof validate === "function")) return [3 /*break*/, 5];
|
|
113
|
+
_d.label = 1;
|
|
114
|
+
case 1:
|
|
115
|
+
_d.trys.push([1, 3, , 4]);
|
|
116
|
+
return [4 /*yield*/, validate(value, item, innerCurrentI + 1, title)];
|
|
117
|
+
case 2:
|
|
118
|
+
_d.sent();
|
|
119
|
+
return [3 /*break*/, 4];
|
|
120
|
+
case 3:
|
|
121
|
+
err_1 = _d.sent();
|
|
122
|
+
if (isInnerPagination) {
|
|
123
|
+
setCurrent(currentPage);
|
|
124
|
+
setTimeout(function () {
|
|
125
|
+
setElementState(innerCurrentI, index, ERROR_TD_CLASSNAME);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
setElementState(i, index, ERROR_TD_CLASSNAME);
|
|
130
|
+
}
|
|
131
|
+
return [2 /*return*/, { value: Promise.reject(err_1) }];
|
|
132
|
+
case 4: return [3 /*break*/, 9];
|
|
133
|
+
case 5:
|
|
134
|
+
if (!!((_a = validate === null || validate === void 0 ? void 0 : validate.pattern) === null || _a === void 0 ? void 0 : _a.test(value))) return [3 /*break*/, 9];
|
|
135
|
+
if (!isInnerPagination) return [3 /*break*/, 7];
|
|
136
|
+
setCurrent(currentPage);
|
|
137
|
+
setTimeout(function () {
|
|
138
|
+
setElementState(innerCurrentI, index, ERROR_TD_CLASSNAME);
|
|
139
|
+
});
|
|
140
|
+
return [4 /*yield*/, Promise.reject({
|
|
141
|
+
errors: "".concat(tableName || "", " \u7B2C").concat(innerCurrentI + 1, "\u884C ").concat(title, " ").concat((validate === null || validate === void 0 ? void 0 : validate.message) || "填写错误!"),
|
|
142
|
+
})];
|
|
143
|
+
case 6:
|
|
144
|
+
_d.sent();
|
|
145
|
+
return [3 /*break*/, 9];
|
|
146
|
+
case 7:
|
|
147
|
+
setElementState(i, index, ERROR_TD_CLASSNAME);
|
|
148
|
+
return [4 /*yield*/, Promise.reject({
|
|
149
|
+
errors: "".concat(tableName || "", " \u7B2C").concat(i + 1, "\u884C ").concat(title, " ").concat((validate === null || validate === void 0 ? void 0 : validate.message) || "填写错误!"),
|
|
150
|
+
})];
|
|
151
|
+
case 8:
|
|
152
|
+
_d.sent();
|
|
153
|
+
_d.label = 9;
|
|
154
|
+
case 9: return [3 /*break*/, 14];
|
|
155
|
+
case 10:
|
|
156
|
+
if (!(value === "" || value == null)) return [3 /*break*/, 14];
|
|
157
|
+
if (!isInnerPagination) return [3 /*break*/, 12];
|
|
158
|
+
setCurrent(currentPage);
|
|
159
|
+
setTimeout(function () {
|
|
160
|
+
setElementState(innerCurrentI, index, ERROR_TD_CLASSNAME);
|
|
161
|
+
});
|
|
162
|
+
return [4 /*yield*/, Promise.reject({
|
|
163
|
+
errors: "".concat(tableName || "", " \u7B2C").concat(innerCurrentI + 1, "\u884C ").concat(title, " \u4E3A\u7A7A!"),
|
|
164
|
+
rowIndex: i,
|
|
165
|
+
colIndex: index,
|
|
166
|
+
})];
|
|
167
|
+
case 11:
|
|
168
|
+
_d.sent();
|
|
169
|
+
return [3 /*break*/, 14];
|
|
170
|
+
case 12:
|
|
171
|
+
setElementState(i, index, ERROR_TD_CLASSNAME);
|
|
172
|
+
return [4 /*yield*/, Promise.reject({
|
|
173
|
+
errors: "".concat(tableName || "", " \u7B2C").concat(i + 1, "\u884C ").concat(title, " \u4E3A\u7A7A!"),
|
|
174
|
+
rowIndex: i,
|
|
175
|
+
colIndex: index,
|
|
176
|
+
})];
|
|
177
|
+
case 13:
|
|
178
|
+
_d.sent();
|
|
179
|
+
_d.label = 14;
|
|
180
|
+
case 14: return [2 /*return*/];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
j = 0;
|
|
185
|
+
_b.label = 2;
|
|
186
|
+
case 2:
|
|
187
|
+
if (!(j < requiredFileds.length)) return [3 /*break*/, 5];
|
|
188
|
+
return [5 /*yield**/, _loop_1(j)];
|
|
189
|
+
case 3:
|
|
190
|
+
state_1 = _b.sent();
|
|
191
|
+
if (typeof state_1 === "object")
|
|
192
|
+
return [2 /*return*/, state_1.value];
|
|
193
|
+
if (state_1 === "break")
|
|
194
|
+
return [3 /*break*/, 5];
|
|
195
|
+
_b.label = 4;
|
|
196
|
+
case 4:
|
|
197
|
+
j++;
|
|
198
|
+
return [3 /*break*/, 2];
|
|
199
|
+
case 5:
|
|
200
|
+
i++;
|
|
201
|
+
return [3 /*break*/, 1];
|
|
202
|
+
case 6: return [2 /*return*/];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export { useTableValidate as default, domFind, tableValidate };
|
package/dist/es/table/utils.js
CHANGED
|
@@ -11,12 +11,13 @@ function getTableColumns(columns, currentDynamicList) {
|
|
|
11
11
|
var middleColumns_1 = [];
|
|
12
12
|
var afterColumns_1 = [];
|
|
13
13
|
// 先从动态列配置信息中 找出column并按配置信息进行排序
|
|
14
|
-
//
|
|
15
14
|
currentDynamicList.forEach(function (item) {
|
|
16
|
-
var key = item.key;
|
|
15
|
+
var key = item.key, checked = item.checked;
|
|
17
16
|
// 这里肯定是能找到的 因为之前就以columns过滤了一遍dynamicList了
|
|
18
17
|
var result = columns.find(function (column) {
|
|
19
|
-
return (column.key === key ||
|
|
18
|
+
return ((column.key === key ||
|
|
19
|
+
(column === null || column === void 0 ? void 0 : column.dataIndex) === key) &&
|
|
20
|
+
checked);
|
|
20
21
|
});
|
|
21
22
|
if (result) {
|
|
22
23
|
middleColumns_1.push(result);
|
package/dist/index.build.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ export { default as Footer } from './es/footer/footer.js';
|
|
|
17
17
|
export { default as Pagination } from './es/pagination/pagination.js';
|
|
18
18
|
export { default as Table } from './es/table/table.js';
|
|
19
19
|
export { default as Tabs } from './es/tabs/tabs.js';
|
|
20
|
+
export { default as Modal } from './es/modal/modal.js';
|
|
21
|
+
export { default as DetailList } from './es/detaillist/list.js';
|
|
20
22
|
export { default as AppLayout } from './es/applayout/appLayout.js';
|
|
21
23
|
export { default as AppLayoutHeader } from './es/applayoutheader/appLayoutHeader.js';
|
|
22
24
|
export { default as AppLayoutSider } from './es/applayoutsider/appLayoutSider.js';
|
|
23
|
-
export { Affix, Alert, Anchor, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Card, Carousel, Cascader, Checkbox, Collapse, Comment, ConfigProvider, Descriptions, Divider, Drawer, Dropdown, Empty, Grid, Image, Layout, List, Mentions, Menu,
|
|
25
|
+
export { Affix, Alert, Anchor, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Card, Carousel, Cascader, Checkbox, Col, Collapse, Comment, ConfigProvider, Descriptions, Divider, Drawer, Dropdown, Empty, Grid, Image, Layout, List, Mentions, Menu, PageHeader, Popconfirm, Popover, Progress, Radio, Rate, Result, Row, Segmented, Select, Skeleton, Slider, Space, Spin, Statistic, Steps, Switch, Tag, Timeline, Tooltip, Transfer, Tree, TreeSelect, Typography, Upload, message, notification } from 'antd';
|