bug修复
This commit is contained in:
parent
f887d00a60
commit
4ae45ff468
@ -21,6 +21,36 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="field-group">
|
||||
<view class="field-label">开单科室</view>
|
||||
<view class="bill-dept-picker">
|
||||
<uni-data-picker
|
||||
v-model="billDeptValue"
|
||||
:localdata="billDeptOptions"
|
||||
popup-title="请选择开单科室"
|
||||
placeholder="请选择开单科室"
|
||||
:clear-icon="true"
|
||||
@change="changeBillDept"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field-group">
|
||||
<view class="field-label">开单医生</view>
|
||||
<picker
|
||||
:range="getBillDoctors()"
|
||||
range-key="anotherName"
|
||||
:disabled="!billDeptId || !getBillDoctors().length"
|
||||
@change="changeBillDoctor"
|
||||
>
|
||||
<view class="project-input">
|
||||
<text :class="billDoctorUserId ? 'value-text' : 'placeholder-text'">
|
||||
{{ billDoctorName || (billDeptId ? "请选择开单医生" : "请先选择开单科室") }}
|
||||
</text>
|
||||
<uni-icons type="right" size="18" color="#999" />
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="section-title">权益项目</view>
|
||||
<view v-for="(entry, index) in entries" :id="`entry-${entry.key}`" :key="entry.key" class="entry-card">
|
||||
<template v-if="entry.isPackage">
|
||||
@ -283,7 +313,6 @@
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="projectPickerVisible" class="picker-mask" @click="closeProjectPicker">
|
||||
<view class="project-picker" :style="{ '--keyboard-height': `${keyboardHeight}px` }" @click.stop>
|
||||
<view class="picker-header">
|
||||
@ -364,6 +393,7 @@ import { onLoad } from "@dcloudio/uni-app";
|
||||
import api from "@/utils/api.js";
|
||||
import useAccountStore from "@/store/account.js";
|
||||
import fullPage from "@/components/full-page.vue";
|
||||
import UniDataPicker from "@/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue";
|
||||
import { TODO_EVENT_TYPE_LABELS } from "@/utils/todo-const.js";
|
||||
|
||||
const PENDING_FOLLOWUP_SEND_STORAGE_KEY = "ykt_followup_pending_send";
|
||||
@ -378,6 +408,11 @@ const teamName = ref("");
|
||||
const corpId = ref("");
|
||||
const showBenefitAmount = ref(true);
|
||||
const staffList = ref([]);
|
||||
const billDeptOptions = ref([]);
|
||||
const billDeptId = ref("");
|
||||
const billDeptName = ref("");
|
||||
const billDoctorUserId = ref("");
|
||||
const billDoctorName = ref("");
|
||||
const entries = ref([]);
|
||||
const saving = ref(false);
|
||||
const projectPickerVisible = ref(false);
|
||||
@ -391,6 +426,7 @@ const projectHasMore = ref(true);
|
||||
const packageHasMore = ref(true);
|
||||
const projectPage = ref(1);
|
||||
const projectPageSize = 30;
|
||||
const billDeptValue = ref("");
|
||||
const VALID_YEAR_SPAN = 50;
|
||||
const validTimeRange = ref([[], [], []]);
|
||||
const validTimeIndex = ref([0, 0, 0]);
|
||||
@ -571,6 +607,10 @@ function createEntry() {
|
||||
minDiscount: 10,
|
||||
usageCount: 1,
|
||||
validTime: "",
|
||||
billDeptId: "",
|
||||
billDeptName: "",
|
||||
billDoctorUserId: "",
|
||||
billDoctorName: "",
|
||||
dept: null,
|
||||
treatmentDoctorUserId: "",
|
||||
treatmentDoctorName: "",
|
||||
@ -601,6 +641,7 @@ onLoad((options = {}) => {
|
||||
entries.value = [createEntry()];
|
||||
loadTeamContext().then(() => {
|
||||
loadCorpSettings();
|
||||
loadBillDeptOptions();
|
||||
loadStaffList();
|
||||
loadTodoTeams();
|
||||
});
|
||||
@ -647,6 +688,22 @@ async function loadStaffList() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadBillDeptOptions() {
|
||||
if (!corpId.value) return;
|
||||
try {
|
||||
// PC 端开单科室使用 getDeptList;移动端同名方法映射到 getRealDeptList,需使用对应映射。
|
||||
const res = await api("getTreatmentDeptList", { corpId: corpId.value }, false);
|
||||
const list = res?.data?.list
|
||||
|| res?.data?.data?.list
|
||||
|| res?.list
|
||||
|| (Array.isArray(res?.data) ? res.data : []);
|
||||
billDeptOptions.value = buildDeptTree(Array.isArray(list) ? list.filter((dept) => dept?._id) : []);
|
||||
} catch (error) {
|
||||
billDeptOptions.value = [];
|
||||
console.error("加载开单科室失败", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTodoTeams() {
|
||||
if (!corpId.value) return;
|
||||
try {
|
||||
@ -691,6 +748,10 @@ async function loadCorpSettings() {
|
||||
}
|
||||
|
||||
function openProjectPicker(index) {
|
||||
if (!billDeptId.value) {
|
||||
uni.showToast({ title: "请先选择开单科室", icon: "none" });
|
||||
return;
|
||||
}
|
||||
projectPickerIndex.value = index;
|
||||
projectPickerVisible.value = true;
|
||||
projectKeyword.value = "";
|
||||
@ -716,6 +777,58 @@ function normalizeProject(project = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function changeBillDept(event) {
|
||||
const selected = event?.detail?.value;
|
||||
const dept = Array.isArray(selected) ? selected[selected.length - 1] : null;
|
||||
billDeptId.value = dept?.value ? String(dept.value) : "";
|
||||
billDeptName.value = dept?.text || dept?.deptName || "";
|
||||
billDeptValue.value = billDeptId.value;
|
||||
billDoctorUserId.value = "";
|
||||
billDoctorName.value = "";
|
||||
}
|
||||
|
||||
function getBillDoctors() {
|
||||
if (!billDeptId.value) return [];
|
||||
const deptId = String(billDeptId.value);
|
||||
const allowedJobs = ["doctor", "expertDoctor", "therapist"];
|
||||
return staffList.value.filter((staff) => {
|
||||
const hasAllowedJob = Array.isArray(staff.job) && staff.job.some((job) => allowedJobs.includes(job));
|
||||
const inDept = Array.isArray(staff.deptIds) && staff.deptIds.map(String).includes(deptId);
|
||||
return hasAllowedJob && inDept;
|
||||
});
|
||||
}
|
||||
|
||||
function changeBillDoctor(event) {
|
||||
const doctor = getBillDoctors()[Number(event.detail.value)] || null;
|
||||
billDoctorUserId.value = doctor?.userid || "";
|
||||
billDoctorName.value = doctor?.anotherName || doctor?.name || "";
|
||||
}
|
||||
|
||||
function buildDeptTree(deptList) {
|
||||
const deptMap = new Map();
|
||||
const rootDepts = [];
|
||||
(deptList || []).forEach((dept) => {
|
||||
if (dept?._id) deptMap.set(String(dept._id), { ...dept, text: dept.deptName || dept.name || "", value: dept._id });
|
||||
});
|
||||
deptMap.forEach((dept) => {
|
||||
const parent = dept.parentId && deptMap.get(String(dept.parentId));
|
||||
if (parent) {
|
||||
if (!parent.children) parent.children = [];
|
||||
parent.children.push(dept);
|
||||
} else {
|
||||
rootDepts.push(dept);
|
||||
}
|
||||
});
|
||||
const sortNodes = (nodes) =>
|
||||
nodes
|
||||
.sort((a, b) => Number(a.sort || 0) - Number(b.sort || 0) || String(a.deptName || "").localeCompare(String(b.deptName || ""), "zh-Hans-CN"))
|
||||
.map((dept) => {
|
||||
if (!dept.children?.length) return dept;
|
||||
return { ...dept, children: sortNodes(dept.children) };
|
||||
});
|
||||
return sortNodes(rootDepts);
|
||||
}
|
||||
|
||||
async function loadProjects({ reset = false } = {}) {
|
||||
if (projectLoading.value) return;
|
||||
if (!reset && !projectHasMore.value && !packageHasMore.value) return;
|
||||
@ -736,6 +849,7 @@ async function loadProjects({ reset = false } = {}) {
|
||||
projectName: projectKeyword.value.trim(),
|
||||
projectStatus: "enable",
|
||||
showDepts: true,
|
||||
billDeptId: billDeptId.value,
|
||||
}, false), api("getProjectPackageList", {
|
||||
corpId: corpId.value,
|
||||
page,
|
||||
@ -1190,6 +1304,7 @@ function goBackToConversation() {
|
||||
}
|
||||
|
||||
function validateEntries() {
|
||||
if (!billDeptId.value) return "请选择开单科室";
|
||||
for (let index = 0; index < entries.value.length; index += 1) {
|
||||
const entry = entries.value[index];
|
||||
if (entry.isPackage) {
|
||||
@ -1386,6 +1501,10 @@ async function submitEntries() {
|
||||
treatmentStatus: "init",
|
||||
deductUsageCount: 0,
|
||||
billType: "门诊",
|
||||
billDeptId: billDeptId.value,
|
||||
billDeptName: billDeptName.value,
|
||||
billDoctorUserId: billDoctorUserId.value,
|
||||
billDoctorName: billDoctorName.value,
|
||||
billdCreator: userId,
|
||||
createTreatementTime: Date.now(),
|
||||
billTime: Date.now(),
|
||||
@ -1779,6 +1898,25 @@ async function submitEntries() {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.bill-dept-picker {
|
||||
display: block;
|
||||
min-height: 76rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.bill-dept-picker :deep(.uni-data-tree-input) {
|
||||
min-height: 76rpx;
|
||||
}
|
||||
|
||||
.bill-dept-picker :deep(.input-value) {
|
||||
min-height: 76rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #d1d5db;
|
||||
border-radius: 12rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.project-input,
|
||||
.picker-value {
|
||||
min-height: 76rpx;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user