v-nuxt-ui 0.2.17 → 0.2.18

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 CHANGED
@@ -7,7 +7,7 @@
7
7
  "dependencies": [
8
8
  "@nuxt/ui"
9
9
  ],
10
- "version": "0.2.17",
10
+ "version": "0.2.18",
11
11
  "builder": {
12
12
  "@nuxt/module-builder": "1.0.2",
13
13
  "unbuild": "3.6.1"
@@ -191,6 +191,11 @@ const columns = [
191
191
  :extra-order-query-options="[
192
192
  { field: 'createdAt', label: '\u521B\u5EFA\u65F6\u95F4', defaultOpr: 'desc' }
193
193
  ]"
194
+ :extra-where-query-init-values="{
195
+ items: [
196
+ { field: 'isAdmin', opr: 'eq', value: false }
197
+ ]
198
+ }"
194
199
  @edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
195
200
  />
196
201
  </template>
@@ -66,6 +66,14 @@ const isWhereQueryEmpty = computed(() => {
66
66
  return !props.whereQuery || Object.keys(props.whereQuery ?? {}).length === 0 || // 仅检查有对应option的item的值是否为空
67
67
  (props.whereQuery?.items?.filter((query) => props.whereOptions.find((option) => option.field === query.field)).length ?? 0) === 0 && (props.whereQuery?.groups?.length ?? 0) === 0;
68
68
  });
69
+ const whereQueryWithoutDefault = computed(() => {
70
+ if (!props.whereQuery) return [];
71
+ const defaultKeys = props.defaultWhereQuery?.items?.map((query) => query.field) ?? [];
72
+ return props.whereQuery.items?.filter((query) => {
73
+ const field = query.field;
74
+ return !defaultKeys.includes(field);
75
+ }) ?? [];
76
+ });
69
77
  const focusField = (field) => {
70
78
  const item = itemRefMap.value.get(field);
71
79
  if (item) {
@@ -84,7 +92,7 @@ defineExpose({ focusField });
84
92
  <!-- key如果是field,那么field修改后,不能聚焦后面的组件,所以这里的key用idx代替 -->
85
93
  <template v-if="!isWhereQueryEmpty">
86
94
  <TableQueryWhereSimpleItem
87
- v-for="(item, idx) in whereQuery?.items"
95
+ v-for="(item, idx) in whereQueryWithoutDefault"
88
96
  :ref="(el) => setItemRef(item.field, el)"
89
97
  :key="idx"
90
98
  :where-query-item="item"
@@ -93,8 +101,11 @@ defineExpose({ focusField });
93
101
  :trigger-fetching="() => triggerFetching(true)"
94
102
  @remove="onRemoveFilter"
95
103
  @update:where-query-item="(newWhereQueryItem) => {
96
- const updatedItems = [...props.whereQuery?.items ?? []];
97
- updatedItems[idx] = newWhereQueryItem;
104
+ const items = props.whereQuery?.items ?? [];
105
+ const realIdx = items.findIndex((q) => q.field === item.field);
106
+ if (realIdx === -1) return;
107
+ const updatedItems = [...items];
108
+ updatedItems[realIdx] = newWhereQueryItem;
98
109
  onUpdateWhereQuery({
99
110
  ...whereQuery,
100
111
  items: updatedItems
@@ -12,9 +12,10 @@ const props = defineProps({
12
12
  const whereQueryItem = defineModel("whereQueryItem", { type: Object, ...{ required: true } });
13
13
  const option = computed(() => props.options.find((option2) => option2.field === whereQueryItem.value.field));
14
14
  watch(
15
- () => whereQueryItem.value.custom,
16
- () => {
17
- whereQueryItem.value = { ...whereQueryItem.value, custom: option.value?.custom };
15
+ () => option.value?.custom,
16
+ (newCustom) => {
17
+ if (whereQueryItem.value.custom === newCustom) return;
18
+ whereQueryItem.value = { ...whereQueryItem.value, custom: newCustom };
18
19
  },
19
20
  { immediate: true }
20
21
  );
@@ -13,9 +13,10 @@ const props = defineProps({
13
13
  const whereQueryItem = defineModel("whereQueryItem", { type: Object, ...{ required: true } });
14
14
  const option = computed(() => props.options.find((option2) => option2.field === whereQueryItem.value.field) ?? { type: "unknown", field: "unknown", label: "\u672A\u77E5\u5B57\u6BB5" });
15
15
  watch(
16
- () => whereQueryItem.value.custom,
17
- () => {
18
- whereQueryItem.value = { ...whereQueryItem.value, custom: option.value?.custom };
16
+ () => option.value?.custom,
17
+ (newCustom) => {
18
+ if (whereQueryItem.value.custom === newCustom) return;
19
+ whereQueryItem.value = { ...whereQueryItem.value, custom: newCustom };
19
20
  },
20
21
  { immediate: true }
21
22
  );
@@ -72,7 +72,8 @@ export function useTableQuery(props) {
72
72
  if (itemsWithOprNoValues.length > 0) {
73
73
  return false;
74
74
  }
75
- return !items.filter((item) => !noValueOprList.includes(item.opr)).some((item) => item.value !== null && item.value !== void 0 && item.value !== "");
75
+ const defaultKeys = whereQueryInitValues.value.items?.map((query) => query.field) ?? [];
76
+ return !items.filter((item) => !defaultKeys.includes(item.field)).filter((item) => !noValueOprList.includes(item.opr)).some((item) => item.value !== null && item.value !== void 0 && item.value !== "");
76
77
  };
77
78
  const checkIfWhereQueryGroupsValueEmpty = (groups) => {
78
79
  for (const group of groups) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v-nuxt-ui",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "Veken UI Component Library - Reusable Nuxt UI components, composables, and utilities for enterprise applications",
5
5
  "type": "module",
6
6
  "style": "./dist/runtime/index.css",