2026-01-20 16:30:03 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view class="profile-page">
|
|
|
|
|
|
<!-- 表单区域 -->
|
|
|
|
|
|
<view class="form-section bg-white">
|
|
|
|
|
|
<!-- 姓名 -->
|
2026-01-21 13:37:54 +08:00
|
|
|
|
<form-input
|
|
|
|
|
|
name="姓名"
|
|
|
|
|
|
:required="true"
|
|
|
|
|
|
:form="formData"
|
2026-01-21 15:27:18 +08:00
|
|
|
|
title="anotherName"
|
2026-01-21 13:37:54 +08:00
|
|
|
|
@change="handleFieldChange"
|
|
|
|
|
|
/>
|
2026-01-20 16:30:03 +08:00
|
|
|
|
<!-- 头像 -->
|
|
|
|
|
|
<common-cell name="头像">
|
|
|
|
|
|
<view class="form-content__wrapper" @click="chooseAvatar">
|
|
|
|
|
|
<view class="flex-main-content flex items-center">
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="formData.avatar"
|
|
|
|
|
|
class="avatar-preview"
|
|
|
|
|
|
:src="formData.avatar"
|
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<uni-icons class="form-arrow" type="arrowright"></uni-icons>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</common-cell>
|
|
|
|
|
|
<!-- 性别 -->
|
|
|
|
|
|
<form-select
|
|
|
|
|
|
name="性别"
|
|
|
|
|
|
:form="formData"
|
|
|
|
|
|
title="gender"
|
|
|
|
|
|
:range="genderOptions"
|
|
|
|
|
|
@change="handleFieldChange"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<!-- 手机号(不可修改) -->
|
|
|
|
|
|
<common-cell name="手机号 (不可修改)">
|
|
|
|
|
|
<view class="form-content__wrapper">
|
2026-01-21 13:37:54 +08:00
|
|
|
|
<view class="flex-main-content text-dark">{{ formData.mobile }}</view>
|
2026-01-20 16:30:03 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</common-cell>
|
|
|
|
|
|
<!-- 岗位 -->
|
|
|
|
|
|
<form-select
|
|
|
|
|
|
name="岗位"
|
|
|
|
|
|
:form="formData"
|
|
|
|
|
|
title="position"
|
|
|
|
|
|
:range="positionOptions"
|
|
|
|
|
|
@change="handleFieldChange"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<!-- 职称 -->
|
|
|
|
|
|
<form-select
|
|
|
|
|
|
name="职称"
|
|
|
|
|
|
:form="formData"
|
|
|
|
|
|
title="title"
|
|
|
|
|
|
:range="titleOptions"
|
|
|
|
|
|
@change="handleFieldChange"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<!-- 科室 -->
|
2026-01-21 13:37:54 +08:00
|
|
|
|
<common-cell name="科室">
|
2026-01-20 16:30:03 +08:00
|
|
|
|
<view class="form-content__wrapper" @click="openDepartmentSelect">
|
|
|
|
|
|
<view
|
|
|
|
|
|
class="flex-main-content text-right"
|
|
|
|
|
|
:class="{ 'text-placeholder': !formData.departmentName }"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ formData.departmentName || "请选择" }}
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<uni-icons class="form-arrow" type="arrowright"></uni-icons>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</common-cell>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 个人介绍 -->
|
|
|
|
|
|
<form-textarea
|
|
|
|
|
|
name="个人介绍"
|
|
|
|
|
|
:form="formData"
|
|
|
|
|
|
title="intro"
|
|
|
|
|
|
:word-limit="500"
|
|
|
|
|
|
@change="handleFieldChange"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<!-- 底部按钮 -->
|
|
|
|
|
|
<view class="button-footer">
|
|
|
|
|
|
<view class="btn btn-cancel" @click="handleCancel">取消</view>
|
|
|
|
|
|
<view class="btn btn-save" @click="handleSave">保存</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
import useGuard from "@/hooks/useGuard.js";
|
2026-01-21 13:37:54 +08:00
|
|
|
|
import { chooseAndUploadImage } from "@/utils/file.js";
|
2026-01-20 16:30:03 +08:00
|
|
|
|
import useAccountStore from "@/store/account.js";
|
|
|
|
|
|
import { storeToRefs } from "pinia";
|
|
|
|
|
|
import CommonCell from "@/components/form-template/common-cell.vue";
|
2026-01-21 13:37:54 +08:00
|
|
|
|
import FormInput from "@/components/form-template/form-cell/form-input.vue";
|
2026-01-20 16:30:03 +08:00
|
|
|
|
import FormSelect from "@/components/form-template/form-cell/form-select.vue";
|
|
|
|
|
|
import FormTextarea from "@/components/form-template/form-cell/form-textarea.vue";
|
2026-01-21 13:37:54 +08:00
|
|
|
|
import api from "@/utils/api.js";
|
|
|
|
|
|
const { account, doctorInfo } = storeToRefs(useAccountStore());
|
2026-01-20 16:30:03 +08:00
|
|
|
|
const { useLoad } = useGuard();
|
2026-01-21 15:27:18 +08:00
|
|
|
|
const { getDoctorInfo } = useAccountStore();
|
2026-01-20 16:30:03 +08:00
|
|
|
|
// 表单数据
|
|
|
|
|
|
const formData = ref({
|
2026-01-21 15:27:18 +08:00
|
|
|
|
anotherName: "",
|
2026-01-20 16:30:03 +08:00
|
|
|
|
avatar: "",
|
|
|
|
|
|
gender: "",
|
2026-01-21 13:37:54 +08:00
|
|
|
|
mobile: "",
|
2026-01-20 16:30:03 +08:00
|
|
|
|
position: "",
|
|
|
|
|
|
title: "",
|
|
|
|
|
|
department: "",
|
|
|
|
|
|
departmentName: "",
|
|
|
|
|
|
departmentId: "",
|
|
|
|
|
|
intro: "",
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 选项数据
|
2026-01-21 15:27:18 +08:00
|
|
|
|
const genderOptions = [
|
|
|
|
|
|
{ label: "男", value: "0" },
|
|
|
|
|
|
{ label: "女", value: "1" },
|
|
|
|
|
|
];
|
2026-01-20 16:30:03 +08:00
|
|
|
|
const positionOptions = ["医生", "护士", "药师", "技师", "其他"];
|
2026-01-21 13:37:54 +08:00
|
|
|
|
const titleOptions = ["主任医师", "副主任医师", "主治医师", "医师", "其他"];
|
2026-01-20 16:30:03 +08:00
|
|
|
|
// 字段变更处理
|
|
|
|
|
|
const handleFieldChange = (e) => {
|
2026-01-21 15:27:18 +08:00
|
|
|
|
if (e.title === "gender") {
|
|
|
|
|
|
formData.value[e.title] = e.value.value;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
formData.value[e.title] = e.value;
|
|
|
|
|
|
}
|
2026-01-20 16:30:03 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 选择头像
|
2026-01-21 13:37:54 +08:00
|
|
|
|
const chooseAvatar = async () => {
|
2026-01-21 15:27:18 +08:00
|
|
|
|
const url = await chooseAndUploadImage();
|
|
|
|
|
|
if (url) {
|
|
|
|
|
|
formData.value.avatar = url;
|
2026-01-21 13:37:54 +08:00
|
|
|
|
}
|
2026-01-20 16:30:03 +08:00
|
|
|
|
};
|
|
|
|
|
|
const handleCancel = () => {
|
|
|
|
|
|
uni.navigateBack();
|
|
|
|
|
|
};
|
|
|
|
|
|
// 保存
|
|
|
|
|
|
const handleSave = async () => {
|
2026-01-21 15:27:18 +08:00
|
|
|
|
createDoctorInfo();
|
2026-01-20 16:30:03 +08:00
|
|
|
|
};
|
2026-01-21 13:37:54 +08:00
|
|
|
|
useLoad(() => {
|
|
|
|
|
|
if (doctorInfo.value) {
|
2026-01-21 15:27:18 +08:00
|
|
|
|
formData.value = { ...doctorInfo.value };
|
2026-01-21 13:37:54 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
formData.value.mobile = account.value.mobile;
|
2026-01-20 16:30:03 +08:00
|
|
|
|
}
|
2026-01-21 13:37:54 +08:00
|
|
|
|
});
|
2026-01-20 16:30:03 +08:00
|
|
|
|
|
2026-01-21 13:37:54 +08:00
|
|
|
|
// 创建医生信息
|
|
|
|
|
|
const createDoctorInfo = async () => {
|
2026-01-21 15:27:18 +08:00
|
|
|
|
if (!formData.value.anotherName) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: "请输入姓名",
|
|
|
|
|
|
icon: "none",
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-01-21 13:37:54 +08:00
|
|
|
|
let params = {
|
2026-01-21 15:27:18 +08:00
|
|
|
|
anotherName: formData.value.anotherName,
|
2026-01-21 13:37:54 +08:00
|
|
|
|
avatar: formData.value.avatar,
|
|
|
|
|
|
gender: formData.value.gender,
|
|
|
|
|
|
mobile: formData.value.mobile,
|
2026-01-21 15:27:18 +08:00
|
|
|
|
weChatOpenId: account.value.openid,
|
2026-01-21 13:37:54 +08:00
|
|
|
|
deptIds: [],
|
2026-01-21 15:27:18 +08:00
|
|
|
|
loginTypes: ["wxApp"],
|
|
|
|
|
|
corpId: account.value.corpId,
|
2026-01-21 13:37:54 +08:00
|
|
|
|
};
|
|
|
|
|
|
const res = await api("addCorpMember", {
|
|
|
|
|
|
params,
|
|
|
|
|
|
});
|
|
|
|
|
|
if (res.success && res.data) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: "创建成功",
|
|
|
|
|
|
icon: "success",
|
2026-01-20 16:30:03 +08:00
|
|
|
|
});
|
2026-01-21 15:27:18 +08:00
|
|
|
|
await getDoctorInfo();
|
|
|
|
|
|
uni.navigateBack();
|
2026-01-21 13:37:54 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: "创建失败",
|
|
|
|
|
|
icon: "none",
|
|
|
|
|
|
});
|
|
|
|
|
|
console.error("创建医生信息失败:", res);
|
2026-01-20 16:30:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2026-01-21 15:27:18 +08:00
|
|
|
|
|
|
|
|
|
|
const updateDoctorInfo = async () => {
|
|
|
|
|
|
let params = {
|
|
|
|
|
|
anotherName: formData.value.anotherName,
|
|
|
|
|
|
avatar: formData.value.avatar,
|
|
|
|
|
|
gender: formData.value.gender,
|
|
|
|
|
|
};
|
|
|
|
|
|
const res = await api("updateCorpMember", {
|
|
|
|
|
|
params,
|
|
|
|
|
|
});
|
|
|
|
|
|
if (res.success && res.data) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: "更新成功",
|
|
|
|
|
|
icon: "success",
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
await getDoctorInfo();
|
|
|
|
|
|
uni.navigateBack();
|
|
|
|
|
|
};
|
2026-01-20 16:30:03 +08:00
|
|
|
|
// 打开科室选择
|
|
|
|
|
|
const openDepartmentSelect = () => {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: "/pages/work/department-select",
|
|
|
|
|
|
events: {
|
|
|
|
|
|
deptSelected: ({ name, deptId }) => {
|
|
|
|
|
|
formData.value.department = name || "";
|
|
|
|
|
|
formData.value.departmentName = name || "";
|
|
|
|
|
|
formData.value.departmentId = deptId || "";
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.profile-page {
|
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
|
background: #f5f5f5;
|
|
|
|
|
|
padding-bottom: 120rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-section {
|
|
|
|
|
|
margin-top: 20rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-content__wrapper {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
text-align: right;
|
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
|
|
|
|
|
|
|
input {
|
|
|
|
|
|
text-align: right;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-placeholder {
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.avatar-preview {
|
|
|
|
|
|
width: 80rpx;
|
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background: #e5e5e5;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.avatar-placeholder {
|
|
|
|
|
|
width: 80rpx;
|
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background: #e5e5e5;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
|
|
|
|
.avatar-icon {
|
|
|
|
|
|
font-size: 48rpx;
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.button-footer {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
padding: 20rpx 30rpx;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border-top: 1px solid #eee;
|
|
|
|
|
|
gap: 20rpx;
|
|
|
|
|
|
z-index: 100;
|
|
|
|
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
height: 88rpx;
|
|
|
|
|
|
line-height: 88rpx;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
border-radius: 8rpx;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.btn-cancel {
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border: 1px solid #007aff;
|
|
|
|
|
|
color: #007aff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.btn-save {
|
|
|
|
|
|
background: #007aff;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|