93 lines
2.6 KiB
Vue
Raw Normal View History

2023-03-20 15:49:41 +08:00
<template>
<div class="basic-information flx-column">
<div class="header-lf">
<div class="logo">
<!-- <img src="@/assets/images/logo.svg" alt="logo" /> -->
2023-07-15 18:20:41 +08:00
<!-- <img src="@/assets/images/login/china.png" style="margin: 0 15px" alt="logo" /> -->
<span>乳山工程建筑管理服务平台</span>
<span class="middle">|</span>
<span>企业注册</span>
</div>
<div class="header-rt" @click="router.push('/login')">
<span>已有帐号</span>
<span class="middle">|</span>
<span style="margin-right: 30px">马上登录</span>
</div>
</div>
2023-03-20 15:49:41 +08:00
<div class="container">
<Setps :datas="datas" :active="active" />
2023-03-20 15:49:41 +08:00
<keep-alive>
2023-03-27 14:17:30 +08:00
<component :ref="setRef" :is="components[active]" @next="next" @prev="prev" />
2023-03-20 15:49:41 +08:00
</keep-alive>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
2023-03-24 19:36:11 +08:00
import { useRouter } from "vue-router";
2023-03-20 15:49:41 +08:00
import Setps from "@/components/Steps/setps.vue";
import BasicForm from "./basic-form.vue";
import Entrepreneur from "./entrepreneur.vue";
import Registered from "./registered.vue";
import { datas as values } from "@/enums/company/SetpsEnum";
2023-03-24 19:36:11 +08:00
import { addCompany } from "@/api/modules/jxjview";
import type { RuleFormData } from "./basic-form.vue";
import type { EnterpriseMains } from "./entrepreneur.vue";
import { ElMessage } from "element-plus";
2023-03-20 15:49:41 +08:00
2023-03-24 19:36:11 +08:00
const router = useRouter();
2023-03-20 15:49:41 +08:00
const datas = reactive(values);
const active = ref(0);
2023-03-24 19:36:11 +08:00
const requestData = ref({});
2023-03-27 14:17:30 +08:00
const onReset = ref<[typeof BasicForm | undefined]>([undefined]);
2023-03-20 15:49:41 +08:00
const components = [BasicForm, Entrepreneur, Registered];
2023-03-27 14:17:30 +08:00
const setRef = (el: any) => {
if (el && el.reset) {
onReset.value = [el];
}
};
2023-03-24 19:36:11 +08:00
const next = (e: RuleFormData | { enterpriseMains: EnterpriseMains[] }) => {
2023-03-20 15:49:41 +08:00
if (active.value >= datas.length - 1)
throw Error(
`if you operate again, active will be greater than the number of setps components.
error in views/companyview/basicinformation/index.vue, function name: next, line: 28`
);
2023-03-24 19:36:11 +08:00
requestData.value = Object.assign({}, requestData.value, e);
if (active.value === 1) {
return onSubmit();
}
2023-03-20 15:49:41 +08:00
active.value++;
};
const prev = () => {
if (active.value <= 0)
throw Error(`no last one. error in views/companyview/basicinformation/index.vue, function name: prve, line: 37`);
active.value--;
};
2023-03-24 19:36:11 +08:00
const onSubmit = async () => {
try {
2023-04-25 10:48:27 +08:00
// @ts-expect-error
2023-03-24 19:36:11 +08:00
await addCompany(requestData.value);
active.value++;
2023-03-27 14:17:30 +08:00
requestData.value = {};
// debugger;
2023-03-27 14:17:30 +08:00
onReset.value[0]?.reset();
2023-03-24 19:36:11 +08:00
} catch (err: any) {
2023-04-25 10:48:27 +08:00
// ElMessage.error(err);
2023-03-27 14:17:30 +08:00
// active.value++;
2023-03-24 19:36:11 +08:00
// router.replace("/login");
}
};
2023-03-20 15:49:41 +08:00
</script>
<style scoped lang="scss">
@import "./index.scss";
</style>