chore: 租户套餐下拉框样式
This commit is contained in:
parent
dff055951f
commit
c2511b13e1
@ -1,6 +1,12 @@
|
|||||||
|
import type { Tenant } from './model';
|
||||||
|
|
||||||
|
import type { ID, IDS, PageQuery } from '#/api/common';
|
||||||
|
|
||||||
|
import { commonExport } from '#/api/helper';
|
||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
enum Api {
|
enum Api {
|
||||||
|
dictSync = '/system/tenant/syncTenantDict',
|
||||||
root = '/system/tenant',
|
root = '/system/tenant',
|
||||||
tenantDynamic = '/system/tenant/dynamic',
|
tenantDynamic = '/system/tenant/dynamic',
|
||||||
tenantDynamicClear = '/system/tenant/dynamic/clear',
|
tenantDynamicClear = '/system/tenant/dynamic/clear',
|
||||||
@ -10,6 +16,39 @@ enum Api {
|
|||||||
tenantSyncPackage = '/system/tenant/syncTenantPackage',
|
tenantSyncPackage = '/system/tenant/syncTenantPackage',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function tenantList(params?: PageQuery) {
|
||||||
|
return requestClient.get<Tenant[]>(Api.tenantList, { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tenantExport(data: any) {
|
||||||
|
return commonExport(Api.tenantExport, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tenantInfo(id: ID) {
|
||||||
|
return requestClient.get<Tenant>(`${Api.root}/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增租户 必须开启加密
|
||||||
|
* @param data data
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
export function tenantAdd(data: any) {
|
||||||
|
return requestClient.postWithMsg<void>(Api.root, data, { encrypt: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tenantUpdate(data: any) {
|
||||||
|
return requestClient.putWithMsg<void>(Api.root, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tenantStatusChange(data: any) {
|
||||||
|
return requestClient.putWithMsg(Api.tenantStatus, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tenantRemove(ids: IDS) {
|
||||||
|
return requestClient.deleteWithMsg(`${Api.root}/${ids}`);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态切换租户
|
* 动态切换租户
|
||||||
* @param tenantId 租户ID
|
* @param tenantId 租户ID
|
||||||
@ -26,3 +65,33 @@ export function tenantDynamicToggle(tenantId: string) {
|
|||||||
export function tenantDynamicClear() {
|
export function tenantDynamicClear() {
|
||||||
return requestClient.get<void>(Api.tenantDynamicClear);
|
return requestClient.get<void>(Api.tenantDynamicClear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户套餐同步
|
||||||
|
* @param tenantId 租户id
|
||||||
|
* @param packageId 套餐id
|
||||||
|
* @param showMsg 是否显示成功信息
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
export function tenantSyncPackage(
|
||||||
|
tenantId: string,
|
||||||
|
packageId: string,
|
||||||
|
showMsg = true,
|
||||||
|
) {
|
||||||
|
return requestClient.get<void>(Api.tenantSyncPackage, {
|
||||||
|
params: { packageId, tenantId },
|
||||||
|
successMessageMode: showMsg ? 'message' : 'none',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步租户字典
|
||||||
|
* @param tenantId 租户ID
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
export function dictSyncTenant(tenantId?: string) {
|
||||||
|
return requestClient.get<void>(Api.dictSync, {
|
||||||
|
params: { tenantId },
|
||||||
|
successMessageMode: 'message',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue';
|
import { computed, h, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenDrawer } from '@vben/common-ui';
|
import { useVbenDrawer } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import { Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter';
|
import { useVbenForm } from '#/adapter';
|
||||||
import { clientAdd, clientUpdate } from '#/api/system/client';
|
import { clientAdd, clientUpdate } from '#/api/system/client';
|
||||||
|
import { tenantInfo } from '#/api/system/tenant';
|
||||||
import { packageSelectList } from '#/api/system/tenant-package';
|
import { packageSelectList } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { drawerSchema } from './data';
|
import { drawerSchema } from './data';
|
||||||
@ -14,7 +17,7 @@ const emit = defineEmits<{ reload: [] }>();
|
|||||||
|
|
||||||
interface DrawerProps {
|
interface DrawerProps {
|
||||||
update: boolean;
|
update: boolean;
|
||||||
record?: any;
|
id?: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
@ -34,11 +37,21 @@ const [BasicForm, formApi] = useVbenForm({
|
|||||||
|
|
||||||
async function setupPackageSelect() {
|
async function setupPackageSelect() {
|
||||||
const tenantPackageList = await packageSelectList();
|
const tenantPackageList = await packageSelectList();
|
||||||
|
const options = tenantPackageList.map((item) => ({
|
||||||
|
label: h('div', { class: 'flex items-center gap-[6px]' }, [
|
||||||
|
h('span', null, item.packageName),
|
||||||
|
h(Tag, { color: 'processing' }, () => `${item.menuIds.length}个菜单项`),
|
||||||
|
]),
|
||||||
|
title: item.packageName,
|
||||||
|
value: item.packageId,
|
||||||
|
}));
|
||||||
formApi.updateSchema([
|
formApi.updateSchema([
|
||||||
{
|
{
|
||||||
componentProps: {
|
componentProps: {
|
||||||
fieldNames: { label: 'packageName', value: 'packageId' },
|
optionFilterProp: 'title',
|
||||||
options: tenantPackageList,
|
optionLabelProp: 'title',
|
||||||
|
options,
|
||||||
|
showSearch: true,
|
||||||
},
|
},
|
||||||
fieldName: 'packageId',
|
fieldName: 'packageId',
|
||||||
},
|
},
|
||||||
@ -53,13 +66,14 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
drawerApi.drawerLoading(true);
|
drawerApi.drawerLoading(true);
|
||||||
const { record, update } = drawerApi.getData() as DrawerProps;
|
const { id, update } = drawerApi.getData() as DrawerProps;
|
||||||
isUpdate.value = update;
|
isUpdate.value = update;
|
||||||
// 初始化
|
// 初始化
|
||||||
await setupPackageSelect();
|
await setupPackageSelect();
|
||||||
if (update && record) {
|
if (update && id) {
|
||||||
|
const record = await tenantInfo(id);
|
||||||
for (const key in record) {
|
for (const key in record) {
|
||||||
await formApi.setFieldValue(key, record[key]);
|
await formApi.setFieldValue(key, record[key as keyof typeof record]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawerApi.drawerLoading(false);
|
drawerApi.drawerLoading(false);
|
||||||
@ -74,7 +88,6 @@ async function handleConfirm() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = await formApi.getValues();
|
const data = await formApi.getValues();
|
||||||
console.log(data);
|
|
||||||
await (isUpdate.value ? clientUpdate(data) : clientAdd(data));
|
await (isUpdate.value ? clientUpdate(data) : clientAdd(data));
|
||||||
emit('reload');
|
emit('reload');
|
||||||
await handleCancel();
|
await handleCancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user