@dt-frames/ui 2.0.6 → 2.0.8
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/es/components/curd/index.js +42 -67
- package/es/components/curd/src/components/Curd.d.ts +2 -8
- package/es/components/curd/src/hooks/useCurd.d.ts +3 -3
- package/es/components/curd/src/props.d.ts +1 -4
- package/es/components/curd/src/types/curd.type.d.ts +3 -9
- package/es/components/form/index.d.ts +30 -54
- package/es/components/form/index.js +74 -41
- package/es/components/form/index.less +1 -0
- package/es/components/form/src/components/FormButtons.d.ts +3 -3
- package/es/components/form/src/components/FormItem.d.ts +5 -8
- package/es/components/form/src/components/formIcon.d.ts +4 -4
- package/es/components/form/src/components/formInputUseDialog.d.ts +3 -3
- package/es/components/form/src/hooks/useFormEvent.d.ts +1 -1
- package/es/components/form/src/index.d.ts +24 -42
- package/es/components/form/src/props.d.ts +5 -8
- package/es/components/modal/index.js +3 -6
- package/es/components/modal/src/components/ModalFooter.d.ts +3 -3
- package/es/components/modal/src/index.d.ts +9 -9
- package/es/components/source/hooks/useSource.d.ts +14 -13
- package/es/components/source/index.js +62 -36
- package/es/components/table/index.js +151 -158
- package/es/components/table/src/index.d.ts +18 -54
- package/es/components/table/src/props.d.ts +6 -18
- package/es/components/table/src/types/table.type.d.ts +1 -4
- package/es/theme/index.d.ts +2 -2
- package/es/theme/index.js +299 -294
- package/es/theme/src/components/sider/index.d.ts +2 -1
- package/es/theme/src/components/sider/mix-sider.d.ts +2 -1
- package/es/theme/src/hooks/useMenu.d.ts +1 -1
- package/es/theme/src/index.d.ts +2 -1
- package/es/theme/src/types/theme.type.d.ts +0 -1
- package/index.js +3 -1
- package/package.json +1 -1
|
@@ -149,11 +149,14 @@ function useSource(props) {
|
|
|
149
149
|
let tableInstance = null;
|
|
150
150
|
let formInstance = null;
|
|
151
151
|
let curdInstance = null;
|
|
152
|
-
function onSearch() {
|
|
152
|
+
function onSearch(params = {}) {
|
|
153
|
+
if (!api.queryPage)
|
|
154
|
+
return;
|
|
153
155
|
tableInstance?.clearSelectedRowKeys();
|
|
154
156
|
const { defaultPageSize } = tableInstance?.getPagination() || {};
|
|
155
157
|
baseData = {
|
|
156
158
|
...formInstance?.getFormValues() ?? {},
|
|
159
|
+
...params,
|
|
157
160
|
pageNumber: 1,
|
|
158
161
|
pageSize: defaultPageSize
|
|
159
162
|
};
|
|
@@ -161,9 +164,10 @@ function useSource(props) {
|
|
|
161
164
|
loading.onQuerypage.value = true;
|
|
162
165
|
setPage();
|
|
163
166
|
}
|
|
164
|
-
function onReset() {
|
|
167
|
+
function onReset(params = {}) {
|
|
165
168
|
const { defaultPageSize } = tableInstance?.getPagination() || {};
|
|
166
169
|
baseData = {
|
|
170
|
+
...params,
|
|
167
171
|
...formInstance?.getFormValues() ?? {},
|
|
168
172
|
pageNumber: 1,
|
|
169
173
|
pageSize: defaultPageSize
|
|
@@ -173,29 +177,32 @@ function useSource(props) {
|
|
|
173
177
|
tableInstance?.clearSelectedRowKeys();
|
|
174
178
|
setPage();
|
|
175
179
|
}
|
|
176
|
-
function setPage(params = {}) {
|
|
180
|
+
async function setPage(params = {}) {
|
|
177
181
|
if (!api.queryPage)
|
|
178
182
|
return;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
try {
|
|
184
|
+
const result = await fetch(api.queryPage, {
|
|
185
|
+
...toRaw(baseData),
|
|
186
|
+
...params
|
|
187
|
+
});
|
|
188
|
+
if (isArray(result)) {
|
|
189
|
+
dataSource.value.splice(0, dataSource.value.length, ...result);
|
|
185
190
|
return;
|
|
186
191
|
}
|
|
187
|
-
const { records, total, size, current } =
|
|
192
|
+
const { records, total, size, current } = result;
|
|
188
193
|
dataSource.value.splice(0, dataSource.value.length, ...records);
|
|
189
194
|
pagination.value = {
|
|
190
195
|
current,
|
|
191
196
|
pageSize: size || appConf?.ui?.table?.defaultPageSize,
|
|
192
197
|
total
|
|
193
198
|
};
|
|
194
|
-
}
|
|
199
|
+
} catch (err) {
|
|
200
|
+
console.error(`\u5206\u9875\u67E5\u8BE2\u9519\u8BEF\uFF1A${err}`);
|
|
201
|
+
} finally {
|
|
195
202
|
loading.onSearch.value = false;
|
|
196
203
|
loading.onQuerypage.value = false;
|
|
197
204
|
loading.onReset.value = false;
|
|
198
|
-
}
|
|
205
|
+
}
|
|
199
206
|
}
|
|
200
207
|
function onTableChange(params) {
|
|
201
208
|
const { pagination: pagination2, sort, filter } = params;
|
|
@@ -224,53 +231,72 @@ function useSource(props) {
|
|
|
224
231
|
};
|
|
225
232
|
setPage(filter);
|
|
226
233
|
}
|
|
227
|
-
function
|
|
228
|
-
curdInstance && curdInstance.
|
|
234
|
+
function onOPenAddDialog() {
|
|
235
|
+
curdInstance && curdInstance.openAddDialog();
|
|
229
236
|
}
|
|
230
|
-
function
|
|
231
|
-
curdInstance && curdInstance.
|
|
237
|
+
async function onOpenUpdateDialog(row) {
|
|
238
|
+
curdInstance && curdInstance.openUpdateDialog(row);
|
|
232
239
|
}
|
|
233
|
-
function onDelete(
|
|
234
|
-
|
|
240
|
+
function onDelete(row) {
|
|
241
|
+
if (curdInstance) {
|
|
242
|
+
curdInstance.del(row);
|
|
243
|
+
} else {
|
|
244
|
+
onDeletes([row?.id]);
|
|
245
|
+
}
|
|
235
246
|
}
|
|
236
247
|
function onQueryById(id) {
|
|
237
248
|
return fetch(api.queryById, { id });
|
|
238
249
|
}
|
|
239
|
-
function onSave() {
|
|
240
|
-
|
|
241
|
-
|
|
250
|
+
async function onSave(params) {
|
|
251
|
+
const methods = curdInstance ? curdInstance.curdFormMethods : formInstance;
|
|
252
|
+
if (!methods) {
|
|
253
|
+
console.log("\u672A\u914D\u7F6E\u8868\u5355\u5B9E\u4F8B\uFF01");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let model = {
|
|
257
|
+
...params,
|
|
258
|
+
...methods.getFormValues()
|
|
259
|
+
};
|
|
260
|
+
try {
|
|
261
|
+
await methods.validate();
|
|
242
262
|
if (beforeUpdate && isFunction(beforeUpdate)) {
|
|
243
263
|
let canUpdate = beforeUpdate(model);
|
|
244
264
|
if (isBoolean(canUpdate) && canUpdate === false) {
|
|
245
265
|
return false;
|
|
246
|
-
} else if (!isBoolean(canUpdate)) {
|
|
247
|
-
model = { ...canUpdate || {} };
|
|
248
266
|
}
|
|
249
267
|
}
|
|
250
268
|
if (!model.id) {
|
|
251
269
|
loading.onAdd.value = true;
|
|
252
|
-
|
|
253
|
-
|
|
270
|
+
try {
|
|
271
|
+
const result = await fetch(api.add, { ...model }, false);
|
|
272
|
+
if (result?.code === appConf?.http?.okCode) {
|
|
254
273
|
message.success(t("ADD_SUCCESS"));
|
|
255
|
-
curdInstance.closeModal();
|
|
274
|
+
curdInstance && curdInstance.closeModal();
|
|
256
275
|
if (queryAfterUpdate !== false)
|
|
257
276
|
onSearch();
|
|
258
277
|
}
|
|
278
|
+
} catch (err) {
|
|
279
|
+
} finally {
|
|
259
280
|
loading.onAdd.value = false;
|
|
260
|
-
}
|
|
281
|
+
}
|
|
261
282
|
} else {
|
|
262
283
|
loading.onUpdate.value = true;
|
|
263
|
-
|
|
264
|
-
|
|
284
|
+
try {
|
|
285
|
+
const result = await fetch(api.update, { ...model }, false);
|
|
286
|
+
if (result?.code === appConf?.http?.okCode) {
|
|
265
287
|
message.success(t("UPDATE_SUCCESS"));
|
|
266
|
-
curdInstance.closeModal();
|
|
288
|
+
curdInstance && curdInstance.closeModal();
|
|
267
289
|
if (queryAfterUpdate !== false)
|
|
268
290
|
onSearch();
|
|
269
291
|
}
|
|
292
|
+
} catch (err) {
|
|
293
|
+
} finally {
|
|
270
294
|
loading.onUpdate.value = false;
|
|
271
|
-
}
|
|
295
|
+
}
|
|
272
296
|
}
|
|
273
|
-
})
|
|
297
|
+
} catch (err) {
|
|
298
|
+
} finally {
|
|
299
|
+
}
|
|
274
300
|
}
|
|
275
301
|
function onDeletes(ids) {
|
|
276
302
|
if (!tableInstance)
|
|
@@ -336,8 +362,8 @@ function useSource(props) {
|
|
|
336
362
|
loading: loading.onQuerypage,
|
|
337
363
|
onSearch,
|
|
338
364
|
onTableChange,
|
|
339
|
-
|
|
340
|
-
|
|
365
|
+
onOPenAddDialog,
|
|
366
|
+
onOpenUpdateDialog,
|
|
341
367
|
onDelete,
|
|
342
368
|
onDeletes,
|
|
343
369
|
onDownload,
|
|
@@ -356,8 +382,8 @@ function useSource(props) {
|
|
|
356
382
|
api,
|
|
357
383
|
loading,
|
|
358
384
|
dataSource,
|
|
359
|
-
|
|
360
|
-
|
|
385
|
+
onOPenAddDialog,
|
|
386
|
+
onOpenUpdateDialog,
|
|
361
387
|
onDelete,
|
|
362
388
|
onDeletes,
|
|
363
389
|
onQueryById,
|