diff --git a/pages.json b/pages.json
index d3c7a99..97e7e37 100644
--- a/pages.json
+++ b/pages.json
@@ -113,7 +113,7 @@
{
"path": "benefit-entry",
"style": {
- "navigationBarTitleText": "权益生成",
+ "navigationBarTitleText": "权益录入",
"disableScroll": true
}
},
diff --git a/pages/message/benefit-entry.vue b/pages/message/benefit-entry.vue
index 931d270..80ce269 100644
--- a/pages/message/benefit-entry.vue
+++ b/pages/message/benefit-entry.vue
@@ -30,12 +30,26 @@
-
+
+
+ 价格
+
+
+
+ 折扣
+
+
数量
-
+
+
+
+ 数量
+
+
+
有效期
@@ -44,17 +58,53 @@
-
- 治疗科室
-
-
-
- {{ entry.dept?.deptName || "请选择治疗科室" }}
-
-
+
+
+ 价格总额
+ ¥{{ formatTotalPrice(entry) }}
-
+
+ 有效期
+
+
+ {{ entry.validTime || "请选择日期" }}
+
+
+
+
+
+ 治疗科室
+
+
+
+ {{ entry.dept?.deptName || (entry.project ? "该项目未配置治疗科室" : "请先选择权益项目") }}
+
+
+
+
+
+
+ 计划治疗医生
+
+
+
+ {{ entry.treatmentDoctorName || (entry.dept ? "选择治疗医生" : "请先选择治疗科室") }}
+
+
+
+
+
删除此项目
@@ -74,9 +124,10 @@
-
+
{{ project.projectName }}
- ¥{{ Number(project.price || 0).toFixed(2) }}
+ ¥{{ Number(project.price || 0).toFixed(2) }}
暂无可用权益项目
加载中...
@@ -107,7 +158,8 @@ const patientName = ref("");
const teamId = ref("");
const teamName = ref("");
const corpId = ref("");
-const deptList = ref([]);
+const showBenefitAmount = ref(true);
+const staffList = ref([]);
const entries = ref([]);
const saving = ref(false);
const projectPickerVisible = ref(false);
@@ -119,7 +171,17 @@ let searchTimer = null;
let entryKey = 0;
function createEntry() {
- return { key: ++entryKey, project: null, usageCount: 1, validTime: "", dept: null };
+ return {
+ key: ++entryKey,
+ project: null,
+ price: 0,
+ discount: 10,
+ usageCount: 1,
+ validTime: "",
+ dept: null,
+ treatmentDoctorUserId: "",
+ treatmentDoctorName: "",
+ };
}
function decodeRouteParam(value = "") {
@@ -137,15 +199,46 @@ onLoad((options = {}) => {
teamName.value = decodeRouteParam(options.teamName);
corpId.value = decodeRouteParam(options.corpId) || accountStore.account?.corpId || "";
entries.value = [createEntry()];
- loadDepartments();
+ loadTeamContext().then(() => {
+ loadCorpSettings();
+ loadStaffList();
+ });
});
-async function loadDepartments() {
+async function loadTeamContext() {
+ if (!teamId.value || !corpId.value) return;
try {
- const res = await api("getTreatmentDeptList", { corpId: corpId.value }, false);
- deptList.value = Array.isArray(res?.data?.list) ? res.data.list : (res?.data || res?.list || []);
+ const res = await api("getTeamData", { teamId: teamId.value, corpId: corpId.value }, false);
+ const team = res?.data || {};
+ if (team.corpId && team.corpId !== corpId.value) corpId.value = team.corpId;
} catch (error) {
- console.error("加载治疗科室失败", error);
+ console.error("加载服务团队失败", error);
+ }
+}
+
+async function loadStaffList() {
+ if (!corpId.value) return;
+ try {
+ const res = await api("getCorpMember", { corpId: corpId.value, page: 1, pageSize: 1000 }, false);
+ const list = res?.data?.data || res?.data?.list || res?.data || [];
+ staffList.value = Array.isArray(list)
+ ? list.filter((staff) => staff?.userid).map((staff) => ({ ...staff, anotherName: staff.anotherName || staff.name || staff.userid }))
+ : [];
+ } catch (error) {
+ staffList.value = [];
+ console.error("加载机构员工失败", error);
+ }
+}
+
+async function loadCorpSettings() {
+ if (!corpId.value) return;
+ try {
+ const res = await api("getCorpInfo", { corpId: corpId.value }, false);
+ const corpInfo = res?.data || {};
+ showBenefitAmount.value = corpInfo.showBenefitAmount !== false;
+ } catch (error) {
+ showBenefitAmount.value = true;
+ console.error("加载机构权益配置失败", error);
}
}
@@ -187,15 +280,54 @@ async function loadProjects() {
}
}
+function formatTotalPrice(entry) {
+ const price = Number(entry.price);
+ const discount = Number(entry.discount);
+ const usageCount = Number(entry.usageCount);
+ const total = Number.isFinite(price) && Number.isFinite(discount) && Number.isFinite(usageCount)
+ ? price * (discount / 10) * usageCount
+ : 0;
+ return Math.max(0, total).toFixed(2);
+}
+
+function getProjectDepts(entry) {
+ return Array.isArray(entry?.project?.depts) ? entry.project.depts : [];
+}
+
+function getTreatmentDoctors(entry) {
+ if (!entry?.dept?._id) return [];
+ const allowedJobs = ["doctor", "expertDoctor", "therapist"];
+ const deptId = String(entry.dept._id);
+
+ 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 selectProject(project) {
const entry = entries.value[projectPickerIndex.value];
if (!entry) return;
entry.project = project;
+ entry.price = Number(project.price || 0);
+ entry.discount = 10;
+ entry.dept = getProjectDepts(entry).length === 1 ? getProjectDepts(entry)[0] : null;
+ entry.treatmentDoctorUserId = "";
+ entry.treatmentDoctorName = "";
closeProjectPicker();
}
function changeDept(event, entry) {
- entry.dept = deptList.value[Number(event.detail.value)] || null;
+ entry.dept = getProjectDepts(entry)[Number(event.detail.value)] || null;
+ entry.treatmentDoctorUserId = "";
+ entry.treatmentDoctorName = "";
+}
+
+function changeTreatmentDoctor(event, entry) {
+ const doctor = getTreatmentDoctors(entry)[Number(event.detail.value)] || null;
+ entry.treatmentDoctorUserId = doctor?.userid || "";
+ entry.treatmentDoctorName = doctor?.anotherName || doctor?.name || "";
}
function changeValidTime(event, entry) {
@@ -220,6 +352,8 @@ function validateEntries() {
const entry = entries.value[index];
const label = `第${index + 1}个权益项目`;
if (!entry.project?._id) return `${label}请选择项目`;
+ if (Number(entry.price) < 0 || Number.isNaN(Number(entry.price))) return `${label}价格不能小于0`;
+ if (!Number.isFinite(Number(entry.discount)) || Number(entry.discount) < 0 || Number(entry.discount) > 10) return `${label}折扣需在0到10之间`;
if (!Number(entry.usageCount) || Number(entry.usageCount) <= 0) return `${label}数量必须大于0`;
if (!entry.dept?._id) return `${label}请选择治疗科室`;
if (!entry.validTime) return `${label}请选择有效期`;
@@ -240,7 +374,8 @@ async function submitEntries() {
try {
for (const entry of entries.value) {
const count = Number(entry.usageCount);
- const price = Number(entry.project.price || 0);
+ const price = Number(entry.price);
+ const discount = Number(entry.discount);
const treatmentData = {
customerId: patientId.value,
customerName: patientName.value,
@@ -249,13 +384,13 @@ async function submitEntries() {
usageCount: count,
restUsageCount: count,
price,
- totalPrice: price * count,
- discount: 10,
+ totalPrice: price * count * (discount / 10),
+ discount,
isFree: false,
treatmentDeptName: entry.dept.deptName,
treatmentDeptId: entry.dept._id,
treatmentDept_id: entry.dept._id,
- treatmentDoctorUserId: userId,
+ treatmentDoctorUserId: entry.treatmentDoctorUserId,
treatmentStatus: "init",
deductUsageCount: 0,
billType: "门诊",
@@ -267,12 +402,12 @@ async function submitEntries() {
corpId: corpId.value,
};
const res = await api("addTreatmentRecord", { params: treatmentData }, false);
- if (!res?.success) throw new Error(res?.message || "权益生成失败");
+ if (!res?.success) throw new Error(res?.message || "权益录入失败");
}
- uni.showToast({ title: "权益生成成功", icon: "success" });
+ uni.showToast({ title: "权益录入成功", icon: "success" });
setTimeout(goBack, 500);
} catch (error) {
- uni.showToast({ title: error.message || "权益生成失败", icon: "none" });
+ uni.showToast({ title: error.message || "权益录入失败", icon: "none" });
} finally {
saving.value = false;
}
@@ -429,6 +564,11 @@ async function submitEntries() {
background: #fff;
}
+.locked-input {
+ background: #f3f4f6;
+ color: #9ca3af;
+}
+
.value-text {
color: #111827;
font-size: 28rpx;
@@ -446,12 +586,20 @@ async function submitEntries() {
margin-top: 20rpx;
}
+.field-group {
+ margin-top: 20rpx;
+}
+
.field-block {
flex: 1;
}
-.field-block-wide {
- flex: 1.5;
+.total-price {
+ min-height: 40rpx;
+ color: #e85c2f;
+ font-size: 30rpx;
+ font-weight: 600;
+ line-height: 40rpx;
}
.number-input {
diff --git a/pages/message/components/chat-input.vue b/pages/message/components/chat-input.vue
index 9f3fe2a..6fd871a 100644
--- a/pages/message/components/chat-input.vue
+++ b/pages/message/components/chat-input.vue
@@ -408,7 +408,7 @@ const goToArticleList = () => {
});
};
-// 跳转到权益生成页面
+// 跳转到权益录入页面
const goToBenefitEntry = () => {
showMorePanel.value = false;
uni.navigateTo({
@@ -482,7 +482,7 @@ const morePanelButtons = computed(() => {
action: goToArticleList,
},
{
- text: "权益生成",
+ text: "权益录入",
icon: "/static/icon/quanyi.svg",
action: goToBenefitEntry,
},