initdata timeout

This commit is contained in:
2023-07-07 17:38:20 +08:00
parent 9bf2d3c7f0
commit b84f94ea3a
4 changed files with 45 additions and 1 deletions

View File

@ -21,3 +21,11 @@ export const initData = (tenantId) => {
timeout: 0, timeout: 0,
}); });
}; };
// 初始化完毕
export const initCompleted = (tenantId) => {
return request({
url: `/tenant/init/initCompleted/${tenantId}`,
method: "POST",
});
};

View File

@ -117,3 +117,11 @@ export function deleteDatasource(ids) {
method: "DELETE", method: "DELETE",
}); });
} }
// 切换为主数据源
export const switchPrimary = (tenantId, id) => {
return request({
url: `/tenant/datasource/switchPrimary/${tenantId}/${id}`,
method: "PUT",
});
};

View File

@ -432,6 +432,16 @@
label="密码" label="密码"
prop="password" prop="password"
></el-table-column> ></el-table-column>
<el-table-column label="使用" align="center">
<template #default="{ row }">
<el-switch
active-value="1"
inactive-value="0"
:model-value="row.isPrimary"
@click="handleSwitchIsPrimary(row)"
/>
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="140"> <el-table-column align="center" label="操作" width="140">
<template #default="{ row }"> <template #default="{ row }">
<el-button <el-button
@ -482,6 +492,7 @@ import {
insertDatasource, insertDatasource,
listTenant, listTenant,
refreshCache, refreshCache,
switchPrimary,
tenantSetting, tenantSetting,
updateDatasource, updateDatasource,
updateTenant, updateTenant,
@ -880,6 +891,17 @@ function handleRefreshCache() {
}); });
} }
/**
* 切换数据源使用状态
* @param row
*/
function handleSwitchIsPrimary(row) {
switchPrimary(tempTenantId.value, row.datasourceId).then(async () => {
const resp = await datasourceList(tempTenantId.value);
datasource.value = resp.data;
});
}
/** /**
* 前往初始化页面 * 前往初始化页面
*/ */

View File

@ -220,7 +220,12 @@
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref, toRefs, watchEffect } from "vue"; import { onMounted, reactive, ref, toRefs, watchEffect } from "vue";
import { check, createTables, initData } from "@/api/tenant/init"; import {
check,
createTables,
initCompleted,
initData,
} from "@/api/tenant/init";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { tenant_mode_dict } from "@/constant/dict"; import { tenant_mode_dict } from "@/constant/dict";
import { Refresh } from "@element-plus/icons-vue"; import { Refresh } from "@element-plus/icons-vue";
@ -317,6 +322,7 @@ const importData = () => {
initDataResult.value = resp; initDataResult.value = resp;
if (resp.result === 200) { if (resp.result === 200) {
currentStepStatus.value = 2; currentStepStatus.value = 2;
initCompleted(tenantId.value);
} else { } else {
currentStepStatus.value = 0; currentStepStatus.value = 0;
throw new Error("导入数据失败"); throw new Error("导入数据失败");