v-nuxt-ui 0.1.30 → 0.1.32
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/module.json +1 -1
- package/dist/runtime/components/form/field/AsyncSelect.d.vue.ts +2 -2
- package/dist/runtime/components/form/field/AsyncSelect.vue +29 -3
- package/dist/runtime/components/form/field/AsyncSelect.vue.d.ts +2 -2
- package/dist/runtime/components/sys/user/Table.vue +12 -2
- package/dist/runtime/composables/table/useTableColumns.js +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Component as VueComponent } from 'vue';
|
|
2
2
|
import type { VFormFieldAsyncSelectProps } from '#v/types';
|
|
3
3
|
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
4
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<(VFormFieldAsyncSelectProps<T> & {
|
|
5
5
|
icon?: string;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
canCreate?: boolean;
|
|
8
|
-
createModalComponent?:
|
|
8
|
+
createModalComponent?: VueComponent;
|
|
9
9
|
createModalOpenProps?: Record<string, any>;
|
|
10
10
|
} & {
|
|
11
11
|
modelValue: string[] | number[] | number | string | null | undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { defu } from "defu";
|
|
4
|
+
import { useFetching } from "#v/composables";
|
|
4
5
|
import { isEmptyString } from "#v/utils";
|
|
6
|
+
import { useOverlay } from "@nuxt/ui/runtime/composables/useOverlay.js";
|
|
5
7
|
import { useDebounceFn } from "@vueuse/core";
|
|
6
|
-
import { defu } from "defu";
|
|
7
8
|
import { useApp } from "#v/composables/useApp";
|
|
8
9
|
const props = defineProps({
|
|
9
10
|
listApi: { type: Function, required: true },
|
|
@@ -103,6 +104,26 @@ const onFetchItems = async () => {
|
|
|
103
104
|
}
|
|
104
105
|
};
|
|
105
106
|
const onDebounceFetchItems = useDebounceFn(onFetchItems, 512);
|
|
107
|
+
const onCreateNew = async () => {
|
|
108
|
+
if (!props.createModalComponent) return;
|
|
109
|
+
open.value = false;
|
|
110
|
+
const modal = useOverlay().create(props.createModalComponent);
|
|
111
|
+
modal.open({
|
|
112
|
+
model: { id: 0 },
|
|
113
|
+
...props.createModalOpenProps,
|
|
114
|
+
onSave: (newModel) => {
|
|
115
|
+
searchedData.value.push(newModel);
|
|
116
|
+
const newValue = newModel[props.valueField];
|
|
117
|
+
if (props.multiple) {
|
|
118
|
+
const currentValues = Array.isArray(modelValue.value) ? [...modelValue.value] : [];
|
|
119
|
+
currentValues.push(newValue);
|
|
120
|
+
onSelect(currentValues);
|
|
121
|
+
} else {
|
|
122
|
+
onSelect(newValue);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
106
127
|
</script>
|
|
107
128
|
|
|
108
129
|
<template>
|
|
@@ -111,6 +132,10 @@ const onDebounceFetchItems = useDebounceFn(onFetchItems, 512);
|
|
|
111
132
|
:model-value="modelValue"
|
|
112
133
|
:search-term="searchTerm"
|
|
113
134
|
:items="items"
|
|
135
|
+
:create-item="canCreate && createModalComponent && {
|
|
136
|
+
position: 'top',
|
|
137
|
+
when: 'always'
|
|
138
|
+
}"
|
|
114
139
|
value-key="value"
|
|
115
140
|
ignore-filter
|
|
116
141
|
:multiple="multiple"
|
|
@@ -139,5 +164,6 @@ const onDebounceFetchItems = useDebounceFn(onFetchItems, 512);
|
|
|
139
164
|
onDebounceFetchItems();
|
|
140
165
|
}"
|
|
141
166
|
@update:model-value="onSelect"
|
|
167
|
+
@create="onCreateNew"
|
|
142
168
|
/>
|
|
143
169
|
</template>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Component as VueComponent } from 'vue';
|
|
2
2
|
import type { VFormFieldAsyncSelectProps } from '#v/types';
|
|
3
3
|
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
4
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<(VFormFieldAsyncSelectProps<T> & {
|
|
5
5
|
icon?: string;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
canCreate?: boolean;
|
|
8
|
-
createModalComponent?:
|
|
8
|
+
createModalComponent?: VueComponent;
|
|
9
9
|
createModalOpenProps?: Record<string, any>;
|
|
10
10
|
} & {
|
|
11
11
|
modelValue: string[] | number[] | number | string | null | undefined;
|
|
@@ -98,7 +98,12 @@ const columns = [
|
|
|
98
98
|
header: "\u662F\u5426\u9700\u8981\u586B\u5199\u5DE5\u65F6",
|
|
99
99
|
filterOption: {
|
|
100
100
|
type: "select",
|
|
101
|
-
items: booleanOptions
|
|
101
|
+
items: booleanOptions,
|
|
102
|
+
empty: {
|
|
103
|
+
label: "\u5426",
|
|
104
|
+
variant: "outline",
|
|
105
|
+
color: "neutral"
|
|
106
|
+
}
|
|
102
107
|
}
|
|
103
108
|
},
|
|
104
109
|
{
|
|
@@ -106,7 +111,12 @@ const columns = [
|
|
|
106
111
|
header: "\u6027\u522B",
|
|
107
112
|
filterOption: {
|
|
108
113
|
type: "select",
|
|
109
|
-
items: genderOptions
|
|
114
|
+
items: genderOptions,
|
|
115
|
+
empty: {
|
|
116
|
+
label: "\u672A\u77E5",
|
|
117
|
+
variant: "outline",
|
|
118
|
+
color: "neutral"
|
|
119
|
+
}
|
|
110
120
|
},
|
|
111
121
|
meta: {
|
|
112
122
|
class: {
|
|
@@ -88,7 +88,7 @@ export function useTableColumns(props) {
|
|
|
88
88
|
color: item?.color ?? "neutral",
|
|
89
89
|
variant: selectOption.variant ?? "outline",
|
|
90
90
|
icon: item?.icon
|
|
91
|
-
}, () => item?.label ?? "\u672A\u77E5\u503C") : h(UBadge, { ...selectOption.empty });
|
|
91
|
+
}, () => item?.label ?? "\u672A\u77E5\u503C") : selectOption.empty ? h(UBadge, { ...selectOption.empty }) : null;
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
}
|
package/package.json
CHANGED