This commit is contained in:
2023-06-29 11:19:07 +08:00
parent a9e88c99ad
commit 5205b26147
2 changed files with 123 additions and 69 deletions

View File

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

View File

@ -143,20 +143,42 @@
</el-row> </el-row>
</div> </div>
<template v-else-if="activeStep === 2"> <template v-else-if="activeStep === 2">
<el-alert :closable="false" show-icon type="error" <el-alert v-if="currentStepStatus === 0" :closable="false" show-icon type="error"
>错误码: {{ createTablesResult.result }}, 错误信息: >错误码: {{ createTablesResult.result }}, 错误信息:
{{ createTablesResult.msg }}</el-alert {{ createTablesResult.msg }}
</el-alert
> >
<el-row justify="center" style="margin-top: 24px"> <el-row justify="center" style="margin-top: 24px">
<el-col :span="1.5"> <el-col :span="1.5">
<div class="circle-button" @click="activeStep = 3">步骤2</div> <div
v-if="currentStepStatus === 0"
class="circle-button error"
@click="router.push({ path: '/tenant/tenant' })"
>
关闭
</div>
<div v-else-if="currentStepStatus === 2" class="circle-button" @click="importData">导入数据</div>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
<template v-else-if="activeStep === 3"> <template v-else-if="activeStep === 3">
<el-row justify="center"> <el-alert v-if="currentStepStatus === 0" :closable="false" show-icon type="error"
>错误码: {{ initDataResult.result }}, 错误信息:
{{ initDataResult.msg }}
</el-alert
>
<el-row justify="center" style="margin-top: 24px">
<el-col :span="1.5"> <el-col :span="1.5">
<div class="circle-button" @click="activeStep = 4">步骤3</div> <div
v-if="currentStepStatus === 0"
class="circle-button error"
@click="router.push({ path: '/tenant/tenant' })"
>
关闭
</div>
<div v-else-if="currentStepStatus===2" class="circle-button finish"
@click="router.push({ path: '/tenant/tenant' })">完成
</div>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
@ -165,7 +187,7 @@
</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 } 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";
@ -184,9 +206,10 @@ if (route.query.id) {
const data = reactive({ const data = reactive({
tenantInitCheckResult: {}, tenantInitCheckResult: {},
createTablesResult: {}, createTablesResult: {},
initDataResult: {},
}); });
const { tenantInitCheckResult, createTablesResult } = toRefs(data); const {tenantInitCheckResult, createTablesResult, initDataResult} = toRefs(data);
const tenantInitCheck = () => { const tenantInitCheck = () => {
activeStep.value = 1; activeStep.value = 1;
currentStepStatus.value = 1; currentStepStatus.value = 1;
@ -197,10 +220,13 @@ const tenantInitCheck = () => {
} else { } else {
currentStepStatus.value = 0; currentStepStatus.value = 0;
} }
}).catch(() => {
currentStepStatus.value = 2;
activeStep.value = 2;
}); });
}; };
// 创建数据库 // 第二步: 创建数据库
const createDatabase = () => { const createDatabase = () => {
activeStep.value = 2; activeStep.value = 2;
currentStepStatus.value = 1; currentStepStatus.value = 1;
@ -211,6 +237,26 @@ const createDatabase = () => {
} else { } else {
currentStepStatus.value = 0; currentStepStatus.value = 0;
} }
}).catch(() => {
currentStepStatus.value = 2;
activeStep.value = 2;
});
};
// 第三步,导入数据
const importData = () => {
activeStep.value = 3;
currentStepStatus.value = 1;
initData(tenantId.value).then((resp) => {
initDataResult.value = resp;
if (resp.result === 200) {
currentStepStatus.value = 2;
} else {
currentStepStatus.value = 0;
}
}).catch(() => {
currentStepStatus.value = 2;
activeStep.value = 2;
}); });
}; };