fix(ui): 修复

This commit is contained in:
廖彦棋 2024-03-14 10:56:54 +08:00
parent 306cd2f945
commit 268acb174d
3 changed files with 11 additions and 8 deletions

View File

@ -9,7 +9,9 @@ function useSubmit<T extends Record<string, any> = Record<string, any>, R = any>
submitting.value = true;
try {
const hasError = await formRef.value?.validate();
if (hasError) return Promise.reject({ validateErrors: hasError });
if (hasError) {
return Promise.reject({ validateErrors: hasError });
}
const { data, code, message } = await api({ ...formData ?? {}, ...unref(params) });
if (code) {

View File

@ -28,13 +28,14 @@ const columns: TableColumnData[] = [
const [reload, data, loading] = useRequest(getList);
const openFormModal = usePopup(SysPermissionForm, {
nodeProps: ([_, record]) => ({ record, options: data.value }),
popupProps: ([reload, record], exposed) => ({
nodeProps: ([record]) => ({ record, options: data.value }),
popupProps: ([record], exposed) => ({
title: `${record?.id ? "编辑" : "新增"}权限`,
onBeforeOk: async (done) => {
await exposed()?.handleSubmit(save, {
id: record?.id,
});
Message.success("操作成功");
await reload();
done(true);
},
@ -52,7 +53,7 @@ reload();
</script>
<template>
<div style="padding-bottom: 10px; text-align: right">
<a-button type="primary" :loading="loading" @click="openFormModal(reload, {})">
<a-button type="primary" :loading="loading" @click="openFormModal({})">
<template #icon>
<icon-plus />
</template>
@ -67,8 +68,8 @@ reload();
:pagination="false"
default-expand-all-rows
>
<template #actions="{ record, reload }">
<a-link @click="openFormModal(reload, record)">编辑</a-link>
<template #actions="{ record }">
<a-link @click="openFormModal(record)">编辑</a-link>
<a-popconfirm
content="是否删除?"
position="left"

View File

@ -48,13 +48,13 @@ const props = defineProps({
const { formRef, formData, handleSubmit } = useSubmit({
name: "",
pid: "0",
pid: 0,
slug: "",
sort: null,
});
const _options = computed(() => {
return [{ id: "0", name: "顶部权限", children: unref(props.options ?? []) }];
return [{ id: 0, name: "顶部权限", children: unref(props.options ?? []) }];
});
Object.assign(formData, props.record);