This commit is contained in:
2023-06-30 15:40:14 +08:00
parent a6bf525fbe
commit dcf9b645f3

View File

@ -13,10 +13,10 @@
class="init-steps" class="init-steps"
finish-status="success" finish-status="success"
> >
<el-step title="开始" /> <el-step title="开始"/>
<el-step title="检查" /> <el-step title="检查"/>
<el-step title="步骤2" /> <el-step title="步骤2"/>
<el-step title="步骤3" /> <el-step title="步骤3"/>
</el-steps> </el-steps>
<!-- 错误提示 --> <!-- 错误提示 -->
@ -143,7 +143,7 @@
<el-col :span="1.5"> <el-col :span="1.5">
<div class="btn-loading"> <div class="btn-loading">
<el-icon size="80"> <el-icon size="80">
<refresh /> <refresh/>
</el-icon> </el-icon>
</div> </div>
</el-col> </el-col>
@ -221,11 +221,11 @@
</div> </div>
</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, initData} from "@/api/tenant/init";
import { useRoute, useRouter } from "vue-router"; import {useRoute, useRouter} from "vue-router";
import { tenantModeDict } from "@/constant/dict"; import {tenantModeDict} from "@/constant/dict";
import { Refresh } from "@element-plus/icons-vue"; import {Refresh} from "@element-plus/icons-vue";
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@ -236,7 +236,7 @@ const loading = ref(false);
if (route.query.id) { if (route.query.id) {
tenantId.value = route.query.id; tenantId.value = route.query.id;
} else { } else {
router.push({ path: "/tenant/tenant" }); router.push({path: "/tenant/tenant"});
} }
const data = reactive({ const data = reactive({
@ -245,7 +245,7 @@ const data = reactive({
initDataResult: {}, initDataResult: {},
}); });
const { tenantInitCheckResult, createTablesResult, initDataResult } = const {tenantInitCheckResult, createTablesResult, initDataResult} =
toRefs(data); toRefs(data);
const initTenant = async () => { const initTenant = async () => {
@ -266,19 +266,19 @@ const tenantInitCheck = () => {
activeStep.value = 1; activeStep.value = 1;
currentStepStatus.value = 1; currentStepStatus.value = 1;
return check(tenantId.value) return check(tenantId.value)
.then((resp) => { .catch(() => {
currentStepStatus.value = 2;
activeStep.value = 0;
throw new Error("租户初始化检查失败");
}).then((resp) => {
tenantInitCheckResult.value = resp; tenantInitCheckResult.value = resp;
if (resp.result === 200) { if (resp.result === 200) {
currentStepStatus.value = 2; currentStepStatus.value = 2;
} else { } else {
currentStepStatus.value = 0; currentStepStatus.value = 0;
throw new Error("租户初始化检查失败");
} }
}) })
.catch(() => {
currentStepStatus.value = 2;
activeStep.value = 0;
throw new Error("租户初始化检查失败");
});
}; };
// 第二步: 创建数据库 // 第二步: 创建数据库
@ -287,19 +287,19 @@ const createDatabase = () => {
activeStep.value = 2; activeStep.value = 2;
currentStepStatus.value = 1; currentStepStatus.value = 1;
return createTables(tenantId.value) return createTables(tenantId.value)
.then((resp) => { .catch(() => {
currentStepStatus.value = 2;
activeStep.value = 1;
throw new Error("创建数据库失败");
}).then((resp) => {
createTablesResult.value = resp; createTablesResult.value = resp;
if (resp.result === 200) { if (resp.result === 200) {
currentStepStatus.value = 2; currentStepStatus.value = 2;
} else { } else {
currentStepStatus.value = 0; currentStepStatus.value = 0;
throw new Error("创建数据库失败");
} }
}) })
.catch(() => {
currentStepStatus.value = 2;
activeStep.value = 1;
throw new Error("创建数据库失败");
});
}; };
// 第三步,导入数据 // 第三步,导入数据
@ -308,19 +308,19 @@ const importData = () => {
activeStep.value = 3; activeStep.value = 3;
currentStepStatus.value = 1; currentStepStatus.value = 1;
return initData(tenantId.value) return initData(tenantId.value)
.then((resp) => { .catch(() => {
currentStepStatus.value = 2;
activeStep.value = 2;
throw new Error("导入数据失败");
}).then((resp) => {
initDataResult.value = resp; initDataResult.value = resp;
if (resp.result === 200) { if (resp.result === 200) {
currentStepStatus.value = 2; currentStepStatus.value = 2;
} else { } else {
currentStepStatus.value = 0; currentStepStatus.value = 0;
throw new Error("导入数据失败");
} }
}) })
.catch(() => {
currentStepStatus.value = 2;
activeStep.value = 2;
throw new Error("导入数据失败");
});
}; };
onMounted(() => { onMounted(() => {