@ftjs/core 1.2.1 → 1.2.2
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/index.js +45 -22
- package/dist/table/types.d.ts +4 -0
- package/dist/utils.d.ts +6 -0
- package/package.json +11 -1
package/dist/index.js
CHANGED
|
@@ -137,6 +137,14 @@ const isEqual = (a, b) => {
|
|
|
137
137
|
(key) => Object.prototype.hasOwnProperty.call(b, key) && isEqual(a[key], b[key])
|
|
138
138
|
);
|
|
139
139
|
};
|
|
140
|
+
function forEachTree(tree, cb) {
|
|
141
|
+
for (const item of tree) {
|
|
142
|
+
cb(item);
|
|
143
|
+
if (item.children) {
|
|
144
|
+
forEachTree(item.children, cb);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
140
148
|
function isFormGetter(fn) {
|
|
141
149
|
return typeof fn === "function";
|
|
142
150
|
}
|
|
@@ -253,20 +261,30 @@ const getFieldsAndValues = (column) => {
|
|
|
253
261
|
return { fields, values };
|
|
254
262
|
};
|
|
255
263
|
const useForm = (props) => {
|
|
256
|
-
var _a;
|
|
257
264
|
const columns = computed(() => props.columns);
|
|
258
|
-
const formLocal = ref(
|
|
259
|
-
|
|
260
|
-
(
|
|
261
|
-
|
|
265
|
+
const formLocal = ref();
|
|
266
|
+
watch(
|
|
267
|
+
() => props.formData,
|
|
268
|
+
(v) => {
|
|
269
|
+
var _a;
|
|
270
|
+
if (v == null) {
|
|
271
|
+
v = {};
|
|
272
|
+
(_a = props["onUpdate:formData"]) == null ? void 0 : _a.call(props, v);
|
|
273
|
+
}
|
|
274
|
+
formLocal.value = v;
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
immediate: true
|
|
278
|
+
}
|
|
279
|
+
);
|
|
262
280
|
const form = computed({
|
|
263
281
|
get() {
|
|
264
282
|
return formLocal.value;
|
|
265
283
|
},
|
|
266
284
|
set(v) {
|
|
267
|
-
var
|
|
285
|
+
var _a;
|
|
268
286
|
formLocal.value = v;
|
|
269
|
-
(
|
|
287
|
+
(_a = props["onUpdate:formData"]) == null ? void 0 : _a.call(props, v);
|
|
270
288
|
}
|
|
271
289
|
});
|
|
272
290
|
const { columnsChecked, resetColumnsChecked } = useColumnsChecked(
|
|
@@ -293,9 +311,9 @@ const useForm = (props) => {
|
|
|
293
311
|
});
|
|
294
312
|
const visibleColumns = computed(() => {
|
|
295
313
|
return columns.value.filter((column) => {
|
|
296
|
-
var
|
|
314
|
+
var _a;
|
|
297
315
|
const key = getField(column);
|
|
298
|
-
return !hideFieldSet.value.has(key) && (((
|
|
316
|
+
return !hideFieldSet.value.has(key) && (((_a = columnsChecked.value) == null ? void 0 : _a.includes(key)) ?? true);
|
|
299
317
|
}).sort((a, b) => {
|
|
300
318
|
const keyA = getField(a);
|
|
301
319
|
const keyB = getField(b);
|
|
@@ -529,22 +547,26 @@ const useFormItem = (options) => {
|
|
|
529
547
|
};
|
|
530
548
|
const useTable = (props) => {
|
|
531
549
|
const formColumns = computed(() => {
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
550
|
+
const tableSearch = [];
|
|
551
|
+
forEachTree(props.columns, (e) => {
|
|
552
|
+
if (e.search) {
|
|
553
|
+
if (typeof e.search === "string") {
|
|
554
|
+
tableSearch.push({
|
|
555
|
+
field: e.field,
|
|
556
|
+
title: e.title,
|
|
557
|
+
type: e.search
|
|
558
|
+
});
|
|
559
|
+
} else {
|
|
560
|
+
tableSearch.push({
|
|
561
|
+
field: e.field,
|
|
562
|
+
title: e.title,
|
|
563
|
+
...e.search
|
|
564
|
+
});
|
|
565
|
+
}
|
|
539
566
|
}
|
|
540
|
-
return {
|
|
541
|
-
field: e.field,
|
|
542
|
-
title: e.title,
|
|
543
|
-
...e.search
|
|
544
|
-
};
|
|
545
567
|
});
|
|
546
568
|
return [
|
|
547
|
-
...
|
|
569
|
+
...tableSearch,
|
|
548
570
|
...props.searchColumns ?? []
|
|
549
571
|
];
|
|
550
572
|
});
|
|
@@ -554,6 +576,7 @@ const useTable = (props) => {
|
|
|
554
576
|
};
|
|
555
577
|
export {
|
|
556
578
|
cloneDeep,
|
|
579
|
+
forEachTree,
|
|
557
580
|
get,
|
|
558
581
|
getDefaultValues,
|
|
559
582
|
getField,
|
package/dist/table/types.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ export interface FtTableColumn<TableData extends Record<string, any>, SColumn ex
|
|
|
18
18
|
* 搜索配置
|
|
19
19
|
*/
|
|
20
20
|
search?: SColumn;
|
|
21
|
+
/**
|
|
22
|
+
* 子列,用于表头合并
|
|
23
|
+
*/
|
|
24
|
+
children?: FtTableColumn<TableData, SColumn>[];
|
|
21
25
|
}
|
|
22
26
|
export interface FtBaseTableProps<T extends Record<string, any>, TableColumn extends FtTableColumn<T>, SearchColumn extends FtFormColumnBase<any>> {
|
|
23
27
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -36,3 +36,9 @@ export declare const setStorage: (key: string, value: any, cache?: string) => vo
|
|
|
36
36
|
* 不考虑循环引用
|
|
37
37
|
*/
|
|
38
38
|
export declare const isEqual: (a: any, b: any) => any;
|
|
39
|
+
interface TreeData {
|
|
40
|
+
children?: TreeData[];
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}
|
|
43
|
+
export declare function forEachTree<T extends TreeData>(tree: T[], cb: (item: T) => void): void;
|
|
44
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftjs/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,16 @@
|
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"vue": ">=3.3.0"
|
|
36
36
|
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/",
|
|
40
|
+
"provenance": true
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/yuhengshen/ftjs",
|
|
45
|
+
"directory": "packages/core"
|
|
46
|
+
},
|
|
37
47
|
"scripts": {
|
|
38
48
|
"build": "vite build",
|
|
39
49
|
"minify": "pnpm dlx esbuild ./dist/index.js --minify --outfile=./dist/index.min.js",
|