This commit is contained in:
2023-06-27 17:33:06 +08:00
parent a018802ee9
commit a9e88c99ad
3 changed files with 37 additions and 8 deletions

View File

@ -6,3 +6,11 @@ export const check = (tenantId) => {
method: "POST",
});
};
// /tenant/init/createTables/{tenantId}
export const createTables = (tenantId) => {
return request({
url: `/tenant/init/createTables/${tenantId}`,
method: "POST",
});
};

View File

@ -81,7 +81,7 @@ export const tenantModeDict = [
elTagType: "primary",
},
{
label: "数据库",
label: "SCHEMA",
value: "2",
elTagType: "warning",
},

View File

@ -38,7 +38,8 @@
: 'success'
"
show-icon
>{{ tenantInitCheckResult.msg }}
>错误码: {{ tenantInitCheckResult.result }}, 错误信息:
{{ tenantInitCheckResult.msg }}
</el-alert>
<el-row style="margin-top: 36px">
<el-col :span="12">
@ -134,15 +135,19 @@
<div
v-else-if="currentStepStatus === 2"
class="circle-button"
@click=""
@click="createDatabase"
>
下一步
创建库
</div>
</el-col>
</el-row>
</div>
<template v-else-if="activeStep === 2">
<el-row justify="center">
<el-alert :closable="false" show-icon type="error"
>错误码: {{ createTablesResult.result }}, 错误信息:
{{ createTablesResult.msg }}</el-alert
>
<el-row justify="center" style="margin-top: 24px">
<el-col :span="1.5">
<div class="circle-button" @click="activeStep = 3">步骤2</div>
</el-col>
@ -160,7 +165,7 @@
</template>
<script setup>
import { onMounted, reactive, ref, toRefs, watchEffect } from "vue";
import { check } from "@/api/tenant/init";
import { check, createTables } from "@/api/tenant/init";
import { useRoute, useRouter } from "vue-router";
import { tenantModeDict } from "@/constant/dict";
@ -178,9 +183,10 @@ if (route.query.id) {
const data = reactive({
tenantInitCheckResult: {},
createTablesResult: {},
});
const { tenantInitCheckResult } = toRefs(data);
const { tenantInitCheckResult, createTablesResult } = toRefs(data);
const tenantInitCheck = () => {
activeStep.value = 1;
currentStepStatus.value = 1;
@ -193,6 +199,21 @@ const tenantInitCheck = () => {
}
});
};
// 创建数据库
const createDatabase = () => {
activeStep.value = 2;
currentStepStatus.value = 1;
createTables(tenantId.value).then((resp) => {
createTablesResult.value = resp;
if (resp.result === 200) {
currentStepStatus.value = 2;
} else {
currentStepStatus.value = 0;
}
});
};
onMounted(() => {
watchEffect(() => {
const progressLineWidth =
@ -202,7 +223,7 @@ onMounted(() => {
let progressLineColor;
if (currentStepStatus.value === 0) {
const percent = (activeStep.value - 1) / progressLineWidth;
const percent = ((activeStep.value - 1) / activeStep.value) * 100;
progressLineColor = `linear-gradient(to right, #67c23a ${percent}%, #f56c6c ${percent}%)`;
// 进度条颜色
} else {