fix:问题修复

This commit is contained in:
huxuejian 2026-09-11 15:10:13 +08:00
parent ba28d6afd6
commit 43f5fdddb8
3 changed files with 98 additions and 17 deletions

View File

@ -104,6 +104,9 @@ const usageList = computed(() => {
const frequencyList = computed(() => { const frequencyList = computed(() => {
return props.consultType === 'onlineMedicinePurchase' ? onlineMedicine.value.frequencyList : storeMedicine.value.frequencyList; return props.consultType === 'onlineMedicinePurchase' ? onlineMedicine.value.frequencyList : storeMedicine.value.frequencyList;
}) })
const timeList = computed(() => {
return props.consultType === 'onlineMedicinePurchase' ? onlineMedicine.value.timeList : storeMedicine.value.timeList;
})
function close() { function close() {
emits('close') emits('close')
@ -163,9 +166,16 @@ function usePreUsageData(matchDrug, item) {
matchDrug.usageCode = usage ? usage.code : ''; matchDrug.usageCode = usage ? usage.code : '';
const dosage = item.dosage > 0 ? item.dosage : matchDrug.dosage; const dosage = item.dosage > 0 ? item.dosage : matchDrug.dosage;
matchDrug.dosage = dosage; matchDrug.dosage = dosage;
const days = Number.isInteger(item.days) && item.days > 0 ? item.days : matchDrug.days; const days = Number.isInteger(Number(item.days)) && Number(item.days) > 0 ? Number(item.days) : matchDrug.days;
matchDrug.days = days; matchDrug.days = days;
const arr = [matchDrug.usageName, matchDrug.frequencyName, matchDrug.dosage ? `每次${matchDrug.dosage}${matchDrug.dosage_unit || ''}` : ''].filter(Boolean); const time = timeList.value.find(i => i.name === item.dose_time_name);
matchDrug.dose_time_name = time ? time.name : "";
const arr = [
matchDrug.usageName,
matchDrug.frequencyName,
matchDrug.dosage ? `每次${matchDrug.dosage}${matchDrug.dosage_unit || ''}` : '',
matchDrug.dose_time_name ? `${matchDrug.dose_time_name}用药`:''
].filter(Boolean);
matchDrug.memo = arr.join(''); matchDrug.memo = arr.join('');
return matchDrug; return matchDrug;
} }
@ -180,9 +190,16 @@ function useStandardUsage(matchDrug, item) {
matchDrug.usageCode = usage ? usage.code : ''; matchDrug.usageCode = usage ? usage.code : '';
const dosage = item.dosage > 0 ? item.dosage : ''; const dosage = item.dosage > 0 ? item.dosage : '';
matchDrug.dosage = dosage; matchDrug.dosage = dosage;
const days = Number.isInteger(item.days) && item.days > 0 ? item.days : matchDrug.days; const days = Number.isInteger(Number(item.days)) && Number(item.days) > 0 ? Number(item.days) : matchDrug.days;
matchDrug.days = days; matchDrug.days = days;
const arr = [matchDrug.usageName, matchDrug.frequencyName, matchDrug.dosage ? `每次${matchDrug.dosage}${matchDrug.dosage_unit || ''}` : ''].filter(Boolean); const time = timeList.value.find(i => i.name === item.dose_time_name);
matchDrug.dose_time_name = time ? time.name : "";
const arr = [
matchDrug.usageName,
matchDrug.frequencyName,
matchDrug.dosage ? `每次${matchDrug.dosage}${matchDrug.dosage_unit || ''}` : '',
matchDrug.dose_time_name ? `${matchDrug.dose_time_name}用药`:''
].filter(Boolean);
matchDrug.memo = arr.join(''); matchDrug.memo = arr.join('');
return matchDrug; return matchDrug;
} }

View File

@ -191,7 +191,59 @@ const customConfirmData = ref({
}); });
const { elderMode, elderVarStyle } = useElder(); const { elderMode, elderVarStyle } = useElder();
const { attachMedicineConfig } = useDb(); const medicineDb = useDb();
const { onlineMedicine, storeMedicine } = storeToRefs(medicineDb);
const { attachMedicineConfig } = medicineDb;
function isPositiveInteger(value) {
const number = Number(value);
return Number.isFinite(number) && Number.isInteger(number) && number > 0;
}
function isPositiveNumber(value) {
const number = Number(value);
return Number.isFinite(number) && number > 0;
}
function isInOptionList(value, options) {
return Array.isArray(options) && options.some(option => option && option.name === value);
}
function validateDrugs() {
const medicine = order.value.consultType === 'onlineMedicinePurchase'
? onlineMedicine.value
: storeMedicine.value;
for (const drug of order.value.drugs) {
const drugName = drug.name || '药品';
if (!isPositiveInteger(drug.quantity)) {
toast(`${drugName}:开药数量必须为正整数`);
return false;
}
if (!isInOptionList(drug.usageName, medicine.usageList)) {
toast(`${drugName}:请选择用药方式`);
return false;
}
if (!isPositiveNumber(drug.dosage)) {
toast(`${drugName}单次剂量必须大于0`);
return false;
}
if (!isInOptionList(drug.frequencyName, medicine.frequencyList)) {
toast(`${drugName}:请选择用药频率`);
return false;
}
if (!isInOptionList(drug.dose_time_name, medicine.timeList)) {
toast(`${drugName}:请选择用药时机`);
return false;
}
if (!isPositiveInteger(drug.days)) {
toast(`${drugName}:用药天数必须为正整数`);
return false;
}
}
return true;
}
function changeDrug(drug) { function changeDrug(drug) {
const index = order.value.drugs.findIndex(item => item._id === drug._id) const index = order.value.drugs.findIndex(item => item._id === drug._id)
@ -361,6 +413,9 @@ async function submit(ignoreUnsuit = false, ignoreRepeat = false) {
toast('请添加药品'); toast('请添加药品');
return; return;
} }
if (!validateDrugs()) {
return;
}
if (inappropriateDrugs.value.length && !ignoreUnsuit) { if (inappropriateDrugs.value.length && !ignoreUnsuit) {
showUnsuitDrugPopup.value = true; showUnsuitDrugPopup.value = true;
return return

View File

@ -52,6 +52,13 @@
<uni-icons type="right" :size="elderMode ? 32 : 24"></uni-icons> <uni-icons type="right" :size="elderMode ? 32 : 24"></uni-icons>
</view> </view>
</picker> </picker>
<view class="row" :class="{ 'row--elder': elderMode }">
<view class="label" :class="{ 'label--elder': elderMode }">用药天数</view>
<view class="value">
<input-number-box v-model="current.days" :elderMode="elderMode" />
</view>
<view v-if="current.unit" class="unit" :class="{ 'unit--elder': elderMode }"></view>
</view>
<view style="height: 80rpx;"></view> <view style="height: 80rpx;"></view>
</view> </view>
</scroll-view> </scroll-view>
@ -141,6 +148,13 @@ function confirm() {
if (!(timeIndex.value >= 0)) { if (!(timeIndex.value >= 0)) {
return toast('请选择用药时机', { mask: false }) return toast('请选择用药时机', { mask: false })
} }
const days = Number(current.value.days);
console.log('current: ', current.value.days)
console.log('days: ', days)
if (!(days > 0 && Number.isInteger(days))) {
return toast('请输入正确的用药天数', { mask: false })
}
current.value.days = days;
// //
setTimeout(() => { setTimeout(() => {
const arr = [ const arr = [
@ -170,6 +184,8 @@ watch(() => props.visible, (val) => {
timeIndex.value = timeList.value.findIndex(item => item.name === current.value.dose_time_name); timeIndex.value = timeList.value.findIndex(item => item.name === current.value.dose_time_name);
const time = timeList.value[timeIndex.value]; const time = timeList.value[timeIndex.value];
current.value.dose_time_name = time ? time.name : ''; current.value.dose_time_name = time ? time.name : '';
const days = Number.isInteger(Number(current.value.days)) && current.value.days >= 0 ? current.value.days : 0;
current.value.days = days;
} else { } else {
popup.value && popup.value.close() popup.value && popup.value.close()
} }
@ -195,13 +211,6 @@ function validateNumber(input, type = 'decimal') {
} }
} }
watch(() => current.value.quantity, (n, o) => {
const isAdd = !(n - 0 > (o || 0));
if (props.visible && n > 0 && current.value.recommended_quantity && isAdd && n > current.value.recommended_quantity) {
uniConfirm('已超过建议开药数量', { showCancel: false })
}
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../drug.scss'; @import '../drug.scss';