@vue-ui-kit/ant 1.3.0 → 1.4.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.
|
@@ -20,11 +20,12 @@ declare const _default: <D = Recordable<any>, F = Recordable<any>>(__VLS_props:
|
|
|
20
20
|
query: import('lodash').DebouncedFunc<() => Promise<D[]>>;
|
|
21
21
|
reload: () => void;
|
|
22
22
|
reloadPage: () => Promise<D[]>;
|
|
23
|
-
passQuery: (params: Partial<F
|
|
23
|
+
passQuery: (params: Partial<F>, lazy?: boolean) => Promise<void> | Promise<D[]> | undefined;
|
|
24
24
|
};
|
|
25
25
|
$table: import('vue').ComputedRef<any>;
|
|
26
26
|
selectedRowKeys: import('vue').ComputedRef<string[] | number[]>;
|
|
27
27
|
$form: import('vue').ComputedRef<any>;
|
|
28
|
+
setLoadings: (value: boolean) => void;
|
|
28
29
|
}>): void;
|
|
29
30
|
attrs: any;
|
|
30
31
|
slots: ReturnType<() => {}>;
|
package/package.json
CHANGED
|
@@ -132,6 +132,8 @@ export interface PButtonProps extends ButtonProps {
|
|
|
132
132
|
|
|
133
133
|
export interface ToolbarButtonProps extends PButtonProps {
|
|
134
134
|
code: string;
|
|
135
|
+
dropdowns?: ToolbarButtonProps[];
|
|
136
|
+
size?: 'small' | 'large' | 'middle';
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
export interface ToolbarConfig {
|
|
@@ -169,16 +171,17 @@ export interface PageConfig {
|
|
|
169
171
|
pageSize?: number;
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
export interface SelectConfig {
|
|
174
|
+
export interface SelectConfig<D = Recordable> {
|
|
173
175
|
multiple?: boolean;
|
|
176
|
+
getCheckboxProps?: (record: D) => { disabled?: boolean };
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
export type PGridProps<D = Recordable, F = Recordable> = {
|
|
177
|
-
selectConfig?: SelectConfig
|
|
180
|
+
selectConfig?: SelectConfig<D>;
|
|
178
181
|
rowKey?: string;
|
|
179
182
|
manualFetch?: boolean;
|
|
180
183
|
formConfig?: PFormProps<F>;
|
|
181
|
-
columns
|
|
184
|
+
columns?: ColumnProps<D>[];
|
|
182
185
|
toolbarConfig?: ToolbarConfig;
|
|
183
186
|
pageConfig?: PageConfig;
|
|
184
187
|
proxyConfig?: ProxyConfig<D, F>;
|
|
@@ -248,11 +251,12 @@ export interface PGridInstance<D = Recordable, F = Recordable> {
|
|
|
248
251
|
query: () => Promise<D[]>;
|
|
249
252
|
reload: () => Promise<D[]>;
|
|
250
253
|
reloadPage: () => Promise<D[]>;
|
|
251
|
-
passQuery: (query: Partial<F
|
|
254
|
+
passQuery: (query: Partial<F>, lazy?: boolean) => Promise<void | D[]>;
|
|
252
255
|
};
|
|
253
256
|
selectedRowKeys: string[] | number[];
|
|
254
257
|
$table: Recordable;
|
|
255
258
|
$form: Recordable;
|
|
259
|
+
setLoadings: (value: boolean) => void;
|
|
256
260
|
}
|
|
257
261
|
|
|
258
262
|
export interface PFormInstance {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
Tooltip as ATooltip,
|
|
25
25
|
} from 'ant-design-vue';
|
|
26
26
|
import { TablePaginationConfig } from 'ant-design-vue/es/table/interface';
|
|
27
|
-
import { InfoCircleOutlined } from '@ant-design/icons-vue';
|
|
27
|
+
import { InfoCircleOutlined, DownOutlined } from '@ant-design/icons-vue';
|
|
28
28
|
|
|
29
29
|
const props = defineProps<PGridProps<D, F>>();
|
|
30
30
|
const {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
} = toRefs(props);
|
|
40
40
|
const loading = reactive({
|
|
41
41
|
table: false,
|
|
42
|
+
toolbar: false,
|
|
42
43
|
form: false,
|
|
43
44
|
});
|
|
44
45
|
const submitOnReset = true;
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
content: '确认删除选中的数据吗?',
|
|
57
58
|
}).then(() => {
|
|
58
59
|
loading.table = true;
|
|
60
|
+
loading.toolbar = true;
|
|
59
61
|
ajax.multiDelete!(selectedRowKeys.value)
|
|
60
62
|
.then(() => {
|
|
61
63
|
$message.success('删除成功');
|
|
@@ -66,6 +68,7 @@
|
|
|
66
68
|
})
|
|
67
69
|
.finally(() => {
|
|
68
70
|
loading.table = false;
|
|
71
|
+
loading.toolbar = false;
|
|
69
72
|
});
|
|
70
73
|
});
|
|
71
74
|
} else {
|
|
@@ -77,7 +80,7 @@
|
|
|
77
80
|
};
|
|
78
81
|
const slotTitleColumns = computed(() => {
|
|
79
82
|
const cols: ColumnProps<D>[] = [];
|
|
80
|
-
eachTree(columns.value, (col) => {
|
|
83
|
+
eachTree(columns.value ?? [], (col) => {
|
|
81
84
|
if (col.slots && col.slots.title) {
|
|
82
85
|
if (!col.field) {
|
|
83
86
|
col.field = '__holder__' + cols.length;
|
|
@@ -101,7 +104,7 @@
|
|
|
101
104
|
const debounceRefreshTable = debounce(refreshTable, 100);
|
|
102
105
|
const slotDefaultColumns = computed(() => {
|
|
103
106
|
const cols: ColumnProps<D>[] = [];
|
|
104
|
-
eachTree(columns.value, (col) => {
|
|
107
|
+
eachTree(columns.value ?? [], (col) => {
|
|
105
108
|
if ((col.slots && col.slots.default) || col.formatter || col.cellRender) {
|
|
106
109
|
if (!col.field) {
|
|
107
110
|
col.field = '__holder__' + cols.length;
|
|
@@ -142,10 +145,13 @@
|
|
|
142
145
|
});
|
|
143
146
|
innerToolbarHandler(code);
|
|
144
147
|
};
|
|
148
|
+
const debounceToolBtnClick = debounce(toolBtnClick, 100);
|
|
149
|
+
const toolBtnMenuClick = ({ key }) => debounceToolBtnClick(key);
|
|
145
150
|
const toolToolClick = (code: string) => {
|
|
146
151
|
emit('toolbarToolClick', { data: tableData.value, code, selectedKeys: selectedRowKeys.value });
|
|
147
152
|
innerToolbarHandler(code);
|
|
148
153
|
};
|
|
154
|
+
const debounceToolToolClick = debounce(toolToolClick, 100);
|
|
149
155
|
const queryFormData = ref<Partial<F>>({}) as Ref<Partial<F>>;
|
|
150
156
|
const pickRow = ({ row, field }: { row: D; field: string }) => {
|
|
151
157
|
emit('pick', { row, field });
|
|
@@ -266,10 +272,10 @@
|
|
|
266
272
|
}
|
|
267
273
|
});
|
|
268
274
|
const debounceFetchData = debounce(fetchData, 160);
|
|
269
|
-
const passQuery = (params: Partial<F
|
|
275
|
+
const passQuery = (params: Partial<F>, lazy?: boolean) => {
|
|
270
276
|
Object.assign(queryFormData.value, params);
|
|
271
277
|
pagination.page = 1;
|
|
272
|
-
return debounceFetchData();
|
|
278
|
+
return lazy ? Promise.resolve() : debounceFetchData();
|
|
273
279
|
};
|
|
274
280
|
const pg = computed(() =>
|
|
275
281
|
mode.value === 'pagination'
|
|
@@ -304,6 +310,7 @@
|
|
|
304
310
|
onChange: (selectedKeys: string[] | number[]) => {
|
|
305
311
|
selectedRowKeys.value = selectedKeys;
|
|
306
312
|
},
|
|
313
|
+
getCheckboxProps: selectConfig.value.getCheckboxProps,
|
|
307
314
|
},
|
|
308
315
|
}
|
|
309
316
|
: {},
|
|
@@ -339,6 +346,11 @@
|
|
|
339
346
|
$table: computed(() => tableEl.value),
|
|
340
347
|
selectedRowKeys: computed(() => selectedRowKeys.value),
|
|
341
348
|
$form: computed(() => formEl.value),
|
|
349
|
+
setLoadings: (value: boolean) => {
|
|
350
|
+
loading.form = value;
|
|
351
|
+
loading.table = value;
|
|
352
|
+
loading.toolbar = value;
|
|
353
|
+
},
|
|
342
354
|
});
|
|
343
355
|
onMounted(() => {
|
|
344
356
|
/*判断本组件所在容器DOM*/
|
|
@@ -438,16 +450,33 @@
|
|
|
438
450
|
>
|
|
439
451
|
<div class="flex items-center flex-1 gap-4px">
|
|
440
452
|
<template v-if="toolbarConfig.buttons && toolbarConfig.buttons.length > 0">
|
|
441
|
-
<
|
|
442
|
-
v-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
453
|
+
<template v-for="(btn, idx) in toolbarConfig.buttons" :key="idx">
|
|
454
|
+
<a-dropdown v-if="btn.dropdowns && btn.dropdowns.length">
|
|
455
|
+
<template #overlay>
|
|
456
|
+
<a-menu @click="toolBtnMenuClick">
|
|
457
|
+
<a-menu-item v-for="sub in btn.dropdowns" :key="sub.code"
|
|
458
|
+
>{{ sub.content }}
|
|
459
|
+
</a-menu-item>
|
|
460
|
+
</a-menu>
|
|
461
|
+
</template>
|
|
462
|
+
<a-button :type="btn.type" :size="btn.size ?? 'small'" :loading="loading.toolbar">
|
|
463
|
+
<Icon v-if="btn.icon" :icon="btn.icon" />
|
|
464
|
+
{{ btn.content }}
|
|
465
|
+
<DownOutlined />
|
|
466
|
+
</a-button>
|
|
467
|
+
</a-dropdown>
|
|
468
|
+
<a-button
|
|
469
|
+
v-else-if="btn.code"
|
|
470
|
+
:type="btn.type"
|
|
471
|
+
:size="btn.size ?? 'small'"
|
|
472
|
+
:loading="loading.toolbar"
|
|
473
|
+
@click="debounceToolBtnClick(btn.code)"
|
|
474
|
+
>
|
|
475
|
+
<Icon v-if="btn.icon" :icon="btn.icon" />
|
|
476
|
+
{{ btn.content }}
|
|
477
|
+
</a-button>
|
|
478
|
+
<div v-else></div>
|
|
479
|
+
</template>
|
|
451
480
|
</template>
|
|
452
481
|
</div>
|
|
453
482
|
<span class="flex items-center gap-4px">
|
|
@@ -457,7 +486,8 @@
|
|
|
457
486
|
:key="idx"
|
|
458
487
|
:type="tool.type"
|
|
459
488
|
size="small"
|
|
460
|
-
@click="
|
|
489
|
+
@click="debounceToolToolClick(tool.code)"
|
|
490
|
+
:loading="loading.toolbar"
|
|
461
491
|
>
|
|
462
492
|
<Icon :icon="tool.icon" />
|
|
463
493
|
</a-button>
|
|
@@ -469,7 +499,7 @@
|
|
|
469
499
|
:key="renderTableKey + '_table'"
|
|
470
500
|
:row-key="rowKey ?? 'id'"
|
|
471
501
|
ref="tableEl"
|
|
472
|
-
:columns="columns.map((c) => cleanCol(c as Recordable))"
|
|
502
|
+
:columns="(columns ?? []).map((c) => cleanCol(c as Recordable))"
|
|
473
503
|
:data-source="tableData"
|
|
474
504
|
:loading="loading.table"
|
|
475
505
|
:pagination="pg"
|