1. 修复了一些交互bug

This commit is contained in:
李琦
2026-05-15 11:18:47 +08:00
parent eacca1bf7b
commit 69195e639b
11 changed files with 135 additions and 29 deletions

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>
@@ -334,7 +334,6 @@ export default {
handleAddNew() {
const initialCategory =
this.prescriptionType === 1 ? 1 : this.prescriptionType === 2 ? 2 : 3;
uni.setStorageSync('add', true);
this.handleClose();
uni.navigateTo({
url: `/subPackages/sub_workbench/prescription_v2/index?save_common=1&initial_category=${initialCategory}`

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>

View File

@@ -5,7 +5,7 @@
:closeable="true"
@close="handleClose"
:safe-area-inset-bottom="true"
:mask-close-able="false"
:mask-close-able="true"
z-index="10078"
height="80%"
>

View File

@@ -1,13 +1,16 @@
<template>
<view class="safe-area-inset-bottom page-bg">
<!-- #ifdef MP-WEIXIN -->
<page-container
:show="pageBackGuardShow"
:overlay="false"
@leave="onPageBackGuardLeave"
/>
<!-- #endif -->
<!-- 导航栏 -->
<u-navbar class="navbar" :is-back="true" :title="navbarTitle" :custom-back="handleCustomBack" title-color="#000" background="{ background: '#fff' }">
</u-navbar>
<view v-if="registerModeHint" class="register-mode-hint mx-32 m-t-12">
<text class="register-mode-hint__text">{{ registerModeHint }}</text>
</view>
<!-- 处方类型Tab切换 -->
<view class="tabs flex p-32 flex-ali-center flex-jus-sp shadow-sm" style="overflow-x: auto; position: relative; z-index: 10;">
<u-button
@@ -28,6 +31,10 @@
</u-button>
</view>
<view v-if="registerModeHint" class="register-mode-hint mx-32 m-t-12">
<text class="register-mode-hint__text">{{ registerModeHint }}</text>
</view>
<!-- 诊断输入区域 -->
<view class="top white p-32 flex-col m-t-16 radius-12 mx-32">
<view class="top_title flex-row flex-ali-center">
@@ -219,7 +226,11 @@
</view>
<view class="tcm-tag-cloud">
<view class="tcm-tag" v-for="(it) in currentDrugs" :key="it.id">
<view
class="tcm-tag"
v-for="(it, tcmIndex) in currentDrugs"
:key="it.id || it.index_id || tcmIndex"
@longpress.stop="onTcmTagLongPress(it, tcmIndex)">
<text class="tcm-name">{{it.drug_name || it.name}}</text>
<text class="tcm-weight">{{String(it.number)}}{{it.unit ? it.unit.name : 'g'}}</text>
</view>
@@ -414,6 +425,7 @@
<ChineseMedicineModal
v-model="showChineseMedicineModal"
:currentDrugs="currentDrugs"
:initial-search-key="chineseModalInitialKeyword"
@select="handleSelectChineseDrug"
/>
@@ -436,6 +448,7 @@
<u-modal
v-model="showSaveCommonPrescriptionModal"
:show-cancel-button="true"
:mask-close-able="true"
title="保存常用方"
@confirm="handleConfirmSaveCommonPrescription"
@cancel="showSaveCommonPrescriptionModal = false">
@@ -484,6 +497,19 @@ import TraditionalTermPickerModal from './components/modals/TraditionalTermPicke
const PENDING_RX_FROM_CHAT = 'xk_pending_rx_from_chat';
/** 与 closeTopOverlayIfAny 一致:任意为 true 时启用微信小程序 page-container 返回拦截 */
const PRESCRIPTION_OVERLAY_KEYS = [
'showWesternUsageModal',
'showTcmPicker',
'showWesternMedicineModal',
'showChineseMedicineModal',
'showSimpleProductModal',
'showCommonPrescriptionModal',
'showDiagnosisModal',
'showDoctorOrderModal',
'showSaveCommonPrescriptionModal'
];
export default {
name: 'PrescriptionV2',
components: {
@@ -605,7 +631,9 @@ export default {
scrollStyle: {
height: 'calc(100vh - 600rpx)',
marginBottom: '200rpx'
}
},
/** 微信小程序 page-container有抽屉/弹层时为 true拦截侧滑等返回 */
pageBackGuardShow: false
};
},
computed: {
@@ -680,18 +708,32 @@ export default {
if (this.tcmPickerField === 'method') return this.onlineTcmMethodId;
if (this.tcmPickerField === 'syndrome') return this.onlineTcmSyndromeId;
return null;
},
hasPrescriptionOverlay() {
for (let i = 0; i < PRESCRIPTION_OVERLAY_KEYS.length; i++) {
if (this[PRESCRIPTION_OVERLAY_KEYS[i]]) return true;
}
return false;
}
},
watch: {
showWesternMedicineModal(val) {
if (!val) this.westernModalInitialKeyword = '';
}
},
// #ifdef MP-WEIXIN
hasPrescriptionOverlay(val) {
this.pageBackGuardShow = !!val;
},
// #endif
},
onLoad(options) {
this.registerId = options.register_id || '';
this.patientId = options.patient_id || '';
this.pendingReusePrescriptionId = options.reuse_prescription_id ? String(options.reuse_prescription_id) : '';
this.isCommonPrescription = options.save_common === '1' || !!uni.getStorageSync('add');
this.isCommonPrescription = String(options.save_common) === '1';
if (!this.isCommonPrescription) {
uni.removeStorageSync('add');
}
if (options.initial_category !== undefined && options.initial_category !== '') {
const n = parseInt(options.initial_category, 10);
if (!Number.isNaN(n)) this._presetActiveCategory = n;
@@ -700,8 +742,16 @@ export default {
},
async onShow() {
this.loadCurrentCategoryDrugs();
if (this.activeCategory === 1 && this.chineseConfig.ruleType === 2) {
await this.hydrateChineseProcessRuleListsFromConfig();
}
if (this.activeCategory === 1) await this.checkAndShowTransferTip();
},
onUnload() {
if (this.isCommonPrescription) {
uni.removeStorageSync('add');
}
},
methods: {
async initializePageData() {
try {
@@ -711,6 +761,9 @@ export default {
await this.loadBasicConfigData();
await this.loadRegisterStoreInfo();
this.loadCurrentCategoryDrugs();
if (this.activeCategory === 1 && this.chineseConfig.ruleType === 2) {
await this.hydrateChineseProcessRuleListsFromConfig();
}
await this.maybeApplyReusePrescription();
if (this.activeCategory === 1) await this.checkAndShowTransferTip();
this.applyPendingExperienceDrugFromChat();
@@ -767,6 +820,21 @@ export default {
this.onlineTcmSyndromeId = null;
}
},
/**
* 从 chineseConfig 中的 ID 拉取委托调剂三级列表(本地缓存只存 ID不存列表
*/
async hydrateChineseProcessRuleListsFromConfig() {
if (this.activeCategory !== 1 || this.chineseConfig.ruleType !== 2) return;
if (!this.processRuleList || this.processRuleList.length === 0) {
await this.loadProcessRuleList(0, 0);
}
if (this.chineseConfig.processRuleId) {
await this.loadProcessRuleList(this.chineseConfig.processRuleId, 0);
}
if (this.chineseConfig.childProcessRuleId) {
await this.loadProcessRuleList(0, this.chineseConfig.childProcessRuleId);
}
},
saveToLocalStorage() {
const data = {
drugs: this.currentDrugs,
@@ -1384,9 +1452,7 @@ export default {
childProcessRuleId: rep0.child_process_rule_id && Number(rep0.child_process_rule_id) > 0 ? rep0.child_process_rule_id : null,
processRuleNoteId: rep0.process_rule_note_id && Number(rep0.process_rule_note_id) > 0 ? rep0.process_rule_note_id : null
};
if (ruleType === 2 && (!this.processRuleList || this.processRuleList.length === 0)) await this.loadProcessRuleList(0, 0);
if (this.chineseConfig.processRuleId) await this.loadProcessRuleList(this.chineseConfig.processRuleId, 0);
if (this.chineseConfig.childProcessRuleId) await this.loadProcessRuleList(0, this.chineseConfig.childProcessRuleId);
if (ruleType === 2) await this.hydrateChineseProcessRuleListsFromConfig();
} else {
const mapped = [];
for (const recipe of repiceList) {
@@ -1599,7 +1665,7 @@ export default {
if (transferId) {
uni.showModal({
title: '转诊提示', content: '该处方已触发转诊流程,转诊消息已发送给委托诊所的在线问诊医生。', showCancel: false, confirmText: '确定',
success: () => { this.clearPrescriptionData(); PrescriptionStorage.clearAllPrescriptionData(this.registerId); setTimeout(() => { uni.navigateBack(); }, 500); }
success: () => { this.clearPrescriptionData(); PrescriptionStorage.clearAllPrescriptionData(this.registerId); this.safeNavigateBack(500); }
});
return;
}
@@ -1614,7 +1680,7 @@ export default {
}
this.clearPrescriptionData();
PrescriptionStorage.clearAllPrescriptionData(this.registerId);
setTimeout(() => { uni.navigateBack(); }, 1500);
this.safeNavigateBack(1500);
} else {
this.$toast(res.msg || res.message || '发送失败');
}
@@ -1683,10 +1749,51 @@ export default {
}
this.$toast('保存成功');
this.showSaveCommonPrescriptionModal = false; this.commonPrescriptionName = '';
if (this.isCommonPrescription) { uni.removeStorageSync('add'); setTimeout(() => uni.navigateBack(), 400); }
if (this.isCommonPrescription) { uni.removeStorageSync('add'); this.safeNavigateBack(400); }
} catch (error) { console.error('保存常用方失败:', error); this.$toast('保存常用方失败,请重试'); }
},
handleCustomBack() { uni.navigateBack(); }
/** 若有弹层打开则关闭第一个并返回 true用于导航返回 / 微信 page-container leave 先关抽屉) */
closeTopOverlayIfAny() {
for (let i = 0; i < PRESCRIPTION_OVERLAY_KEYS.length; i++) {
const k = PRESCRIPTION_OVERLAY_KEYS[i];
if (this[k]) {
this[k] = false;
return true;
}
}
return false;
},
/** 微信小程序:先关闭 page-container 拦截再退栈,避免 navigateBack 被吞 */
safeNavigateBack(delayMs = 0) {
const runNav = () => {
// #ifdef MP-WEIXIN
this.pageBackGuardShow = false;
setTimeout(() => {
uni.navigateBack();
}, 16);
// #endif
// #ifndef MP-WEIXIN
uni.navigateBack();
// #endif
};
if (delayMs > 0) {
setTimeout(runNav, delayMs);
} else {
runNav();
}
},
// #ifdef MP-WEIXIN
onPageBackGuardLeave() {
this.closeTopOverlayIfAny();
this.$nextTick(() => {
this.pageBackGuardShow = this.hasPrescriptionOverlay;
});
},
// #endif
handleCustomBack() {
if (this.closeTopOverlayIfAny()) return;
this.safeNavigateBack(0);
}
}
};
</script>

View File

@@ -175,7 +175,7 @@
<d-loading-page :loading="loading"></d-loading-page>
<!-- 底部操作栏 -->
<view class="bottom-action-bar safe-area-inset-bottom shadow-up flex-row flex-jus-between flex-ali-center white" v-if="flag&&infoList.status!=3">
<view class="bottom-action-bar safe-area-inset-bottom shadow-up flex-row flex-jus-center flex-ali-center white" v-if="flag&&infoList.status!=3">
<u-button v-if="infoList.status==1" @click="$go('workbench_reason?id='+infoList.id)" shape="circle"
:custom-style="{ height: '88rpx', width: '330rpx', backgroundColor: '#F4F6F8', color: '#2A2E35', border: 'none', fontSize: '30rpx', fontWeight: 'bold' }">拒绝
</u-button>
@@ -186,7 +186,6 @@
:custom-style="{ height: '88rpx', width: '330rpx', backgroundColor: '#F4F6F8', color: '#2A2E35', border: 'none', fontSize: '30rpx', fontWeight: 'bold' }">结束问诊
</u-button>
<u-button v-if="infoList.status==2" @click="goToPrescriptionV2" shape="circle"
style="margin-left: 20rpx"
:custom-style="{ height: '88rpx', width: '330rpx', backgroundColor: '#00A88A', color: '#fff', border: 'none', fontSize: '30rpx', fontWeight: 'bold' }">开具处方
</u-button>
</view>
@@ -437,8 +436,9 @@ export default {
this.$toast('已接诊');
this.getList()
setTimeout(() => {
this.$go(`../../subPackages/sub_workbench/workbench_recipe/index?r_id=` + e +
'&id=' + pid);
let url = `/subPackages/sub_workbench/prescription_v2/index?register_id=${e}`;
if (pid) url += `&patient_id=${pid}`;
this.$go(url);
}, 800)
} else {
this.$toast(this.apiMsg(res));
@@ -701,6 +701,7 @@ page {
left: 0;
width: 100%;
padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
gap: 32rpx;
background-color: #fff;
z-index: 99;

View File

@@ -248,7 +248,6 @@
return len
},
add() {
uni.setStorageSync('add', true);
let initial = 2;
if (this.type === 2) initial = 1;
else if (this.type === 3) initial = 3;