v-nuxt-ui 0.2.17 → 0.2.19

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.19",
11
11
  "builder": {
12
12
  "@nuxt/module-builder": "1.0.2",
13
13
  "unbuild": "3.6.1"
@@ -45,6 +45,7 @@ const columns = [
45
45
  labelField: "name",
46
46
  valueField: "id",
47
47
  multiple: true,
48
+ initHide: false,
48
49
  defaultOpr: "in"
49
50
  }
50
51
  },
@@ -191,6 +192,11 @@ const columns = [
191
192
  :extra-order-query-options="[
192
193
  { field: 'createdAt', label: '\u521B\u5EFA\u65F6\u95F4', defaultOpr: 'desc' }
193
194
  ]"
195
+ :extra-where-query-init-values="{
196
+ items: [
197
+ { field: 'isAdmin', opr: 'eq', value: false }
198
+ ]
199
+ }"
194
200
  @edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
195
201
  />
196
202
  </template>
@@ -6,6 +6,7 @@ import TableQueryWhereSimpleItem from "#v/components/table/query/where/simple/it
6
6
  import TableQueryWhereNewer from "#v/components/table/query/where/Newer.vue";
7
7
  const props = defineProps({
8
8
  whereOptions: { type: Array, required: true },
9
+ extraWhereQueryInitValues: { type: Object, required: false },
9
10
  defaultWhereQuery: { type: Object, required: false },
10
11
  whereQuery: { type: null, required: true },
11
12
  onUpdateWhereQuery: { type: Function, required: true },
@@ -66,6 +67,14 @@ const isWhereQueryEmpty = computed(() => {
66
67
  return !props.whereQuery || Object.keys(props.whereQuery ?? {}).length === 0 || // 仅检查有对应option的item的值是否为空
67
68
  (props.whereQuery?.items?.filter((query) => props.whereOptions.find((option) => option.field === query.field)).length ?? 0) === 0 && (props.whereQuery?.groups?.length ?? 0) === 0;
68
69
  });
70
+ const whereQueryWithoutInitValues = computed(() => {
71
+ if (!props.whereQuery) return [];
72
+ const defaultKeys = props.extraWhereQueryInitValues?.items?.map((query) => query.field) ?? [];
73
+ return props.whereQuery.items?.filter((query) => {
74
+ const field = query.field;
75
+ return !defaultKeys.includes(field);
76
+ }) ?? [];
77
+ });
69
78
  const focusField = (field) => {
70
79
  const item = itemRefMap.value.get(field);
71
80
  if (item) {
@@ -84,7 +93,7 @@ defineExpose({ focusField });
84
93
  <!-- key如果是field,那么field修改后,不能聚焦后面的组件,所以这里的key用idx代替 -->
85
94
  <template v-if="!isWhereQueryEmpty">
86
95
  <TableQueryWhereSimpleItem
87
- v-for="(item, idx) in whereQuery?.items"
96
+ v-for="(item, idx) in whereQueryWithoutInitValues"
88
97
  :ref="(el) => setItemRef(item.field, el)"
89
98
  :key="idx"
90
99
  :where-query-item="item"
@@ -93,8 +102,11 @@ defineExpose({ focusField });
93
102
  :trigger-fetching="() => triggerFetching(true)"
94
103
  @remove="onRemoveFilter"
95
104
  @update:where-query-item="(newWhereQueryItem) => {
96
- const updatedItems = [...props.whereQuery?.items ?? []];
97
- updatedItems[idx] = newWhereQueryItem;
105
+ const items = props.whereQuery?.items ?? [];
106
+ const realIdx = items.findIndex((q) => q.field === item.field);
107
+ if (realIdx === -1) return;
108
+ const updatedItems = [...items];
109
+ updatedItems[realIdx] = newWhereQueryItem;
98
110
  onUpdateWhereQuery({
99
111
  ...whereQuery,
100
112
  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
  );
@@ -254,6 +254,7 @@ export function useTable(props) {
254
254
  }));
255
255
  const tblWhereQueryProps = computed(() => ({
256
256
  whereOptions: whereQueryOptions.value,
257
+ extraWhereQueryInitValues,
257
258
  defaultWhereQuery: whereQueryInitValues.value,
258
259
  whereQuery: whereQuery.value,
259
260
  onUpdateWhereQuery: (query) => whereQuery.value = query,
@@ -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) {
@@ -241,12 +241,18 @@ const _useEChart = () => {
241
241
  enableXAxis = true,
242
242
  enableYAxis = true
243
243
  } = config;
244
- const commonOption = defu(
244
+ const hasXAxisOption = option?.xAxis !== void 0;
245
+ const hasYAxisOption = option?.yAxis !== void 0;
246
+ let commonOption = defu(
245
247
  getCommonGridOption(),
246
- getCommonLegendOption(),
247
- getCommonXAxisOption(enableXAxis),
248
- getCommonYAxisOption(enableYAxis)
248
+ getCommonLegendOption()
249
249
  );
250
+ if (enableXAxis || hasXAxisOption) {
251
+ commonOption = defu(commonOption, getCommonXAxisOption(enableXAxis));
252
+ }
253
+ if (enableYAxis || hasYAxisOption) {
254
+ commonOption = defu(commonOption, getCommonYAxisOption(enableYAxis));
255
+ }
250
256
  const merged = defu(option, commonOption);
251
257
  if (merged.xAxis && Array.isArray(merged.xAxis) && merged.xAxis.length > 1) {
252
258
  const xAxisDefaults = getCommonXAxisOption(enableXAxis).xAxis;
@@ -5,6 +5,7 @@ export type WhereQueryOption<T> = {
5
5
  } & WhereQueryColumnOption<T>;
6
6
  export type WhereQueryProps<T> = {
7
7
  whereOptions: WhereQueryOption<T>[];
8
+ extraWhereQueryInitValues?: WhereQuery<T>;
8
9
  defaultWhereQuery?: WhereQuery<T>;
9
10
  whereQuery: WhereQuery<T> | undefined;
10
11
  onUpdateWhereQuery: (query: WhereQuery<T> | undefined) => void;
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.19",
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",