diff --git a/api/reception.js b/api/reception.js
index cf7cadc..0aafe7e 100644
--- a/api/reception.js
+++ b/api/reception.js
@@ -135,6 +135,14 @@ export function getProductListDoctorReception(data) {
})
}
+/** 中药全局快捷克数(与药品无关,每次打开中药抽屉拉取) */
+export function getChineseMedicineQuickGramsApi() {
+ return req.request({
+ url: '/newApi/doctor-reception-wx/chinese-medicine-quick-grams',
+ method: 'GET'
+ })
+}
+
// 获取药品使用方式列表
export function getDrugUseList() {
return req.request({
diff --git a/config/app-env.js b/config/app-env.js
index 6d5c290..a8b8bae 100644
--- a/config/app-env.js
+++ b/config/app-env.js
@@ -1,3 +1,5 @@
+import {checkDev} from "@/utils/utils";
+
/**
* 医生小程序环境唯一开关:旧 HTTP、newApi、WebSocket 均由此派生。
* 发布生产前将 USE_DOCTOR_WX_DEV 改为 false。
@@ -22,7 +24,7 @@ export function isDoctorWxDev() {
}
export function getDoctorWxEnv() {
- return USE_DOCTOR_WX_DEV ? DEV : PROD;
+ return checkDev('dev') ? DEV : PROD;
}
/** 开发 / 生产 WebSocket 地址(与 getDoctorWxEnv 同源,供 websocket 配置展示) */
diff --git a/subPackages/sub_workbench/prescription_v2/components/modals/ChineseMedicineModal.vue b/subPackages/sub_workbench/prescription_v2/components/modals/ChineseMedicineModal.vue
index 5db4057..5bd710a 100644
--- a/subPackages/sub_workbench/prescription_v2/components/modals/ChineseMedicineModal.vue
+++ b/subPackages/sub_workbench/prescription_v2/components/modals/ChineseMedicineModal.vue
@@ -27,6 +27,31 @@
/>
+
+
+
+
+
+
+ {{ sel.drug_name || sel.name || '—' }}
+ {{ String(sel.number || 0) }}{{ sel.unit && sel.unit.name ? sel.unit.name : 'g' }}
+
+
+
+
+
+
+
+
+
// 保留所有原有逻辑代码与注释
-import { getProductListDoctorReception } from '@/api/reception.js';
+import { getProductListDoctorReception, getChineseMedicineQuickGramsApi } from '@/api/reception.js';
export default {
name: 'ChineseMedicineModal',
@@ -166,6 +191,11 @@ export default {
currentDrugs: {
type: Array,
default: () => []
+ },
+ /** 打开时预填搜索关键词(如标签长按「编辑」) */
+ initialSearchKey: {
+ type: String,
+ default: ''
}
},
data() {
@@ -179,8 +209,8 @@ export default {
page: 1,
pageSize: 20,
hasMore: false,
- // 常用克数(后端返回,暂时硬编码)
- commonQuantities: [5, 8, 10]
+ // 常用克数(后端全局配置,每次打开抽屉拉取)
+ commonQuantities: []
};
},
watch: {
@@ -188,7 +218,17 @@ export default {
this.show = newVal;
if (newVal) {
this.selectedDrugs = JSON.parse(JSON.stringify(this.currentDrugs));
- this.resetList();
+ this.fetchQuickGrams();
+ const kw = (this.initialSearchKey || '').trim();
+ if (kw) {
+ clearTimeout(this.searchTimer);
+ this.searchKey = kw;
+ this.page = 1;
+ this.hasMore = true;
+ this.loadDrugList(kw);
+ } else {
+ this.resetList();
+ }
}
},
show(newVal) {
@@ -198,6 +238,56 @@ export default {
}
},
methods: {
+ /**
+ * 拉取全局中药快捷克数(每次打开抽屉一次)
+ */
+ async fetchQuickGrams() {
+ try {
+ const res = await getChineseMedicineQuickGramsApi();
+ if (res && (res.code === 0 || res.errcode === 0)) {
+ const data = res.data || res.result || {};
+ const list = Array.isArray(data.grams) ? data.grams : (Array.isArray(data) ? data : []);
+ this.commonQuantities = list
+ .map((v) => parseFloat(v))
+ .filter((n) => !Number.isNaN(n) && n > 0);
+ } else {
+ this.commonQuantities = [];
+ }
+ } catch (e) {
+ console.error('获取中药快捷克数失败:', e);
+ this.commonQuantities = [];
+ }
+ },
+ /**
+ * 点击已选 chip:用药名搜索列表(小程序端勿在 @click 传对象,用 data-six + dataset)
+ */
+ handleSelectedChipSearch(e) {
+ const six = Number(e && e.currentTarget && e.currentTarget.dataset ? e.currentTarget.dataset.six : NaN);
+ if (Number.isNaN(six)) return;
+ const sel = this.selectedDrugs[six];
+ if (!sel) return;
+ const name = String(sel.drug_name || sel.name || '').trim();
+ if (!name) return;
+ clearTimeout(this.searchTimer);
+ this.searchKey = name;
+ this.page = 1;
+ this.hasMore = true;
+ this.loadDrugList(name);
+ },
+ /**
+ * 从已选条移除一味(不同步二次确认)
+ */
+ handleSelectedChipRemove(e) {
+ const six = Number(e && e.currentTarget && e.currentTarget.dataset ? e.currentTarget.dataset.six : NaN);
+ if (Number.isNaN(six) || six < 0 || six >= this.selectedDrugs.length) return;
+ this.selectedDrugs.splice(six, 1);
+ this.emitSelect();
+ const name = (this.searchKey || '').trim();
+ if (name) {
+ this.page = 1;
+ this.loadDrugList(name);
+ }
+ },
resetList() {
this.searchKey = '';
this.drugList = [];
@@ -325,33 +415,17 @@ export default {
},
/**
- * 获取单位名称
- * @param {Object} drug - 药品数据
- * @returns {string} 单位名称
+ * 获取单位名称(中药抽屉内统一按克展示)
*/
- getUnitName(drug) {
- if (drug.drug && drug.drug.unit && drug.drug.unit.name) {
- return drug.drug.unit.name;
- }
- if (drug.unit && drug.unit.name) {
- return drug.unit.name;
- }
+ getUnitName() {
return 'g';
},
/**
- * 获取规格
- * @param {Object} drug - 药品数据
- * @returns {string} 规格
+ * 获取规格(中药抽屉内统一按克展示)
*/
- getSpecification(drug) {
- if (drug.drug && drug.drug.specification) {
- return drug.drug.specification;
- }
- if (drug.specification) {
- return drug.specification;
- }
- return '--';
+ getSpecification() {
+ return 'g';
},
/**
@@ -698,6 +772,7 @@ export default {
display: flex;
flex-direction: column;
height: 100%;
+ min-height: 0;
overflow: hidden;
}
@@ -713,6 +788,62 @@ export default {
display: flex;
flex-direction: column;
overflow: hidden;
+ min-height: 0;
+}
+
+.selected-strip-wrap {
+ width: 100%;
+ flex-shrink: 0;
+}
+
+.selected-strip-scroll {
+ width: 100%;
+ white-space: nowrap;
+}
+
+.selected-strip-inner {
+ display: inline-flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ padding-bottom: 4rpx;
+}
+
+.selected-chip {
+ flex-shrink: 0;
+ margin-right: 16rpx;
+ background: #fff;
+ border-radius: 32rpx;
+ padding: 8rpx 8rpx 8rpx 20rpx;
+ border: 1rpx solid #E2E8F0;
+ box-shadow: 0 2rpx 8rpx rgba(42, 46, 53, 0.06);
+}
+
+.selected-chip-main {
+ max-width: 280rpx;
+}
+
+.selected-chip-name {
+ font-size: 26rpx;
+ font-weight: bold;
+ color: #2A2E35;
+ max-width: 180rpx;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.selected-chip-dose {
+ font-size: 24rpx;
+ color: #00A88A;
+ margin-left: 8rpx;
+ white-space: nowrap;
+}
+
+.selected-chip-close {
+ padding: 8rpx 12rpx 8rpx 8rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
.drug-list-scroll {
diff --git a/subPackages/sub_workbench/prescription_v2/index.vue b/subPackages/sub_workbench/prescription_v2/index.vue
index 2fb7fe1..741da36 100644
--- a/subPackages/sub_workbench/prescription_v2/index.vue
+++ b/subPackages/sub_workbench/prescription_v2/index.vue
@@ -229,8 +229,9 @@
+ :key="tcmTagKey(it, tcmIndex)"
+ :data-idx="tcmIndex"
+ @longpress.stop="onTcmTagLongPress">
{{it.drug_name || it.name}}
{{String(it.number)}}{{it.unit ? it.unit.name : 'g'}}
@@ -569,6 +570,7 @@ export default {
showWesternMedicineModal: false,
westernModalInitialKeyword: '',
showChineseMedicineModal: false,
+ chineseModalInitialKeyword: '',
showSimpleProductModal: false,
showWesternUsageModal: false,
showSaveCommonPrescriptionModal: false,
@@ -720,6 +722,9 @@ export default {
showWesternMedicineModal(val) {
if (!val) this.westernModalInitialKeyword = '';
},
+ showChineseMedicineModal(val) {
+ if (!val) this.chineseModalInitialKeyword = '';
+ },
// #ifdef MP-WEIXIN
hasPrescriptionOverlay(val) {
this.pageBackGuardShow = !!val;
@@ -1207,7 +1212,37 @@ export default {
this.saveToLocalStorage();
this.$toast(`已添加 ${newDrug.drug_name}`);
},
- handleOpenChineseMedicineModal() { this.showChineseMedicineModal = true; },
+ handleOpenChineseMedicineModal() {
+ this.chineseModalInitialKeyword = '';
+ this.showChineseMedicineModal = true;
+ },
+ /** 微信小程序 :key 中勿写 it.id || it.index_id 等表达式,会编译异常 */
+ tcmTagKey(it, tcmIndex) {
+ if (it && it.id != null && it.id !== '') return `tcm-${it.id}`;
+ if (it && it.index_id != null && it.index_id !== '') return `tcm-i-${it.index_id}`;
+ return `tcm-idx-${tcmIndex}`;
+ },
+ /**
+ * 中药标签长按菜单(小程序 showActionSheet 回调里勿依赖闭包 item,用 dataset.idx + currentDrugs)
+ */
+ onTcmTagLongPress(e) {
+ const raw = e && e.currentTarget && e.currentTarget.dataset ? e.currentTarget.dataset.idx : undefined;
+ const idx = raw === undefined || raw === '' ? NaN : Number(raw);
+ if (Number.isNaN(idx) || idx < 0 || idx >= this.currentDrugs.length) return;
+ uni.showActionSheet({
+ itemList: ['编辑', '删除'],
+ success: (res) => {
+ const row = this.currentDrugs[idx];
+ if (!row) return;
+ if (res.tapIndex === 0) {
+ this.chineseModalInitialKeyword = String(row.drug_name || row.name || '').trim();
+ this.showChineseMedicineModal = true;
+ } else if (res.tapIndex === 1) {
+ this.handleRemoveDrug(idx);
+ }
+ }
+ });
+ },
handleSelectChineseDrug(drugs) {
this.currentDrugs = drugs || [];
this.saveToLocalStorage();
diff --git a/utils/utils.js b/utils/utils.js
new file mode 100644
index 0000000..62c7394
--- /dev/null
+++ b/utils/utils.js
@@ -0,0 +1,17 @@
+export function checkImageUrl(url) {
+ // 如果url包含http,则返回url,反之加上 data:image/jpeg;base64,
+ return url.includes('http') ? url : 'data:image/jpeg;base64,' + url
+};
+export function checkDev(key = '') {
+ // 判断某些模块是否开启
+ switch (key) {
+ case 'dev':
+ return false;
+ // return true;
+ case 'open-im':
+ // return false;
+ return true;
+ default:
+ return false;
+ }
+};
\ No newline at end of file