ztxkutils 2.0.6 → 2.1.0
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/hooks/useTableValidate.d.ts +11 -4
- package/dist/hooks.js +4 -2
- package/package.json +1 -1
@@ -1,17 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* value 当前值
|
3
|
+
* record 当前行数据
|
4
|
+
* index 当前第几行
|
5
|
+
* title 当前列标题
|
6
|
+
*/
|
7
|
+
declare type validateFn = (value: any, record: any, index: number, title: string) => any;
|
1
8
|
interface IColumns {
|
2
9
|
dataIndex: string;
|
3
10
|
title: string;
|
4
|
-
required?: boolean;
|
11
|
+
required?: boolean | string;
|
5
12
|
validate?: {
|
6
13
|
pattern: any;
|
7
14
|
message?: string;
|
8
|
-
} |
|
15
|
+
} | validateFn;
|
9
16
|
[props: string]: any;
|
10
17
|
}
|
11
18
|
/**
|
12
19
|
* @description 表格验证相关操作
|
13
20
|
*/
|
14
|
-
declare function useTableValidate(records: any, columns: IColumns, tableName?: string): {
|
15
|
-
tableValidate: () => Promise<
|
21
|
+
declare function useTableValidate(records: any, columns: IColumns[], tableName?: string): {
|
22
|
+
tableValidate: () => Promise<void>;
|
16
23
|
};
|
17
24
|
export default useTableValidate;
|
package/dist/hooks.js
CHANGED
@@ -112,8 +112,10 @@ function useTableValidate(records, columns, tableName) {
|
|
112
112
|
value = item[key];
|
113
113
|
if (!validate) return [3 /*break*/, 7];
|
114
114
|
if (!(typeof validate === 'function')) return [3 /*break*/, 4];
|
115
|
-
return [4 /*yield*/, validate(value, item)];
|
116
|
-
case 3:
|
115
|
+
return [4 /*yield*/, validate(value, item, i + 1, title)];
|
116
|
+
case 3:
|
117
|
+
_c.sent();
|
118
|
+
return [3 /*break*/, 6];
|
117
119
|
case 4:
|
118
120
|
if (!!((_b = validate.pattern) === null || _b === void 0 ? void 0 : _b.test(value))) return [3 /*break*/, 6];
|
119
121
|
return [4 /*yield*/, Promise.reject({
|