feat: 会员管理、在线复诊优化、新增配送仓库
This commit is contained in:
29
App.vue
29
App.vue
@@ -100,6 +100,9 @@
|
|||||||
if (uni.getStorageSync('token') && !isWebSocketConnected()) {
|
if (uni.getStorageSync('token') && !isWebSocketConnected()) {
|
||||||
this.initWebSocketConnection();
|
this.initWebSocketConnection();
|
||||||
}
|
}
|
||||||
|
// 检测拨号返回:详情页 onCallbackCall 调用 makePhoneCall 前写入了 pendingCallback,
|
||||||
|
// 回到小程序时广播给当前详情页/抽屉组件,由其自动弹回访表单
|
||||||
|
this.checkPendingCallback();
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
// 应用隐藏时不断开WebSocket,保持连接以便接收消息
|
// 应用隐藏时不断开WebSocket,保持连接以便接收消息
|
||||||
@@ -121,6 +124,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测从拨号返回小程序的场景
|
||||||
|
* 就诊人详情点击"回访"时写入 pendingCallback(upId/phone/ts);
|
||||||
|
* 用户回到小程序时若 5 分钟内有效,则广播事件触发回访表单抽屉,
|
||||||
|
* 之后立即清除 storage 标记,避免下次 onShow 重复弹窗
|
||||||
|
*/
|
||||||
|
checkPendingCallback() {
|
||||||
|
let payload = null;
|
||||||
|
try {
|
||||||
|
payload = uni.getStorageSync('pendingCallback');
|
||||||
|
} catch (e) {
|
||||||
|
payload = null;
|
||||||
|
}
|
||||||
|
if (!payload || typeof payload !== 'object') return;
|
||||||
|
const now = Date.now();
|
||||||
|
const ts = Number(payload.ts) || 0;
|
||||||
|
// 时间窗 5 分钟:避免误判;超时直接丢弃
|
||||||
|
if (ts && now - ts > 5 * 60 * 1000) {
|
||||||
|
try { uni.removeStorageSync('pendingCallback'); } catch (e) { /* ignore */ }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 广播后清理,由当前可见的详情页/抽屉组件接收处理
|
||||||
|
try { uni.removeStorageSync('pendingCallback'); } catch (e) { /* ignore */ }
|
||||||
|
uni.$emit('patient:callbackReturned', payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
async getInfo() {
|
async getInfo() {
|
||||||
let role = uni.getStorageSync('identity')
|
let role = uni.getStorageSync('identity')
|
||||||
|
|||||||
@@ -130,3 +130,43 @@ export function getUserPatientOrderList(upId, params) {
|
|||||||
data: { up_id: upId, ...params },
|
data: { up_id: upId, ...params },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 就诊人回访记录列表
|
||||||
|
* @param {number|string} upId 就诊人ID
|
||||||
|
* @param {object} params { pageSize }
|
||||||
|
*/
|
||||||
|
export function getPatientCallLogList(upId, params) {
|
||||||
|
const { prefix } = getProfileContext();
|
||||||
|
return profileRequest({
|
||||||
|
url: `${prefix}/call-log-list`,
|
||||||
|
method: 'GET',
|
||||||
|
data: { up_id: upId, ...(params || {}) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建就诊人回访记录
|
||||||
|
* @param {number|string} upId 就诊人ID
|
||||||
|
* @param {object} payload { phone, call_at, result, tags, conclusion, remark, next_at }
|
||||||
|
*/
|
||||||
|
export function createPatientCallLog(upId, payload) {
|
||||||
|
const { prefix } = getProfileContext();
|
||||||
|
return profileRequest({
|
||||||
|
url: `${prefix}/call-log-create`,
|
||||||
|
method: 'POST',
|
||||||
|
data: { up_id: upId, ...(payload || {}) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序回访字典(启用中的结果/标签 + 颜色)
|
||||||
|
* 返回结构:{ results: [{value,name,color}], tags: [...] }
|
||||||
|
*/
|
||||||
|
export function getPatientCallLogDict() {
|
||||||
|
const { prefix } = getProfileContext();
|
||||||
|
return profileRequest({
|
||||||
|
url: `${prefix}/call-log-dict`,
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ const DEV = {
|
|||||||
wsUrl: 'ws://127.0.0.1:12080/ws',
|
wsUrl: 'ws://127.0.0.1:12080/ws',
|
||||||
};
|
};
|
||||||
|
|
||||||
// const PROD = {
|
const PROD = {
|
||||||
// legacyApiBase: 'https://app.xiaokang88.com/service/v1/',
|
legacyApiBase: 'https://app.xiaokang88.com/service/v1/',
|
||||||
// newApiBase: 'https://api.xiaokang88.com/api/doctor/',
|
newApiBase: 'https://api.xiaokang88.com/api/doctor/',
|
||||||
// wsUrl: 'wss://api.ws.g.xiaokang88.com/ws',
|
wsUrl: 'wss://api.ws.g.xiaokang88.com/ws',
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const TEST = {
|
// const TEST = {
|
||||||
const PROD = {
|
const TEST = {
|
||||||
legacyApiBase: 'https://xk.test.saas.api-yii.nailaoyun.cn/service/v1/',
|
legacyApiBase: 'https://xk.test.saas.api-yii.nailaoyun.cn/service/v1/',
|
||||||
newApiBase: 'https://xk.test.saas.api.nailaoyun.cn/api/doctor/',
|
newApiBase: 'https://xk.test.saas.api.nailaoyun.cn/api/doctor/',
|
||||||
// wsUrl: 'wss://api.ws.g.xiaokang88.com/ws',
|
// wsUrl: 'wss://api.ws.g.xiaokang88.com/ws',
|
||||||
@@ -33,7 +33,11 @@ export function isDoctorWxDev() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getDoctorWxEnv() {
|
export function getDoctorWxEnv() {
|
||||||
return checkDev('dev') ? DEV : PROD;
|
let env = checkDev('dev') ? DEV : PROD;
|
||||||
|
if (checkDev('test')) {
|
||||||
|
env = TEST;
|
||||||
|
}
|
||||||
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 开发 / 生产 WebSocket 地址(与 getDoctorWxEnv 同源,供 websocket 配置展示) */
|
/** 开发 / 生产 WebSocket 地址(与 getDoctorWxEnv 同源,供 websocket 配置展示) */
|
||||||
|
|||||||
@@ -259,19 +259,24 @@ export function mapOrderProductItem(p, prescriptionType) {
|
|||||||
? '*' + ((p.number != null ? p.number : 0) * dosage)
|
? '*' + ((p.number != null ? p.number : 0) * dosage)
|
||||||
: '×' + (p.number != null ? p.number : 0)
|
: '×' + (p.number != null ? p.number : 0)
|
||||||
const isTcm = prescriptionType === 1
|
const isTcm = prescriptionType === 1
|
||||||
|
const unitName =
|
||||||
|
(drug.unit && drug.unit.name) ||
|
||||||
|
(p.unit && p.unit.name) ||
|
||||||
|
p.unit_name ||
|
||||||
|
'g'
|
||||||
return {
|
return {
|
||||||
id: p.id,
|
id: p.id,
|
||||||
drugName: p.drug_name || drug.drug_name || '药品',
|
drugName: p.drug_name || drug.drug_name || '药品',
|
||||||
drugNumber: drug.drug_number || '',
|
drugNumber: drug.drug_number || '',
|
||||||
imageUrl: resolveDrugImage(p.drug_image || drug.image),
|
imageUrl: resolveDrugImage(p.drug_image || drug.image),
|
||||||
specification: drug.specification || (isTcm ? 'g' : '暂无'),
|
specification: drug.specification || (isTcm ? unitName : '暂无'),
|
||||||
manufacturer,
|
manufacturer,
|
||||||
qty,
|
qty,
|
||||||
price: isTcm
|
price: isTcm
|
||||||
? (p.price != null && p.price !== '' ? p.price + ' 元/g' : '—')
|
? (p.price != null && p.price !== '' ? p.price + ' 元/' + unitName : '—')
|
||||||
: formatMoney(p.price),
|
: formatMoney(p.price),
|
||||||
buyPrice: p.buy_price != null && p.buy_price !== ''
|
buyPrice: p.buy_price != null && p.buy_price !== ''
|
||||||
? p.buy_price + ' 元/g'
|
? p.buy_price + ' 元/' + unitName
|
||||||
: '—',
|
: '—',
|
||||||
isTcm,
|
isTcm,
|
||||||
}
|
}
|
||||||
@@ -348,9 +353,13 @@ export function mapPrescriptionDetailView(item) {
|
|||||||
const name = d.name || d.drug_name || '—'
|
const name = d.name || d.drug_name || '—'
|
||||||
const num = d.number != null ? d.number : ''
|
const num = d.number != null ? d.number : ''
|
||||||
const way = (d.use_way && d.use_way.name) || d.useWay || '煎服'
|
const way = (d.use_way && d.use_way.name) || d.useWay || '煎服'
|
||||||
|
const unit =
|
||||||
|
(d.unit && d.unit.name) ||
|
||||||
|
(d.use_unit && d.use_unit.name) ||
|
||||||
|
'g'
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
qty: num ? num + ' /g' : '',
|
qty: num !== '' ? num + ' /' + unit : '',
|
||||||
usage: way,
|
usage: way,
|
||||||
specification: d.specification || '',
|
specification: d.specification || '',
|
||||||
}
|
}
|
||||||
|
|||||||
550
subPackages/sub_business_shared/components/CallLogDrawer.vue
Normal file
550
subPackages/sub_business_shared/components/CallLogDrawer.vue
Normal file
@@ -0,0 +1,550 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<!-- 回访记录表单抽屉:使用 page-container 防止用户误退出页面;用 v-if 控制挂载/卸载 -->
|
||||||
|
<page-container
|
||||||
|
v-if="visible"
|
||||||
|
:show="visible"
|
||||||
|
:overlay="true"
|
||||||
|
position="bottom"
|
||||||
|
:round="true"
|
||||||
|
@beforeleave="onClose"
|
||||||
|
@clickoverlay="onClose"
|
||||||
|
>
|
||||||
|
<view class="cl-drawer">
|
||||||
|
<view class="cl-head">
|
||||||
|
<text class="cl-title">记录本次回访</text>
|
||||||
|
<text class="cl-close" @click="onClose">关闭</text>
|
||||||
|
</view>
|
||||||
|
<scroll-view scroll-y class="cl-body">
|
||||||
|
<view class="cl-section">
|
||||||
|
<!-- 拨打号码:展示脱敏,form.phone 仍存完整号供提交 -->
|
||||||
|
<view class="cl-row">
|
||||||
|
<text class="cl-label">拨打号码</text>
|
||||||
|
<text class="cl-value">{{ phoneDisplay || '—' }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 拨号时间(只读展示) -->
|
||||||
|
<view class="cl-row">
|
||||||
|
<text class="cl-label">拨号时间</text>
|
||||||
|
<text class="cl-value">{{ callAtText || '—' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 回访结果:tag 横排单选(dict 驱动,颜色预计算到 computed) -->
|
||||||
|
<view class="cl-section">
|
||||||
|
<text class="cl-section-title">是否接通 <text class="cl-required">*</text></text>
|
||||||
|
<view class="cl-tags">
|
||||||
|
<view
|
||||||
|
v-for="r in dictResultsView"
|
||||||
|
:key="r.value"
|
||||||
|
class="cl-tag"
|
||||||
|
:style="{ color: r.selected ? r.color : '#6b7280', background: r.selected ? r.bgColor : '#f3f4f6', borderColor: r.selected ? r.color : '#e5e7eb' }"
|
||||||
|
@click="form.result = r.value"
|
||||||
|
>
|
||||||
|
<text class="cl-tag-text">{{ r.name }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 下次回访时间:紧跟是否接通;仅选日期(年月日) -->
|
||||||
|
<view class="cl-section">
|
||||||
|
<text class="cl-section-title">下次回访时间</text>
|
||||||
|
<!-- 快捷标签:3天后/7天后;选中态与 form.next_at 联动 -->
|
||||||
|
<view class="cl-quick-tags">
|
||||||
|
<view
|
||||||
|
v-for="opt in nextAtQuickOptions"
|
||||||
|
:key="opt.key"
|
||||||
|
class="cl-tag"
|
||||||
|
:style="{ color: opt.selected ? '#1a9b88' : '#6b7280', background: opt.selected ? '#e8f5f2' : '#f3f4f6', borderColor: opt.selected ? '#1a9b88' : '#e5e7eb' }"
|
||||||
|
@click="onQuickPick(opt)"
|
||||||
|
>
|
||||||
|
<text class="cl-tag-text">{{ opt.label }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="cl-picker" @click="openNextAtPicker">
|
||||||
|
<text :class="['cl-picker-text', { placeholder: !nextAtText }]">{{ nextAtText || '暂不安排' }}</text>
|
||||||
|
<text v-if="form.next_at" class="cl-clear" @click.stop="clearNextAt">清除</text>
|
||||||
|
<text class="cl-arrow">›</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 回访标签:tag 横排多选(dict 驱动,颜色预计算到 computed) -->
|
||||||
|
<view class="cl-section">
|
||||||
|
<text class="cl-section-title">回访标签</text>
|
||||||
|
<view class="cl-tags">
|
||||||
|
<view
|
||||||
|
v-for="tag in dictTagsView"
|
||||||
|
:key="tag.value"
|
||||||
|
class="cl-tag"
|
||||||
|
:style="{ color: tag.selected ? tag.color : '#6b7280', background: tag.selected ? tag.bgColor : '#f3f4f6', borderColor: tag.selected ? tag.color : '#e5e7eb' }"
|
||||||
|
@click="toggleTag(tag.value)"
|
||||||
|
>
|
||||||
|
<text class="cl-tag-text">{{ tag.name }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 随访结论:textarea -->
|
||||||
|
<view class="cl-section">
|
||||||
|
<text class="cl-section-title">随访结论</text>
|
||||||
|
<textarea
|
||||||
|
class="cl-textarea"
|
||||||
|
v-model="form.conclusion"
|
||||||
|
:maxlength="120"
|
||||||
|
placeholder="请填写随访结论(选填)"
|
||||||
|
placeholder-class="cl-placeholder"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<!-- 备注:textarea -->
|
||||||
|
<view class="cl-section">
|
||||||
|
<text class="cl-section-title">备注</text>
|
||||||
|
<textarea
|
||||||
|
class="cl-textarea"
|
||||||
|
v-model="form.remark"
|
||||||
|
:maxlength="200"
|
||||||
|
placeholder="请填写备注(选填)"
|
||||||
|
placeholder-class="cl-placeholder"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
<view class="cl-footer safe-area-inset-bottom">
|
||||||
|
<view class="cl-btn cl-btn-cancel" @click="onClose"><text>取消</text></view>
|
||||||
|
<view class="cl-btn cl-btn-ok" @click="onSubmit"><text>提交</text></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</page-container>
|
||||||
|
<!-- 下次回访时间 picker:uView 时间模式(只到天,不选时分) -->
|
||||||
|
<u-picker
|
||||||
|
v-model="nextAtPickerShow"
|
||||||
|
mode="time"
|
||||||
|
:params="nextAtParams"
|
||||||
|
confirm-text="确定"
|
||||||
|
@confirm="onNextAtConfirm"
|
||||||
|
@cancel="nextAtPickerShow = false"
|
||||||
|
></u-picker>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* 回访记录表单抽屉
|
||||||
|
* 用途:在就诊人详情页(抽屉/页面)拨号后或手动点击"记录本次回访"时打开
|
||||||
|
* 字段:phone/call_at(由父组件预填) + result/tags/conclusion/remark/next_at
|
||||||
|
* 数据源:dict(回访结果/回访标签)从后台维护的 xk_patient_call_log_dict 表加载
|
||||||
|
*/
|
||||||
|
import { createPatientCallLog, getPatientCallLogDict } from '@/api/userPatientProfile.js';
|
||||||
|
|
||||||
|
/** 兜底数据:dict 接口失败时使用,保证 UI 不崩 */
|
||||||
|
const FALLBACK_RESULTS = [
|
||||||
|
{ value: 'connected', name: '接通', color: '#1a9b88' },
|
||||||
|
{ value: 'no_answer', name: '未接', color: '#b45309' },
|
||||||
|
{ value: 'hangup', name: '挂断', color: '#b91c1c' },
|
||||||
|
{ value: 'invalid', name: '号码错误', color: '#6b7280' },
|
||||||
|
];
|
||||||
|
const FALLBACK_TAGS = [
|
||||||
|
{ value: 'care', name: '关怀', color: '#6acdbb' },
|
||||||
|
{ value: 'condition', name: '病情', color: '#ef4444' },
|
||||||
|
{ value: 'medication', name: '用药提醒', color: '#3b82f6' },
|
||||||
|
{ value: 'review', name: '复诊提醒', color: '#f59e0b' },
|
||||||
|
{ value: 'complaint', name: '投诉处理', color: '#8b5cf6' },
|
||||||
|
];
|
||||||
|
|
||||||
|
/** 时间选择器精度:仅年月日(用户要求选日期即可,不选时分) */
|
||||||
|
const NEXT_AT_PARAMS = {
|
||||||
|
year: true,
|
||||||
|
month: true,
|
||||||
|
day: true,
|
||||||
|
hour: false,
|
||||||
|
minute: false,
|
||||||
|
second: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'CallLogDrawer',
|
||||||
|
props: {
|
||||||
|
/** 控制抽屉显隐,v-if 挂载 */
|
||||||
|
visible: { type: Boolean, default: false },
|
||||||
|
/** 就诊人ID */
|
||||||
|
upId: { type: [Number, String], default: 0 },
|
||||||
|
/**
|
||||||
|
* 预填数据:拨号场景下父组件传入 { phone, call_at }
|
||||||
|
* 手动点击场景不传,phone/call_at 留空,由用户填写
|
||||||
|
*/
|
||||||
|
prefill: { type: Object, default: () => ({}) },
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
submitting: false,
|
||||||
|
form: {
|
||||||
|
phone: '',
|
||||||
|
call_at: 0,
|
||||||
|
result: '',
|
||||||
|
tags: [],
|
||||||
|
conclusion: '',
|
||||||
|
remark: '',
|
||||||
|
next_at: 0,
|
||||||
|
},
|
||||||
|
// dict:后台维护的结果/标签列表,含 color
|
||||||
|
dictResults: FALLBACK_RESULTS,
|
||||||
|
dictTags: FALLBACK_TAGS,
|
||||||
|
nextAtParams: NEXT_AT_PARAMS,
|
||||||
|
nextAtPickerShow: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
/**
|
||||||
|
* 拨打号码脱敏展示:保留前3后4,中间 ****
|
||||||
|
* form.phone 仍为完整号码,提交时不脱敏
|
||||||
|
*/
|
||||||
|
phoneDisplay() {
|
||||||
|
const phone = String(this.form.phone || '').trim();
|
||||||
|
if (!phone) return '';
|
||||||
|
if (phone.length < 7) return phone;
|
||||||
|
return phone.slice(0, 3) + '****' + phone.slice(-4);
|
||||||
|
},
|
||||||
|
/** 拨号时间格式化展示(call_at 为秒级时间戳) */
|
||||||
|
callAtText() {
|
||||||
|
if (!this.form.call_at) return '';
|
||||||
|
return this.formatTimestamp(Number(this.form.call_at), true);
|
||||||
|
},
|
||||||
|
/** 下次回访时间展示(仅日期) */
|
||||||
|
nextAtText() {
|
||||||
|
if (!this.form.next_at) return '';
|
||||||
|
return this.formatTimestamp(Number(this.form.next_at), false);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 回访结果列表(带 selected 标记 + 浅色背景 bgColor)
|
||||||
|
* 注意:小程序模板 :style 不允许调函数,故把颜色计算放进 computed
|
||||||
|
*/
|
||||||
|
dictResultsView() {
|
||||||
|
const cur = this.form.result;
|
||||||
|
return this.dictResults.map((r) => {
|
||||||
|
const color = r.color || '#6acdbb';
|
||||||
|
return {
|
||||||
|
value: r.value,
|
||||||
|
name: r.name,
|
||||||
|
color,
|
||||||
|
bgColor: this.hexToRgba(color, 0.1),
|
||||||
|
selected: r.value === cur,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 回访标签列表(同上) */
|
||||||
|
dictTagsView() {
|
||||||
|
const tags = this.form.tags || [];
|
||||||
|
return this.dictTags.map((t) => {
|
||||||
|
const color = t.color || '#6acdbb';
|
||||||
|
return {
|
||||||
|
value: t.value,
|
||||||
|
name: t.name,
|
||||||
|
color,
|
||||||
|
bgColor: this.hexToRgba(color, 0.1),
|
||||||
|
selected: tags.indexOf(t.value) >= 0,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下次回访时间快捷选项:3天后 / 7天后
|
||||||
|
* selected 标记是否与当前 form.next_at 命中同一天(避免时分差异导致不选中)
|
||||||
|
*/
|
||||||
|
nextAtQuickOptions() {
|
||||||
|
const cur = this.form.next_at;
|
||||||
|
const curDay = cur ? this.dayStartTs(cur) : 0;
|
||||||
|
return [
|
||||||
|
{ key: '3d', label: '3天后', days: 3, ts: this.daysLaterTs(3) },
|
||||||
|
{ key: '7d', label: '7天后', days: 7, ts: this.daysLaterTs(7) },
|
||||||
|
].map((o) => Object.assign({}, o, {
|
||||||
|
selected: cur > 0 && this.dayStartTs(o.ts) === curDay,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
/**
|
||||||
|
* v-if 挂载时 visible 已是 true,用 immediate 同步初始化表单 + 加载 dict
|
||||||
|
*/
|
||||||
|
visible: {
|
||||||
|
immediate: true,
|
||||||
|
handler(val) {
|
||||||
|
if (val) {
|
||||||
|
this.initForm();
|
||||||
|
this.loadDict();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 打开抽屉时根据 prefill 初始化表单 */
|
||||||
|
initForm() {
|
||||||
|
const pre = this.prefill || {};
|
||||||
|
this.submitting = false;
|
||||||
|
this.form = {
|
||||||
|
phone: String(pre.phone || ''),
|
||||||
|
call_at: Number(pre.call_at || 0),
|
||||||
|
result: '',
|
||||||
|
tags: [],
|
||||||
|
conclusion: '',
|
||||||
|
remark: '',
|
||||||
|
next_at: 0,
|
||||||
|
};
|
||||||
|
this.nextAtPickerShow = false;
|
||||||
|
},
|
||||||
|
/** 拉取后台维护的回访结果/标签字典,加载失败兜底用 FALLBACK */
|
||||||
|
async loadDict() {
|
||||||
|
try {
|
||||||
|
const wrap = await getPatientCallLogDict();
|
||||||
|
const body = wrap && wrap.res ? wrap.res : null;
|
||||||
|
const payload = body && body.result ? body.result : null;
|
||||||
|
if (payload) {
|
||||||
|
if (Array.isArray(payload.results) && payload.results.length) {
|
||||||
|
this.dictResults = payload.results;
|
||||||
|
}
|
||||||
|
if (Array.isArray(payload.tags) && payload.tags.length) {
|
||||||
|
this.dictTags = payload.tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// 静默兜底,使用 FALLBACK 数据保证 UI 可用
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 关闭抽屉 */
|
||||||
|
onClose() {
|
||||||
|
if (this.submitting) return;
|
||||||
|
this.$emit('update:visible', false);
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
/** 判断标签是否已选中 */
|
||||||
|
isTagChecked(value) {
|
||||||
|
return this.form.tags.indexOf(value) >= 0;
|
||||||
|
},
|
||||||
|
/** 切换标签选中态 */
|
||||||
|
toggleTag(value) {
|
||||||
|
const idx = this.form.tags.indexOf(value);
|
||||||
|
if (idx >= 0) {
|
||||||
|
this.form.tags.splice(idx, 1);
|
||||||
|
} else {
|
||||||
|
this.form.tags.push(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** hex(#RRGGBB) -> rgba 字符串,alpha 控制浅色背景 */
|
||||||
|
hexToRgba(hex, alpha) {
|
||||||
|
const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex || '');
|
||||||
|
if (!m) return `rgba(106,205,187,${alpha})`;
|
||||||
|
const r = parseInt(m[1], 16);
|
||||||
|
const g = parseInt(m[2], 16);
|
||||||
|
const b = parseInt(m[3], 16);
|
||||||
|
return `rgba(${r},${g},${b},${alpha})`;
|
||||||
|
},
|
||||||
|
/** 打开下次回访时间选择器 */
|
||||||
|
openNextAtPicker() {
|
||||||
|
this.nextAtPickerShow = true;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下次回访时间确认
|
||||||
|
* uView u-picker mode=time 的 confirm 回调返回对象:
|
||||||
|
* { year, month, day, hour, minute, second, timestamp }
|
||||||
|
* 其中 timestamp 为秒级时间戳;仅选年月日时,时间部分为当天 0 点
|
||||||
|
*/
|
||||||
|
onNextAtConfirm(e) {
|
||||||
|
if (e && typeof e.timestamp === 'number' && e.timestamp > 0) {
|
||||||
|
// 优先用 uView 提供的秒级时间戳
|
||||||
|
this.form.next_at = e.timestamp;
|
||||||
|
} else if (e && e.year) {
|
||||||
|
// 兜底:手动拼接 YYYY-MM-DD 再解析(兼容 Safari/iOS)
|
||||||
|
const pad = (n) => (Number(n) < 10 ? '0' + Number(n) : '' + n);
|
||||||
|
const text = `${e.year}-${pad(e.month)}-${pad(e.day)}`;
|
||||||
|
this.form.next_at = Math.floor(Date.parse(text.replace(/-/g, '/')) / 1000) || 0;
|
||||||
|
} else {
|
||||||
|
this.form.next_at = 0;
|
||||||
|
}
|
||||||
|
this.nextAtPickerShow = false;
|
||||||
|
},
|
||||||
|
/** 清除下次回访时间 */
|
||||||
|
clearNextAt() {
|
||||||
|
this.form.next_at = 0;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 点击快捷标签:再次点击同一天则取消;否则写入"今天起 N 天后 00:00:00"
|
||||||
|
* @param opt {key,label,days,ts,selected}
|
||||||
|
*/
|
||||||
|
onQuickPick(opt) {
|
||||||
|
if (opt && opt.selected) {
|
||||||
|
this.form.next_at = 0;
|
||||||
|
} else if (opt) {
|
||||||
|
this.form.next_at = this.daysLaterTs(opt.days);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 当前时间 + N 天的当天 00:00:00 秒级时间戳 */
|
||||||
|
daysLaterTs(days) {
|
||||||
|
const n = Number(days) || 0;
|
||||||
|
const now = new Date();
|
||||||
|
const d = new Date(now.getFullYear(), now.getMonth(), now.getDate() + n, 0, 0, 0);
|
||||||
|
return Math.floor(d.getTime() / 1000);
|
||||||
|
},
|
||||||
|
/** 取某时间戳所在自然日 00:00:00 的秒级时间戳(同日判断用) */
|
||||||
|
dayStartTs(ts) {
|
||||||
|
const d = new Date(ts * 1000);
|
||||||
|
const start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0);
|
||||||
|
return Math.floor(start.getTime() / 1000);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 时间戳 -> 字符串
|
||||||
|
* @param ts 秒级时间戳
|
||||||
|
* @param withTime true 返回 YYYY-MM-DD HH:mm;false 仅 YYYY-MM-DD
|
||||||
|
*/
|
||||||
|
formatTimestamp(ts, withTime) {
|
||||||
|
if (!ts) return '';
|
||||||
|
const d = new Date(ts * 1000);
|
||||||
|
const pad = (n) => (n < 10 ? '0' + n : '' + n);
|
||||||
|
const ymd = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
||||||
|
return withTime ? `${ymd} ${pad(d.getHours())}:${pad(d.getMinutes())}` : ymd;
|
||||||
|
},
|
||||||
|
/** 提交表单 */
|
||||||
|
async onSubmit() {
|
||||||
|
if (this.submitting) return;
|
||||||
|
if (!this.form.result) {
|
||||||
|
uni.showToast({ title: '请选择是否接通', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.upId) {
|
||||||
|
uni.showToast({ title: '缺少就诊人信息', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.submitting = true;
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true });
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
phone: this.form.phone,
|
||||||
|
call_at: this.form.call_at,
|
||||||
|
result: this.form.result,
|
||||||
|
tags: this.form.tags,
|
||||||
|
conclusion: this.form.conclusion,
|
||||||
|
remark: this.form.remark,
|
||||||
|
next_at: this.form.next_at,
|
||||||
|
};
|
||||||
|
const wrap = await createPatientCallLog(this.upId, payload);
|
||||||
|
const ok = !!(wrap && wrap.ok);
|
||||||
|
uni.hideLoading();
|
||||||
|
if (!ok) {
|
||||||
|
uni.showToast({ title: '提交失败', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uni.showToast({ title: '已记录', icon: 'success' });
|
||||||
|
this.$emit('success');
|
||||||
|
this.$emit('update:visible', false);
|
||||||
|
this.$emit('close');
|
||||||
|
} catch (e) {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '网络异常', icon: 'none' });
|
||||||
|
} finally {
|
||||||
|
this.submitting = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.cl-drawer {
|
||||||
|
height: 80vh;
|
||||||
|
background: #f9fafb;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.cl-head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 28rpx 32rpx;
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 1rpx solid #f0f0f0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.cl-title { font-size: 30rpx; font-weight: 600; color: #111827; }
|
||||||
|
.cl-close { font-size: 26rpx; color: #6acdbb; }
|
||||||
|
.cl-body {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 16rpx 24rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.cl-section {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 14rpx;
|
||||||
|
padding: 20rpx 24rpx;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
}
|
||||||
|
.cl-section-title {
|
||||||
|
display: block;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
}
|
||||||
|
.cl-required { color: #dc2626; margin-left: 4rpx; }
|
||||||
|
.cl-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 8rpx 0;
|
||||||
|
}
|
||||||
|
.cl-label { font-size: 24rpx; color: #9ca3af; }
|
||||||
|
.cl-value { font-size: 26rpx; color: #374151; }
|
||||||
|
.cl-picker {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12rpx;
|
||||||
|
border: 1rpx solid #e5e7eb;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
padding: 18rpx 20rpx;
|
||||||
|
}
|
||||||
|
.cl-picker-text { flex: 1; font-size: 26rpx; color: #111827; }
|
||||||
|
.cl-picker-text.placeholder { color: #9ca3af; }
|
||||||
|
.cl-clear { font-size: 24rpx; color: #6acdbb; padding: 0 12rpx; }
|
||||||
|
.cl-arrow { font-size: 32rpx; color: #9ca3af; line-height: 1; }
|
||||||
|
.cl-tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
.cl-quick-tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16rpx;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
}
|
||||||
|
.cl-tag {
|
||||||
|
padding: 10rpx 24rpx;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
background: #f3f4f6;
|
||||||
|
border: 1rpx solid #e5e7eb;
|
||||||
|
}
|
||||||
|
.cl-tag-text { font-size: 24rpx; color: #6b7280; }
|
||||||
|
.cl-textarea {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: #f9fafb;
|
||||||
|
border: 1rpx solid #e5e7eb;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
padding: 18rpx 20rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #111827;
|
||||||
|
min-height: 120rpx;
|
||||||
|
}
|
||||||
|
.cl-placeholder { color: #9ca3af; font-size: 26rpx; }
|
||||||
|
.cl-footer {
|
||||||
|
display: flex;
|
||||||
|
gap: 16rpx;
|
||||||
|
padding: 16rpx 24rpx 24rpx;
|
||||||
|
background: #fff;
|
||||||
|
border-top: 1rpx solid #f0f0f0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.cl-btn {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 80rpx;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
.cl-btn-cancel { background: #f3f4f6; color: #6b7280; }
|
||||||
|
.cl-btn-ok { background: #6acdbb; color: #fff; }
|
||||||
|
</style>
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 患者视角详情:page-container 抽屉,避免误退出页面;用 v-if 控制挂载 -->
|
<view>
|
||||||
|
<!-- 患者视角详情:page-container 抽屉;用 v-if 控制挂载 -->
|
||||||
|
<!-- 微信同一页只能有一个 page-container:打开回访表单前必须先卸掉本实例,再挂 CallLogDrawer -->
|
||||||
<page-container
|
<page-container
|
||||||
v-if="visible"
|
v-if="visible && !patientSheetHiddenForCallLog"
|
||||||
:show="visible"
|
:show="true"
|
||||||
:overlay="true"
|
:overlay="true"
|
||||||
position="bottom"
|
position="bottom"
|
||||||
:round="true"
|
:round="true"
|
||||||
@beforeleave="onBeforeLeave"
|
@beforeleave="onBeforeLeave"
|
||||||
@clickoverlay="close"
|
@clickoverlay="onClickOverlay"
|
||||||
>
|
>
|
||||||
<view class="drawer">
|
<view class="drawer">
|
||||||
<view class="drawer-head">
|
<view class="drawer-head">
|
||||||
@@ -33,16 +35,22 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="patient-block">
|
<view class="patient-block">
|
||||||
<view class="patient-head">
|
<view class="patient-head">
|
||||||
<view class="patient-head-left">
|
<view class="patient-head-left">
|
||||||
<text class="p-name">{{ profile.patient.name || '—' }}</text>
|
<text class="p-name">{{ profile.patient.name || '—' }}</text>
|
||||||
<text v-if="sexText !== '—'" class="sex-tag" :class="sexTagClass">{{ sexText }}</text>
|
<text v-if="sexText !== '—'" class="sex-tag" :class="sexTagClass">{{ sexText }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="patient-actions">
|
||||||
<!-- 回访:拨打就诊人/用户手机 -->
|
<!-- 回访:拨打就诊人/用户手机 -->
|
||||||
<view class="callback-btn" @click.stop="onCallbackCall">
|
<view class="callback-btn" @click.stop="onCallbackCall">
|
||||||
<text class="callback-btn-text">回访</text>
|
<text class="callback-btn-text">回访</text>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 记录本次回访:手动打开回访记录表单抽屉 -->
|
||||||
|
<view class="callback-link" @click.stop="openCallLogForm">
|
||||||
|
<text class="callback-link-text">记录本次回访</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
<text class="p-sub">
|
<text class="p-sub">
|
||||||
{{ profile.patient.age || '—' }}岁
|
{{ profile.patient.age || '—' }}岁
|
||||||
<template v-if="profile.patient.mobile"> · {{ profile.patient.mobile }}</template>
|
<template v-if="profile.patient.mobile"> · {{ profile.patient.mobile }}</template>
|
||||||
@@ -63,7 +71,7 @@
|
|||||||
<view v-if="tabIndex === idx" class="tab-bar" />
|
<view v-if="tabIndex === idx" class="tab-bar" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 四页左右滑:资料 / 挂号 / 处方 / 订单 -->
|
<!-- 五页左右滑:资料 / 回访 / 挂号 / 处方 / 订单 -->
|
||||||
<swiper
|
<swiper
|
||||||
class="tab-swiper"
|
class="tab-swiper"
|
||||||
:style="{ height: swiperHeightPx + 'px' }"
|
:style="{ height: swiperHeightPx + 'px' }"
|
||||||
@@ -71,7 +79,7 @@
|
|||||||
:duration="200"
|
:duration="200"
|
||||||
@change="onTabSwiperChange"
|
@change="onTabSwiperChange"
|
||||||
>
|
>
|
||||||
<swiper-item v-for="t in tabs" :key="'sw-' + t.key">
|
<swiper-item v-for="t in tabs" :key="t.key">
|
||||||
<scroll-view
|
<scroll-view
|
||||||
scroll-y
|
scroll-y
|
||||||
class="tab-scroll"
|
class="tab-scroll"
|
||||||
@@ -113,13 +121,44 @@
|
|||||||
</template>
|
</template>
|
||||||
<view v-else class="empty-inline">暂无健康问诊记录</view>
|
<view v-else class="empty-inline">暂无健康问诊记录</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 回访:历史回访记录列表(懒加载) -->
|
||||||
|
<view v-else-if="t.key === 'calllog'" class="call-log-card in-tab">
|
||||||
|
<view class="call-log-head">
|
||||||
|
<text class="call-log-head-title">回访记录</text>
|
||||||
|
<text v-if="callLogList.length" class="call-log-head-count">{{ callLogTotal }} 条</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="callLogLoading" class="empty-inline">加载中...</view>
|
||||||
|
<view v-else-if="!callLogList.length" class="empty-inline">暂无回访记录</view>
|
||||||
|
<view v-else>
|
||||||
|
<view v-for="log in callLogList" :key="log.id" class="call-log-item">
|
||||||
|
<view class="call-log-item-head">
|
||||||
|
<text
|
||||||
|
class="call-log-result-tag"
|
||||||
|
:style="{ color: log.result_color || '#6b7280', background: log.result_bg, borderColor: log.result_color || '#e5e7eb' }"
|
||||||
|
>{{ log.result_text }}</text>
|
||||||
|
<text class="call-log-item-time">{{ log.call_at }}</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="log.tags.length" class="call-log-tags">
|
||||||
|
<text
|
||||||
|
v-for="tg in log.tags"
|
||||||
|
:key="tg.value"
|
||||||
|
class="call-log-tag-text"
|
||||||
|
:style="{ color: tg.color || '#6b7280' }"
|
||||||
|
>#{{ tg.name }}</text>
|
||||||
|
</view>
|
||||||
|
<text v-if="log.conclusion" class="call-log-line">结论:{{ log.conclusion }}</text>
|
||||||
|
<text v-if="log.remark" class="call-log-line">备注:{{ log.remark }}</text>
|
||||||
|
<text v-if="log.next_at" class="call-log-line call-log-next">下次回访:{{ log.next_at_text }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<view v-if="tabLoading && activeTab === t.key" class="empty">加载中...</view>
|
<view v-if="tabLoading && activeTab === t.key" class="empty">加载中...</view>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<view v-if="!listForTab(t.key).length" class="empty">暂无记录</view>
|
<view v-if="!listForTab(t.key).length" class="empty">暂无记录</view>
|
||||||
<view
|
<view
|
||||||
v-for="item in listForTab(t.key)"
|
v-for="item in listForTab(t.key)"
|
||||||
:key="t.key + '-' + item.id"
|
:key="item.id"
|
||||||
class="record-card"
|
class="record-card"
|
||||||
@click="onRecordClick(item, t.key)"
|
@click="onRecordClick(item, t.key)"
|
||||||
>
|
>
|
||||||
@@ -150,25 +189,54 @@
|
|||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</page-container>
|
</page-container>
|
||||||
|
<!-- 回访记录表单抽屉:独立 page-container,避免与详情抽屉嵌套 -->
|
||||||
|
<CallLogDrawer
|
||||||
|
v-if="callLogDrawerVisible"
|
||||||
|
:visible="callLogDrawerVisible"
|
||||||
|
:up-id="upId"
|
||||||
|
:prefill="callLogPrefill"
|
||||||
|
@update:visible="onCallLogDrawerVisibleChange"
|
||||||
|
@close="onCallLogDrawerClose"
|
||||||
|
@success="onCallLogSuccess"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/**
|
/**
|
||||||
* 患者视角详情抽屉:微信用户/就诊人信息 + 挂号/处方/订单
|
* 患者视角详情抽屉:微信用户/就诊人信息 + 挂号/处方/订单
|
||||||
* 对齐详情页展示与回访;四 Tab 支持点击与左右滑动(懒加载)
|
* 对齐详情页展示与回访;五 Tab 支持点击与左右滑动(懒加载)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
getUserPatientDetail,
|
getUserPatientDetail,
|
||||||
getUserPatientRegisterList,
|
getUserPatientRegisterList,
|
||||||
getUserPatientPrescriptionList,
|
getUserPatientPrescriptionList,
|
||||||
getUserPatientOrderList,
|
getUserPatientOrderList,
|
||||||
|
getPatientCallLogList,
|
||||||
} from '@/api/userPatientProfile.js';
|
} from '@/api/userPatientProfile.js';
|
||||||
|
import CallLogDrawer from './CallLogDrawer.vue';
|
||||||
|
|
||||||
/** 抽屉左右滑提示只展示一次 */
|
/** 抽屉左右滑提示只展示一次 */
|
||||||
const SWIPE_TIP_STORAGE_KEY = 'user_patient_drawer_swipe_tip';
|
const SWIPE_TIP_STORAGE_KEY = 'user_patient_drawer_swipe_tip';
|
||||||
|
/** 拨号返回事件名:与 App.vue 中的 uni.$emit 配合使用 */
|
||||||
|
const CALLBACK_RETURNED_EVENT = 'patient:callbackReturned';
|
||||||
|
/** pendingCallback 存储键:写入拨号上下文,App.onShow 读取后广播 */
|
||||||
|
const PENDING_CALLBACK_KEY = 'pendingCallback';
|
||||||
|
/** 拨号返回判定时间窗:5 分钟内的 onAppShow 才认为是本次拨号的返回 */
|
||||||
|
const CALLBACK_RETURN_WINDOW_MS = 5 * 60 * 1000;
|
||||||
|
|
||||||
|
/** 回访标签 code -> 中文,用于列表展示 */
|
||||||
|
const TAG_LABEL_MAP = {
|
||||||
|
care: '关怀',
|
||||||
|
condition: '病情',
|
||||||
|
medication: '用药提醒',
|
||||||
|
review: '复诊提醒',
|
||||||
|
complaint: '投诉处理',
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UserPatientDetail',
|
name: 'UserPatientDetail',
|
||||||
|
components: { CallLogDrawer },
|
||||||
props: {
|
props: {
|
||||||
visible: { type: Boolean, default: false },
|
visible: { type: Boolean, default: false },
|
||||||
upId: { type: [Number, String], default: 0 },
|
upId: { type: [Number, String], default: 0 },
|
||||||
@@ -185,6 +253,7 @@ export default {
|
|||||||
swiperHeightPx: 320,
|
swiperHeightPx: 320,
|
||||||
tabs: [
|
tabs: [
|
||||||
{ key: 'info', label: '资料' },
|
{ key: 'info', label: '资料' },
|
||||||
|
{ key: 'calllog', label: '回访' },
|
||||||
{ key: 'register', label: '挂号' },
|
{ key: 'register', label: '挂号' },
|
||||||
{ key: 'prescription', label: '处方' },
|
{ key: 'prescription', label: '处方' },
|
||||||
{ key: 'order', label: '订单' },
|
{ key: 'order', label: '订单' },
|
||||||
@@ -197,6 +266,23 @@ export default {
|
|||||||
registerList: [],
|
registerList: [],
|
||||||
prescriptionList: [],
|
prescriptionList: [],
|
||||||
orderList: [],
|
orderList: [],
|
||||||
|
// 回访记录相关状态
|
||||||
|
callLogList: [],
|
||||||
|
callLogTotal: 0,
|
||||||
|
callLogLoading: false,
|
||||||
|
callLogDrawerVisible: false,
|
||||||
|
// 传给 CallLogDrawer 的预填字段(拨号后自动填 phone + call_at)
|
||||||
|
callLogPrefill: {},
|
||||||
|
/**
|
||||||
|
* 打开回访表单时同步置 true,拦截外层卸载触发的 beforeleave/clickoverlay
|
||||||
|
* 避免误 emit close 导致父页卸载本组件
|
||||||
|
*/
|
||||||
|
suppressPatientClose: false,
|
||||||
|
/**
|
||||||
|
* true 时卸载外层 page-container(尚未或不再挂 CallLogDrawer)
|
||||||
|
* 与 callLogDrawerVisible 配合两阶段互斥,保证页面上最多一个 page-container
|
||||||
|
*/
|
||||||
|
patientSheetHiddenForCallLog: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -231,6 +317,12 @@ export default {
|
|||||||
if (val && this.upId) {
|
if (val && this.upId) {
|
||||||
this.openAndLoad();
|
this.openAndLoad();
|
||||||
}
|
}
|
||||||
|
// 抽屉挂载时注册"拨号返回"监听;卸载时取消
|
||||||
|
if (val) {
|
||||||
|
uni.$on(CALLBACK_RETURNED_EVENT, this.handleCallbackReturned);
|
||||||
|
} else {
|
||||||
|
uni.$off(CALLBACK_RETURNED_EVENT, this.handleCallbackReturned);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/** 抽屉打开时切换不同就诊人,重新拉详情 */
|
/** 抽屉打开时切换不同就诊人,重新拉详情 */
|
||||||
@@ -240,11 +332,26 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
/** 兜底:组件销毁前移除事件监听,避免重复触发 */
|
||||||
|
beforeDestroy() {
|
||||||
|
uni.$off(CALLBACK_RETURNED_EVENT, this.handleCallbackReturned);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close() {
|
close() {
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 遮罩点击:为打开回访而卸载本抽屉时勿关
|
||||||
|
*/
|
||||||
|
onClickOverlay() {
|
||||||
|
if (this.suppressPatientClose || this.callLogDrawerVisible || this.patientSheetHiddenForCallLog) return;
|
||||||
|
this.close();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* page-container 即将关闭:为打开回访而卸载本抽屉时勿当成用户关闭
|
||||||
|
*/
|
||||||
onBeforeLeave() {
|
onBeforeLeave() {
|
||||||
|
if (this.suppressPatientClose || this.callLogDrawerVisible || this.patientSheetHiddenForCallLog) return;
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -257,9 +364,16 @@ export default {
|
|||||||
this.registerList = [];
|
this.registerList = [];
|
||||||
this.prescriptionList = [];
|
this.prescriptionList = [];
|
||||||
this.orderList = [];
|
this.orderList = [];
|
||||||
|
this.callLogList = [];
|
||||||
|
this.callLogTotal = 0;
|
||||||
|
this.callLogDrawerVisible = false;
|
||||||
|
this.callLogPrefill = {};
|
||||||
|
this.suppressPatientClose = false;
|
||||||
|
this.patientSheetHiddenForCallLog = false;
|
||||||
this.profile = { user: {}, patient: {} };
|
this.profile = { user: {}, patient: {} };
|
||||||
this.calcSwiperHeight();
|
this.calcSwiperHeight();
|
||||||
this.loadDetail();
|
this.loadDetail();
|
||||||
|
// 回访列表改为切到「回访」Tab 时懒加载,不再一进页就拉
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 抽屉内 swiper 高度:80vh − 头 − 资料卡 − Tab(保证横向滑动可用)
|
* 抽屉内 swiper 高度:80vh − 头 − 资料卡 − Tab(保证横向滑动可用)
|
||||||
@@ -280,7 +394,7 @@ export default {
|
|||||||
this.swiperHeightPx = 320;
|
this.swiperHeightPx = 320;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 按 Tab key 取对应列表(四页同时渲染) */
|
/** 按 Tab key 取对应列表(swiper 多页同时渲染时不能只用 activeTab) */
|
||||||
listForTab(key) {
|
listForTab(key) {
|
||||||
if (key === 'register') return this.registerList;
|
if (key === 'register') return this.registerList;
|
||||||
if (key === 'prescription') return this.prescriptionList;
|
if (key === 'prescription') return this.prescriptionList;
|
||||||
@@ -301,6 +415,8 @@ export default {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 回访:调起系统拨号;无号 toast,按钮始终显示
|
* 回访:调起系统拨号;无号 toast,按钮始终显示
|
||||||
|
* 同时把拨号上下文写入 storage,App.onShow 检测到返回时
|
||||||
|
* 通过 uni.$emit 广播事件,触发本组件自动打开回访表单抽屉
|
||||||
*/
|
*/
|
||||||
onCallbackCall() {
|
onCallbackCall() {
|
||||||
const phone = this.callbackPhone;
|
const phone = this.callbackPhone;
|
||||||
@@ -308,10 +424,113 @@ export default {
|
|||||||
uni.showToast({ title: '暂无手机号', icon: 'none' });
|
uni.showToast({ title: '暂无手机号', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
uni.setStorageSync(PENDING_CALLBACK_KEY, {
|
||||||
|
upId: Number(this.upId),
|
||||||
|
phone,
|
||||||
|
ts: Date.now(),
|
||||||
|
});
|
||||||
|
} catch (e) { /* ignore */ }
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({
|
||||||
phoneNumber: phone,
|
phoneNumber: phone,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* App.onShow 广播的"拨号返回"事件处理
|
||||||
|
* 校验是当前就诊人后,两阶段打开回访表单(先卸外层再挂表单)
|
||||||
|
*/
|
||||||
|
handleCallbackReturned(payload) {
|
||||||
|
if (!this.visible) return;
|
||||||
|
if (!payload || Number(payload.upId) !== Number(this.upId)) return;
|
||||||
|
this.suppressPatientClose = true;
|
||||||
|
this.callLogPrefill = {
|
||||||
|
phone: payload.phone || '',
|
||||||
|
call_at: Math.floor((payload.ts || Date.now()) / 1000),
|
||||||
|
};
|
||||||
|
this.beginOpenCallLogDrawer();
|
||||||
|
},
|
||||||
|
/** 手动点击"记录本次回访":两阶段打开,避免双 page-container */
|
||||||
|
openCallLogForm() {
|
||||||
|
this.suppressPatientClose = true;
|
||||||
|
this.callLogPrefill = {
|
||||||
|
phone: this.callbackPhone || '',
|
||||||
|
call_at: Math.floor(Date.now() / 1000),
|
||||||
|
};
|
||||||
|
this.beginOpenCallLogDrawer();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 两阶段打开回访表单:先卸外层 page-container,nextTick 后再挂 CallLogDrawer
|
||||||
|
* 微信同一页只能存在一个 page-container 实例
|
||||||
|
*/
|
||||||
|
beginOpenCallLogDrawer() {
|
||||||
|
this.patientSheetHiddenForCallLog = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.callLogDrawerVisible = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 关闭回访表单后恢复就诊人抽屉:先卸 CallLogDrawer,nextTick 再挂外层
|
||||||
|
*/
|
||||||
|
restorePatientSheetAfterCallLog() {
|
||||||
|
this.callLogDrawerVisible = false;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.patientSheetHiddenForCallLog = false;
|
||||||
|
this.suppressPatientClose = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** CallLogDrawer 通过 .sync 更新 visible */
|
||||||
|
onCallLogDrawerVisibleChange(val) {
|
||||||
|
if (val) {
|
||||||
|
this.callLogDrawerVisible = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.restorePatientSheetAfterCallLog();
|
||||||
|
},
|
||||||
|
/** 抽屉关闭 */
|
||||||
|
onCallLogDrawerClose() {
|
||||||
|
this.restorePatientSheetAfterCallLog();
|
||||||
|
},
|
||||||
|
/** 提交成功回调:刷新列表并切到「回访」Tab,方便看到刚写入的记录 */
|
||||||
|
onCallLogSuccess() {
|
||||||
|
this.loadCallLogList();
|
||||||
|
const idx = this.tabs.findIndex((t) => t.key === 'calllog');
|
||||||
|
if (idx >= 0) {
|
||||||
|
this.selectTab(idx);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 拉取就诊人回访记录列表 */
|
||||||
|
async loadCallLogList() {
|
||||||
|
if (!this.upId) return;
|
||||||
|
this.callLogLoading = true;
|
||||||
|
try {
|
||||||
|
const wrap = await getPatientCallLogList(this.upId);
|
||||||
|
const body = wrap && wrap.res ? wrap.res : null;
|
||||||
|
const list = (body && body.result && Array.isArray(body.result.items)) ? body.result.items : [];
|
||||||
|
// 预算每条记录的 result 浅色背景,避免模板 :style 调函数(小程序禁止)
|
||||||
|
this.callLogList = list.map((log) => Object.assign({}, log, {
|
||||||
|
result_bg: this.hexToRgba(log.result_color || '#6b7280', 0.12),
|
||||||
|
}));
|
||||||
|
this.callLogTotal = (body && body.result && Number(body.result.total)) || list.length;
|
||||||
|
} catch (e) {
|
||||||
|
this.callLogList = [];
|
||||||
|
this.callLogTotal = 0;
|
||||||
|
} finally {
|
||||||
|
this.callLogLoading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** hex -> rgba,用于结果标签浅色背景 */
|
||||||
|
hexToRgba(hex, alpha) {
|
||||||
|
const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex || '');
|
||||||
|
if (!m) return `rgba(106,205,187,${alpha})`;
|
||||||
|
const r = parseInt(m[1], 16);
|
||||||
|
const g = parseInt(m[2], 16);
|
||||||
|
const b = parseInt(m[3], 16);
|
||||||
|
return `rgba(${r},${g},${b},${alpha})`;
|
||||||
|
},
|
||||||
|
/** 模板渲染用:tag code 转中文(已废弃:后端列表直接返回 name/color 对象,保留兜底用) */
|
||||||
|
tagLabelOf(code) {
|
||||||
|
return TAG_LABEL_MAP[code] || code;
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 首次打开抽屉短暂提示可左右滑动
|
* 首次打开抽屉短暂提示可左右滑动
|
||||||
*/
|
*/
|
||||||
@@ -384,7 +603,9 @@ export default {
|
|||||||
this.tabIndex = idx;
|
this.tabIndex = idx;
|
||||||
}
|
}
|
||||||
if (key === 'info') return;
|
if (key === 'info') return;
|
||||||
if (key === 'register' && !this.registerList.length) {
|
if (key === 'calllog' && !this.callLogList.length) {
|
||||||
|
await this.loadCallLogList();
|
||||||
|
} else if (key === 'register' && !this.registerList.length) {
|
||||||
await this.loadRegisters();
|
await this.loadRegisters();
|
||||||
} else if (key === 'prescription' && !this.prescriptionList.length) {
|
} else if (key === 'prescription' && !this.prescriptionList.length) {
|
||||||
await this.loadPrescriptions();
|
await this.loadPrescriptions();
|
||||||
@@ -493,6 +714,13 @@ export default {
|
|||||||
background: #e8f5f2;
|
background: #e8f5f2;
|
||||||
}
|
}
|
||||||
.callback-btn-text { font-size: 24rpx; color: #1a9b88; font-weight: 500; }
|
.callback-btn-text { font-size: 24rpx; color: #1a9b88; font-weight: 500; }
|
||||||
|
/* 回访/记录按钮区 */
|
||||||
|
.patient-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
.p-sub { display: block; font-size: 22rpx; color: #6b7280; margin-top: 6rpx; }
|
.p-sub { display: block; font-size: 22rpx; color: #6b7280; margin-top: 6rpx; }
|
||||||
.tabs {
|
.tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -553,4 +781,87 @@ export default {
|
|||||||
.r-sub { display: block; font-size: 22rpx; color: #6b7280; margin-top: 6rpx; }
|
.r-sub { display: block; font-size: 22rpx; color: #6b7280; margin-top: 6rpx; }
|
||||||
.arrow { font-size: 36rpx; color: #d1d5db; line-height: 1; }
|
.arrow { font-size: 36rpx; color: #d1d5db; line-height: 1; }
|
||||||
.empty { text-align: center; color: #9ca3af; padding: 48rpx 0; font-size: 26rpx; }
|
.empty { text-align: center; color: #9ca3af; padding: 48rpx 0; font-size: 26rpx; }
|
||||||
|
/* "记录本次回访" link 按钮 */
|
||||||
|
.callback-link {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 8rpx 16rpx;
|
||||||
|
margin-left: 12rpx;
|
||||||
|
}
|
||||||
|
.callback-link-text {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #1a9b88;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
/* 回访记录卡片(Tab 内用 in-tab 去掉外边距,与 health-card 对齐) */
|
||||||
|
.call-log-card {
|
||||||
|
margin: 16rpx 24rpx 0;
|
||||||
|
padding: 20rpx 24rpx;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.call-log-card.in-tab {
|
||||||
|
margin: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.call-log-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
.call-log-head-title {
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
}
|
||||||
|
.call-log-head-count {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
.call-log-item {
|
||||||
|
padding: 16rpx 0;
|
||||||
|
border-bottom: 1rpx solid #f3f4f6;
|
||||||
|
}
|
||||||
|
.call-log-item:last-child { border-bottom: none; }
|
||||||
|
.call-log-item-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
.call-log-result-tag {
|
||||||
|
font-size: 20rpx;
|
||||||
|
padding: 2rpx 12rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
background: #e5e7eb;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
.call-log-result-tag.connected { background: #e8f5f2; color: #1a9b88; }
|
||||||
|
.call-log-result-tag.no_answer { background: #fef3c7; color: #b45309; }
|
||||||
|
.call-log-result-tag.hangup { background: #fee2e2; color: #b91c1c; }
|
||||||
|
.call-log-result-tag.invalid { background: #f3f4f6; color: #6b7280; }
|
||||||
|
.call-log-item-time {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
.call-log-tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8rpx;
|
||||||
|
margin: 4rpx 0;
|
||||||
|
}
|
||||||
|
.call-log-tag-text {
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #6acdbb;
|
||||||
|
}
|
||||||
|
.call-log-line {
|
||||||
|
display: block;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #374151;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.call-log-next { color: #1a9b88; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -14,22 +14,28 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="patient-block">
|
<view class="patient-block">
|
||||||
<view class="patient-head">
|
<view class="patient-head">
|
||||||
<view class="patient-head-left">
|
<view class="patient-head-left">
|
||||||
<text class="p-name">{{ profile.patient.name || '—' }}</text>
|
<text class="p-name">{{ profile.patient.name || '—' }}</text>
|
||||||
<text v-if="sexText !== '—'" class="sex-tag" :class="sexTagClass">{{ sexText }}</text>
|
<text v-if="sexText !== '—'" class="sex-tag" :class="sexTagClass">{{ sexText }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="patient-actions">
|
||||||
<!-- 回访:拨打就诊人/用户手机 -->
|
<!-- 回访:拨打就诊人/用户手机 -->
|
||||||
<view class="callback-btn" @click.stop="onCallbackCall">
|
<view class="callback-btn" @click.stop="onCallbackCall">
|
||||||
<text class="callback-btn-text">回访</text>
|
<text class="callback-btn-text">回访</text>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 记录本次回访:link 按钮 -->
|
||||||
|
<view class="callback-link" @click.stop="openCallLogForm">
|
||||||
|
<text class="callback-link-text">记录本次回访</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="p-sub">
|
</view>
|
||||||
{{ profile.patient.age || '—' }}岁
|
<text class="p-sub">
|
||||||
<template v-if="profile.patient.mobile"> · {{ profile.patient.mobile }}</template>
|
{{ profile.patient.age || '—' }}岁
|
||||||
</text>
|
<template v-if="profile.patient.mobile"> · {{ profile.patient.mobile }}</template>
|
||||||
<!-- 门店后端不返回身份证时不展示 -->
|
</text>
|
||||||
<text v-if="profile.patient.id_card" class="p-sub">身份证 {{ profile.patient.id_card }}</text>
|
<!-- 门店后端不返回身份证时不展示 -->
|
||||||
|
<text v-if="profile.patient.id_card" class="p-sub">身份证 {{ profile.patient.id_card }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- Tab:下划线选中态 -->
|
<!-- Tab:下划线选中态 -->
|
||||||
@@ -45,7 +51,7 @@
|
|||||||
<view v-if="tabIndex === idx" class="tab-bar" />
|
<view v-if="tabIndex === idx" class="tab-bar" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 四页左右滑:资料 / 挂号 / 处方 / 订单 -->
|
<!-- 五页左右滑:资料 / 回访 / 挂号 / 处方 / 订单 -->
|
||||||
<swiper
|
<swiper
|
||||||
class="tab-swiper"
|
class="tab-swiper"
|
||||||
:style="{ height: swiperHeightPx + 'px' }"
|
:style="{ height: swiperHeightPx + 'px' }"
|
||||||
@@ -53,7 +59,7 @@
|
|||||||
:duration="200"
|
:duration="200"
|
||||||
@change="onTabSwiperChange"
|
@change="onTabSwiperChange"
|
||||||
>
|
>
|
||||||
<swiper-item v-for="t in tabs" :key="'sw-' + t.key">
|
<swiper-item v-for="t in tabs" :key="t.key">
|
||||||
<scroll-view
|
<scroll-view
|
||||||
scroll-y
|
scroll-y
|
||||||
class="tab-scroll"
|
class="tab-scroll"
|
||||||
@@ -95,6 +101,37 @@
|
|||||||
</template>
|
</template>
|
||||||
<view v-else class="empty-inline">暂无健康问诊记录</view>
|
<view v-else class="empty-inline">暂无健康问诊记录</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 回访:历史回访记录列表(懒加载) -->
|
||||||
|
<view v-else-if="t.key === 'calllog'" class="call-log-card in-tab">
|
||||||
|
<view class="call-log-head">
|
||||||
|
<text class="call-log-head-title">回访记录</text>
|
||||||
|
<text v-if="callLogList.length" class="call-log-head-count">{{ callLogTotal }} 条</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="callLogLoading" class="empty-inline">加载中...</view>
|
||||||
|
<view v-else-if="!callLogList.length" class="empty-inline">暂无回访记录</view>
|
||||||
|
<view v-else>
|
||||||
|
<view v-for="log in callLogList" :key="log.id" class="call-log-item">
|
||||||
|
<view class="call-log-item-head">
|
||||||
|
<text
|
||||||
|
class="call-log-result-tag"
|
||||||
|
:style="{ color: log.result_color || '#6b7280', background: log.result_bg, borderColor: log.result_color || '#e5e7eb' }"
|
||||||
|
>{{ log.result_text }}</text>
|
||||||
|
<text class="call-log-item-time">{{ log.call_at }}</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="log.tags.length" class="call-log-tags">
|
||||||
|
<text
|
||||||
|
v-for="tg in log.tags"
|
||||||
|
:key="tg.value"
|
||||||
|
class="call-log-tag-text"
|
||||||
|
:style="{ color: tg.color || '#6b7280' }"
|
||||||
|
>#{{ tg.name }}</text>
|
||||||
|
</view>
|
||||||
|
<text v-if="log.conclusion" class="call-log-line">结论:{{ log.conclusion }}</text>
|
||||||
|
<text v-if="log.remark" class="call-log-line">备注:{{ log.remark }}</text>
|
||||||
|
<text v-if="log.next_at" class="call-log-line call-log-next">下次回访:{{ log.next_at_text }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<!-- 挂号 / 处方 / 订单列表 -->
|
<!-- 挂号 / 处方 / 订单列表 -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<view v-if="tabLoading && activeTab === t.key" class="empty">加载中...</view>
|
<view v-if="tabLoading && activeTab === t.key" class="empty">加载中...</view>
|
||||||
@@ -102,7 +139,7 @@
|
|||||||
<view v-if="!listForTab(t.key).length" class="empty">暂无记录</view>
|
<view v-if="!listForTab(t.key).length" class="empty">暂无记录</view>
|
||||||
<view
|
<view
|
||||||
v-for="item in listForTab(t.key)"
|
v-for="item in listForTab(t.key)"
|
||||||
:key="t.key + '-' + item.id"
|
:key="item.id"
|
||||||
class="record-card"
|
class="record-card"
|
||||||
@click="onRecordClick(item, t.key)"
|
@click="onRecordClick(item, t.key)"
|
||||||
>
|
>
|
||||||
@@ -135,28 +172,52 @@
|
|||||||
</business-page-layout>
|
</business-page-layout>
|
||||||
<!-- page-container 抽屉挂在页面根级 -->
|
<!-- page-container 抽屉挂在页面根级 -->
|
||||||
<prescription-detail-popup ref="prescriptionPopup" />
|
<prescription-detail-popup ref="prescriptionPopup" />
|
||||||
|
<!-- 回访记录表单抽屉 -->
|
||||||
|
<CallLogDrawer
|
||||||
|
v-if="callLogDrawerVisible"
|
||||||
|
:visible="callLogDrawerVisible"
|
||||||
|
:up-id="upId"
|
||||||
|
:prefill="callLogPrefill"
|
||||||
|
@update:visible="onCallLogDrawerVisibleChange"
|
||||||
|
@close="onCallLogDrawerClose"
|
||||||
|
@success="onCallLogSuccess"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/**
|
/**
|
||||||
* 就诊人详情:资料(健康问诊)+ 挂号/处方/订单
|
* 就诊人详情:资料(健康问诊)+ 回访 + 挂号/处方/订单
|
||||||
* 顶部资料卡固定,下方四 Tab 支持点击与左右滑动切换(懒加载列表)
|
* 顶部资料卡固定,下方五 Tab 支持点击与左右滑动切换(懒加载列表)
|
||||||
*/
|
*/
|
||||||
import BusinessPageLayout from '@/subPackages/sub_business_shared/components/business-page-layout.vue';
|
import BusinessPageLayout from '@/subPackages/sub_business_shared/components/business-page-layout.vue';
|
||||||
import PrescriptionDetailPopup from '@/subPackages/sub_business_shared/order/components/PrescriptionDetailPopup.vue';
|
import PrescriptionDetailPopup from '@/subPackages/sub_business_shared/order/components/PrescriptionDetailPopup.vue';
|
||||||
|
import CallLogDrawer from '@/subPackages/sub_business_shared/components/CallLogDrawer.vue';
|
||||||
import {
|
import {
|
||||||
getUserPatientDetail,
|
getUserPatientDetail,
|
||||||
getUserPatientRegisterList,
|
getUserPatientRegisterList,
|
||||||
getUserPatientPrescriptionList,
|
getUserPatientPrescriptionList,
|
||||||
getUserPatientOrderList,
|
getUserPatientOrderList,
|
||||||
|
getPatientCallLogList,
|
||||||
} from '@/api/userPatientProfile.js';
|
} from '@/api/userPatientProfile.js';
|
||||||
|
|
||||||
/** 就诊人详情左右滑提示只展示一次 */
|
/** 就诊人详情左右滑提示只展示一次 */
|
||||||
const SWIPE_TIP_STORAGE_KEY = 'user_patient_detail_swipe_tip';
|
const SWIPE_TIP_STORAGE_KEY = 'user_patient_detail_swipe_tip';
|
||||||
|
/** 拨号返回事件名(与 App.vue 内的 emit 配合) */
|
||||||
|
const CALLBACK_RETURNED_EVENT = 'patient:callbackReturned';
|
||||||
|
/** pendingCallback 存储键:记录拨号上下文 */
|
||||||
|
const PENDING_CALLBACK_KEY = 'pendingCallback';
|
||||||
|
/** 回访标签 code -> 中文 */
|
||||||
|
const TAG_LABEL_MAP = {
|
||||||
|
care: '关怀',
|
||||||
|
condition: '病情',
|
||||||
|
medication: '用药提醒',
|
||||||
|
review: '复诊提醒',
|
||||||
|
complaint: '投诉处理',
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { BusinessPageLayout, PrescriptionDetailPopup },
|
components: { BusinessPageLayout, PrescriptionDetailPopup, CallLogDrawer },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
upId: 0,
|
upId: 0,
|
||||||
@@ -169,6 +230,7 @@ export default {
|
|||||||
swiperHeightPx: 400,
|
swiperHeightPx: 400,
|
||||||
tabs: [
|
tabs: [
|
||||||
{ key: 'info', label: '资料' },
|
{ key: 'info', label: '资料' },
|
||||||
|
{ key: 'calllog', label: '回访' },
|
||||||
{ key: 'register', label: '挂号' },
|
{ key: 'register', label: '挂号' },
|
||||||
{ key: 'prescription', label: '处方' },
|
{ key: 'prescription', label: '处方' },
|
||||||
{ key: 'order', label: '订单' },
|
{ key: 'order', label: '订单' },
|
||||||
@@ -178,6 +240,12 @@ export default {
|
|||||||
registerList: [],
|
registerList: [],
|
||||||
prescriptionList: [],
|
prescriptionList: [],
|
||||||
orderList: [],
|
orderList: [],
|
||||||
|
// 回访记录相关状态
|
||||||
|
callLogList: [],
|
||||||
|
callLogTotal: 0,
|
||||||
|
callLogLoading: false,
|
||||||
|
callLogDrawerVisible: false,
|
||||||
|
callLogPrefill: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -213,8 +281,11 @@ export default {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.patientName = (options && options.name) || '';
|
this.patientName = (options && options.name) || '';
|
||||||
}
|
}
|
||||||
|
// 监听 App.onShow 广播的"拨号返回"事件
|
||||||
|
uni.$on(CALLBACK_RETURNED_EVENT, this.handleCallbackReturned);
|
||||||
if (this.upId) {
|
if (this.upId) {
|
||||||
this.loadDetail();
|
this.loadDetail();
|
||||||
|
// 回访列表改为切到「回访」Tab 时懒加载
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onReady() {
|
onReady() {
|
||||||
@@ -226,6 +297,7 @@ export default {
|
|||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
this.closePrescriptionPopup();
|
this.closePrescriptionPopup();
|
||||||
|
uni.$off(CALLBACK_RETURNED_EVENT, this.handleCallbackReturned);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
@@ -247,7 +319,7 @@ export default {
|
|||||||
this.swiperHeightPx = 400;
|
this.swiperHeightPx = 400;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 按 Tab key 取对应列表(swiper 四页同时渲染时不能只用 activeTab) */
|
/** 按 Tab key 取对应列表(swiper 多页同时渲染时不能只用 activeTab) */
|
||||||
listForTab(key) {
|
listForTab(key) {
|
||||||
if (key === 'register') return this.registerList;
|
if (key === 'register') return this.registerList;
|
||||||
if (key === 'prescription') return this.prescriptionList;
|
if (key === 'prescription') return this.prescriptionList;
|
||||||
@@ -264,6 +336,8 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 回访:调起系统拨号盘拨打 callbackPhone
|
* 回访:调起系统拨号盘拨打 callbackPhone
|
||||||
* 无号时 toast,不隐藏按钮以免布局跳动
|
* 无号时 toast,不隐藏按钮以免布局跳动
|
||||||
|
* 同时记录 pendingCallback,App.onShow 检测到回到小程序时
|
||||||
|
* 通过 uni.$emit 触发本页自动打开回访表单抽屉
|
||||||
*/
|
*/
|
||||||
onCallbackCall() {
|
onCallbackCall() {
|
||||||
const phone = this.callbackPhone;
|
const phone = this.callbackPhone;
|
||||||
@@ -271,10 +345,83 @@ export default {
|
|||||||
uni.showToast({ title: '暂无手机号', icon: 'none' });
|
uni.showToast({ title: '暂无手机号', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
uni.setStorageSync(PENDING_CALLBACK_KEY, {
|
||||||
|
upId: Number(this.upId),
|
||||||
|
phone,
|
||||||
|
ts: Date.now(),
|
||||||
|
});
|
||||||
|
} catch (e) { /* ignore */ }
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({
|
||||||
phoneNumber: phone,
|
phoneNumber: phone,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** App.onShow 广播"拨号返回"事件 */
|
||||||
|
handleCallbackReturned(payload) {
|
||||||
|
if (!payload || Number(payload.upId) !== Number(this.upId)) return;
|
||||||
|
this.callLogPrefill = {
|
||||||
|
phone: payload.phone || '',
|
||||||
|
call_at: Math.floor((payload.ts || Date.now()) / 1000),
|
||||||
|
};
|
||||||
|
this.callLogDrawerVisible = true;
|
||||||
|
},
|
||||||
|
/** 手动点击"记录本次回访" */
|
||||||
|
openCallLogForm() {
|
||||||
|
this.callLogPrefill = {
|
||||||
|
phone: this.callbackPhone || '',
|
||||||
|
call_at: Math.floor(Date.now() / 1000),
|
||||||
|
};
|
||||||
|
this.callLogDrawerVisible = true;
|
||||||
|
},
|
||||||
|
/** CallLogDrawer visible 同步 */
|
||||||
|
onCallLogDrawerVisibleChange(val) {
|
||||||
|
this.callLogDrawerVisible = !!val;
|
||||||
|
},
|
||||||
|
/** 抽屉关闭 */
|
||||||
|
onCallLogDrawerClose() {
|
||||||
|
this.callLogDrawerVisible = false;
|
||||||
|
},
|
||||||
|
/** 提交成功:刷新列表 */
|
||||||
|
onCallLogSuccess() {
|
||||||
|
this.loadCallLogList();
|
||||||
|
const idx = this.tabs.findIndex((t) => t.key === 'calllog');
|
||||||
|
if (idx >= 0) {
|
||||||
|
this.selectTab(idx);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 拉取回访记录列表 */
|
||||||
|
async loadCallLogList() {
|
||||||
|
if (!this.upId) return;
|
||||||
|
this.callLogLoading = true;
|
||||||
|
try {
|
||||||
|
const wrap = await getPatientCallLogList(this.upId);
|
||||||
|
const body = wrap && wrap.res ? wrap.res : null;
|
||||||
|
const list = (body && body.result && Array.isArray(body.result.items)) ? body.result.items : [];
|
||||||
|
// 预算每条记录的结果标签浅色背景,避免模板 :style 调函数(小程序禁止)
|
||||||
|
this.callLogList = list.map((log) => Object.assign({}, log, {
|
||||||
|
result_bg: this.hexToRgba(log.result_color || '#6b7280', 0.12),
|
||||||
|
}));
|
||||||
|
this.callLogTotal = (body && body.result && Number(body.result.total)) || list.length;
|
||||||
|
} catch (e) {
|
||||||
|
this.callLogList = [];
|
||||||
|
this.callLogTotal = 0;
|
||||||
|
} finally {
|
||||||
|
this.callLogLoading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** hex -> rgba,用于结果标签浅色背景 */
|
||||||
|
hexToRgba(hex, alpha) {
|
||||||
|
const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex || '');
|
||||||
|
if (!m) return `rgba(106,205,187,${alpha})`;
|
||||||
|
const r = parseInt(m[1], 16);
|
||||||
|
const g = parseInt(m[2], 16);
|
||||||
|
const b = parseInt(m[3], 16);
|
||||||
|
return `rgba(${r},${g},${b},${alpha})`;
|
||||||
|
},
|
||||||
|
/** tag code -> 中文 */
|
||||||
|
tagLabelOf(code) {
|
||||||
|
return TAG_LABEL_MAP[code] || code;
|
||||||
|
},
|
||||||
/** 既往/过敏/家族:0 无,否则展示 history */
|
/** 既往/过敏/家族:0 无,否则展示 history */
|
||||||
historyText(status, history) {
|
historyText(status, history) {
|
||||||
if (Number(status) === 0) return '无';
|
if (Number(status) === 0) return '无';
|
||||||
@@ -362,7 +509,9 @@ export default {
|
|||||||
this.tabIndex = idx;
|
this.tabIndex = idx;
|
||||||
}
|
}
|
||||||
if (key === 'info') return;
|
if (key === 'info') return;
|
||||||
if (key === 'register' && !this.registerList.length) {
|
if (key === 'calllog' && !this.callLogList.length) {
|
||||||
|
await this.loadCallLogList();
|
||||||
|
} else if (key === 'register' && !this.registerList.length) {
|
||||||
await this.loadRegisters();
|
await this.loadRegisters();
|
||||||
} else if (key === 'prescription' && !this.prescriptionList.length) {
|
} else if (key === 'prescription' && !this.prescriptionList.length) {
|
||||||
await this.loadPrescriptions();
|
await this.loadPrescriptions();
|
||||||
@@ -512,4 +661,91 @@ export default {
|
|||||||
.r-sub { display: block; font-size: 22rpx; color: #6b7280; margin-top: 6rpx; }
|
.r-sub { display: block; font-size: 22rpx; color: #6b7280; margin-top: 6rpx; }
|
||||||
.arrow { font-size: 36rpx; color: #d1d5db; line-height: 1; padding-left: 4rpx; }
|
.arrow { font-size: 36rpx; color: #d1d5db; line-height: 1; padding-left: 4rpx; }
|
||||||
.empty { text-align: center; color: #9ca3af; padding: 80rpx 0; font-size: 28rpx; }
|
.empty { text-align: center; color: #9ca3af; padding: 80rpx 0; font-size: 28rpx; }
|
||||||
|
/* 回访/记录按钮区 */
|
||||||
|
.patient-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.callback-link {
|
||||||
|
padding: 8rpx 12rpx;
|
||||||
|
}
|
||||||
|
.callback-link-text {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #1a9b88;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
/* 回访记录卡片(Tab 内用 in-tab 去掉外边距,与 health-card 对齐) */
|
||||||
|
.call-log-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 20rpx 24rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
.call-log-card.in-tab {
|
||||||
|
margin: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.call-log-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
.call-log-head-title {
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
}
|
||||||
|
.call-log-head-count {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
.call-log-item {
|
||||||
|
padding: 16rpx 0;
|
||||||
|
border-bottom: 1rpx solid #f3f4f6;
|
||||||
|
}
|
||||||
|
.call-log-item:last-child { border-bottom: none; }
|
||||||
|
.call-log-item-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
.call-log-result-tag {
|
||||||
|
font-size: 20rpx;
|
||||||
|
padding: 2rpx 12rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
background: #e5e7eb;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
.call-log-result-tag.connected { background: #e8f5f2; color: #1a9b88; }
|
||||||
|
.call-log-result-tag.no_answer { background: #fef3c7; color: #b45309; }
|
||||||
|
.call-log-result-tag.hangup { background: #fee2e2; color: #b91c1c; }
|
||||||
|
.call-log-result-tag.invalid { background: #f3f4f6; color: #6b7280; }
|
||||||
|
.call-log-item-time {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
.call-log-tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8rpx;
|
||||||
|
margin: 4rpx 0;
|
||||||
|
}
|
||||||
|
.call-log-tag-text {
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #6acdbb;
|
||||||
|
}
|
||||||
|
.call-log-line {
|
||||||
|
display: block;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #374151;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.call-log-next { color: #1a9b88; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -259,19 +259,24 @@ export function mapOrderProductItem(p, prescriptionType) {
|
|||||||
? '*' + ((p.number != null ? p.number : 0) * dosage)
|
? '*' + ((p.number != null ? p.number : 0) * dosage)
|
||||||
: '×' + (p.number != null ? p.number : 0)
|
: '×' + (p.number != null ? p.number : 0)
|
||||||
const isTcm = prescriptionType === 1
|
const isTcm = prescriptionType === 1
|
||||||
|
const unitName =
|
||||||
|
(drug.unit && drug.unit.name) ||
|
||||||
|
(p.unit && p.unit.name) ||
|
||||||
|
p.unit_name ||
|
||||||
|
'g'
|
||||||
return {
|
return {
|
||||||
id: p.id,
|
id: p.id,
|
||||||
drugName: p.drug_name || drug.drug_name || '药品',
|
drugName: p.drug_name || drug.drug_name || '药品',
|
||||||
drugNumber: drug.drug_number || '',
|
drugNumber: drug.drug_number || '',
|
||||||
imageUrl: resolveDrugImage(p.drug_image || drug.image),
|
imageUrl: resolveDrugImage(p.drug_image || drug.image),
|
||||||
specification: drug.specification || (isTcm ? 'g' : '暂无'),
|
specification: drug.specification || (isTcm ? unitName : '暂无'),
|
||||||
manufacturer,
|
manufacturer,
|
||||||
qty,
|
qty,
|
||||||
price: isTcm
|
price: isTcm
|
||||||
? (p.price != null && p.price !== '' ? p.price + ' 元/g' : '—')
|
? (p.price != null && p.price !== '' ? p.price + ' 元/' + unitName : '—')
|
||||||
: formatMoney(p.price),
|
: formatMoney(p.price),
|
||||||
buyPrice: p.buy_price != null && p.buy_price !== ''
|
buyPrice: p.buy_price != null && p.buy_price !== ''
|
||||||
? p.buy_price + ' 元/g'
|
? p.buy_price + ' 元/' + unitName
|
||||||
: '—',
|
: '—',
|
||||||
isTcm,
|
isTcm,
|
||||||
}
|
}
|
||||||
@@ -348,9 +353,13 @@ export function mapPrescriptionDetailView(item) {
|
|||||||
const name = d.name || d.drug_name || '—'
|
const name = d.name || d.drug_name || '—'
|
||||||
const num = d.number != null ? d.number : ''
|
const num = d.number != null ? d.number : ''
|
||||||
const way = (d.use_way && d.use_way.name) || d.useWay || '煎服'
|
const way = (d.use_way && d.use_way.name) || d.useWay || '煎服'
|
||||||
|
const unit =
|
||||||
|
(d.unit && d.unit.name) ||
|
||||||
|
(d.use_unit && d.use_unit.name) ||
|
||||||
|
'g'
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
qty: num ? num + ' /g' : '',
|
qty: num !== '' ? num + ' /' + unit : '',
|
||||||
usage: way,
|
usage: way,
|
||||||
specification: d.specification || '',
|
specification: d.specification || '',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,11 @@ export function transferDrugToChineseRow(drug, prescriptionType) {
|
|||||||
instruction: drug.instruction || '',
|
instruction: drug.instruction || '',
|
||||||
type: drug.type != null ? drug.type : pt,
|
type: drug.type != null ? drug.type : pt,
|
||||||
select_number: drug.select_number != null ? Number(drug.select_number) : drug.number != null ? Number(drug.number) : 1,
|
select_number: drug.select_number != null ? Number(drug.select_number) : drug.number != null ? Number(drug.number) : 1,
|
||||||
specification: drug.specification || ''
|
specification: drug.specification || '',
|
||||||
|
// 带上真实单位,避免导入后标签云仍显示默认 g
|
||||||
|
unit_id: drug.unit_id || (drug.unit && drug.unit.id) || 0,
|
||||||
|
unit: drug.unit || null,
|
||||||
|
way_id: drug.way_id || 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
:data-index="index"
|
:data-index="index"
|
||||||
:data-quantity="qty"
|
:data-quantity="qty"
|
||||||
>
|
>
|
||||||
快捷 {{ qty }}g
|
快捷 {{ qty }}{{ getUnitName(item) }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -522,17 +522,54 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单位名称(中药抽屉内统一按克展示)
|
* 获取单位名称:优先接口返回的 unit,再回退 g
|
||||||
|
* @param {Object} item 选药列表项
|
||||||
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getUnitName() {
|
getUnitName(item) {
|
||||||
return 'g';
|
if (!item) return 'g';
|
||||||
|
const unit =
|
||||||
|
(item.unit && item.unit.name) ||
|
||||||
|
(item.drug && item.drug.unit && item.drug.unit.name) ||
|
||||||
|
'';
|
||||||
|
return unit || 'g';
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取规格(中药抽屉内统一按克展示)
|
* 获取规格文案:有规格用规格,否则用真实单位名
|
||||||
|
* @param {Object} item 选药列表项
|
||||||
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getSpecification() {
|
getSpecification(item) {
|
||||||
return 'g';
|
if (!item) return 'g';
|
||||||
|
const spec =
|
||||||
|
(item.specification) ||
|
||||||
|
(item.drug && item.drug.specification) ||
|
||||||
|
'';
|
||||||
|
if (spec) return spec;
|
||||||
|
return this.getUnitName(item);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从列表项解析单位对象与 unit_id,供写入处方行
|
||||||
|
* @param {Object} drug
|
||||||
|
* @returns {{ unit: Object|null, unit_id: number }}
|
||||||
|
*/
|
||||||
|
resolveDrugUnit(drug) {
|
||||||
|
if (!drug) return { unit: null, unit_id: 0 };
|
||||||
|
const unitObj =
|
||||||
|
drug.unit ||
|
||||||
|
(drug.drug && drug.drug.unit) ||
|
||||||
|
null;
|
||||||
|
const unitId =
|
||||||
|
(unitObj && unitObj.id) ||
|
||||||
|
drug.unit_id ||
|
||||||
|
(drug.drug && drug.drug.unit_id) ||
|
||||||
|
0;
|
||||||
|
return {
|
||||||
|
unit: unitObj || (unitId ? { id: unitId, name: 'g' } : null),
|
||||||
|
unit_id: Number(unitId) || 0,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -595,6 +632,8 @@ export default {
|
|||||||
drug._way_id ?? (drug.drug && drug.drug.way_id) ?? drug.way_id ?? 0
|
drug._way_id ?? (drug.drug && drug.drug.way_id) ?? drug.way_id ?? 0
|
||||||
);
|
);
|
||||||
const wayHit = (this.drugUseWayList || []).find((w) => Number(w.id) === wayId);
|
const wayHit = (this.drugUseWayList || []).find((w) => Number(w.id) === wayId);
|
||||||
|
// 写入真实单位,保证父页标签云与提交后展示一致
|
||||||
|
const { unit, unit_id: unitId } = this.resolveDrugUnit(drug);
|
||||||
return {
|
return {
|
||||||
index_id: indexId,
|
index_id: indexId,
|
||||||
id: entityId,
|
id: entityId,
|
||||||
@@ -604,6 +643,8 @@ export default {
|
|||||||
buy_price: drug.buy_price ?? 0,
|
buy_price: drug.buy_price ?? 0,
|
||||||
way_id: wayId || 0,
|
way_id: wayId || 0,
|
||||||
use_ways: wayHit || null,
|
use_ways: wayHit || null,
|
||||||
|
unit,
|
||||||
|
unit_id: unitId,
|
||||||
select_number: 1,
|
select_number: 1,
|
||||||
_wxKey: wxKeyBase ? `sch-${wxKeyBase}` : `sch${this.selectedDrugs.length}`,
|
_wxKey: wxKeyBase ? `sch-${wxKeyBase}` : `sch${this.selectedDrugs.length}`,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ export function checkDev(key = '') {
|
|||||||
case 'open-im':
|
case 'open-im':
|
||||||
// return false;
|
// return false;
|
||||||
return true;
|
return true;
|
||||||
|
case 'test':
|
||||||
|
return false;
|
||||||
|
// return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user