feat: 添加租户和子账号删除功能,优化用户操作体验
This commit is contained in:
parent
81f4d33a4a
commit
3d9bba7e03
|
|
@ -75,6 +75,13 @@ export const exportTenant = (params: Partial<TenantListDTO>) => {
|
|||
responseType: 'blob',
|
||||
});
|
||||
};
|
||||
// 租户删除
|
||||
export const deleteTenant = (data: { id: number }) => {
|
||||
return request({
|
||||
url: `/tenant/${data.id}/delete`,
|
||||
method: 'post',
|
||||
});
|
||||
};
|
||||
|
||||
// 获取子账号列表参数
|
||||
type TenantUserListDTO = {
|
||||
|
|
@ -155,3 +162,10 @@ export const enableTenantUser = (data: { id: number }) => {
|
|||
data,
|
||||
});
|
||||
};
|
||||
// 租户子账号删除
|
||||
export const deleteTenantUser = (data: { id: number }) => {
|
||||
return request({
|
||||
url: `/tenant/user/${data.id}/delete`,
|
||||
method: 'post',
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ async function submit() {
|
|||
updateTenant(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
if(oldPhone.value !== formData.phone) {
|
||||
ElMessage.success('租户手机号已更新,如需使用新手机号作为子账号登录,请手动修改!');
|
||||
ElMessage.success('租户手机号已更新,如需使用新手机号作为子账号登录,请手动修改默认子账号!');
|
||||
} else {
|
||||
ElMessage.success('操作成功');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@
|
|||
<el-button type="text" @click="addOpen(scope.row)">编辑</el-button>
|
||||
<el-button type="text" v-if="scope.row.status === 1" @click="doUpdateStatus(scope.row)">启用</el-button>
|
||||
<el-button type="text" v-else @click="doUpdateStatus(scope.row)">禁用</el-button>
|
||||
<el-popconfirm v-if="scope.row.type !== 1" title="请确认是否删除" placement="top" @confirm="doDeleteTenant(scope.row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" text>删除</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</tableComponents>
|
||||
|
|
@ -85,7 +90,7 @@ import tableComponents from '/@/components/tableComponents/index.vue';
|
|||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import addDialog from './add.vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { disableTenant, enableTenant, getTenantList, exportTenant } from '/@/api/tenant';
|
||||
import { disableTenant, enableTenant, getTenantList, exportTenant, deleteTenant } from '/@/api/tenant';
|
||||
import { COMPANYTYPE_CONST, ACCOUNTTYPE_CONST, STATUS_CONST } from './constant';
|
||||
|
||||
type FormData = {
|
||||
|
|
@ -159,6 +164,16 @@ async function doUpdateStatus(row: IData) {
|
|||
}
|
||||
});
|
||||
}
|
||||
// 删除
|
||||
async function doDeleteTenant(row: IData) {
|
||||
let { code, data } = await deleteTenant({
|
||||
id: row.id,
|
||||
});
|
||||
if (code == 200) {
|
||||
ElMessage.success('操作成功');
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
const addDialogRef = ref();
|
||||
// 新增弹窗打开
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function submit() {
|
|||
}
|
||||
|
||||
function downloadTemplate() {
|
||||
window.open('https://cankao.obs.cn-east-3.myhuaweicloud.com/%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx');
|
||||
window.open('https://cankao.obs.cn-east-3.myhuaweicloud.com/%E5%AD%90%E8%B4%A6%E5%8F%B7%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx');
|
||||
}
|
||||
|
||||
const errorMsg = ref('');
|
||||
|
|
|
|||
|
|
@ -64,6 +64,11 @@
|
|||
<el-button type="text" @click="addOpen(scope.row)">编辑</el-button>
|
||||
<el-button type="text" v-if="scope.row.status === 1" @click="doUpdateStatus(scope.row)">启用</el-button>
|
||||
<el-button type="text" v-else @click="doUpdateStatus(scope.row)">禁用</el-button>
|
||||
<el-popconfirm title="请确认是否删除" placement="top" @confirm="doDeleteTenantUser(scope.row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" text>删除</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</tableComponents>
|
||||
|
|
@ -81,7 +86,7 @@ import { ElMessage, ElMessageBox } from 'element-plus';
|
|||
import addDialog from './add.vue';
|
||||
import importDialog from './import.vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { disableTenantUser, enableTenantUser, exportTenantUser, getTenantUserList } from '/@/api/tenant';
|
||||
import { deleteTenantUser, disableTenantUser, enableTenantUser, exportTenantUser, getTenantUserList } from '/@/api/tenant';
|
||||
import { ACCOUNTTYPE_CONST, STATUS_CONST } from '/@/views/pages/tenant/constant';
|
||||
|
||||
type FormData = {
|
||||
|
|
@ -149,9 +154,23 @@ async function doUpdateStatus(row: IData) {
|
|||
if (code == 200) {
|
||||
ElMessage.success('操作成功');
|
||||
getData();
|
||||
} else {
|
||||
if(row.status === 1) {
|
||||
ElMessage.error('启用失败,当前可管理子账号已达上限,请先删除无用子账号再启用');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 删除
|
||||
async function doDeleteTenantUser(row: IData) {
|
||||
let { code, data } = await deleteTenantUser({
|
||||
id: row.id,
|
||||
});
|
||||
if (code == 200) {
|
||||
ElMessage.success('操作成功');
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
const addDialogRef = ref();
|
||||
// 新增弹窗打开
|
||||
|
|
|
|||
Loading…
Reference in New Issue