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);
|
||||
});
|
||||
/**
|
||||
|
@ -105,7 +105,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async (_params) => {
|
||||
const res = await getAllDeptTree(1);
|
||||
const res = await getAllDeptTree(0);
|
||||
return {
|
||||
items: res,
|
||||
};
|
||||
|
@ -1,7 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { PPTTempItem } from '@vben/common-ui';
|
||||
|
||||
import type { ResultItem } from './typing';
|
||||
import type { PPTTempItem, ResultItem } from './typing';
|
||||
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
|
||||
|
@ -104,12 +104,12 @@ function confirm(content: string, title: string) {
|
||||
*/
|
||||
async function onStatusChange(newStatus: number, row: RoleApi.Role) {
|
||||
const status: Recordable<string> = {
|
||||
0: '禁用',
|
||||
1: '启用',
|
||||
false: '禁用',
|
||||
true: '启用',
|
||||
};
|
||||
try {
|
||||
await confirm(
|
||||
`你要将${row.name}的状态切换为 【${status[newStatus.toString()]}】 吗?`,
|
||||
`你要将${row.name}的状态切换为 【${status[newStatus]}】 吗?`,
|
||||
`切换状态`,
|
||||
);
|
||||
await enabledRole(row.id);
|
||||
|
@ -36,6 +36,10 @@ const [Drawer, drawerApi] = useVbenDrawer({
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) return;
|
||||
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();
|
||||
(id.value ? updateRole(id.value, values) : createRole(values))
|
||||
.then(() => {
|
||||
|
@ -56,7 +56,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
component: 'InputPassword',
|
||||
fieldName: 'password',
|
||||
label: '密码',
|
||||
rules: 'required',
|
||||
@ -186,6 +186,16 @@ export function useColumns<T = UserApi.User>(
|
||||
nameField: 'name',
|
||||
nameTitle: '用户',
|
||||
onClick: onActionClick,
|
||||
options: [
|
||||
{
|
||||
code: 'edit',
|
||||
text: '修改',
|
||||
},
|
||||
{
|
||||
code: 'delete',
|
||||
text: '删除',
|
||||
},
|
||||
],
|
||||
},
|
||||
name: 'CellOperation',
|
||||
},
|
||||
|
@ -104,12 +104,12 @@ function confirm(content: string, title: string) {
|
||||
*/
|
||||
async function onStatusChange(newStatus: number, row: UserApi.User) {
|
||||
const status: Recordable<string> = {
|
||||
0: '禁用',
|
||||
1: '启用',
|
||||
false: '禁用',
|
||||
true: '启用',
|
||||
};
|
||||
try {
|
||||
await confirm(
|
||||
`你要将${row.name}的状态切换为 【${status[newStatus.toString()]}】 吗?`,
|
||||
`你要将${row.name}的状态切换为 【${status[newStatus]}】 吗?`,
|
||||
`切换状态`,
|
||||
);
|
||||
await enabledUser(row.id);
|
||||
|
Loading…
Reference in New Issue
Block a user