加入套餐改造并且加入权益详情
This commit is contained in:
parent
826924db78
commit
8daf6ce4e5
@ -118,6 +118,12 @@
|
||||
:reachBottomTime="reachBottomTime"
|
||||
:floatingBottom="floatingBottom"
|
||||
/>
|
||||
<BenefitProjectTab
|
||||
v-else-if="currentTab === 'benefitProject'"
|
||||
:data="archive"
|
||||
:archiveId="archiveId"
|
||||
:floatingBottom="floatingBottom"
|
||||
/>
|
||||
<FollowUpManageTab
|
||||
v-else
|
||||
:data="archive"
|
||||
@ -232,6 +238,7 @@ import dayjs from 'dayjs';
|
||||
import HealthProfileTab from '@/pages/case/components/archive-detail/health-profile-tab.vue';
|
||||
import ServiceInfoTab from '@/pages/case/components/archive-detail/service-info-tab.vue';
|
||||
import FollowUpManageTab from '@/pages/case/components/archive-detail/follow-up-manage-tab.vue';
|
||||
import BenefitProjectTab from '@/pages/case/components/archive-detail/benefit-project-tab.vue';
|
||||
import api from '@/utils/api';
|
||||
import useAccountStore from '@/store/account';
|
||||
import { hideLoading, loading, toast } from '@/utils/widget';
|
||||
@ -243,6 +250,7 @@ const NEED_RELOAD_STORAGE_KEY = 'ykt_case_need_reload';
|
||||
const tabs = [
|
||||
{ key: 'visitRecord', title: '病历记录' },
|
||||
{ key: 'followUp', title: '回访任务' },
|
||||
{ key: 'benefitProject', title: '权益项目' },
|
||||
{ key: 'serviceRecord', title: '服务记录' }
|
||||
];
|
||||
|
||||
|
||||
451
pages/case/components/archive-detail/benefit-project-tab.vue
Normal file
451
pages/case/components/archive-detail/benefit-project-tab.vue
Normal file
@ -0,0 +1,451 @@
|
||||
<template>
|
||||
<view class="wrap">
|
||||
<view class="switcher">
|
||||
<view
|
||||
v-for="item in recordTypes"
|
||||
:key="item.value"
|
||||
class="switch-item"
|
||||
:class="{ active: currentType === item.value }"
|
||||
@click="switchType(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="list.length" class="list">
|
||||
<view v-for="item in list" :key="item._id" class="record-card">
|
||||
<view class="record-header">
|
||||
<view class="record-title">{{ item.projectName || '未命名权益项目' }}</view>
|
||||
<view v-if="currentType === 'treatment'" class="status" :class="item.statusClass">
|
||||
{{ item.statusLabel }}
|
||||
</view>
|
||||
<view v-else class="status status-blue">已治疗</view>
|
||||
</view>
|
||||
|
||||
<template v-if="currentType === 'treatment'">
|
||||
<view class="summary-row">
|
||||
<view class="summary-item">
|
||||
<text class="summary-label">总数</text>
|
||||
<text class="summary-value">{{ item.usageCount }}</text>
|
||||
</view>
|
||||
<view class="summary-item highlight">
|
||||
<text class="summary-label">剩余数</text>
|
||||
<text class="summary-value">{{ item.restUsageCount }}</text>
|
||||
</view>
|
||||
<view class="summary-item">
|
||||
<text class="summary-label">有效期</text>
|
||||
<text class="summary-value">{{ item.validTimeText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">购买日期</text>
|
||||
<text class="detail-value">{{ item.purchaseDate }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">治疗科室</text>
|
||||
<text class="detail-value">{{ item.treatmentDeptName || '--' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">录单人</text>
|
||||
<text class="detail-value">{{ item.creatorName || item.billdCreator || '--' }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">治疗日期</text>
|
||||
<text class="detail-value">{{ item.treatmentDate }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">治疗数</text>
|
||||
<text class="detail-value strong">{{ item.deductUsageCount }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">治疗部位</text>
|
||||
<text class="detail-value">{{ item.treatmentArea || '--' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">治疗科室</text>
|
||||
<text class="detail-value">{{ item.treatmentDeptName || '--' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">治疗医生</text>
|
||||
<text class="detail-value">{{ item.doctorName || item.treatmentDoctorUserId || '--' }}</text>
|
||||
</view>
|
||||
<view v-if="item.treatmentRemark" class="remark">{{ item.treatmentRemark }}</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="loading" class="state">加载中...</view>
|
||||
<view v-else class="state">暂无{{ currentType === 'treatment' ? '权益记录' : '治疗明细' }}</view>
|
||||
|
||||
<uni-load-more
|
||||
v-if="list.length"
|
||||
:status="loadMoreStatus"
|
||||
:contentText="loadMoreText"
|
||||
@clickLoadMore="loadMore"
|
||||
/>
|
||||
|
||||
<view
|
||||
v-if="canBenefitEntry"
|
||||
class="fab"
|
||||
:style="{ bottom: `${floatingBottom}px` }"
|
||||
@click="goToBenefitEntry"
|
||||
>
|
||||
<uni-icons type="plusempty" size="24" color="#fff" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import api from '@/utils/api';
|
||||
import useAccountStore from '@/store/account';
|
||||
import { toast } from '@/utils/widget';
|
||||
|
||||
const props = defineProps({
|
||||
data: { type: Object, default: () => ({}) },
|
||||
archiveId: { type: String, default: '' },
|
||||
floatingBottom: { type: Number, default: 16 },
|
||||
});
|
||||
|
||||
const recordTypes = [
|
||||
{ label: '权益记录', value: 'treatment' },
|
||||
{ label: '治疗明细', value: 'deduct' },
|
||||
];
|
||||
const currentType = ref('treatment');
|
||||
const list = ref([]);
|
||||
const page = ref(1);
|
||||
const pageSize = 10;
|
||||
const total = ref(0);
|
||||
const loading = ref(false);
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
const { account, doctorInfo } = storeToRefs(accountStore);
|
||||
const { getDoctorInfo } = accountStore;
|
||||
const canBenefitEntry = computed(() => doctorInfo.value?.benefitEntryEnabled === true);
|
||||
|
||||
const loadMoreStatus = computed(() => {
|
||||
if (loading.value) return 'loading';
|
||||
return list.value.length < total.value ? 'more' : 'no-more';
|
||||
});
|
||||
const loadMoreText = {
|
||||
contentdown: '点击加载更多',
|
||||
contentrefresh: '加载中...',
|
||||
contentnomore: '没有更多了',
|
||||
};
|
||||
|
||||
function getCorpId() {
|
||||
const team = uni.getStorageSync('ykt_case_current_team') || {};
|
||||
return String(team.corpId || doctorInfo.value?.corpId || account.value?.corpId || '');
|
||||
}
|
||||
|
||||
async function ensureDoctor() {
|
||||
if (doctorInfo.value || !account.value?.openid) return;
|
||||
await getDoctorInfo();
|
||||
}
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value) return '--';
|
||||
const date = dayjs(value);
|
||||
return date.isValid() ? date.format('YYYY-MM-DD') : '--';
|
||||
}
|
||||
|
||||
function mapTreatment(row) {
|
||||
const expired = row.validTime && dayjs(row.validTime).isBefore(dayjs(), 'day');
|
||||
return {
|
||||
...row,
|
||||
_id: String(row._id || row.id || `${row.projectId}_${row.billTime}`),
|
||||
usageCount: row.usageCount ?? 0,
|
||||
restUsageCount: row.restUsageCount ?? 0,
|
||||
validTimeText: !row.validTime ? '无限期' : `${formatDate(row.validTime)}${expired ? '(已过期)' : ''}`,
|
||||
purchaseDate: formatDate(row.billTime || row.createTreatementTime),
|
||||
statusLabel: expired ? '已过期' : row.restUsageCount > 0 ? '可使用' : '已用完',
|
||||
statusClass: expired ? 'status-red' : row.restUsageCount > 0 ? 'status-green' : 'status-gray',
|
||||
creatorName: row.billdCreatorName || row.doctorName || '',
|
||||
};
|
||||
}
|
||||
|
||||
function mapDeduct(row) {
|
||||
return {
|
||||
...row,
|
||||
_id: String(row._id || row.id || `${row.projectId}_${row.treatmentTime}`),
|
||||
treatmentDate: formatDate(row.treatmentTime || row.createTreatementTime),
|
||||
deductUsageCount: row.deductUsageCount ?? 0,
|
||||
doctorName: row.doctorName || row.treatmentDoctorName || '',
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchList(reset = false) {
|
||||
if (!props.archiveId || loading.value) return;
|
||||
if (reset) {
|
||||
page.value = 1;
|
||||
total.value = 0;
|
||||
list.value = [];
|
||||
}
|
||||
|
||||
await ensureDoctor();
|
||||
const corpId = getCorpId();
|
||||
if (!corpId) return;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const params = {
|
||||
corpId,
|
||||
customerId: String(props.archiveId),
|
||||
page: page.value,
|
||||
pageSize,
|
||||
};
|
||||
const res = currentType.value === 'treatment'
|
||||
? await api('getTreatmentRecord', params, false)
|
||||
: await api('getDeductRecord', { ...params, deductStatus: ['deducted'] }, false);
|
||||
if (!res?.success) {
|
||||
toast(res?.message || '获取权益数据失败');
|
||||
return;
|
||||
}
|
||||
const payload = res?.data && typeof res.data === 'object' ? res.data : res;
|
||||
const rows = Array.isArray(res?.list)
|
||||
? res.list
|
||||
: Array.isArray(payload?.list)
|
||||
? payload.list
|
||||
: Array.isArray(payload?.data)
|
||||
? payload.data
|
||||
: Array.isArray(payload)
|
||||
? payload
|
||||
: [];
|
||||
total.value = Number(res?.total ?? payload?.total ?? rows.length);
|
||||
const mapped = rows.map(currentType.value === 'treatment' ? mapTreatment : mapDeduct);
|
||||
list.value = page.value === 1 ? mapped : [...list.value, ...mapped];
|
||||
page.value += 1;
|
||||
} catch (error) {
|
||||
toast('获取权益数据失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function switchType(type) {
|
||||
if (currentType.value === type) return;
|
||||
currentType.value = type;
|
||||
fetchList(true);
|
||||
}
|
||||
|
||||
function loadMore() {
|
||||
if (list.value.length < total.value) fetchList();
|
||||
}
|
||||
|
||||
function goToBenefitEntry() {
|
||||
if (!canBenefitEntry.value || !props.archiveId) return;
|
||||
const team = uni.getStorageSync('ykt_case_current_team') || {};
|
||||
const rawGroupId = String(props.data?.chatGroupId || props.data?.groupId || '');
|
||||
const groupId = rawGroupId.startsWith('GROUP') ? rawGroupId.slice(5) : rawGroupId;
|
||||
const teamId = String(team.teamId || team._id || team.id || '');
|
||||
const teamName = String(team.name || team.teamName || '');
|
||||
const corpId = getCorpId();
|
||||
const patientName = String(props.data?.name || '');
|
||||
const query = [
|
||||
`groupId=${encodeURIComponent(groupId)}`,
|
||||
`patientId=${encodeURIComponent(props.archiveId)}`,
|
||||
`patientName=${encodeURIComponent(patientName)}`,
|
||||
`teamId=${encodeURIComponent(teamId)}`,
|
||||
`teamName=${encodeURIComponent(teamName)}`,
|
||||
`corpId=${encodeURIComponent(corpId)}`,
|
||||
].join('&');
|
||||
uni.navigateTo({ url: `/pages/message/benefit-entry?${query}` });
|
||||
}
|
||||
|
||||
onMounted(() => fetchList(true));
|
||||
|
||||
watch(() => props.archiveId, (value, oldValue) => {
|
||||
if (value && value !== oldValue) fetchList(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrap {
|
||||
padding: 20rpx 28rpx 180rpx;
|
||||
}
|
||||
|
||||
.switcher {
|
||||
display: flex;
|
||||
padding: 6rpx;
|
||||
background: #eef4ff;
|
||||
border-radius: 14rpx;
|
||||
}
|
||||
|
||||
.switch-item {
|
||||
flex: 1;
|
||||
height: 68rpx;
|
||||
line-height: 68rpx;
|
||||
text-align: center;
|
||||
color: #5d6878;
|
||||
font-size: 26rpx;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.switch-item.active {
|
||||
color: #0877f1;
|
||||
background: #fff;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 4rpx 12rpx rgba(8, 119, 241, 0.1);
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
margin-bottom: 20rpx;
|
||||
padding: 24rpx;
|
||||
background: #fff;
|
||||
border-radius: 18rpx;
|
||||
box-shadow: 0 10rpx 26rpx rgba(31, 41, 55, 0.06);
|
||||
}
|
||||
|
||||
.record-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 2rpx solid #f1f3f5;
|
||||
}
|
||||
|
||||
.record-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: #1f2937;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
line-height: 42rpx;
|
||||
}
|
||||
|
||||
.status {
|
||||
flex-shrink: 0;
|
||||
padding: 8rpx 14rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.status-green {
|
||||
color: #16834b;
|
||||
background: #e8f8ef;
|
||||
}
|
||||
|
||||
.status-red {
|
||||
color: #d14343;
|
||||
background: #fff0f0;
|
||||
}
|
||||
|
||||
.status-gray {
|
||||
color: #6b7280;
|
||||
background: #f1f3f5;
|
||||
}
|
||||
|
||||
.status-blue {
|
||||
color: #0877f1;
|
||||
background: #eaf3ff;
|
||||
}
|
||||
|
||||
.summary-row {
|
||||
display: flex;
|
||||
margin: 20rpx 0;
|
||||
padding: 18rpx 0;
|
||||
background: #f8fafc;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
border-right: 2rpx solid #e7ebf0;
|
||||
}
|
||||
|
||||
.summary-item:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.summary-label,
|
||||
.summary-value {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
color: #8a94a3;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
margin-top: 8rpx;
|
||||
color: #27364a;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.summary-item.highlight .summary-value {
|
||||
color: #0877f1;
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: flex;
|
||||
padding-top: 16rpx;
|
||||
font-size: 25rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
width: 136rpx;
|
||||
flex-shrink: 0;
|
||||
color: #8a94a3;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: #3b4654;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.detail-value.strong {
|
||||
color: #0877f1;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.remark {
|
||||
margin-top: 18rpx;
|
||||
padding: 16rpx;
|
||||
color: #687385;
|
||||
background: #f8fafc;
|
||||
border-radius: 10rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.state {
|
||||
padding: 240rpx 0;
|
||||
color: #9aa0a6;
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.fab {
|
||||
position: fixed;
|
||||
right: 32rpx;
|
||||
width: 104rpx;
|
||||
height: 104rpx;
|
||||
border-radius: 52rpx;
|
||||
background: #0877f1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 20rpx 36rpx rgba(8, 119, 241, 0.3);
|
||||
z-index: 20;
|
||||
}
|
||||
</style>
|
||||
@ -22,6 +22,71 @@
|
||||
|
||||
<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">
|
||||
<view class="package-card-head">
|
||||
<view>
|
||||
<view class="field-label">套餐名称</view>
|
||||
<view class="package-name">{{ entry.packageName }}</view>
|
||||
</view>
|
||||
<view class="package-price">¥{{ Number(entry.price || 0).toFixed(2) }}</view>
|
||||
</view>
|
||||
<view class="package-summary">
|
||||
<text>组合形式:{{ entry.packageType === "free" ? `${entry.projects.length}选${entry.projectNumber}` : "固定组合" }}</text>
|
||||
<text>必选项:{{ entry.requiredCount }}</text>
|
||||
<text v-if="entry.packageType === 'free'">可选项:{{ entry.optionalSelectedCount }} / {{ entry.optionalCount }}</text>
|
||||
</view>
|
||||
<view v-if="showBenefitAmount" class="field-row">
|
||||
<view class="field-block">
|
||||
<view class="field-label">数量</view>
|
||||
<input class="number-input" type="number" v-model="entry.usageCount" @input="calculatePackageTotal(entry)" />
|
||||
</view>
|
||||
<view class="field-block">
|
||||
<view class="field-label">折扣</view>
|
||||
<input class="number-input" type="digit" v-model="entry.discount" @input="calculatePackageTotal(entry)" />
|
||||
</view>
|
||||
<view class="field-block">
|
||||
<view class="field-label">总价</view>
|
||||
<view class="readonly-input">¥{{ Number(entry.totalPrice || 0).toFixed(2) }}</view>
|
||||
</view>
|
||||
</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" @input="calculatePackageTotal(entry)" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-for="projectEntry in entry.projects" :key="projectEntry.key" class="package-project-card">
|
||||
<view class="package-project-title">
|
||||
<checkbox
|
||||
v-if="entry.packageType === 'free'"
|
||||
:checked="projectEntry.selected"
|
||||
:disabled="projectEntry.required || (!projectEntry.selected && isPackageSelectionFull(entry))"
|
||||
color="#0877f1"
|
||||
@click="togglePackageProject(entry, projectEntry)"
|
||||
/>
|
||||
<text>{{ projectEntry.project.projectName }}</text>
|
||||
</view>
|
||||
<view class="package-project-detail">¥{{ Number(projectEntry.price || 0).toFixed(2) }} × {{ projectEntry.usageCount }},折扣 {{ Number(projectEntry.discount || 0).toFixed(1) }}</view>
|
||||
<view v-if="projectEntry.selected" class="field-group">
|
||||
<view class="field-label">治疗科室</view>
|
||||
<picker :range="getProjectDepts(projectEntry)" range-key="deptName" :disabled="!getProjectDepts(projectEntry).length" @change="changeDept($event, projectEntry)">
|
||||
<view class="project-input"><text :class="projectEntry.dept ? 'value-text' : 'placeholder-text'">{{ projectEntry.dept?.deptName || "请选择治疗科室" }}</text><uni-icons type="right" size="18" color="#999" /></view>
|
||||
</picker>
|
||||
</view>
|
||||
<view v-if="projectEntry.selected" class="field-group">
|
||||
<view class="field-label">计划治疗医生</view>
|
||||
<picker :range="getTreatmentDoctors(projectEntry)" range-key="anotherName" :disabled="!projectEntry.dept?._id || !getTreatmentDoctors(projectEntry).length" @change="changeTreatmentDoctor($event, projectEntry)">
|
||||
<view class="project-input"><text :class="projectEntry.treatmentDoctorUserId ? 'value-text' : 'placeholder-text'">{{ projectEntry.treatmentDoctorName || "选择治疗医生" }}</text><uni-icons type="right" size="18" color="#999" /></view>
|
||||
</picker>
|
||||
</view>
|
||||
<view v-if="projectEntry.selected && projectEntry.hasValidDays" class="field-group">
|
||||
<view class="field-label">有效期</view>
|
||||
<view class="valid-time-picker" @tap="prepareValidTimePicker(projectEntry)"><picker mode="multiSelector" :range="validTimeRange" :value="validTimeIndex" @columnchange="onValidTimeColumnChange" @change="changeValidTime($event, projectEntry)"><view class="picker-value value-text">{{ projectEntry.validTime }}</view></picker></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="remove-entry" @click="removeEntry(index)">删除套餐</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="field-label">项目名称</view>
|
||||
<view class="project-input" @click="openProjectPicker(index)">
|
||||
<text :class="entry.project ? 'value-text' : 'placeholder-text'">
|
||||
@ -138,6 +203,7 @@
|
||||
</picker>
|
||||
</view>
|
||||
<view v-if="entries.length > 1" class="remove-entry" @click="removeEntry(index)">删除此项目</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<view class="add-entry" @click="addEntry">
|
||||
@ -148,15 +214,16 @@
|
||||
<view v-if="projectPickerVisible" class="picker-mask" @click="closeProjectPicker">
|
||||
<view class="project-picker" @click.stop>
|
||||
<view class="picker-header">
|
||||
<text class="picker-title">选择权益项目</text>
|
||||
<text class="picker-title">选择权益项目或套餐</text>
|
||||
<uni-icons type="closeempty" size="22" color="#666" @click="closeProjectPicker" />
|
||||
</view>
|
||||
<view class="search-box">
|
||||
<uni-icons type="search" size="18" color="#999" />
|
||||
<input v-model="projectKeyword" class="search-input" placeholder="输入项目名称搜索" @input="searchProjects" />
|
||||
<input v-model="projectKeyword" class="search-input" placeholder="输入项目或套餐名称搜索" @input="searchProjects" />
|
||||
</view>
|
||||
<scroll-view scroll-y class="project-list" @scrolltolower="loadMoreProjects">
|
||||
<view v-for="project in projectList" :key="project._id" class="project-item"
|
||||
<view v-if="projectList.length" class="picker-group-title">单项目</view>
|
||||
<view v-for="project in projectList" :key="`project_${project._id}`" class="project-item"
|
||||
@click="selectProject(project)">
|
||||
<view class="project-info">
|
||||
<view class="project-name">{{ project.projectName }}</view>
|
||||
@ -164,7 +231,12 @@
|
||||
</view>
|
||||
<view v-if="showBenefitAmount" class="project-price">¥{{ Number(project.price || 0).toFixed(2) }}</view>
|
||||
</view>
|
||||
<view v-if="!projectLoading && !projectList.length" class="empty-text">暂无可用权益项目</view>
|
||||
<view v-if="packageList.length" class="picker-group-title">套餐</view>
|
||||
<view v-for="packageItem in packageList" :key="`package_${packageItem._id}`" class="project-item" @click="selectPackage(packageItem)">
|
||||
<view class="project-info"><view class="project-name">{{ packageItem.name }}</view><view class="project-depts">{{ packageItem.packageType === "free" ? `自由组合:${packageItem.projects.length}选${packageItem.projectNumber}` : "固定组合" }} · {{ (packageItem.projects || []).map((item) => item.projectName).join("、") }}</view></view>
|
||||
<view v-if="showBenefitAmount" class="project-price">¥{{ Number(packageItem.packagePrice || 0).toFixed(2) }}</view>
|
||||
</view>
|
||||
<view v-if="!projectLoading && !projectList.length && !packageList.length" class="empty-text">暂无可用权益项目或套餐</view>
|
||||
<view v-if="projectLoading" class="empty-text">加载中...</view>
|
||||
<view v-else-if="projectList.length && !projectHasMore" class="empty-text">已加载全部权益项目</view>
|
||||
</scroll-view>
|
||||
@ -206,8 +278,10 @@ const projectPickerVisible = ref(false);
|
||||
const projectPickerIndex = ref(-1);
|
||||
const projectKeyword = ref("");
|
||||
const projectList = ref([]);
|
||||
const packageList = ref([]);
|
||||
const projectLoading = ref(false);
|
||||
const projectHasMore = ref(true);
|
||||
const packageHasMore = ref(true);
|
||||
const projectPage = ref(1);
|
||||
const projectPageSize = 30;
|
||||
const VALID_YEAR_SPAN = 50;
|
||||
@ -413,31 +487,47 @@ function normalizeProject(project = {}) {
|
||||
|
||||
async function loadProjects({ reset = false } = {}) {
|
||||
if (projectLoading.value) return;
|
||||
if (!reset && !projectHasMore.value) return;
|
||||
if (!reset && !projectHasMore.value && !packageHasMore.value) return;
|
||||
|
||||
const page = reset ? 1 : projectPage.value;
|
||||
projectLoading.value = true;
|
||||
if (reset) {
|
||||
projectList.value = [];
|
||||
packageList.value = [];
|
||||
projectHasMore.value = true;
|
||||
packageHasMore.value = true;
|
||||
}
|
||||
try {
|
||||
const res = await api("getProjectList", {
|
||||
const [res, packageRes] = await Promise.all([api("getProjectList", {
|
||||
corpId: corpId.value,
|
||||
page,
|
||||
pageSize: projectPageSize,
|
||||
projectName: projectKeyword.value.trim(),
|
||||
projectStatus: "enable",
|
||||
showDepts: true,
|
||||
}, false);
|
||||
}, false), api("getProjectPackageList", {
|
||||
corpId: corpId.value,
|
||||
page,
|
||||
pageSize: projectPageSize,
|
||||
name: projectKeyword.value.trim(),
|
||||
enable: true,
|
||||
}, false)]);
|
||||
const list = res?.data?.list || res?.list || res?.data || [];
|
||||
const nextList = Array.isArray(list) ? list.map(normalizeProject) : [];
|
||||
projectList.value = reset ? nextList : projectList.value.concat(nextList);
|
||||
const packages = packageRes?.data?.list || packageRes?.list || packageRes?.data || [];
|
||||
const nextPackages = Array.isArray(packages) ? packages.filter((item) => Array.isArray(item.projects) && item.projects.length) : [];
|
||||
packageList.value = reset ? nextPackages : packageList.value.concat(nextPackages);
|
||||
projectPage.value = page + 1;
|
||||
projectHasMore.value = nextList.length >= projectPageSize;
|
||||
packageHasMore.value = nextPackages.length >= projectPageSize;
|
||||
} catch (error) {
|
||||
if (reset) projectList.value = [];
|
||||
if (reset) {
|
||||
projectList.value = [];
|
||||
packageList.value = [];
|
||||
}
|
||||
projectHasMore.value = false;
|
||||
packageHasMore.value = false;
|
||||
uni.showToast({ title: "项目加载失败", icon: "none" });
|
||||
} finally {
|
||||
projectLoading.value = false;
|
||||
@ -525,6 +615,110 @@ function selectProject(project) {
|
||||
closeProjectPicker();
|
||||
}
|
||||
|
||||
function createPackageProjectEntry(project = {}, packageItem = {}) {
|
||||
const normalizedProject = normalizeProject(project);
|
||||
const hasValidDays = packageItem.hasValidDays === true;
|
||||
const validDays = Number(packageItem.validDays || 0);
|
||||
const validDate = hasValidDays && validDays > 0
|
||||
? formatDate(new Date(Date.now() + validDays * 24 * 60 * 60 * 1000))
|
||||
: "";
|
||||
return {
|
||||
...createEntry(),
|
||||
project: normalizedProject,
|
||||
price: Number(normalizedProject.price ?? project.price ?? 0),
|
||||
usageCount: Number(project.number || 1),
|
||||
discount: packageItem.packageType === "free" ? 10 : Number(project.discount || 10),
|
||||
totalPrice: Number(project.totalPrice || 0),
|
||||
selected: packageItem.packageType === "fixed" || project.required === true,
|
||||
required: project.required === true,
|
||||
hasValidDays,
|
||||
validDays,
|
||||
validTime: validDate,
|
||||
dept: normalizedProject.depts?.length === 1 ? normalizedProject.depts[0] : null,
|
||||
};
|
||||
}
|
||||
|
||||
async function selectPackage(packageItem) {
|
||||
const targetIndex = projectPickerIndex.value;
|
||||
if (targetIndex < 0) return;
|
||||
try {
|
||||
uni.showLoading({ title: "加载套餐项目" });
|
||||
const ids = packageItem.projects.map((item) => item._id).filter(Boolean);
|
||||
const res = await api("getProjectList", { corpId: corpId.value, ids, page: 1, pageSize: ids.length, projectStatus: "enable", showDepts: true }, false);
|
||||
const fullProjects = res?.data?.list || res?.list || res?.data || [];
|
||||
const projects = packageItem.projects.map((item) => {
|
||||
const fullProject = Array.isArray(fullProjects) ? fullProjects.find((project) => project._id === item._id) : null;
|
||||
return createPackageProjectEntry({ ...(fullProject || {}), ...item }, packageItem);
|
||||
});
|
||||
const requiredCount = projects.filter((item) => item.required).length;
|
||||
const entry = {
|
||||
...createEntry(),
|
||||
isPackage: true,
|
||||
packageId: packageItem._id,
|
||||
packageName: packageItem.name,
|
||||
packageType: packageItem.packageType,
|
||||
packagePrice: Number(packageItem.packagePrice || 0),
|
||||
price: Number(packageItem.packagePrice || 0),
|
||||
usageCount: 1,
|
||||
discount: 10,
|
||||
totalPrice: Number(packageItem.packagePrice || 0),
|
||||
projectNumber: Number(packageItem.projectNumber || projects.length),
|
||||
requiredCount,
|
||||
optionalCount: Math.max(Number(packageItem.projectNumber || projects.length) - requiredCount, 0),
|
||||
projects,
|
||||
};
|
||||
syncPackageSelection(entry);
|
||||
syncPackageTotals(entry);
|
||||
entries.value.splice(targetIndex, 1, entry);
|
||||
closeProjectPicker();
|
||||
} catch (error) {
|
||||
uni.showToast({ title: "套餐加载失败", icon: "none" });
|
||||
} finally {
|
||||
uni.hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
function syncPackageSelection(entry) {
|
||||
entry.selectedCount = entry.projects.filter((item) => item.selected).length;
|
||||
entry.optionalSelectedCount = Math.max(entry.selectedCount - entry.requiredCount, 0);
|
||||
}
|
||||
|
||||
function isPackageSelectionFull(entry) {
|
||||
return Number(entry.selectedCount || 0) >= Number(entry.projectNumber || 0);
|
||||
}
|
||||
|
||||
function togglePackageProject(entry, projectEntry) {
|
||||
if (projectEntry.required) return;
|
||||
if (!projectEntry.selected && isPackageSelectionFull(entry)) {
|
||||
uni.showToast({ title: "已达到可选项目上限", icon: "none" });
|
||||
return;
|
||||
}
|
||||
projectEntry.selected = !projectEntry.selected;
|
||||
syncPackageSelection(entry);
|
||||
syncPackageTotals(entry);
|
||||
}
|
||||
|
||||
function calculatePackageTotal(entry) {
|
||||
entry.usageCount = Math.max(1, Number(entry.usageCount || 1));
|
||||
entry.discount = clampNumber(toNumber(entry.discount, 10), 0, 10);
|
||||
entry.totalPrice = toFixedNumber(Number(entry.price || 0) * entry.usageCount * entry.discount / 10, 2);
|
||||
syncPackageTotals(entry);
|
||||
}
|
||||
|
||||
function syncPackageTotals(entry) {
|
||||
const selected = entry.projects.filter((item) => item.selected);
|
||||
const baseTotal = selected.reduce((sum, item) => sum + Number(item.price || 0) * Number(item.usageCount || 1), 0);
|
||||
let allocated = 0;
|
||||
selected.forEach((item, index) => {
|
||||
const total = index === selected.length - 1
|
||||
? Number(entry.totalPrice || 0) - allocated
|
||||
: (baseTotal ? Number(entry.totalPrice || 0) * (Number(item.price || 0) * Number(item.usageCount || 1)) / baseTotal : 0);
|
||||
item.totalPrice = toFixedNumber(Math.max(total, 0), 2);
|
||||
item.discount = item.price && item.usageCount ? toFixedNumber(item.totalPrice / (item.price * item.usageCount) * 10, 1) : 0;
|
||||
allocated += item.totalPrice;
|
||||
});
|
||||
}
|
||||
|
||||
function changeDept(event, entry) {
|
||||
entry.dept = getProjectDepts(entry)[Number(event.detail.value)] || null;
|
||||
entry.treatmentDoctorUserId = "";
|
||||
@ -576,9 +770,33 @@ function goBack() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
|
||||
function goBackToConversation() {
|
||||
if (!groupId.value) {
|
||||
goBack();
|
||||
return;
|
||||
}
|
||||
const conversationID = `GROUP${groupId.value}`;
|
||||
uni.redirectTo({
|
||||
url: `/pages/message/index?conversationID=${encodeURIComponent(conversationID)}&groupID=${encodeURIComponent(groupId.value)}&fromCase=true`,
|
||||
});
|
||||
}
|
||||
|
||||
function validateEntries() {
|
||||
for (let index = 0; index < entries.value.length; index += 1) {
|
||||
const entry = entries.value[index];
|
||||
if (entry.isPackage) {
|
||||
if (!Number(entry.usageCount) || Number(entry.usageCount) <= 0) return `${entry.packageName}数量必须大于0`;
|
||||
if (!Number.isFinite(Number(entry.discount)) || Number(entry.discount) < 0 || Number(entry.discount) > 10) return `${entry.packageName}折扣需在0到10之间`;
|
||||
if (entry.packageType === "free" && entry.selectedCount !== entry.projectNumber) {
|
||||
return `${entry.packageName}需要选择${entry.projectNumber}项,当前已选择${entry.selectedCount}项`;
|
||||
}
|
||||
const selectedProjects = entry.projects.filter((item) => item.selected);
|
||||
for (const projectEntry of selectedProjects) {
|
||||
if (!projectEntry.dept?._id) return `${projectEntry.project.projectName}请选择治疗科室`;
|
||||
if (projectEntry.hasValidDays && !projectEntry.validTime) return `${projectEntry.project.projectName}请选择有效日期`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const label = `第${index + 1}个权益项目`;
|
||||
if (!entry.project?._id) return `${label}请选择项目`;
|
||||
if (Number(entry.price) < 0 || Number.isNaN(Number(entry.price))) return `${label}价格不能小于0`;
|
||||
@ -643,7 +861,17 @@ async function submitEntries() {
|
||||
const userId = accountStore.doctorInfo?.userid || accountStore.account?.userid || "";
|
||||
try {
|
||||
const createdEntries = [];
|
||||
for (const entry of entries.value) {
|
||||
const submitEntries = entries.value.flatMap((entry) => {
|
||||
if (!entry.isPackage) return [entry];
|
||||
return entry.projects.filter((item) => item.selected).map((item) => ({
|
||||
...item,
|
||||
packageId: entry.packageId,
|
||||
packageName: entry.packageName,
|
||||
packageType: entry.packageType,
|
||||
packagePrice: Number(entry.packagePrice || 0),
|
||||
}));
|
||||
});
|
||||
for (const entry of submitEntries) {
|
||||
const count = Number(entry.usageCount);
|
||||
const price = Number(entry.price);
|
||||
const discount = Number(entry.discount);
|
||||
@ -670,16 +898,22 @@ async function submitEntries() {
|
||||
createTreatementTime: Date.now(),
|
||||
billTime: Date.now(),
|
||||
validTime: entry.validTime ? new Date(`${entry.validTime} 23:59:59`).getTime() : null,
|
||||
hasValidDays: Boolean(entry.hasValidDays),
|
||||
validDays: Number(entry.validDays || 0),
|
||||
packageId: entry.packageId || "",
|
||||
packageName: entry.packageName || "",
|
||||
packageType: entry.packageType || "",
|
||||
packagePrice: Number(entry.packagePrice || 0),
|
||||
teamId: teamId.value,
|
||||
corpId: corpId.value,
|
||||
};
|
||||
const res = await api("addTreatmentRecord", { params: treatmentData }, false);
|
||||
const res = await api("addTreatmentRecord", { userId, operationSource: "wxApp", params: treatmentData }, false);
|
||||
if (!res?.success) throw new Error(res?.message || "权益录入失败");
|
||||
createdEntries.push(entry);
|
||||
}
|
||||
queueBenefitMessage(createdEntries);
|
||||
uni.showToast({ title: "权益录入成功", icon: "success" });
|
||||
setTimeout(goBack, 500);
|
||||
setTimeout(goBackToConversation, 500);
|
||||
} catch (error) {
|
||||
uni.showToast({ title: error.message || "权益录入失败", icon: "none" });
|
||||
} finally {
|
||||
@ -817,6 +1051,75 @@ async function submitEntries() {
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 23, 42, 0.05);
|
||||
}
|
||||
|
||||
.package-card-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.package-name {
|
||||
color: #111827;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.package-price {
|
||||
flex-shrink: 0;
|
||||
color: #e85c2f;
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.package-summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10rpx 20rpx;
|
||||
margin-top: 18rpx;
|
||||
padding: 16rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #f5f7fa;
|
||||
color: #606266;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.package-project-card {
|
||||
margin-top: 20rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #e5e7eb;
|
||||
border-radius: 14rpx;
|
||||
background: #fafbfc;
|
||||
}
|
||||
|
||||
.package-project-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
color: #1f2937;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.package-project-detail {
|
||||
margin-top: 10rpx;
|
||||
color: #6b7280;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.readonly-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 76rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #f3f4f6;
|
||||
color: #606266;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
margin-bottom: 12rpx;
|
||||
color: #374151;
|
||||
@ -1068,6 +1371,13 @@ async function submitEntries() {
|
||||
max-height: 55vh;
|
||||
}
|
||||
|
||||
.picker-group-title {
|
||||
padding: 18rpx 8rpx 8rpx;
|
||||
color: #374151;
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.project-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@ -90,6 +90,7 @@ const props = defineProps({
|
||||
corpId: { type: String, default: "" },
|
||||
orderStatus: { type: String, default: "" },
|
||||
isGenerating: { type: Boolean, default: false },
|
||||
canBenefitEntry: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
// Emits
|
||||
@ -481,11 +482,6 @@ const morePanelButtons = computed(() => {
|
||||
icon: "/static/icon/xuanjiaowenzhang.png",
|
||||
action: goToArticleList,
|
||||
},
|
||||
{
|
||||
text: "权益录入",
|
||||
icon: "/static/icon/quanyi.svg",
|
||||
action: goToBenefitEntry,
|
||||
},
|
||||
{
|
||||
text: "问卷",
|
||||
icon: "/static/icon/wenjuan.png",
|
||||
@ -493,6 +489,14 @@ const morePanelButtons = computed(() => {
|
||||
},
|
||||
];
|
||||
|
||||
if (props.canBenefitEntry) {
|
||||
buttons.splice(4, 0, {
|
||||
text: "权益录入",
|
||||
icon: "/static/icon/quanyi.svg",
|
||||
action: goToBenefitEntry,
|
||||
});
|
||||
}
|
||||
|
||||
// 根据订单状态显示不同的按钮
|
||||
if (props.orderStatus === "finished") {
|
||||
// 已结束状态:显示"开启会话"按钮
|
||||
|
||||
@ -157,6 +157,7 @@
|
||||
:patientInfo="patientInfo"
|
||||
:orderStatus="orderStatus"
|
||||
:isGenerating="isGenerating"
|
||||
:canBenefitEntry="doctorInfo?.benefitEntryEnabled === true"
|
||||
@scrollToBottom="() => scrollToBottom(true)"
|
||||
@messageSent="() => scrollToBottom(true)"
|
||||
@endConsult="handleEndConsult"
|
||||
|
||||
@ -94,6 +94,9 @@ const urlsConfig = {
|
||||
// 健康档案相关接口
|
||||
addMedicalRecord: 'addMedicalRecord',
|
||||
addTreatmentRecord: "addTreatmentRecord",
|
||||
getProjectPackageList: "getProjectPackageList",
|
||||
getTreatmentRecord: "getTreatmentRecord",
|
||||
getDeductRecord: "getDeductRecord",
|
||||
getMedicalRecordById: 'getMedicalRecordById',
|
||||
updateMedicalRecord: 'updateMedicalRecord',
|
||||
removeMedicalRecord: 'removeMedicalRecord',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user