租户字典同步

This commit is contained in:
抓蛙师 2024-08-26 10:43:36 +08:00
parent 2c8873402f
commit d124fdf5ca
3 changed files with 42 additions and 7 deletions

View File

@ -60,3 +60,12 @@ export function optionselect(): AxiosPromise<DictTypeVO[]> {
method: 'get'
});
}
// 同步租户字典
export function asyncTenantDict(tenantId?: string) {
return request({
url: '/system/dict/type/asyncTenantDict',
method: 'get',
params: { tenantId }
});
}

View File

@ -49,6 +49,9 @@
<el-col :span="1.5">
<el-button v-hasPermi="['system:dict:remove']" type="danger" plain icon="Refresh" @click="handleRefreshCache">刷新缓存</el-button>
</el-col>
<el-col :span="1.5">
<el-button v-hasRole="['superadmin']" type="success" plain icon="Refresh" @click="handleAsyncTenantDict">同步租户字典</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @query-table="getList"></right-toolbar>
</el-row>
</template>
@ -109,7 +112,7 @@
<script setup name="Dict" lang="ts">
import useDictStore from '@/store/modules/dict';
import { listType, getType, delType, addType, updateType, refreshCache } from '@/api/system/dict/type';
import { listType, getType, delType, addType, updateType, refreshCache ,asyncTenantDict} from '@/api/system/dict/type';
import { DictTypeForm, DictTypeQuery, DictTypeVO } from '@/api/system/dict/type/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -239,7 +242,12 @@ const handleRefreshCache = async () => {
proxy?.$modal.msgSuccess('刷新成功');
useDictStore().cleanDict();
};
/**同步租户字典*/
const handleAsyncTenantDict = async () => {
await proxy?.$modal.confirm('确认要同步所有租户字典吗?');
let res = await asyncTenantDict();
proxy?.$modal.msgSuccess(res.msg);
};
onMounted(() => {
getList();
});

View File

@ -29,12 +29,12 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button v-hasPermi="['system:tenant:add']" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
<el-button v-hasPermi="['system:tenant:add']" type="primary" plain icon="Plus" @click="handleAdd">新增 </el-button>
</el-col>
<el-col :span="1.5">
<el-button v-hasPermi="['system:tenant:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()"
>修改</el-button
>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button v-hasPermi="['system:tenant:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()">
@ -42,7 +42,7 @@
</el-button>
</el-col>
<el-col :span="1.5">
<el-button v-hasPermi="['system:tenant:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
<el-button v-hasPermi="['system:tenant:export']" type="warning" plain icon="Download" @click="handleExport"> 导出 </el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @query-table="getList"></right-toolbar>
</el-row>
@ -75,6 +75,9 @@
<el-button v-hasPermi="['system:tenant:edit']" link type="primary" icon="Refresh" @click="handleSyncTenantPackage(scope.row)">
</el-button>
</el-tooltip>
<el-tooltip content="同步字典" placement="top">
<el-button v-hasRole="['superadmin']" link type="primary" icon="Refresh" @click="handleAsyncTenantDict(scope.row)"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button v-hasPermi="['system:tenant:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
</el-tooltip>
@ -145,6 +148,7 @@ import { listTenant, getTenant, delTenant, addTenant, updateTenant, changeTenant
import { selectTenantPackage } from '@/api/system/tenantPackage';
import { TenantForm, TenantQuery, TenantVO } from '@/api/system/tenant/types';
import { TenantPkgVO } from '@/api/system/tenantPackage/types';
import { asyncTenantDict } from '@/api/system/dict/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -322,7 +326,21 @@ const handleSyncTenantPackage = async (row: TenantVO) => {
try {
await proxy?.$modal.confirm('是否确认同步租户套餐租户编号为"' + row.tenantId + '"的数据项?');
loading.value = true;
await syncTenantPackage(row.tenantId, row.packageId);
let res = await syncTenantPackage(row.tenantId, row.packageId);
proxy?.$modal.msgSuccess(res.msg);
} catch {
return;
} finally {
loading.value = false;
}
};
/**同步租户字典*/
const handleAsyncTenantDict = async (row: TenantVO) => {
try {
await proxy?.$modal.confirm('是否确认同步租户套餐租户编号为"' + row.tenantId + '"的字典数据吗?');
loading.value = true;
await asyncTenantDict(row.tenantId);
await getList();
proxy?.$modal.msgSuccess('同步成功');
} catch {