1. 医生端开方2.0测试
This commit is contained in:
@@ -197,17 +197,43 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom-border p-col-32" v-for="(item, index) in currentDrugs" :key="index">
|
||||
<view class="flex-row flex-jus-sp flex-ali-center">
|
||||
<d-text :text="`${index+1}、${item.drug_name}`" className="fs-3 content-c"></d-text>
|
||||
<d-text :text="`¥${parseFloat(item.price || 0).toFixed(2)}`" className="error-c fs-3"></d-text>
|
||||
</view>
|
||||
<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
|
||||
<view class="flex-row flex-ali-center m-t-16">
|
||||
<d-text text="规格:" color="#6C7380"></d-text>
|
||||
<d-text :text="item.specification || '--'" color="#6C7380"></d-text>
|
||||
</view>
|
||||
<view class="flex-row flex-ali-center m-t-16">
|
||||
<d-text :text="`${item.select_number || item.number}${getProductUnit(activeCategory)}`" color="#6C7380"></d-text>
|
||||
<view class="drug-item-content flex-row">
|
||||
<image
|
||||
v-if="item.image"
|
||||
:src="item.image"
|
||||
class="drug-image"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="drug-info-wrapper flex-1">
|
||||
<view class="flex-row flex-jus-sp flex-ali-center">
|
||||
<d-text :text="`${index+1}、${item.drug_name}`" className="fs-3 content-c"></d-text>
|
||||
<d-text :text="`¥${parseFloat(item.price || 0).toFixed(2)}`" className="error-c fs-3"></d-text>
|
||||
</view>
|
||||
<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
|
||||
<view class="flex-row flex-ali-center m-t-16">
|
||||
<d-text text="规格:" color="#6C7380"></d-text>
|
||||
<d-text :text="item.specification || '--'" color="#6C7380"></d-text>
|
||||
</view>
|
||||
<view class="flex-row flex-ali-center m-t-16">
|
||||
<view class="quantity-control flex-row flex-ali-center">
|
||||
<u-button
|
||||
size="mini"
|
||||
:custom-style="{ backgroundColor: '#6ACDBB', color: '#fff', width: '48rpx', height: '48rpx', padding: 0 }"
|
||||
@click.stop="handleDecrementSimpleProduct(index)"
|
||||
>
|
||||
-
|
||||
</u-button>
|
||||
<d-text :text="`${item.select_number || item.number}${getProductUnit(activeCategory)}`" color="#6C7380" className="m-l-16 m-r-16"></d-text>
|
||||
<u-button
|
||||
size="mini"
|
||||
:custom-style="{ backgroundColor: '#6ACDBB', color: '#fff', width: '48rpx', height: '48rpx', padding: 0 }"
|
||||
@click.stop="handleIncrementSimpleProduct(index)"
|
||||
>
|
||||
+
|
||||
</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-t-24 flex-row flex-jus-sa btnBox">
|
||||
@@ -1155,17 +1181,17 @@ export default {
|
||||
}
|
||||
|
||||
// 添加到列表
|
||||
// 参考PC端:index_id, id, drug_name, number, price, image, instruction, type, select_number
|
||||
const newProduct = {
|
||||
index_id: product.id,
|
||||
id: product.drug_id || product.drug?.id || product.id,
|
||||
drug_id: product.drug_id || product.drug?.id || product.id,
|
||||
drug_name: product.drug_name || product.drug?.drug_name || product.name,
|
||||
number: 1,
|
||||
select_number: 1,
|
||||
price: product.price || 0,
|
||||
specification: product.specification || product.drug?.specification || '',
|
||||
image: product.image || product.drug?.image || '',
|
||||
instruction: product.instruction || product.drug?.instruction || ''
|
||||
instruction: product.instruction || product.drug?.instruction || '',
|
||||
type: product.drug?.type || product.type || this.activeCategory,
|
||||
select_number: 1
|
||||
};
|
||||
|
||||
this.currentDrugs.push(newProduct);
|
||||
@@ -1236,6 +1262,52 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 增加简单产品数量
|
||||
* @param {number} index - 产品索引
|
||||
* 职责:增加简单产品的数量
|
||||
*/
|
||||
handleIncrementSimpleProduct(index) {
|
||||
if (index >= 0 && index < this.currentDrugs.length) {
|
||||
const product = this.currentDrugs[index];
|
||||
const currentNumber = product.select_number || product.number || 1;
|
||||
this.$set(product, 'select_number', currentNumber + 1);
|
||||
// 保存到本地存储
|
||||
this.saveToLocalStorage();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 减少简单产品数量
|
||||
* @param {number} index - 产品索引
|
||||
* 职责:减少简单产品的数量,如果为1则提示删除
|
||||
*/
|
||||
handleDecrementSimpleProduct(index) {
|
||||
if (index >= 0 && index < this.currentDrugs.length) {
|
||||
const product = this.currentDrugs[index];
|
||||
const currentNumber = product.select_number || product.number || 1;
|
||||
if (currentNumber > 1) {
|
||||
this.$set(product, 'select_number', currentNumber - 1);
|
||||
// 保存到本地存储
|
||||
this.saveToLocalStorage();
|
||||
} else {
|
||||
// 数量为1时,提示是否删除
|
||||
uni.showModal({
|
||||
title: '删除产品',
|
||||
content: '数量为1时,是否要删除该产品?',
|
||||
showCancel: true,
|
||||
success: ({ confirm }) => {
|
||||
if (confirm) {
|
||||
this.currentDrugs.splice(index, 1);
|
||||
// 保存到本地存储
|
||||
this.saveToLocalStorage();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除所有药品(中药)
|
||||
* 职责:清空中药列表,保存到本地存储
|
||||
@@ -1630,6 +1702,30 @@ export default {
|
||||
select_number: drug.select_number || 1 // 选择数量
|
||||
};
|
||||
|
||||
return cleanDrug;
|
||||
});
|
||||
} else if ([3, 5, 6, 7].includes(this.activeCategory)) {
|
||||
// 简单产品(保健食品、产品服务包、非药品、医疗器械):参考PC端,不需要用法用量
|
||||
// PC端字段:index_id, id, drug_name, number, price, image, instruction, type, select_number
|
||||
drugsData = this.currentDrugs.map((drug) => {
|
||||
const cleanDrug = {
|
||||
index_id: drug.index_id,
|
||||
id: drug.id,
|
||||
drug_name: drug.drug_name || drug.name,
|
||||
number: drug.number || 1,
|
||||
price: drug.price || '0.0000',
|
||||
select_number: drug.select_number || 1
|
||||
};
|
||||
// 可选字段:image, instruction, type(如果存在则保留)
|
||||
if (drug.image) {
|
||||
cleanDrug.image = drug.image;
|
||||
}
|
||||
if (drug.instruction) {
|
||||
cleanDrug.instruction = drug.instruction;
|
||||
}
|
||||
if (drug.type) {
|
||||
cleanDrug.type = drug.type;
|
||||
}
|
||||
return cleanDrug;
|
||||
});
|
||||
} else {
|
||||
@@ -1903,6 +1999,20 @@ export default {
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.m-l-16 {
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.m-r-16 {
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.quantity-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
@@ -1986,12 +2096,17 @@ export default {
|
||||
background: #fff;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
z-index: 99;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.btnText {
|
||||
color: #6ACDBB;
|
||||
font-size: 28rpx;
|
||||
padding: 0 32rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
|
||||
Reference in New Issue
Block a user