bug fix and performance improve
This commit is contained in:
@ -125,3 +125,15 @@ export const switchPrimary = (tenantId, id) => {
|
|||||||
method: "PUT",
|
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="用户数量" prop="accountCount" />
|
||||||
<el-table-column align="center" label="状态">
|
<el-table-column align="center" label="状态">
|
||||||
<template #default="{ row }">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="center" label="初始化状态">
|
<el-table-column align="center" label="初始化状态">
|
||||||
@ -435,10 +441,11 @@
|
|||||||
<el-table-column label="使用" align="center">
|
<el-table-column label="使用" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-switch
|
<el-switch
|
||||||
|
:loading="isSwitchingIsPrimary"
|
||||||
active-value="1"
|
active-value="1"
|
||||||
inactive-value="0"
|
inactive-value="0"
|
||||||
:model-value="row.isPrimary"
|
:model-value="row.isPrimary"
|
||||||
@click="handleSwitchIsPrimary(row)"
|
@change="handleSwitchIsPrimary($event, row)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -496,6 +503,7 @@ import {
|
|||||||
updateMode,
|
updateMode,
|
||||||
updateDatasource,
|
updateDatasource,
|
||||||
updateTenant,
|
updateTenant,
|
||||||
|
updateStatus,
|
||||||
} from "@/api/tenant/tenant";
|
} from "@/api/tenant/tenant";
|
||||||
import { getCurrentInstance, reactive, ref, toRefs } from "vue";
|
import { getCurrentInstance, reactive, ref, toRefs } from "vue";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
@ -814,6 +822,39 @@ const handleSetting = (row) => {
|
|||||||
showTenantSetting.value = true;
|
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() {
|
function submitForm() {
|
||||||
proxy.$refs["tenantRef"].validate((valid) => {
|
proxy.$refs["tenantRef"].validate((valid) => {
|
||||||
@ -891,14 +932,39 @@ function handleRefreshCache() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 正在切换isPrimary 的索引
|
||||||
|
const switchingIsPrimaryIndex = ref(-1);
|
||||||
|
const isSwitchingIsPrimary = ref(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 切换数据源使用状态
|
* 切换数据源使用状态
|
||||||
|
* @param val
|
||||||
* @param row
|
* @param row
|
||||||
*/
|
*/
|
||||||
function handleSwitchIsPrimary(row) {
|
function handleSwitchIsPrimary(val, row) {
|
||||||
switchPrimary(tempTenantId.value, row.datasourceId).then(async () => {
|
const messageVNode = () => (
|
||||||
const resp = await datasourceList(tempTenantId.value);
|
<>
|
||||||
datasource.value = resp.data;
|
要修改
|
||||||
|
<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