2023-06-09 17:31:39 +08:00
|
|
|
<template>
|
|
|
|
<div class="app-container">
|
2023-06-13 13:40:54 +08:00
|
|
|
<el-card shadow="always" style="width: 55%; margin: 0 auto"
|
|
|
|
><p><b>基本资料</b></p>
|
|
|
|
<el-form
|
2023-06-09 17:31:39 +08:00
|
|
|
ref="personFormRef"
|
|
|
|
:model="personForm"
|
|
|
|
:rules="rules"
|
|
|
|
label-width="100px"
|
2023-06-13 13:40:54 +08:00
|
|
|
>
|
|
|
|
<el-form-item label="姓名:" prop="nickName">
|
|
|
|
<el-input v-model="personForm.nickName" placeholder="请输入姓名" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="手机:" prop="mobile">
|
|
|
|
<el-input v-model="personForm.mobile" placeholder="请输入手机号" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="邮箱:" prop="email">
|
|
|
|
<el-input v-model="personForm.email" placeholder="请输入邮箱" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="职务:" prop="post">
|
|
|
|
<el-input v-model="personForm.post" placeholder="请输入职务" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="固定电话:" prop="phone">
|
|
|
|
<el-input v-model="personForm.phone" placeholder="请输入固定电话" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button type="primary" @click="submitPersonalInfo">提交</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
<p><b>实验室资料</b></p>
|
|
|
|
<!-- <laboratory-form ref="labFormRef" v-model="form" :is-add="false"/>-->
|
|
|
|
<agent-form ref="agentFormRef" v-model="form" :is-add="false" />
|
|
|
|
<div :style="{ marginLeft: labelWidth + 'px' }">
|
|
|
|
<el-button type="primary" @click="submitExpertForm">提交</el-button>
|
|
|
|
</div>
|
|
|
|
</el-card>
|
2023-06-09 17:31:39 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import AgentForm from "@/views/components/AgentForm";
|
2023-06-13 13:40:54 +08:00
|
|
|
import { reactive, ref, toRefs } from "vue";
|
|
|
|
import { getInfo, updateLaboratory } from "@/api/admin/laboratory/account";
|
|
|
|
import { ElMessage } from "element-plus";
|
|
|
|
import { insertClientUser } from "@/api/admin/enterprise";
|
2023-06-09 17:31:39 +08:00
|
|
|
|
|
|
|
const data = reactive({
|
|
|
|
form: {
|
|
|
|
researchs: [],
|
2023-06-13 13:40:54 +08:00
|
|
|
keywords: [],
|
2023-06-09 17:31:39 +08:00
|
|
|
},
|
|
|
|
personForm: {},
|
|
|
|
rules: {},
|
2023-06-13 13:40:54 +08:00
|
|
|
personRules: {},
|
|
|
|
});
|
|
|
|
const { form, personForm, rules } = toRefs(data);
|
|
|
|
const agentFormRef = ref();
|
|
|
|
const personFormRef = ref();
|
2023-06-09 17:31:39 +08:00
|
|
|
const labelWidth = ref(140);
|
|
|
|
|
|
|
|
// 获取基础信息用于回显
|
|
|
|
const getBasicInfo = async () => {
|
2023-06-13 13:40:54 +08:00
|
|
|
const { data } = await getInfo();
|
|
|
|
data.laboratory.researchs =
|
|
|
|
data.laboratory.researchDirection?.split(",") ?? [];
|
2023-06-09 17:31:39 +08:00
|
|
|
data.laboratory.keywords = data.laboratory.keyword?.split(",") ?? [];
|
2023-06-13 13:40:54 +08:00
|
|
|
form.value = data.laboratory ?? {};
|
2023-06-09 17:31:39 +08:00
|
|
|
personForm.value = data.user ?? {};
|
|
|
|
};
|
|
|
|
|
|
|
|
const submitPersonalInfo = async () => {
|
|
|
|
try {
|
|
|
|
await personFormRef.value.validate();
|
|
|
|
await insertClientUser(personForm.value);
|
|
|
|
ElMessage.success("更新个人信息成功");
|
2023-06-13 13:40:54 +08:00
|
|
|
const { data } = await getInfo();
|
2023-06-09 17:31:39 +08:00
|
|
|
personForm.value = data.user ?? {};
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
2023-06-13 13:40:54 +08:00
|
|
|
};
|
2023-06-09 17:31:39 +08:00
|
|
|
const submitExpertForm = async () => {
|
|
|
|
const valid = await agentFormRef.value.validateForm();
|
|
|
|
if (valid) {
|
2023-06-13 13:40:54 +08:00
|
|
|
form.value.researchDirection = form.value.researchs?.join(",") ?? null;
|
|
|
|
form.value.keyword = form.value.keywords?.join(",") ?? null;
|
2023-06-09 17:31:39 +08:00
|
|
|
updateLaboratory(form.value).then((res) => {
|
|
|
|
ElMessage.success("修改成功");
|
2023-06-13 13:40:54 +08:00
|
|
|
getBasicInfo();
|
2023-06-09 17:31:39 +08:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
console.log("校验未通过");
|
|
|
|
}
|
2023-06-13 13:40:54 +08:00
|
|
|
};
|
2023-06-09 17:31:39 +08:00
|
|
|
getBasicInfo();
|
|
|
|
</script>
|
|
|
|
|
2023-06-13 13:40:54 +08:00
|
|
|
<style lang="scss" scoped></style>
|