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