1. 推广员功能增强
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled

This commit is contained in:
李琦
2026-06-04 16:05:02 +08:00
parent ee25ed00fb
commit b40c7402aa
62 changed files with 4373 additions and 467 deletions

View File

@@ -1,4 +1,4 @@
import { computed, nextTick, ref } from 'vue';
import { computed, nextTick, ref, watch } from 'vue';
import { message, notification } from 'ant-design-vue';
import { debounce } from 'lodash-es';
@@ -10,12 +10,18 @@ import { sendMessage } from '#/views/business/chat/utils/request';
import {
addWestPrescription,
checkChineseMedicineConflictApi,
getCurrentStoreTypeApi,
getDrugUseList,
getMyStoreListApi,
getPatientItem,
getProcessRuleList,
getProductListDoctorReception,
} from '#/views/doctor/doctor-reception/api';
import {
calcItemMarginPercent,
calcTotalMarginPercent,
isSeeRateEnabled,
} from '#/utils/chinesePrescriptionMargin';
import { getRegisterStoreInfo as getRegisterStoreInfoPharmacy } from '#/views/doctor/online-consultation/api';
import { getRegisterStoreInfo as getRegisterStoreInfoClinic } from '#/views/doctor/online-consultation-clinic/api';
import traditionalJson from '#/views/business/chat/config/traditional.json';
@@ -89,6 +95,9 @@ export const usePrescriptionStore = defineStore('prescription', () => {
// 存储前缀(用于区分在线复诊-药店和在线复诊-诊所)
const storagePrefix = ref('onlineConsultation-'); // 默认前缀
/** 当前取价门店是否允许查看毛利率(0/1,来自 xk-api) */
const seeRate = ref(0);
// 获取localStorage key(按类型分开存储)
const getStorageKey = (category?: number) => {
const cat = category ?? activeCategory.value;
@@ -143,6 +152,56 @@ export const usePrescriptionStore = defineStore('prescription', () => {
return totalProductCost.value + processingFee.value;
});
const resolvePrescribingStoreId = () => {
if (sendMode.value === 1 && selectedStoreId.value) {
return selectedStoreId.value;
}
return myStoreId.value;
};
const fetchStoreSeeRate = async () => {
try {
const params: { register_id?: number; store_id?: number } = {};
const sid = resolvePrescribingStoreId();
if (sid) {
params.store_id = sid;
}
if (currentRegisterId.value) {
params.register_id = Number(currentRegisterId.value);
}
const res = await getCurrentStoreTypeApi(params);
seeRate.value = Number(res?.see_rate ?? 0);
} catch (error) {
console.error('获取毛利率权限失败:', error);
}
};
watch(
[myStoreId, selectedStoreId, sendMode, currentRegisterId],
() => {
if (myStoreId.value) {
fetchStoreSeeRate();
}
},
);
const chineseGrossMarginPercent = computed(() => {
if (!isSeeRateEnabled(seeRate.value) || activeCategory.value !== 1) {
return null;
}
return calcTotalMarginPercent(currentDrugs.value, dosage.value);
});
const getChineseItemMargin = (drug: {
price?: number | string;
buy_price?: number | string;
}) => {
if (!isSeeRateEnabled(seeRate.value)) {
return null;
}
return calcItemMarginPercent(drug.price, drug.buy_price);
};
// localStorage同步方法
const syncToLocalStorage = () => {
try {
@@ -240,6 +299,8 @@ export const usePrescriptionStore = defineStore('prescription', () => {
await initializeBasicData();
}
await fetchStoreSeeRate();
// 获取患者信息(只在需要时调用,如 PrescriptionModal)
if (shouldFetchPatientInfo) {
if (
@@ -377,6 +438,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
sendMode.value = 1;
}
console.log('获取挂号诊所信息成功:', res);
await fetchStoreSeeRate();
} catch (error) {
console.error('获取挂号诊所信息失败:', error);
}
@@ -435,6 +497,9 @@ export const usePrescriptionStore = defineStore('prescription', () => {
store_id: myStoreId.value,
type: activeCategory.value,
name: searchText,
...(currentRegisterId.value
? { register_id: Number(currentRegisterId.value) }
: {}),
});
drugList.value = res.map((item) => {
@@ -476,6 +541,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
),
unit: drugUnit.value.find((item) => item.id === data.drug.unit_id),
price: data.price,
buy_price: data.buy_price,
way_id: data.drug?.way_id,
use_ways: drugUseWay.value.find((item) => item.id === data.drug.way_id),
time_id: data.drug.time_id,
@@ -605,6 +671,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
),
unit: drugUnit.value.find((item) => item.id === data.drug.unit_id),
price: data.price,
buy_price: data.buy_price,
way_id: data.drug?.way_id,
use_ways: drugUseWay.value.find((item) => item.id === data.drug.way_id),
time_id: data.drug.time_id,
@@ -985,6 +1052,10 @@ export const usePrescriptionStore = defineStore('prescription', () => {
totalProductCost,
processingFee,
totalCost,
seeRate,
chineseGrossMarginPercent,
getChineseItemMargin,
fetchStoreSeeRate,
// 方法
initializePrescription,