@skyfox2000/webui 1.4.13 → 1.4.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/webui",
3
- "version": "1.4.13",
3
+ "version": "1.4.15",
4
4
  "description": "后台前端通用组件定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -28,7 +28,7 @@ const props = defineProps<{
28
28
  /**
29
29
  * 表格控制对象
30
30
  */
31
- gridCtrl: GridControl<AnyData>;
31
+ gridCtrl?: GridControl<AnyData>;
32
32
  /**
33
33
  * 模糊查询字段
34
34
  */
@@ -39,7 +39,8 @@ const props = defineProps<{
39
39
 
40
40
  const emits = defineEmits<{
41
41
  (e: 'update:search', val: Record<string, any>): void;
42
- (e: 'reset'): void;
42
+ (e: 'onsearch', val: Record<string, any>): void;
43
+ (e: 'onreset'): void;
43
44
  }>();
44
45
 
45
46
  /**
@@ -60,13 +61,13 @@ const updateHolderSize = () => {
60
61
  defaultSlots.value = 0;
61
62
  controlSlots.value = 0;
62
63
  if (slots.default) defaultSlots.value = getSlotLen(slots.default({}));
63
- if (props.gridCtrl.searchBar && slots.control) controlSlots.value = getSlotLen(slots.control({}));
64
+ if (props.gridCtrl && props.gridCtrl.searchBar && slots.control) controlSlots.value = getSlotLen(slots.control({}));
64
65
 
65
66
  holderSize.value = 2 - ((defaultSlots.value + controlSlots.value) % 3);
66
67
  };
67
68
 
68
69
  watch(
69
- () => props.gridCtrl.searchBar,
70
+ () => props.gridCtrl?.searchBar,
70
71
  () => {
71
72
  updateHolderSize();
72
73
  },
@@ -77,13 +78,15 @@ const defaultData: Record<string, any> = JSON.parse(JSON.stringify(props.search)
77
78
  onMounted(() => {
78
79
  updateHolderSize();
79
80
  let search = { ...props.search };
80
- props.gridCtrl.gridQuery = {
81
- ...props.gridCtrl.gridQuery,
82
- Query: {
83
- ...props.gridCtrl.gridQuery?.Query,
84
- ...search,
85
- },
86
- };
81
+ if (props.gridCtrl) {
82
+ props.gridCtrl.gridQuery = {
83
+ ...props.gridCtrl.gridQuery,
84
+ Query: {
85
+ ...props.gridCtrl.gridQuery?.Query,
86
+ ...search,
87
+ },
88
+ };
89
+ }
87
90
  });
88
91
 
89
92
  const onSearch = () => {
@@ -96,18 +99,21 @@ const onSearch = () => {
96
99
  }
97
100
  }
98
101
 
99
- props.gridCtrl.gridQuery = {
100
- ...props.gridCtrl.gridQuery,
101
- Query: {
102
- ...props.gridCtrl.gridQuery?.Query,
103
- ...search,
104
- },
105
- };
102
+ if (props.gridCtrl) {
103
+ props.gridCtrl.gridQuery = {
104
+ ...props.gridCtrl.gridQuery,
105
+ Query: {
106
+ ...props.gridCtrl.gridQuery?.Query,
107
+ ...search,
108
+ },
109
+ };
106
110
 
107
- // 包含分页,需要重新设置
108
- props.gridCtrl.pageNo.value = 1;
111
+ // 包含分页,需要重新设置
112
+ props.gridCtrl.pageNo.value = 1;
109
113
 
110
- props.gridCtrl.reload.value = true;
114
+ props.gridCtrl.reload.value = true;
115
+ }
116
+ emits('onsearch', search);
111
117
  };
112
118
 
113
119
  const onReset = () => {
@@ -119,7 +125,7 @@ const onReset = () => {
119
125
  }
120
126
  emits('update:search', data);
121
127
 
122
- emits('reset');
128
+ emits('onreset');
123
129
  };
124
130
  </script>
125
131
  <template>
@@ -130,11 +136,11 @@ const onReset = () => {
130
136
  <!-- 默认插槽 -->
131
137
  <slot></slot>
132
138
  <!-- 受控插槽 -->
133
- <slot name="control" v-if="gridCtrl.searchBar"></slot>
139
+ <slot name="control" v-if="gridCtrl?.searchBar"></slot>
134
140
  <!-- 表单操作按钮 占位数量 -->
135
141
  <SearchItem class="w-1/3" v-if="holderSize >= 1"> </SearchItem>
136
142
  <SearchItem class="w-1/3" v-if="holderSize >= 2"> </SearchItem>
137
- <SearchItem v-if="defaultSlots || gridCtrl.searchBar" class="w-1/3 flex justify-end text-right pr-5"
143
+ <SearchItem v-if="defaultSlots || gridCtrl?.searchBar" class="w-1/3 flex justify-end text-right pr-5"
138
144
  :wrapper-col="{ flex: 'auto' }">
139
145
  <Space>
140
146
  <Button type="primary" @click="onSearch" icon="icon-search">搜索</Button>
@@ -173,6 +173,15 @@ onActivated(() => {
173
173
  onMounted(async () => {
174
174
  provide(ProviderKeys.GridControl, gridCtrl);
175
175
 
176
+ if (gridCtrl.page && gridCtrl.gridUrl?.url) {
177
+ if (gridCtrl.gridUrl?.url === gridCtrl.page.urls.list?.url) {
178
+ gridCtrl.remotePage = false;
179
+ }
180
+ if (gridCtrl.gridUrl?.url === gridCtrl.page.urls.find?.url) {
181
+ gridCtrl.remotePage = true;
182
+ }
183
+ }
184
+
176
185
  if (gridCtrl.tableData.value) {
177
186
  dataList.value = gridCtrl.tableData.value;
178
187
  gridCtrl.total.value = dataList.value.length;
@@ -180,14 +189,6 @@ onMounted(async () => {
180
189
  pagination.value.total = gridCtrl.total.value ?? 0;
181
190
  }
182
191
  } else if (gridCtrl.autoload !== false) {
183
- if (gridCtrl.page) {
184
- if (gridCtrl.gridUrl?.url === gridCtrl.page.urls.list) {
185
- gridCtrl.remotePage = false;
186
- }
187
- if (gridCtrl.gridUrl?.url === gridCtrl.page.urls.find) {
188
- gridCtrl.remotePage = true;
189
- }
190
- }
191
192
  if (gridCtrl.remotePage) {
192
193
  dataList.value = (await gridQueryFind(gridCtrl)).rows;
193
194
  } else {
@@ -81,9 +81,9 @@ const formatFileName = (fileName: string) => {
81
81
  return dayjs().format(formatStr);
82
82
  });
83
83
  };
84
+
84
85
  // 下载当前条件全部数据
85
86
  // 表头相同
86
-
87
87
  export const exportResults = async <T extends Record<string, any>>(
88
88
  fileName: string,
89
89
  columns: TableColumn[],