fix:问题修复
This commit is contained in:
parent
ba28d6afd6
commit
43f5fdddb8
@ -104,6 +104,9 @@ const usageList = computed(() => {
|
||||
const frequencyList = computed(() => {
|
||||
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() {
|
||||
emits('close')
|
||||
@ -163,9 +166,16 @@ function usePreUsageData(matchDrug, item) {
|
||||
matchDrug.usageCode = usage ? usage.code : '';
|
||||
const dosage = item.dosage > 0 ? item.dosage : matchDrug.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;
|
||||
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(',');
|
||||
return matchDrug;
|
||||
}
|
||||
@ -180,9 +190,16 @@ function useStandardUsage(matchDrug, item) {
|
||||
matchDrug.usageCode = usage ? usage.code : '';
|
||||
const dosage = item.dosage > 0 ? item.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;
|
||||
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(',');
|
||||
return matchDrug;
|
||||
}
|
||||
|
||||
@ -191,7 +191,59 @@ const customConfirmData = ref({
|
||||
});
|
||||
|
||||
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) {
|
||||
const index = order.value.drugs.findIndex(item => item._id === drug._id)
|
||||
@ -361,6 +413,9 @@ async function submit(ignoreUnsuit = false, ignoreRepeat = false) {
|
||||
toast('请添加药品');
|
||||
return;
|
||||
}
|
||||
if (!validateDrugs()) {
|
||||
return;
|
||||
}
|
||||
if (inappropriateDrugs.value.length && !ignoreUnsuit) {
|
||||
showUnsuitDrugPopup.value = true;
|
||||
return
|
||||
|
||||
@ -52,6 +52,13 @@
|
||||
<uni-icons type="right" :size="elderMode ? 32 : 24"></uni-icons>
|
||||
</view>
|
||||
</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>
|
||||
</scroll-view>
|
||||
@ -141,6 +148,13 @@ function confirm() {
|
||||
if (!(timeIndex.value >= 0)) {
|
||||
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(() => {
|
||||
const arr = [
|
||||
@ -170,6 +184,8 @@ watch(() => props.visible, (val) => {
|
||||
timeIndex.value = timeList.value.findIndex(item => item.name === current.value.dose_time_name);
|
||||
const time = timeList.value[timeIndex.value];
|
||||
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 {
|
||||
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>
|
||||
<style lang="scss" scoped>
|
||||
@import '../drug.scss';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user