This commit is contained in:
huxuejian 2026-10-15 16:32:45 +08:00
commit 265dc9381d

View File

@ -24,7 +24,7 @@
<view class="field-group"> <view class="field-group">
<view class="field-label">开单科室</view> <view class="field-label">开单科室</view>
<view class="project-input" @tap="openBillDeptPicker"> <view class="project-input" :class="{ 'disabled-input': hasBenefitEntries }" @tap="openBillDeptPicker">
<text :class="billDeptId ? 'value-text' : 'placeholder-text'">{{ billDeptName || "请选择开单科室" }}</text> <text :class="billDeptId ? 'value-text' : 'placeholder-text'">{{ billDeptName || "请选择开单科室" }}</text>
<uni-icons type="right" size="18" color="#999" /> <uni-icons type="right" size="18" color="#999" />
</view> </view>
@ -127,15 +127,15 @@
<view v-if="projectEntry.selected && Number(projectEntry.validDays || 0) > 0" class="field-group"> <view v-if="projectEntry.selected && Number(projectEntry.validDays || 0) > 0" class="field-group">
<view class="field-label">有效期</view> <view class="field-label">有效期</view>
<view class="valid-time-wrap"> <view class="valid-time-wrap">
<view class="valid-time-picker disabled-picker"> <view class="valid-time-picker" @tap="prepareValidTimePicker(projectEntry)">
<picker mode="multiSelector" :range="validTimeRange" :value="validTimeIndex" disabled <picker mode="multiSelector" :range="validTimeRange" :value="validTimeIndex"
@columnchange="onValidTimeColumnChange" @change="changeValidTime($event, projectEntry)"> @columnchange="onValidTimeColumnChange" @change="changeValidTime($event, projectEntry)">
<view class="picker-value" :class="projectEntry.validTime ? 'value-text' : 'placeholder-text'"> <view class="picker-value" :class="projectEntry.validTime ? 'value-text' : 'placeholder-text'">
{{ projectEntry.validTime || "选择日期/长期" }} {{ projectEntry.validTime || "选择日期/长期" }}
</view> </view>
</picker> </picker>
</view> </view>
<view class="valid-time-locked-tip">套餐有效期已锁定</view> <view class="unlimited-button" @tap="clearValidTime(projectEntry)">长期</view>
</view> </view>
</view> </view>
<view v-if="projectEntry.selected" class="todo-switch-row"> <view v-if="projectEntry.selected" class="todo-switch-row">
@ -339,15 +339,47 @@
<view v-if="batchTodoVisible" class="picker-mask" @tap="closeBatchTodoPicker"> <view v-if="batchTodoVisible" class="picker-mask" @tap="closeBatchTodoPicker">
<view class="batch-todo-picker" @tap.stop> <view class="batch-todo-picker" @tap.stop>
<view class="picker-header"> <view class="picker-header">
<text class="picker-title">生成待办批量操作</text> <text class="picker-title">权益批量操作</text>
<uni-icons type="closeempty" size="22" color="#666" @tap="closeBatchTodoPicker" /> <uni-icons type="closeempty" size="22" color="#666" @tap="closeBatchTodoPicker" />
</view> </view>
<view class="batch-todo-row" @tap.stop> <view class="batch-todo-row" @tap.stop>
<text>批量生成待办</text> <text>批量生成待办</text>
<switch :checked="batchTodoConfig.todoEnabled" color="#0877f1" <switch :checked="batchTodoConfig.todoEnabled" color="#0877f1"
@change="batchTodoConfig.todoEnabled = $event.detail.value" /> @change="batchTodoConfig.todoEnabled = $event.detail.value; batchTodoConfig.todoEnabledTouched = true" />
</view>
<view class="batch-todo-row">
<text>批量设置项目有效期</text>
<switch :checked="batchTodoConfig.setBenefitValidTime" color="#0877f1"
@change="batchTodoConfig.setBenefitValidTime = $event.detail.value" />
</view>
<view v-if="batchTodoConfig.setBenefitValidTime" class="batch-todo-field">
<text>项目有效期:</text>
<picker mode="multiSelector" :range="validTimeRange" :value="validTimeIndex"
@tap="openBatchDatePicker('benefitValidTime')" @columnchange="onValidTimeColumnChange"
@change="changeTodoDate($event)">
<text :class="batchTodoConfig.benefitValidTime ? 'value-text' : 'placeholder-text'">
{{ batchTodoConfig.benefitValidTime || "选择日期" }}
</text>
</picker>
<text class="batch-unlimited" @tap.stop="batchTodoConfig.benefitValidTime = ''">长期</text>
</view> </view>
<template v-if="batchTodoConfig.todoEnabled"> <template v-if="batchTodoConfig.todoEnabled">
<view class="batch-todo-row">
<text>批量设置回访计划有效期</text>
<switch :checked="batchTodoConfig.setTodoExpireDate" color="#0877f1"
@change="batchTodoConfig.setTodoExpireDate = $event.detail.value" />
</view>
<view v-if="batchTodoConfig.setTodoExpireDate" class="batch-todo-field">
<text>截止日期:</text>
<picker mode="multiSelector" :range="validTimeRange" :value="validTimeIndex"
@tap="openBatchDatePicker('todoExpireDate')" @columnchange="onValidTimeColumnChange"
@change="changeTodoDate($event)">
<text :class="batchTodoConfig.todoExpireDate ? 'value-text' : 'placeholder-text'">
{{ batchTodoConfig.todoExpireDate || "请选择截止日期" }}
</text>
</picker>
<uni-icons type="right" size="16" color="#999" />
</view>
<view class="batch-todo-row"> <view class="batch-todo-row">
<text>待办完成后关联核销权益</text> <text>待办完成后关联核销权益</text>
<switch :checked="batchTodoConfig.deductBenefit" color="#0877f1" <switch :checked="batchTodoConfig.deductBenefit" color="#0877f1"
@ -529,6 +561,11 @@ const billDeptKeyword = ref("");
const billDeptPickerVisible = ref(false); const billDeptPickerVisible = ref(false);
const billDeptExpanded = ref(new Set()); const billDeptExpanded = ref(new Set());
const entries = ref([]); const entries = ref([]);
const hasBenefitEntries = computed(() => entries.value.some((entry) => (
entry.isPackage
|| entry.project?._id
|| (Array.isArray(entry.projects) && entry.projects.some((project) => project?.project?._id || project?.selected))
)));
const saving = ref(false); const saving = ref(false);
const projectPickerVisible = ref(false); const projectPickerVisible = ref(false);
const projectPickerIndex = ref(-1); const projectPickerIndex = ref(-1);
@ -560,6 +597,11 @@ const batchTodoConfig = ref({
executorName: "", executorName: "",
executeTeamId: "", executeTeamId: "",
executeTeamName: "", executeTeamName: "",
todoEnabledTouched: false,
setBenefitValidTime: false,
benefitValidTime: "",
setTodoExpireDate: false,
todoExpireDate: "",
}); });
const batchExecutorTarget = ref(null); const batchExecutorTarget = ref(null);
const benefitDetailVisible = ref(false); const benefitDetailVisible = ref(false);
@ -917,6 +959,21 @@ function changeBillDoctor(event) {
const doctor = getBillDoctors()[Number(event.detail.value)] || null; const doctor = getBillDoctors()[Number(event.detail.value)] || null;
billDoctorUserId.value = doctor?.userid || ""; billDoctorUserId.value = doctor?.userid || "";
billDoctorName.value = doctor?.anotherName || doctor?.name || ""; billDoctorName.value = doctor?.anotherName || doctor?.name || "";
refreshTreatmentDoctorDefaults();
}
function refreshTreatmentDoctorDefaults() {
entries.value.forEach((entry) => {
if (entry.isPackage) {
entry.projects.forEach((project) => {
if (project.selected && String(project.dept?._id || "") === String(billDeptId.value || "")) {
applyTreatmentDefaults(project);
}
});
} else if (entry.project?._id && String(entry.dept?._id || "") === String(billDeptId.value || "")) {
applyTreatmentDefaults(entry);
}
});
} }
const filteredBillDeptOptions = computed(() => { const filteredBillDeptOptions = computed(() => {
@ -944,6 +1001,10 @@ const filteredBillDeptOptions = computed(() => {
}); });
function openBillDeptPicker() { function openBillDeptPicker() {
if (hasBenefitEntries.value) {
uni.showToast({ title: "已有权益项目,请先清空后修改开单科室", icon: "none" });
return;
}
billDeptPickerVisible.value = true; billDeptPickerVisible.value = true;
billDeptKeyword.value = ""; billDeptKeyword.value = "";
billDeptExpanded.value = new Set(billDeptOptions.value.filter((item) => item.children?.length).map((item) => String(item._id))); billDeptExpanded.value = new Set(billDeptOptions.value.filter((item) => item.children?.length).map((item) => String(item._id)));
@ -962,11 +1023,16 @@ function toggleBillDept(item) {
} }
function selectBillDept(dept) { function selectBillDept(dept) {
if (hasBenefitEntries.value) {
uni.showToast({ title: "已有权益项目,请先清空后修改开单科室", icon: "none" });
return;
}
billDeptId.value = String(dept._id || ""); billDeptId.value = String(dept._id || "");
billDeptName.value = dept.deptName || dept.name || ""; billDeptName.value = dept.deptName || dept.name || "";
billDeptValue.value = billDeptId.value; billDeptValue.value = billDeptId.value;
billDoctorUserId.value = ""; billDoctorUserId.value = "";
billDoctorName.value = ""; billDoctorName.value = "";
refreshTreatmentDoctorDefaults();
closeBillDeptPicker(); closeBillDeptPicker();
} }
@ -1171,9 +1237,7 @@ function selectProject(project) {
entry.discount = normalizeDiscount({ ...entry, discount: 10 }); entry.discount = normalizeDiscount({ ...entry, discount: 10 });
entry.isFree = false; entry.isFree = false;
calculateTotalPrice(entry); calculateTotalPrice(entry);
entry.dept = getProjectDepts(entry).length === 1 ? getProjectDepts(entry)[0] : null; applyTreatmentDefaults(entry);
entry.treatmentDoctorUserId = "";
entry.treatmentDoctorName = "";
closeProjectPicker(); closeProjectPicker();
} }
@ -1184,7 +1248,7 @@ function createPackageProjectEntry(project = {}, packageItem = {}) {
const validDate = hasValidDays && validDays > 0 const validDate = hasValidDays && validDays > 0
? formatDate(new Date(Date.now() + validDays * 24 * 60 * 60 * 1000)) ? formatDate(new Date(Date.now() + validDays * 24 * 60 * 60 * 1000))
: ""; : "";
return { const entry = {
...createEntry(), ...createEntry(),
project: normalizedProject, project: normalizedProject,
price: Number(normalizedProject.price ?? project.price ?? 0), price: Number(normalizedProject.price ?? project.price ?? 0),
@ -1196,11 +1260,26 @@ function createPackageProjectEntry(project = {}, packageItem = {}) {
totalPrice: Number(project.totalPrice || 0), totalPrice: Number(project.totalPrice || 0),
selected: packageItem.packageType === "fixed" || project.required === true, selected: packageItem.packageType === "fixed" || project.required === true,
required: project.required === true, required: project.required === true,
packageId: packageItem._id || "",
packageName: packageItem.name || "",
packageType: packageItem.packageType || "",
hasValidDays, hasValidDays,
validDays, validDays,
validTime: validDate, validTime: validDate,
dept: normalizedProject.depts?.length === 1 ? normalizedProject.depts[0] : null, dept: null,
}; };
applyTreatmentDefaults(entry);
return entry;
}
function applyTreatmentDefaults(entry) {
const depts = getProjectDepts(entry);
entry.dept = depts.length === 1
? depts[0]
: depts.find((dept) => String(dept._id) === String(billDeptId.value)) || null;
const doctor = getTreatmentDoctors(entry).find((item) => String(item.userid) === String(billDoctorUserId.value));
entry.treatmentDoctorUserId = doctor?.userid || "";
entry.treatmentDoctorName = doctor?.anotherName || doctor?.name || "";
} }
async function selectPackage(packageItem) { async function selectPackage(packageItem) {
@ -1300,6 +1379,11 @@ function openBatchTodoPicker() {
batchTodoVisible.value = true; batchTodoVisible.value = true;
} }
function openBatchDatePicker(field) {
todoDateTarget.value = { entry: batchTodoConfig.value, field };
prepareValidTimePicker({ validTime: batchTodoConfig.value[field] });
}
function closeBatchTodoPicker() { function closeBatchTodoPicker() {
batchTodoVisible.value = false; batchTodoVisible.value = false;
} }
@ -1313,15 +1397,39 @@ function openBatchExecutorPicker() {
} }
function applyBatchTodoConfig() { function applyBatchTodoConfig() {
let skippedValidityCount = 0;
const applyConfig = (entry) => { const applyConfig = (entry) => {
if (!entry?.project?._id) return; if (!entry?.project?._id) return;
if (batchTodoConfig.value.setBenefitValidTime) {
if (entry.packageId && entry.hasValidDays !== true) {
skippedValidityCount += 1;
} else {
entry.validTime = batchTodoConfig.value.benefitValidTime || "";
}
}
if (batchTodoConfig.value.todoEnabledTouched) {
entry.todoEnabled = Boolean(batchTodoConfig.value.todoEnabled); entry.todoEnabled = Boolean(batchTodoConfig.value.todoEnabled);
}
const shouldApplyTodoSettings = batchTodoConfig.value.todoEnabledTouched
|| batchTodoConfig.value.setTodoExpireDate
|| Boolean(batchTodoConfig.value.executorUserId);
if (!shouldApplyTodoSettings) return;
if (!entry.todoEnabled) { if (!entry.todoEnabled) {
if (batchTodoConfig.value.setTodoExpireDate && batchTodoConfig.value.todoExpireDate) {
entry.todoConfig = entry.todoConfig || getDefaultTodoConfig(entry);
entry.todoConfig.expireDate = batchTodoConfig.value.todoExpireDate;
entry.todoConfig.expireDateManual = true;
} else if (batchTodoConfig.value.todoEnabledTouched) {
entry.todoConfig = null; entry.todoConfig = null;
}
return; return;
} }
entry.todoConfig = entry.todoConfig || getDefaultTodoConfig(entry); entry.todoConfig = entry.todoConfig || getDefaultTodoConfig(entry);
entry.todoConfig.deductBenefit = Boolean(batchTodoConfig.value.deductBenefit); entry.todoConfig.deductBenefit = Boolean(batchTodoConfig.value.deductBenefit);
if (batchTodoConfig.value.setTodoExpireDate && batchTodoConfig.value.todoExpireDate) {
entry.todoConfig.expireDate = batchTodoConfig.value.todoExpireDate;
entry.todoConfig.expireDateManual = true;
}
if (batchTodoConfig.value.executorUserId) { if (batchTodoConfig.value.executorUserId) {
Object.assign(entry.todoConfig, { Object.assign(entry.todoConfig, {
executorUserId: batchTodoConfig.value.executorUserId, executorUserId: batchTodoConfig.value.executorUserId,
@ -1339,6 +1447,9 @@ function applyBatchTodoConfig() {
applyConfig(entry); applyConfig(entry);
} }
}); });
if (skippedValidityCount) {
uni.showToast({ title: `${skippedValidityCount}个套餐项目不支持有效期`, icon: "none" });
}
closeBatchTodoPicker() closeBatchTodoPicker()
} }
@ -1431,6 +1542,12 @@ function changeTodoDate(event) {
const month = Number(validTimeRange.value[1][monthIndex].replace("月", "")); const month = Number(validTimeRange.value[1][monthIndex].replace("月", ""));
const day = Number(validTimeRange.value[2][dayIndex].replace("日", "")); const day = Number(validTimeRange.value[2][dayIndex].replace("日", ""));
const selectedDate = `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`; const selectedDate = `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
if (target.entry === batchTodoConfig.value) {
batchTodoConfig.value[target.field] = selectedDate;
validTimeIndex.value = [yearIndex, monthIndex, dayIndex];
todoDateTarget.value = null;
return;
}
target.entry.todoConfig[target.field] = selectedDate; target.entry.todoConfig[target.field] = selectedDate;
validTimeIndex.value = [yearIndex, monthIndex, dayIndex]; validTimeIndex.value = [yearIndex, monthIndex, dayIndex];
if (target.field === "planDate" && !target.entry.validTime) { if (target.field === "planDate" && !target.entry.validTime) {
@ -1455,8 +1572,9 @@ function syncPackageTotals(entry) {
function changeDept(event, entry) { function changeDept(event, entry) {
entry.dept = getProjectDepts(entry)[Number(event.detail.value)] || null; entry.dept = getProjectDepts(entry)[Number(event.detail.value)] || null;
entry.treatmentDoctorUserId = ""; const doctor = getTreatmentDoctors(entry).find((item) => String(item.userid) === String(billDoctorUserId.value));
entry.treatmentDoctorName = ""; entry.treatmentDoctorUserId = doctor?.userid || "";
entry.treatmentDoctorName = doctor?.anotherName || doctor?.name || "";
} }
function changeTreatmentDoctor(event, entry) { function changeTreatmentDoctor(event, entry) {
@ -2155,6 +2273,8 @@ async function submitEntries() {
left: 0; left: 0;
z-index: 10001; z-index: 10001;
box-sizing: border-box; box-sizing: border-box;
max-height: calc(100vh - var(--keyboard-height));
overflow-y: auto;
padding: 28rpx 28rpx 32rpx; padding: 28rpx 28rpx 32rpx;
border-radius: 24rpx 24rpx 0 0; border-radius: 24rpx 24rpx 0 0;
background: #fff; background: #fff;
@ -2199,6 +2319,19 @@ async function submitEntries() {
text-align: right; text-align: right;
} }
.batch-todo-field picker {
flex: 1;
min-width: 0;
text-align: right;
}
.batch-todo-field picker text {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.batch-todo-actions { .batch-todo-actions {
display: flex; display: flex;
gap: 20rpx; gap: 20rpx;