no message
This commit is contained in:
parent
e3631a61a7
commit
1514dc606a
@ -113,7 +113,7 @@
|
|||||||
{
|
{
|
||||||
"path": "benefit-entry",
|
"path": "benefit-entry",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "权益生成",
|
"navigationBarTitleText": "权益录入",
|
||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -30,12 +30,26 @@
|
|||||||
<uni-icons type="right" size="18" color="#999" />
|
<uni-icons type="right" size="18" color="#999" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="field-row">
|
<view v-if="showBenefitAmount" class="field-row">
|
||||||
|
<view class="field-block">
|
||||||
|
<view class="field-label">价格</view>
|
||||||
|
<input class="number-input locked-input" type="digit" :value="entry.price" disabled />
|
||||||
|
</view>
|
||||||
|
<view class="field-block">
|
||||||
|
<view class="field-label">折扣</view>
|
||||||
|
<input class="number-input" type="digit" v-model="entry.discount" />
|
||||||
|
</view>
|
||||||
<view class="field-block">
|
<view class="field-block">
|
||||||
<view class="field-label">数量</view>
|
<view class="field-label">数量</view>
|
||||||
<input class="number-input" type="number" v-model="entry.usageCount" />
|
<input class="number-input" type="number" v-model="entry.usageCount" />
|
||||||
</view>
|
</view>
|
||||||
<view class="field-block field-block-wide">
|
</view>
|
||||||
|
<view v-else class="field-row">
|
||||||
|
<view class="field-block">
|
||||||
|
<view class="field-label">数量</view>
|
||||||
|
<input class="number-input" type="number" v-model="entry.usageCount" />
|
||||||
|
</view>
|
||||||
|
<view class="field-block">
|
||||||
<view class="field-label">有效期</view>
|
<view class="field-label">有效期</view>
|
||||||
<picker mode="date" :value="entry.validTime" @change="changeValidTime($event, entry)">
|
<picker mode="date" :value="entry.validTime" @change="changeValidTime($event, entry)">
|
||||||
<view class="picker-value" :class="entry.validTime ? 'value-text' : 'placeholder-text'">
|
<view class="picker-value" :class="entry.validTime ? 'value-text' : 'placeholder-text'">
|
||||||
@ -44,17 +58,53 @@
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-if="showBenefitAmount" class="field-row">
|
||||||
|
<view class="field-block">
|
||||||
|
<view class="field-label">价格总额</view>
|
||||||
|
<view class="total-price">¥{{ formatTotalPrice(entry) }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="field-block">
|
||||||
|
<view class="field-label">有效期</view>
|
||||||
|
<picker mode="date" :value="entry.validTime" @change="changeValidTime($event, entry)">
|
||||||
|
<view class="picker-value" :class="entry.validTime ? 'value-text' : 'placeholder-text'">
|
||||||
|
{{ entry.validTime || "请选择日期" }}
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="field-group">
|
||||||
<view class="field-label">治疗科室</view>
|
<view class="field-label">治疗科室</view>
|
||||||
<picker :range="deptList" range-key="deptName" @change="changeDept($event, entry)">
|
<picker
|
||||||
|
:range="getProjectDepts(entry)"
|
||||||
|
range-key="deptName"
|
||||||
|
:disabled="!entry.project?._id || !getProjectDepts(entry).length"
|
||||||
|
@change="changeDept($event, entry)"
|
||||||
|
>
|
||||||
<view class="project-input">
|
<view class="project-input">
|
||||||
<text :class="entry.dept ? 'value-text' : 'placeholder-text'">
|
<text :class="entry.dept ? 'value-text' : 'placeholder-text'">
|
||||||
{{ entry.dept?.deptName || "请选择治疗科室" }}
|
{{ entry.dept?.deptName || (entry.project ? "该项目未配置治疗科室" : "请先选择权益项目") }}
|
||||||
</text>
|
</text>
|
||||||
<uni-icons type="right" size="18" color="#999" />
|
<uni-icons type="right" size="18" color="#999" />
|
||||||
</view>
|
</view>
|
||||||
</picker>
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="field-group">
|
||||||
|
<view class="field-label">计划治疗医生</view>
|
||||||
|
<picker
|
||||||
|
:range="getTreatmentDoctors(entry)"
|
||||||
|
range-key="anotherName"
|
||||||
|
:disabled="!entry.dept?._id || !getTreatmentDoctors(entry).length"
|
||||||
|
@change="changeTreatmentDoctor($event, entry)"
|
||||||
|
>
|
||||||
|
<view class="project-input">
|
||||||
|
<text :class="entry.treatmentDoctorUserId ? 'value-text' : 'placeholder-text'">
|
||||||
|
{{ entry.treatmentDoctorName || (entry.dept ? "选择治疗医生" : "请先选择治疗科室") }}
|
||||||
|
</text>
|
||||||
|
<uni-icons type="right" size="18" color="#999" />
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
<view v-if="entries.length > 1" class="remove-entry" @click="removeEntry(index)">删除此项目</view>
|
<view v-if="entries.length > 1" class="remove-entry" @click="removeEntry(index)">删除此项目</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -74,9 +124,10 @@
|
|||||||
<input v-model="projectKeyword" class="search-input" placeholder="输入项目名称搜索" @input="searchProjects" />
|
<input v-model="projectKeyword" class="search-input" placeholder="输入项目名称搜索" @input="searchProjects" />
|
||||||
</view>
|
</view>
|
||||||
<scroll-view scroll-y class="project-list">
|
<scroll-view scroll-y class="project-list">
|
||||||
<view v-for="project in projectList" :key="project._id" class="project-item" @click="selectProject(project)">
|
<view v-for="project in projectList" :key="project._id" class="project-item"
|
||||||
|
@click="selectProject(project)">
|
||||||
<view class="project-name">{{ project.projectName }}</view>
|
<view class="project-name">{{ project.projectName }}</view>
|
||||||
<view class="project-price">¥{{ Number(project.price || 0).toFixed(2) }}</view>
|
<view v-if="showBenefitAmount" class="project-price">¥{{ Number(project.price || 0).toFixed(2) }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="!projectLoading && !projectList.length" class="empty-text">暂无可用权益项目</view>
|
<view v-if="!projectLoading && !projectList.length" class="empty-text">暂无可用权益项目</view>
|
||||||
<view v-if="projectLoading" class="empty-text">加载中...</view>
|
<view v-if="projectLoading" class="empty-text">加载中...</view>
|
||||||
@ -107,7 +158,8 @@ const patientName = ref("");
|
|||||||
const teamId = ref("");
|
const teamId = ref("");
|
||||||
const teamName = ref("");
|
const teamName = ref("");
|
||||||
const corpId = ref("");
|
const corpId = ref("");
|
||||||
const deptList = ref([]);
|
const showBenefitAmount = ref(true);
|
||||||
|
const staffList = ref([]);
|
||||||
const entries = ref([]);
|
const entries = ref([]);
|
||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
const projectPickerVisible = ref(false);
|
const projectPickerVisible = ref(false);
|
||||||
@ -119,7 +171,17 @@ let searchTimer = null;
|
|||||||
let entryKey = 0;
|
let entryKey = 0;
|
||||||
|
|
||||||
function createEntry() {
|
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 = "") {
|
function decodeRouteParam(value = "") {
|
||||||
@ -137,15 +199,46 @@ onLoad((options = {}) => {
|
|||||||
teamName.value = decodeRouteParam(options.teamName);
|
teamName.value = decodeRouteParam(options.teamName);
|
||||||
corpId.value = decodeRouteParam(options.corpId) || accountStore.account?.corpId || "";
|
corpId.value = decodeRouteParam(options.corpId) || accountStore.account?.corpId || "";
|
||||||
entries.value = [createEntry()];
|
entries.value = [createEntry()];
|
||||||
loadDepartments();
|
loadTeamContext().then(() => {
|
||||||
|
loadCorpSettings();
|
||||||
|
loadStaffList();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function loadDepartments() {
|
async function loadTeamContext() {
|
||||||
|
if (!teamId.value || !corpId.value) return;
|
||||||
try {
|
try {
|
||||||
const res = await api("getTreatmentDeptList", { corpId: corpId.value }, false);
|
const res = await api("getTeamData", { teamId: teamId.value, corpId: corpId.value }, false);
|
||||||
deptList.value = Array.isArray(res?.data?.list) ? res.data.list : (res?.data || res?.list || []);
|
const team = res?.data || {};
|
||||||
|
if (team.corpId && team.corpId !== corpId.value) corpId.value = team.corpId;
|
||||||
} catch (error) {
|
} 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) {
|
function selectProject(project) {
|
||||||
const entry = entries.value[projectPickerIndex.value];
|
const entry = entries.value[projectPickerIndex.value];
|
||||||
if (!entry) return;
|
if (!entry) return;
|
||||||
entry.project = project;
|
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();
|
closeProjectPicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeDept(event, entry) {
|
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) {
|
function changeValidTime(event, entry) {
|
||||||
@ -220,6 +352,8 @@ function validateEntries() {
|
|||||||
const entry = entries.value[index];
|
const entry = entries.value[index];
|
||||||
const label = `第${index + 1}个权益项目`;
|
const label = `第${index + 1}个权益项目`;
|
||||||
if (!entry.project?._id) return `${label}请选择项目`;
|
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 (!Number(entry.usageCount) || Number(entry.usageCount) <= 0) return `${label}数量必须大于0`;
|
||||||
if (!entry.dept?._id) return `${label}请选择治疗科室`;
|
if (!entry.dept?._id) return `${label}请选择治疗科室`;
|
||||||
if (!entry.validTime) return `${label}请选择有效期`;
|
if (!entry.validTime) return `${label}请选择有效期`;
|
||||||
@ -240,7 +374,8 @@ async function submitEntries() {
|
|||||||
try {
|
try {
|
||||||
for (const entry of entries.value) {
|
for (const entry of entries.value) {
|
||||||
const count = Number(entry.usageCount);
|
const count = Number(entry.usageCount);
|
||||||
const price = Number(entry.project.price || 0);
|
const price = Number(entry.price);
|
||||||
|
const discount = Number(entry.discount);
|
||||||
const treatmentData = {
|
const treatmentData = {
|
||||||
customerId: patientId.value,
|
customerId: patientId.value,
|
||||||
customerName: patientName.value,
|
customerName: patientName.value,
|
||||||
@ -249,13 +384,13 @@ async function submitEntries() {
|
|||||||
usageCount: count,
|
usageCount: count,
|
||||||
restUsageCount: count,
|
restUsageCount: count,
|
||||||
price,
|
price,
|
||||||
totalPrice: price * count,
|
totalPrice: price * count * (discount / 10),
|
||||||
discount: 10,
|
discount,
|
||||||
isFree: false,
|
isFree: false,
|
||||||
treatmentDeptName: entry.dept.deptName,
|
treatmentDeptName: entry.dept.deptName,
|
||||||
treatmentDeptId: entry.dept._id,
|
treatmentDeptId: entry.dept._id,
|
||||||
treatmentDept_id: entry.dept._id,
|
treatmentDept_id: entry.dept._id,
|
||||||
treatmentDoctorUserId: userId,
|
treatmentDoctorUserId: entry.treatmentDoctorUserId,
|
||||||
treatmentStatus: "init",
|
treatmentStatus: "init",
|
||||||
deductUsageCount: 0,
|
deductUsageCount: 0,
|
||||||
billType: "门诊",
|
billType: "门诊",
|
||||||
@ -267,12 +402,12 @@ async function submitEntries() {
|
|||||||
corpId: corpId.value,
|
corpId: corpId.value,
|
||||||
};
|
};
|
||||||
const res = await api("addTreatmentRecord", { params: treatmentData }, false);
|
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);
|
setTimeout(goBack, 500);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({ title: error.message || "权益生成失败", icon: "none" });
|
uni.showToast({ title: error.message || "权益录入失败", icon: "none" });
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false;
|
saving.value = false;
|
||||||
}
|
}
|
||||||
@ -429,6 +564,11 @@ async function submitEntries() {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.locked-input {
|
||||||
|
background: #f3f4f6;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
.value-text {
|
.value-text {
|
||||||
color: #111827;
|
color: #111827;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
@ -446,12 +586,20 @@ async function submitEntries() {
|
|||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.field-group {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.field-block {
|
.field-block {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field-block-wide {
|
.total-price {
|
||||||
flex: 1.5;
|
min-height: 40rpx;
|
||||||
|
color: #e85c2f;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.number-input {
|
.number-input {
|
||||||
|
|||||||
@ -408,7 +408,7 @@ const goToArticleList = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 跳转到权益生成页面
|
// 跳转到权益录入页面
|
||||||
const goToBenefitEntry = () => {
|
const goToBenefitEntry = () => {
|
||||||
showMorePanel.value = false;
|
showMorePanel.value = false;
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -482,7 +482,7 @@ const morePanelButtons = computed(() => {
|
|||||||
action: goToArticleList,
|
action: goToArticleList,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "权益生成",
|
text: "权益录入",
|
||||||
icon: "/static/icon/quanyi.svg",
|
icon: "/static/icon/quanyi.svg",
|
||||||
action: goToBenefitEntry,
|
action: goToBenefitEntry,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user