bug fix and performance improve
This commit is contained in:
@ -125,3 +125,15 @@ export const switchPrimary = (tenantId, id) => {
|
||||
method: "PUT",
|
||||
});
|
||||
};
|
||||
|
||||
// 修改租户状态
|
||||
export const updateStatus = (tenantId, status) => {
|
||||
return request({
|
||||
url: "/tenant/update-status",
|
||||
method: "put",
|
||||
params: {
|
||||
tenantId,
|
||||
status,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -122,7 +122,13 @@
|
||||
<el-table-column align="center" label="用户数量" prop="accountCount" />
|
||||
<el-table-column align="center" label="状态">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="tenant_status_dict" :value="row.status" />
|
||||
<el-switch
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
:model-value="row.status"
|
||||
:loading="isTenantStatusSwitching"
|
||||
@change="handleChangeTenantStatus($event, row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="初始化状态">
|
||||
@ -435,10 +441,11 @@
|
||||
<el-table-column label="使用" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
:loading="isSwitchingIsPrimary"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
:model-value="row.isPrimary"
|
||||
@click="handleSwitchIsPrimary(row)"
|
||||
@change="handleSwitchIsPrimary($event, row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -496,6 +503,7 @@ import {
|
||||
updateMode,
|
||||
updateDatasource,
|
||||
updateTenant,
|
||||
updateStatus,
|
||||
} from "@/api/tenant/tenant";
|
||||
import { getCurrentInstance, reactive, ref, toRefs } from "vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
@ -814,6 +822,39 @@ const handleSetting = (row) => {
|
||||
showTenantSetting.value = true;
|
||||
};
|
||||
|
||||
const tenantStatusSwitchingIndex = ref(-1); // 租户状态切换中的索引
|
||||
// 是否正在租户状态切换
|
||||
const isTenantStatusSwitching = ref(false);
|
||||
/**
|
||||
* 修改租户状态
|
||||
*/
|
||||
const handleChangeTenantStatus = (val, row) => {
|
||||
const messageVNode = () => (
|
||||
<>
|
||||
要修改
|
||||
<el-tag type="success">{row.companyName}</el-tag>
|
||||
的状态, 请在下方输入"<span style="color: tomato">确定</span>".
|
||||
</>
|
||||
);
|
||||
ElMessageBox.prompt(messageVNode, "修改租户状态", {
|
||||
inputPattern: /^确定$/,
|
||||
inputErrorMessage: "输入不正确",
|
||||
}).then(async () => {
|
||||
// tenantStatusSwitchingIndex.value = index;
|
||||
isTenantStatusSwitching.value = true;
|
||||
updateStatus(row.tenantId, val)
|
||||
.then(() => {
|
||||
ElMessage.success("修改租户状态成功");
|
||||
})
|
||||
.finally(() => {
|
||||
isTenantStatusSwitching.value = false;
|
||||
})
|
||||
.then(() => {
|
||||
getList();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["tenantRef"].validate((valid) => {
|
||||
@ -891,15 +932,40 @@ function handleRefreshCache() {
|
||||
});
|
||||
}
|
||||
|
||||
// 正在切换isPrimary 的索引
|
||||
const switchingIsPrimaryIndex = ref(-1);
|
||||
const isSwitchingIsPrimary = ref(false);
|
||||
|
||||
/**
|
||||
* 切换数据源使用状态
|
||||
* @param val
|
||||
* @param row
|
||||
*/
|
||||
function handleSwitchIsPrimary(row) {
|
||||
switchPrimary(tempTenantId.value, row.datasourceId).then(async () => {
|
||||
function handleSwitchIsPrimary(val, row) {
|
||||
const messageVNode = () => (
|
||||
<>
|
||||
要修改
|
||||
<el-tag type="success">{row.dbName}</el-tag>
|
||||
的状态, 请在下方输入"<span style="color: tomato">确定</span>".
|
||||
</>
|
||||
);
|
||||
ElMessageBox.prompt(messageVNode, "修改数据源使用状态", {
|
||||
inputPattern: /^确定$/,
|
||||
inputErrorMessage: "输入不正确",
|
||||
}).then(async () => {
|
||||
isSwitchingIsPrimary.value = true;
|
||||
switchPrimary(tempTenantId.value, row.datasourceId)
|
||||
.then(() => {
|
||||
ElMessage.success("修改租户状态成功");
|
||||
})
|
||||
.finally(() => {
|
||||
isSwitchingIsPrimary.value = false;
|
||||
})
|
||||
.then(async () => {
|
||||
const resp = await datasourceList(tempTenantId.value);
|
||||
datasource.value = resp.data;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user