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; submitting.value = true;
try { try {
const hasError = await formRef.value?.validate(); 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) }); const { data, code, message } = await api({ ...formData ?? {}, ...unref(params) });
if (code) { if (code) {

View File

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

View File

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