ztxkutils 2.3.3 → 2.3.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/dist/constants.d.ts +28 -0
- package/dist/constants.js +31 -2
- package/dist/hooks/useTableValidate.d.ts +2 -2
- package/dist/hooks.js +3 -3
- package/dist/index.js +1 -1
- package/dist/tools-53fed4bb.js +241 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.js +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
@@ -4,3 +4,31 @@
|
|
4
4
|
*/
|
5
5
|
export declare const clientType = 1;
|
6
6
|
export declare const microPortalRoute = "/portal";
|
7
|
+
/**
|
8
|
+
* @description 是否隐藏业务系统框架结构key值
|
9
|
+
*/
|
10
|
+
export declare const WORKFLOW_HIDEFRAME_KEY = "hideFrame";
|
11
|
+
/**
|
12
|
+
* @description 通过地址栏传递token信息key值
|
13
|
+
*/
|
14
|
+
export declare const WORKFLOW_TOKEN = "token";
|
15
|
+
/**
|
16
|
+
* @description 父级通知获取子级表单高度
|
17
|
+
*/
|
18
|
+
export declare const WORKFLOW_GET_HEIGHT = "getHeight";
|
19
|
+
/**
|
20
|
+
* @description 子级发送表单高度给父级
|
21
|
+
*/
|
22
|
+
export declare const WORKFLOW_RETURN_HEIGHT = "returnHeight";
|
23
|
+
/**
|
24
|
+
* @description 父级通知子级保存数据
|
25
|
+
*/
|
26
|
+
export declare const WORKFLOW_SAVE_HANDLE = "submitBizForm";
|
27
|
+
/**
|
28
|
+
* @description 子级传递保存数据成功后,传递某些数据给父级
|
29
|
+
*/
|
30
|
+
export declare const WORKFLOW_TRANSMIT_HANDLE = "returnRelevantDatas";
|
31
|
+
/**
|
32
|
+
* @description 父级通知子级保存,流程实例数据
|
33
|
+
*/
|
34
|
+
export declare const WORKFLOW_SAVE_INSTID = "saveWorkfLow";
|
package/dist/constants.js
CHANGED
@@ -5,6 +5,35 @@
|
|
5
5
|
// web端客户端类型
|
6
6
|
var clientType = 1;
|
7
7
|
// 微前端入口路由
|
8
|
-
var microPortalRoute = '/portal';
|
8
|
+
var microPortalRoute = '/portal';
|
9
|
+
// 流程中心相关常量
|
10
|
+
/**
|
11
|
+
* @description 是否隐藏业务系统框架结构key值
|
12
|
+
*/
|
13
|
+
var WORKFLOW_HIDEFRAME_KEY = 'hideFrame';
|
14
|
+
/**
|
15
|
+
* @description 通过地址栏传递token信息key值
|
16
|
+
*/
|
17
|
+
var WORKFLOW_TOKEN = 'token';
|
18
|
+
/**
|
19
|
+
* @description 父级通知获取子级表单高度
|
20
|
+
*/
|
21
|
+
var WORKFLOW_GET_HEIGHT = 'getHeight';
|
22
|
+
/**
|
23
|
+
* @description 子级发送表单高度给父级
|
24
|
+
*/
|
25
|
+
var WORKFLOW_RETURN_HEIGHT = 'returnHeight';
|
26
|
+
/**
|
27
|
+
* @description 父级通知子级保存数据
|
28
|
+
*/
|
29
|
+
var WORKFLOW_SAVE_HANDLE = 'submitBizForm';
|
30
|
+
/**
|
31
|
+
* @description 子级传递保存数据成功后,传递某些数据给父级
|
32
|
+
*/
|
33
|
+
var WORKFLOW_TRANSMIT_HANDLE = 'returnRelevantDatas';
|
34
|
+
/**
|
35
|
+
* @description 父级通知子级保存,流程实例数据
|
36
|
+
*/
|
37
|
+
var WORKFLOW_SAVE_INSTID = 'saveWorkfLow';
|
9
38
|
|
10
|
-
export { clientType, microPortalRoute };
|
39
|
+
export { WORKFLOW_GET_HEIGHT, WORKFLOW_HIDEFRAME_KEY, WORKFLOW_RETURN_HEIGHT, WORKFLOW_SAVE_HANDLE, WORKFLOW_SAVE_INSTID, WORKFLOW_TOKEN, WORKFLOW_TRANSMIT_HANDLE, clientType, microPortalRoute };
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* index 当前第几行
|
5
5
|
* title 当前列标题
|
6
6
|
*/
|
7
|
-
declare type validateFn = (value: any, record: any, index: number, title: string) => any;
|
7
|
+
declare type validateFn = (value: any, record: any, index: number, title: string, expandProps?: any) => any;
|
8
8
|
interface IColumns {
|
9
9
|
dataIndex: string;
|
10
10
|
title: string;
|
@@ -18,7 +18,7 @@ interface IColumns {
|
|
18
18
|
/**
|
19
19
|
* @description 表格验证相关操作
|
20
20
|
*/
|
21
|
-
declare function useTableValidate(records: any, columns: IColumns[], tableName?: string): {
|
21
|
+
declare function useTableValidate(records: any, columns: IColumns[], tableName?: string, expandProps?: any): {
|
22
22
|
tableValidate: () => Promise<void>;
|
23
23
|
};
|
24
24
|
export default useTableValidate;
|
package/dist/hooks.js
CHANGED
@@ -79,7 +79,7 @@ function useFetchState(props) {
|
|
79
79
|
/**
|
80
80
|
* @description 表格验证相关操作
|
81
81
|
*/
|
82
|
-
function useTableValidate(records, columns, tableName) {
|
82
|
+
function useTableValidate(records, columns, tableName, expandProps) {
|
83
83
|
var _this = this;
|
84
84
|
var tableValidate = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
85
85
|
var requiredFileds, i, item, j, _a, key, title, validate, value;
|
@@ -118,7 +118,7 @@ function useTableValidate(records, columns, tableName) {
|
|
118
118
|
value = item[key];
|
119
119
|
if (!validate) return [3 /*break*/, 7];
|
120
120
|
if (!(typeof validate === 'function')) return [3 /*break*/, 4];
|
121
|
-
return [4 /*yield*/, validate(value, item, i + 1, title)];
|
121
|
+
return [4 /*yield*/, validate(value, item, i + 1, title, expandProps)];
|
122
122
|
case 3:
|
123
123
|
_c.sent();
|
124
124
|
return [3 /*break*/, 6];
|
@@ -154,7 +154,7 @@ function useTableValidate(records, columns, tableName) {
|
|
154
154
|
case 11: return [2 /*return*/];
|
155
155
|
}
|
156
156
|
});
|
157
|
-
}); }, [records, columns]);
|
157
|
+
}); }, [records, columns, expandProps]);
|
158
158
|
return {
|
159
159
|
tableValidate: tableValidate,
|
160
160
|
};
|
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { c as authority } from './authority-17b7fde2.js';
|
2
2
|
export { d as dataModel } from './dataModel-1fbaff40.js';
|
3
|
-
export { t as tools } from './tools-
|
3
|
+
export { t as tools } from './tools-53fed4bb.js';
|
4
4
|
export { v as validate } from './validate-ebe369e9.js';
|
5
5
|
export { r as request } from './request-35a68ae8.js';
|
6
6
|
export { r as reqUrl } from './reqUrl-93cf6870.js';
|
@@ -0,0 +1,241 @@
|
|
1
|
+
import { _ as __assign, a as __spreadArray } from './tslib.es6-f9459658.js';
|
2
|
+
import dayjs from 'dayjs';
|
3
|
+
import { divide as divide$1, round, plus, minus, times } from 'number-precision';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @description 时间格式转换
|
7
|
+
*/
|
8
|
+
function timeTransfrom(timeParams) {
|
9
|
+
var _a, _b, _c, _d, _e;
|
10
|
+
var params = timeParams.params, fromKey = timeParams.fromKey, toKey = timeParams.toKey, _f = timeParams.type, type = _f === void 0 ? 'string' : _f, format = timeParams.format;
|
11
|
+
var copyParams = __assign({}, params);
|
12
|
+
for (var i = 0; i < fromKey.length; i++) {
|
13
|
+
var fromKeyItem = fromKey[i];
|
14
|
+
var toKeyItem = toKey[i];
|
15
|
+
var formatItem = Array.isArray(format)
|
16
|
+
? format[i]
|
17
|
+
? format[i]
|
18
|
+
: 'YYYY-MM-DD'
|
19
|
+
: format
|
20
|
+
? format
|
21
|
+
: 'YYYY-MM-DD';
|
22
|
+
// 从一个键转换成两个键
|
23
|
+
if (typeof fromKeyItem === 'string' && typeof toKeyItem === 'object') {
|
24
|
+
if (type === 'string' && copyParams[fromKeyItem]) {
|
25
|
+
var _g = copyParams[fromKeyItem], startMoment = _g[0], endMoment = _g[1];
|
26
|
+
var start = void 0, end = void 0;
|
27
|
+
if (dayjs.isDayjs(startMoment)) {
|
28
|
+
start = startMoment.format(formatItem);
|
29
|
+
}
|
30
|
+
if (dayjs.isDayjs(endMoment)) {
|
31
|
+
end = endMoment.format(formatItem);
|
32
|
+
}
|
33
|
+
if (formatItem === 'YYYY-MM-DD HH:mm:ss') {
|
34
|
+
start = start.substr(0, 10) + ' 00:00:00';
|
35
|
+
end = end.substr(0, 10) + ' 23:59:59';
|
36
|
+
}
|
37
|
+
delete copyParams[fromKeyItem];
|
38
|
+
copyParams = __assign(__assign({}, copyParams), (_a = {}, _a[toKeyItem[0]] = start, _a[toKeyItem[1]] = end, _a));
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
copyParams = __assign(__assign({}, copyParams), (_b = {}, _b[toKeyItem[0]] = undefined, _b[toKeyItem[1]] = undefined, _b));
|
42
|
+
}
|
43
|
+
}
|
44
|
+
// 从一个键转换成一个键
|
45
|
+
if (typeof fromKeyItem === 'string' && typeof toKeyItem === 'string') {
|
46
|
+
if (type === 'string') {
|
47
|
+
var _dayjsObj = copyParams[fromKeyItem];
|
48
|
+
var start = void 0;
|
49
|
+
if (dayjs.isDayjs(_dayjsObj)) {
|
50
|
+
start = _dayjsObj.format(formatItem);
|
51
|
+
}
|
52
|
+
if (formatItem === 'startTime') {
|
53
|
+
start = start.substr(0, 10) + ' 00:00:00';
|
54
|
+
}
|
55
|
+
if (formatItem === 'endTime') {
|
56
|
+
start = start.substr(0, 10) + ' 23:59:59';
|
57
|
+
}
|
58
|
+
delete copyParams[fromKeyItem];
|
59
|
+
copyParams = __assign(__assign({}, copyParams), (_c = {}, _c[toKeyItem] = start, _c));
|
60
|
+
}
|
61
|
+
if (type === 'object') {
|
62
|
+
var start = copyParams[fromKeyItem]
|
63
|
+
? dayjs(copyParams[fromKeyItem])
|
64
|
+
: undefined;
|
65
|
+
delete copyParams[fromKeyItem];
|
66
|
+
copyParams = __assign(__assign({}, copyParams), (_d = {}, _d[toKeyItem] = start, _d));
|
67
|
+
}
|
68
|
+
}
|
69
|
+
// 从两个键转换成一个键
|
70
|
+
if (typeof fromKeyItem === 'object' && typeof toKeyItem === 'string') {
|
71
|
+
if (type === 'object') {
|
72
|
+
var startMoment = fromKeyItem[0], endMoment = fromKeyItem[1];
|
73
|
+
var intime = copyParams[toKeyItem] || [null, null];
|
74
|
+
if (copyParams[startMoment]) {
|
75
|
+
intime[0] = dayjs(copyParams[startMoment]);
|
76
|
+
delete copyParams[startMoment];
|
77
|
+
}
|
78
|
+
if (copyParams[endMoment]) {
|
79
|
+
intime[1] = dayjs(copyParams[endMoment]);
|
80
|
+
delete copyParams[endMoment];
|
81
|
+
}
|
82
|
+
if (intime[0] == null || intime[1] == null) {
|
83
|
+
intime = null;
|
84
|
+
}
|
85
|
+
copyParams = __assign(__assign({}, copyParams), (_e = {}, _e[toKeyItem] = intime, _e));
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return copyParams;
|
90
|
+
}
|
91
|
+
function divide(num1, num2) {
|
92
|
+
var others = [];
|
93
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
94
|
+
others[_i - 2] = arguments[_i];
|
95
|
+
}
|
96
|
+
try {
|
97
|
+
return divide$1.apply(void 0, __spreadArray([num1, num2], others));
|
98
|
+
}
|
99
|
+
catch (err) {
|
100
|
+
console.log(err);
|
101
|
+
return 0;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
/**
|
105
|
+
* @description 精确四舍五入后保留几位小数
|
106
|
+
*/
|
107
|
+
function exactRound(num, ratio) {
|
108
|
+
var typeNum = typeof num;
|
109
|
+
if (typeNum !== 'number' && typeNum !== 'string') {
|
110
|
+
return num;
|
111
|
+
}
|
112
|
+
try {
|
113
|
+
return round(num, ratio).toFixed(ratio);
|
114
|
+
}
|
115
|
+
catch (err) {
|
116
|
+
console.error(err);
|
117
|
+
return num;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
/**
|
121
|
+
* @description 添加千分符符号
|
122
|
+
*/
|
123
|
+
function toThousand(num) {
|
124
|
+
var typeNum = typeof num;
|
125
|
+
if (typeNum !== 'number' && typeNum !== 'string') {
|
126
|
+
return num;
|
127
|
+
}
|
128
|
+
var str = (num + '').replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,');
|
129
|
+
return str;
|
130
|
+
}
|
131
|
+
/**
|
132
|
+
* @description 去除指定字符串
|
133
|
+
*/
|
134
|
+
function clearAssignStr(str, originalStr) {
|
135
|
+
if (!originalStr) {
|
136
|
+
return originalStr;
|
137
|
+
}
|
138
|
+
if (originalStr.startsWith(str)) {
|
139
|
+
return originalStr.replace(str, '');
|
140
|
+
}
|
141
|
+
return originalStr;
|
142
|
+
}
|
143
|
+
/**
|
144
|
+
* @description 下载重命名
|
145
|
+
*/
|
146
|
+
function loadFileRename(fileUrl, fileName) {
|
147
|
+
var xhr = new XMLHttpRequest();
|
148
|
+
xhr.open('GET', fileUrl, true);
|
149
|
+
xhr.responseType = 'blob';
|
150
|
+
xhr.onload = function () {
|
151
|
+
if (xhr.status === 200) {
|
152
|
+
var link = document.createElement('a');
|
153
|
+
var body = document.querySelector('body');
|
154
|
+
link.href = window.URL.createObjectURL(xhr.response);
|
155
|
+
link.download = fileName;
|
156
|
+
// fix Firefox
|
157
|
+
link.style.display = 'none';
|
158
|
+
body.appendChild(link);
|
159
|
+
link.click();
|
160
|
+
body.removeChild(link);
|
161
|
+
window.URL.revokeObjectURL(link.href);
|
162
|
+
}
|
163
|
+
};
|
164
|
+
xhr.send();
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* @description 文件大小提示转换
|
168
|
+
*/
|
169
|
+
function transformFileSize(value) {
|
170
|
+
if (value < 1024) {
|
171
|
+
return round(value, 2).toFixed(2) + 'B';
|
172
|
+
}
|
173
|
+
else if (value < 1024 * 1024) {
|
174
|
+
return round(divide(value, 1024), 2).toFixed(2) + 'KB';
|
175
|
+
}
|
176
|
+
return round(divide(value, 1024, 1024), 2).toFixed(2) + 'MB';
|
177
|
+
}
|
178
|
+
/**
|
179
|
+
* @description 更具key判断前后值是否一致
|
180
|
+
*/
|
181
|
+
function isEqualByKey(keys, record, preRecord) {
|
182
|
+
var isEqual = false; // 是否相等
|
183
|
+
if (!record || !preRecord) {
|
184
|
+
isEqual = true;
|
185
|
+
return isEqual;
|
186
|
+
}
|
187
|
+
// 如果数据源相同的话,那么判断是初次更改,应该更新
|
188
|
+
if (record === preRecord) {
|
189
|
+
isEqual = true;
|
190
|
+
return isEqual;
|
191
|
+
}
|
192
|
+
for (var i = 0; i < keys.length; i++) {
|
193
|
+
var key = keys[i];
|
194
|
+
if (record[key] !== preRecord[key]) {
|
195
|
+
isEqual = true;
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
return isEqual;
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* @description 判断是否显示框架
|
203
|
+
*/
|
204
|
+
var SHOWFRAME_KEY = 'showFrame';
|
205
|
+
function showFrame() {
|
206
|
+
var _a;
|
207
|
+
var search = (_a = window.location) === null || _a === void 0 ? void 0 : _a.search;
|
208
|
+
try {
|
209
|
+
if (search) {
|
210
|
+
var searchList = search.slice(1).split('&');
|
211
|
+
for (var i = 0; i < searchList.length; i++) {
|
212
|
+
var _b = searchList[i].split('='), key = _b[0], value = _b[1];
|
213
|
+
if (key === SHOWFRAME_KEY)
|
214
|
+
return false;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
catch (err) {
|
219
|
+
return true;
|
220
|
+
}
|
221
|
+
return true;
|
222
|
+
}
|
223
|
+
|
224
|
+
var tools = /*#__PURE__*/Object.freeze({
|
225
|
+
__proto__: null,
|
226
|
+
timeTransfrom: timeTransfrom,
|
227
|
+
plus: plus,
|
228
|
+
minus: minus,
|
229
|
+
times: times,
|
230
|
+
divide: divide,
|
231
|
+
exactRound: exactRound,
|
232
|
+
toThousand: toThousand,
|
233
|
+
clearAssignStr: clearAssignStr,
|
234
|
+
loadFileRename: loadFileRename,
|
235
|
+
transformFileSize: transformFileSize,
|
236
|
+
isEqualByKey: isEqualByKey,
|
237
|
+
SHOWFRAME_KEY: SHOWFRAME_KEY,
|
238
|
+
showFrame: showFrame
|
239
|
+
});
|
240
|
+
|
241
|
+
export { SHOWFRAME_KEY as S, timeTransfrom as a, toThousand as b, clearAssignStr as c, divide as d, exactRound as e, transformFileSize as f, isEqualByKey as i, loadFileRename as l, showFrame as s, tools as t };
|
package/dist/tools.d.ts
CHANGED
@@ -50,3 +50,8 @@ export declare function transformFileSize(value: number): string;
|
|
50
50
|
* @description 更具key判断前后值是否一致
|
51
51
|
*/
|
52
52
|
export declare function isEqualByKey(keys: string[], record: any, preRecord: any): boolean;
|
53
|
+
/**
|
54
|
+
* @description 判断是否显示框架
|
55
|
+
*/
|
56
|
+
export declare const SHOWFRAME_KEY = "showFrame";
|
57
|
+
export declare function showFrame(): boolean;
|
package/dist/tools.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import './tslib.es6-f9459658.js';
|
2
2
|
import 'dayjs';
|
3
3
|
export { minus, plus, times } from 'number-precision';
|
4
|
-
export { c as clearAssignStr, d as divide, e as exactRound, i as isEqualByKey, l as loadFileRename, a as timeTransfrom, b as toThousand, f as transformFileSize } from './tools-
|
4
|
+
export { S as SHOWFRAME_KEY, c as clearAssignStr, d as divide, e as exactRound, i as isEqualByKey, l as loadFileRename, s as showFrame, a as timeTransfrom, b as toThousand, f as transformFileSize } from './tools-53fed4bb.js';
|