fix:问题修复

This commit is contained in:
huxuejian 2026-02-05 17:12:52 +08:00
parent 620a7b8f7e
commit 10d7bd7ac9
11 changed files with 307 additions and 175 deletions

View File

@ -18,7 +18,7 @@ const emits = defineEmits(['cancel', 'confirm']);
const props = defineProps({
hidedenShadow: {
type: Boolean,
dfault: true
default: false
},
cancelText: {
type: String,

View File

@ -1,5 +1,5 @@
<template>
<view>
<view :class="fullCenter ? 'flex flex-col justify-center h-full w-full ' : ''">
<image class="block mx-auto" :style="style" src="/static/empty.svg"></image>
<view v-if="showText" class="mt-10 text-base text-center text-gray">{{ text }}</view>
</view>
@ -7,6 +7,10 @@
<script setup>
import { computed } from 'vue';
const props = defineProps({
fullCenter: {
type: Boolean,
default: false
},
showText: {
type: Boolean,
default: true

View File

@ -107,6 +107,12 @@
"navigationBarTitleText": "选择科室"
}
},
{
"path": "hospital-select",
"style": {
"navigationBarTitleText": "选择医院"
}
},
{
"path": "verify/assistant",
"style": {

View File

@ -1,80 +1,84 @@
<template>
<view class="dept-page">
<view class="dept-container bg-white">
<view class="sidebar">
<view class="sidebar-search">
<input
v-model="keyword"
class="search-input"
type="text"
confirm-type="search"
placeholder="搜索一级科室"
placeholder-class="search-placeholder"
/>
<view v-if="keyword" class="clear-btn" @click="keyword = ''"
>清空</view
>
<full-page :customScroll="true">
<template #header>
<view class="flex items-center px-15 py-12 bg-white border-b">
<view class="w-0 flex-grow mr-10 border py-5 px-15 rounded-full">
<input v-model="keyword" class="w-full text-dark text-base" type="text" placeholder="搜索科室"
placeholder-class="text-base text-gray" />
</view>
<scroll-view class="sidebar-list" scroll-y>
<view
v-for="item in filteredLevel1List"
:key="item.deptId"
:class="[
'sidebar-item',
item.deptId === selectedParentId ? 'active' : '',
]"
@click="selectParent(item)"
>
<text class="sidebar-text">{{
item.hlwDeptName || item.deptName
}}</text>
<view class="text-primary text-base" @click="keyword = ''">
清空
</view>
</view>
</template>
<scroll-view v-if="filteredList.length" class="h-full bg-white" scroll-y="true">
<view v-for="i in filteredList" :key="`filter-${i.deptId}`" class="px-15 py-12 text-base text-dark border-b"
@click="select(i)">
{{ i.deptName }}
</view>
</scroll-view>
<view v-else-if="level1List.length" class="flex w-full h-full">
<view class="flex-shrink-0 sidebar h-full bg-white">
<scroll-view scroll-y="true" class="h-full" :scroll-into-view="anchor">
<view v-for="item in level1List" :key="item.deptId" :id="item.deptId"
class="relative p-10 text-center text-base border-b"
:class="item.deptId === selectedParentId ? 'text-primary active' : 'text-dark'" @click="selectParent(item)">
{{ item.hlwDeptName || item.deptName }}
</view>
</scroll-view>
</view>
<scroll-view class="content" scroll-y>
<view v-if="contentList.length" class="content-list">
<view
v-for="child in contentList"
:key="child.deptId"
:class="['dept-item', isSelected(child) ? 'selected' : '']"
@click="selectDept(child)"
>
<view class="dept-name-row">
<view class="dept-name">{{ child.deptName }}</view>
<text v-if="isSelected(child)" class="check-tag">已选</text>
<view class="flex-grow h-full bg-white">
<scroll-view v-if="contentList.length" scroll-y="true" class="h-full" :scroll-into-view="anchor2">
<view v-for="child in contentList" :key="child.deptId" :id="child.deptId"
class="flex justify-between items-center p-10 border-b"
:class="selectedMap[child.deptId] ? 'text-primary ' : 'text-dark'" @click="selectDept(child)">
<view class="flex-shrink-0 mr-10 text-base">
{{ child.deptName }}
</view>
<image v-if="selectedMap[child.deptId]" class="flex-shrink-0 icon-checked" src="/static/form/checked.svg" />
</view>
</view>
<view v-else class="empty-wrapper">
<empty-data text="暂无科室" />
</view>
</scroll-view>
</scroll-view>
<empty-data v-else fullCenter />
</view>
</view>
<empty-data v-else fullCenter />
<template #footer>
<view class="relative z-2 shadow-up bg-white">
<view class="pt-12 px-15 text-center" @click="toService()">
<text class="mr-5 text-base text-gray">如没有符合的内容</text>
<text class="text-base text-primary">联系客服</text>
</view>
<button-footer :showCancel="false" @confirm="save()" />
</view>
</template>
</full-page>
<view class="footer-tip">
如没有符合的内容请联系客服
<text class="link" @click="contactService">点击添加客服</text>
</view>
</view>
</template>
<script setup>
import { computed, ref, watch } from "vue";
import { computed, ref, nextTick } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { storeToRefs } from "pinia";
import useGuard from "@/hooks/useGuard.js";
import useAccountStore from "@/store/account.js";
import EmptyData from "@/components/empty-data.vue";
import api from "@/utils/api";
import { toast } from "@/utils/widget";
import buttonFooter from "@/components/button-footer.vue";
import EmptyData from "@/components/empty-data.vue";
import fullPage from "@/components/full-page.vue";
const { useLoad } = useGuard();
const deptList = ref([]);
const selectedParentId = ref("");
const selectedDeptId = ref("");
const selectedDeptIds = ref([]);
const keyword = ref("");
const anchor = ref('');
const anchor2 = ref('');
const eventName = ref('')
const selectedMap = computed(() => selectedDeptIds.value.reduce((acc, cur) => {
acc[cur] = true;
return acc
}, {}))
const sorter = (a, b) => {
const sortA = typeof a.sort === "number" ? a.sort : 0;
@ -88,13 +92,18 @@ const sorter = (a, b) => {
const level1List = computed(() =>
deptList.value.filter((i) => i.level === 1).sort(sorter)
);
const level2List = computed(() =>
deptList.value.filter((i) => i.level === 2).sort(sorter)
);
const filteredLevel1List = computed(() => {
const key = keyword.value.trim().toLowerCase();
if (!key) return level1List.value;
return level1List.value.filter((i) =>
i.deptName.toString().toLowerCase().includes(key)
);
const filteredList = computed(() => {
const target = keyword.value.trim();
if (target.trim()) {
const list1 = level1List.value.filter(i => i.deptName.includes(target));
const list2 = level2List.value.filter(i => i.deptName.includes(target));
return [...list1, ...list2];
}
return []
});
const contentList = computed(() => {
@ -107,114 +116,114 @@ const contentList = computed(() => {
return children;
});
function isSelected(item) {
const targetId = selectedDeptId.value;
return !!targetId && (item.deptId === targetId || item.deptId === targetId);
function select(i) {
if (i.level === 1) {
selectedParentId.value = i.deptId;
scrollTo(i.deptId);
} else if (i.level === 2) {
selectedParentId.value = i.parentId;
scrollTo(i.parentId, i.deptId);
}
keyword.value = '';
}
function scrollTo(parentId, deptId) {
if (parentId) anchor.value = '';
if (deptId) anchor2.value = '';
setTimeout(() => {
if (parentId) anchor.value = parentId;
if (deptId) anchor2.value = deptId;
}, 600);
}
async function fetchDeptList() {
uni.showLoading({ title: "加载中..." });
try {
const res = await api("getDeptList");
const res = await api("getAllHlwDeptList");
if (res && res.success && Array.isArray(res.data)) {
deptList.value = res.data;
hydrateSelectedParent();
deptList.value = res.data.map(i=>({
deptId:i.hlwDeptId,
deptName:i.hlwDeptName,
level:i.level,
parentId:i.parentId,
sort:i.sort,
createTime:i.createTime
}));
} else {
toast(res?.message || "获取科室失败");
}
} catch (error) {
console.error("获取科室失败", error);
toast("获取科室失败");
} finally {
uni.hideLoading();
}
}
function hydrateSelectedParent() {
//
if (selectedDeptId.value) {
const match =
deptList.value.find(
(i) =>
i.deptId === selectedDeptId.value || i.deptId === selectedDeptId.value
) || null;
if (match?.parentId) {
selectedParentId.value = match.parentId;
return;
}
}
// 使 parentId
if (selectedParentId.value) return;
//
const first = level1List.value[0];
if (first) {
selectedParentId.value = first.deptId;
}
}
watch(
filteredLevel1List,
(list) => {
if (!list.length) return;
const exists = list.some((i) => i.deptId === selectedParentId.value);
if (!exists) {
selectedParentId.value = list[0].deptId;
}
},
{ immediate: false }
);
function selectParent(item) {
selectedParentId.value = item.deptId;
console.log("selectedParentId", selectedParentId.value);
}
function emitSelection(item) {
const eventChannel =
typeof getOpenerEventChannel === "function"
? getOpenerEventChannel()
: null;
eventChannel?.emit("deptSelected", {
id: item.deptId,
deptId: item.deptId || item.deptId,
name: item.deptName,
level: item.level,
parentId: item.parentId,
});
}
function selectDept(item) {
selectedDeptId.value = item.deptId || item.deptId;
emitSelection(item);
uni.navigateBack();
if (selectedDeptIds.value.includes(item.deptId)) {
selectedDeptIds.value = selectedDeptIds.value.filter(i => i !== item.deptId);
} else {
selectedDeptIds.value.push(item.deptId)
}
}
function contactService() {
uni.showToast({
title: "请联系客服添加科室",
icon: "none",
});
function toService() {
uni.navigateTo({
url: '/pages/work/service/contact-service'
})
}
useLoad(() => {
function save() {
const depts = selectedDeptIds.value.map(i => {
const dept = level2List.value.find(j => j.deptId === i);
return dept ? { deptId: dept.deptId, deptName: dept.deptName } : null;
}).filter(Boolean);
if (depts.length) {
uni.$emit(eventName.value, depts);
uni.navigateBack();
} else {
toast('请选择科室');
}
}
useLoad((opt) => {
eventName.value = opt.eventName;
const deptIds = typeof opt.deptIds === 'string' ? opt.deptIds.split(',').filter(Boolean) : [];
selectedDeptIds.value = deptIds;
fetchDeptList();
});
onLoad((opts) => {
//
if (opts.parentId) {
selectedParentId.value = opts.parentId;
}
const passedDeptId = opts.deptId || opts.departmentId || opts.id;
if (passedDeptId) {
selectedDeptId.value = passedDeptId;
}
});
</script>
<style lang="scss" scoped>
.sidebar {
width: 280rpx;
border-right: 1px solid #eee;
}
.active::before {
content: "";
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 8rpx;
background: #0074ff;
}
.pt-12 {
padding-top: 24rpx;
}
.icon-checked {
width: 40rpx;
height: 40rpx;
}
.dept-page {
min-height: 100vh;
background: #f5f5f5;
@ -231,22 +240,6 @@ onLoad((opts) => {
height: 88vh;
}
.sidebar {
width: 230rpx;
background: #f8f9fb;
border-right: 1px solid #eef0f5;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.sidebar-search {
padding: 16rpx 14rpx 12rpx;
display: flex;
align-items: center;
gap: 10rpx;
}
.search-input {
flex: 1;
height: 64rpx;
@ -399,4 +392,3 @@ onLoad((opts) => {
color: #2a6ff2;
}
</style>

View File

@ -0,0 +1,99 @@
<template>
<full-page :customScroll="true" @reachBottom="getMore()">
<template #header>
<view class="flex items-center px-15 py-12 bg-white border-b">
<view class="w-0 flex-grow mr-10 border py-5 px-15 rounded-full">
<input v-model="keyword" class="w-full text-dark text-base" type="text" placeholder="搜索科室"
placeholder-class="text-base text-gray" />
</view>
<view class="text-primary text-base" @click="keyword = ''">
清空
</view>
</view>
</template>
<scroll-view v-if="list.length" class="h-full bg-white" scroll-y="true">
<view v-for="i in list" :key="`filter-${i.hospitalId}`" class="flex items-center px-15 py-12 border-b"
@click="select(i)">
<view class="mr-10 w-0 flex-grow text-base text-dark">{{ i.name }}</view>
<image v-if="hospital && hospital.hospitalId === i.hospitalId" class="flex-shrink-0 icon-checked"
src="/static/form/checked.svg" />
</view>
</scroll-view>
<empty-data v-else fullCenter />
<template #footer>
<view class="relative z-2 shadow-up bg-white">
<view class="pt-12 px-15 text-center" @click="toService()">
<text class="mr-5 text-base text-gray">如没有符合的内容</text>
<text class="text-base text-primary">联系客服</text>
</view>
<button-footer :showCancel="false" @confirm="save()" />
</view>
</template>
</full-page>
</template>
<script setup>
import { computed, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import usePageList from "@/hooks/usePageList"
import api from "@/utils/api";
import { toast } from "@/utils/widget";
import buttonFooter from "@/components/button-footer.vue";
import EmptyData from "@/components/empty-data.vue";
import fullPage from "@/components/full-page.vue";
const { total, list, loading, hasMore, page, pages, pageSize, keyword, changePage } = usePageList(getList)
const eventName = ref('');
const hospital = ref();
function select(i) {
hospital.value = i;
}
function getMore() {
if (hasMore.value && !loading.value) {
changePage(page.value + 1)
}
}
function save() {
if (hospital.value) {
uni.$emit(eventName.value, hospital.value.name)
uni.navigateBack()
} else {
toast('请选择医院')
}
}
function toService() {
uni.navigateTo({
url: '/pages/work/service/contact-service'
})
}
async function getList() {
const res = await api('getHlwHospitalList', { page: page.value, pageSize: pageSize.value, name: keyword.value })
const arr = res && Array.isArray(res.data) ? res.data : [];
list.value = page.value === 1 ? arr : list.value.concat(arr);
total.value = res && typeof res.total === 'number' ? res.total : 0;
pages.value = res && typeof res.pages === 'number' ? res.pages : 0;
if (!res || !res.success) {
toast(res?.message || '获取数据失败');
}
}
onLoad((opt) => {
eventName.value = opt.eventName;
changePage(1);
});
</script>
<style lang="scss" scoped>
.icon-checked {
width: 40rpx;
height: 40rpx;
}
</style>

View File

@ -27,8 +27,7 @@
</picker>
</common-cell>
<common-cell title="title" :name="rule.title.name">
<picker mode="selector" :disable="rule.title.disable" :range="titleOptions"
@change="changeTitle($event)">
<picker mode="selector" :disable="rule.title.disable" :range="titleOptions" @change="changeTitle($event)">
<view class="flex-grow flex items-center justify-end">
<view class="text-base text-base">{{ formData.title }}</view>
<uni-icons color="#999" type="right" size="16" />
@ -36,7 +35,8 @@
</picker>
</common-cell>
<common-cell title="dept" :name="rule.dept.name">
<view class="flex-grow flex items-center justify-end">
<view class="flex-grow flex items-center justify-end" @click="selectDept()">
<view class="text-base text-base">{{ deptNames }}</view>
<uni-icons color="#999" type="right" size="16" />
</view>
</common-cell>
@ -115,6 +115,10 @@ const rule = computed(() => {
dept: { name: "科室", disabled: false },
};
});
const deptNames = computed(() => {
const hlwDepts = formData.value.hlwDepts || [];
return hlwDepts.map(i => i && i.deptName ? i.deptName : '').filter(Boolean).join(',')
})
//
const genderOptions = [
@ -190,6 +194,17 @@ function toCert() {
}
}
function selectDept() {
const eventName = `selectDept_${Date.now()}`
const deptIds = (formData.value.hlwDepts || []).map(i => i.deptId).filter(Boolean).join(',')
uni.navigateTo({
url: `/pages/work/department-select?eventName=${eventName}&deptIds=${deptIds}`
})
uni.$once(eventName, data => {
form.value.hlwDepts = data
})
}
async function save() {
if (
typeof formData.value.anotherName !== "string" ||
@ -217,7 +232,7 @@ async function save() {
}
const res = await api(apiName, data);
if (res && res.success) {
await getDoctorInfo();
await getDoctorInfo({ withHlwDeptInfo: true });
form.value = {};
if (type.value === "cert") {
toCert();
@ -238,7 +253,7 @@ useLoad((opts) => {
});
useShow(() => {
getDoctorInfo();
getDoctorInfo({ withHlwDeptInfo: true });
});
</script>

View File

@ -1,17 +1,17 @@
<template>
<full-page pageClass="bg-white">
<view class="p-15">
<view class="title-bar relative text-dark text-base font-semibold" @click="log()">请填写执业医院</view>
<!-- <view class="mt-12 p-10 flex items-center justify-between border rounded">
<view class="title-bar relative text-dark text-base font-semibold">请填写执业医院</view>
<view class="mt-12 p-10 flex items-center justify-between border rounded" @click="selectHospital()">
<view class="w-0 flex-grow truncate text-base mr-10" :class="formData.hospitalName ? 'text-dark' : 'text-gray'">
{{ formData.hospitalName || '请填写执业医院' }}
</view>
<uni-icons class="flex-shrink-0" color="#666" type="right" size="16" />
</view> -->
<view class="mt-12 p-10 flex items-center justify-between border rounded">
</view>
<!-- <view class="mt-12 p-10 flex items-center justify-between border rounded">
<input class="w-0 flex-grow text-base mr-10" :value="formData.hospitalName" @change="inputHospitalName($event)"
placeholder="请填写执业医院" />
</view>
</view> -->
<view class="mt-15 title-bar relative font-semibold">
<text class="mr-5 text-dark text-base">请上传</text>
<text class="text-primary text-base">医师执业资格证</text>
@ -72,6 +72,16 @@ function inputHospitalName(e) {
form.value.hospitalName = e.detail.value
}
function selectHospital() {
const eventName = `selectHospital_${Date.now()}`;
uni.navigateTo({
url: `/pages/work/hospital-select?eventName=${eventName}`
})
uni.$once(eventName, data => {
form.value.hospitalName = data
})
}
function uploadLicense(type) {
uni.chooseImage({
count: 1,

View File

@ -141,6 +141,10 @@ export default [
path: 'pages/work/department-select',
meta: { title: '选择科室' }
},
{
path: 'pages/work/hospital-select',
meta: { title: '选择医院' }
},
{
path: 'pages/work/verify/assistant',
meta: { title: '上传证照', login: true }

View File

@ -80,9 +80,10 @@ export default defineStore("accountStore", () => {
return Promise.reject()
}
async function getDoctorInfo() {
async function getDoctorInfo(data = {}) {
try {
const res = await api('getCorpMemberData', {
...data,
weChatOpenId: account.value.openid,
});
doctorInfo.value = res?.data || null;

View File

@ -26,7 +26,10 @@ const urlsConfig = {
removeTeammate: "removeTeammate",
toggleTeamLeaderRole: "toggleTeamLeaderRole",
joinTheInvitedTeam: 'joinTheInvitedTeam',
getTeamMemberAvatarsAndName: 'getTeamMemberAvatarsAndName'
getTeamMemberAvatarsAndName: 'getTeamMemberAvatarsAndName',
getHlwDeptTree: 'getHlwDeptTree',
getAllHlwDeptList: "getAllHlwDeptList",
getHlwHospitalList: 'getHlwHospitalList'
},
knowledgeBase: {

View File

@ -1,12 +1,10 @@
export default function useDebounce(callback, delay = 1000) {
let cd = false;
let timer = null;
return (...args) => {
if (cd) return;
cd = true;
callback(...args);
setTimeout(() => {
cd = false;
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
callback(...args);
}, delay);
}
}