style: system views code style
This commit is contained in:
@@ -2,11 +2,12 @@ import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum } from '#/utils/constants';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||
import { useAccess } from '@vben/access';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
@@ -53,7 +54,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -93,7 +94,9 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns<T = SystemTenantPackageApi.SystemTenantPackage>(onActionClick: OnActionClickFn<T>): VxeTableGridOptions['columns'] {
|
||||
export function useGridColumns<T = SystemTenantPackageApi.SystemTenantPackage>(
|
||||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import Form from './modules/form.vue';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteTenantPackage, getTenantPackagePage } from '#/api/system/tenant-package';
|
||||
import {
|
||||
deleteTenantPackage,
|
||||
getTenantPackagePage,
|
||||
} from '#/api/system/tenant-package';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
@@ -53,16 +60,19 @@ async function onDelete(row: SystemTenantPackageApi.SystemTenantPackage) {
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({ code, row }: OnActionClickParams<SystemTenantPackageApi.SystemTenantPackage>) {
|
||||
function onActionClick({
|
||||
code,
|
||||
row,
|
||||
}: OnActionClickParams<SystemTenantPackageApi.SystemTenantPackage>) {
|
||||
switch (code) {
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +114,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="租户套餐列表">
|
||||
<template #toolbar-tools>
|
||||
<Button type="primary" @click="onCreate" v-access:code="['system:tenant-package:create']">
|
||||
<Button
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['system:tenant-package:create']"
|
||||
>
|
||||
<Plus class="size-5" />
|
||||
{{ $t('ui.actionTitle.create', ['套餐']) }}
|
||||
</Button>
|
||||
|
||||
@@ -2,14 +2,20 @@
|
||||
import type { SystemDeptApi } from '#/api/system/dept';
|
||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal, VbenTree } from '@vben/common-ui';
|
||||
|
||||
import { Checkbox, message } from 'ant-design-vue';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { $t } from '#/locales';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getMenuList } from '#/api/system/menu';
|
||||
import { createTenantPackage, getTenantPackage, updateTenantPackage } from '#/api/system/tenant-package';
|
||||
import {
|
||||
createTenantPackage,
|
||||
getTenantPackage,
|
||||
updateTenantPackage,
|
||||
} from '#/api/system/tenant-package';
|
||||
import { $t } from '#/locales';
|
||||
import { handleTree } from '#/utils/tree';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
@@ -17,7 +23,9 @@ import { useFormSchema } from '../data';
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<SystemTenantPackageApi.SystemTenantPackage>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value ? $t('ui.actionTitle.edit', ['套餐']) : $t('ui.actionTitle.create', ['套餐']);
|
||||
return formData.value
|
||||
? $t('ui.actionTitle.edit', ['套餐'])
|
||||
: $t('ui.actionTitle.create', ['套餐']);
|
||||
});
|
||||
const menuTree = ref<SystemDeptApi.SystemDept[]>([]); // 菜单树
|
||||
const menuLoading = ref(false); // 加载菜单列表
|
||||
@@ -39,9 +47,12 @@ const [Modal, modalApi] = useVbenModal({
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as SystemTenantPackageApi.SystemTenantPackage;
|
||||
const data =
|
||||
(await formApi.getValues()) as SystemTenantPackageApi.SystemTenantPackage;
|
||||
try {
|
||||
await (formData.value ? updateTenantPackage(data) : createTenantPackage(data));
|
||||
await (formData.value
|
||||
? updateTenantPackage(data)
|
||||
: createTenantPackage(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
@@ -78,7 +89,7 @@ async function loadMenuTree() {
|
||||
menuLoading.value = true;
|
||||
try {
|
||||
const data = await getMenuList();
|
||||
menuTree.value = handleTree(data);
|
||||
menuTree.value = handleTree(data) as SystemDeptApi.SystemDept[];
|
||||
} finally {
|
||||
menuLoading.value = false;
|
||||
}
|
||||
@@ -119,14 +130,26 @@ function getAllNodeIds(nodes: any[], ids: number[] = []): number[] {
|
||||
<template #menuIds="slotProps">
|
||||
<Spin :spinning="menuLoading" class="w-full">
|
||||
<!-- TODO @芋艿:可优化,使用 antd 的 tree?原因是,更原生 -->
|
||||
<VbenTree :tree-data="menuTree" multiple bordered :expanded="expandedKeys" v-bind="slotProps" value-field="id" label-field="name" />
|
||||
<VbenTree
|
||||
:tree-data="menuTree"
|
||||
multiple
|
||||
bordered
|
||||
:expanded="expandedKeys"
|
||||
v-bind="slotProps"
|
||||
value-field="id"
|
||||
label-field="name"
|
||||
/>
|
||||
</Spin>
|
||||
</template>
|
||||
</Form>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center">
|
||||
<Checkbox :checked="isAllSelected" @change="toggleSelectAll"> 全选 </Checkbox>
|
||||
<Checkbox :checked="isExpanded" @change="toggleExpandAll"> 全部展开 </Checkbox>
|
||||
<Checkbox :checked="isAllSelected" @change="toggleSelectAll">
|
||||
全选
|
||||
</Checkbox>
|
||||
<Checkbox :checked="isExpanded" @change="toggleExpandAll">
|
||||
全部展开
|
||||
</Checkbox>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user