refactor(@vben/web-antd): 优化多个组件的代码和功能
This commit is contained in:
parent
2911293bc8
commit
5026ae0bbd
@ -21,7 +21,7 @@ function transformToTreeData(data: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用示例
|
// 使用示例
|
||||||
getAllDeptTree(1).then((res) => {
|
getAllDeptTree(0).then((res) => {
|
||||||
treeData.value = transformToTreeData(res);
|
treeData.value = transformToTreeData(res);
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +105,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async (_params) => {
|
query: async (_params) => {
|
||||||
const res = await getAllDeptTree(1);
|
const res = await getAllDeptTree(0);
|
||||||
return {
|
return {
|
||||||
items: res,
|
items: res,
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { PPTTempItem } from '@vben/common-ui';
|
import type { PPTTempItem, ResultItem } from './typing';
|
||||||
|
|
||||||
import type { ResultItem } from './typing';
|
|
||||||
|
|
||||||
import { onMounted, reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
|
||||||
|
@ -104,12 +104,12 @@ function confirm(content: string, title: string) {
|
|||||||
*/
|
*/
|
||||||
async function onStatusChange(newStatus: number, row: RoleApi.Role) {
|
async function onStatusChange(newStatus: number, row: RoleApi.Role) {
|
||||||
const status: Recordable<string> = {
|
const status: Recordable<string> = {
|
||||||
0: '禁用',
|
false: '禁用',
|
||||||
1: '启用',
|
true: '启用',
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await confirm(
|
await confirm(
|
||||||
`你要将${row.name}的状态切换为 【${status[newStatus.toString()]}】 吗?`,
|
`你要将${row.name}的状态切换为 【${status[newStatus]}】 吗?`,
|
||||||
`切换状态`,
|
`切换状态`,
|
||||||
);
|
);
|
||||||
await enabledRole(row.id);
|
await enabledRole(row.id);
|
||||||
|
@ -36,6 +36,10 @@ const [Drawer, drawerApi] = useVbenDrawer({
|
|||||||
const { valid } = await formApi.validate();
|
const { valid } = await formApi.validate();
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
const values = await formApi.getValues();
|
const values = await formApi.getValues();
|
||||||
|
// 过滤 menuIds 中的 null/undefined/false 值
|
||||||
|
if (Array.isArray(values.menuIds)) {
|
||||||
|
values.menuIds = values.menuIds.filter((id) => id !== null && id !== '');
|
||||||
|
}
|
||||||
drawerApi.lock();
|
drawerApi.lock();
|
||||||
(id.value ? updateRole(id.value, values) : createRole(values))
|
(id.value ? updateRole(id.value, values) : createRole(values))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -56,7 +56,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Input',
|
component: 'InputPassword',
|
||||||
fieldName: 'password',
|
fieldName: 'password',
|
||||||
label: '密码',
|
label: '密码',
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
@ -186,6 +186,16 @@ export function useColumns<T = UserApi.User>(
|
|||||||
nameField: 'name',
|
nameField: 'name',
|
||||||
nameTitle: '用户',
|
nameTitle: '用户',
|
||||||
onClick: onActionClick,
|
onClick: onActionClick,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
code: 'edit',
|
||||||
|
text: '修改',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'delete',
|
||||||
|
text: '删除',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
name: 'CellOperation',
|
name: 'CellOperation',
|
||||||
},
|
},
|
||||||
|
@ -104,12 +104,12 @@ function confirm(content: string, title: string) {
|
|||||||
*/
|
*/
|
||||||
async function onStatusChange(newStatus: number, row: UserApi.User) {
|
async function onStatusChange(newStatus: number, row: UserApi.User) {
|
||||||
const status: Recordable<string> = {
|
const status: Recordable<string> = {
|
||||||
0: '禁用',
|
false: '禁用',
|
||||||
1: '启用',
|
true: '启用',
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await confirm(
|
await confirm(
|
||||||
`你要将${row.name}的状态切换为 【${status[newStatus.toString()]}】 吗?`,
|
`你要将${row.name}的状态切换为 【${status[newStatus]}】 吗?`,
|
||||||
`切换状态`,
|
`切换状态`,
|
||||||
);
|
);
|
||||||
await enabledUser(row.id);
|
await enabledUser(row.id);
|
||||||
|
Loading…
Reference in New Issue
Block a user