Files

103 lines
2.3 KiB
Vue
Raw Normal View History

2022-07-22 17:32:45 +08:00
<template>
<div class="app-container">
<!-- <div style="width: 50%">
<ExpertForm
v-model="form"
:showTitle="true"
:formType="formType"
:labelWidth="140"
ref="expertFormRef"
/>
</div> -->
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="submitForm">提交</el-button>
</div>
</template>
<script setup name="EnterpriseAdd">
// import ExpertForm from "@/views/components/ExpertForm";
import tab from "@/plugins/tab";
import {
companyAdd,
companyDetail,
companyEdit,
} from "@/api/dataList/enterprise";
import { reactive, toRefs } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
const router = useRouter();
const formType = ref(2);
const expertFormRef = ref(null);
const data = reactive({
form: {
image: undefined,
name: undefined,
tenantId: undefined,
province: undefined, // 省code
city: undefined, // 市code
district: undefined, // 区code
address: undefined, // 详细地址
product: undefined,
kind: undefined,
code: undefined,
inviterCode: undefined,
url: undefined,
industrys: [],
keywords: [],
directions: [],
introduce: undefined,
license: undefined,
},
});
const { form } = toRefs(data);
const cancel = () => {
router.back();
tab.closeOpenPage();
};
const submitForm = () => {
if (this.$refs.expertForm.submitForm()) {
console.log(form.value);
// todo... 提交出错
if (form.value.id != undefined) {
companyEdit(form.value).then((response) => {
this.$store.dispatch("tagsView/delView", this.$route);
router.go(-1);
ElMessage.success("修改成功");
});
} else {
companyAdd(form.value).then((res) => {
this.$store.dispatch("tagsView/delView", this.$route);
router.go(-1);
ElMessage.success("新增成功");
});
}
} else {
console.log("校验未通过");
}
};
</script>
<!-- <script>
export default {
components: {
ExpertForm,
},
data() {
return {
// formType: 2,
// labelWidth: 140,
};
},
methods: {},
created() {
const { id } = this.$route.query;
if (id) {
companyDetail({ id }).then((res) => {
form.value = res.data;
});
}
},
};
</script> -->