// 點擊葯品或檢查項目抽屜頁面的添加並關閉按鈕
hanldeAddCareItem() {
const coType = this.submitCareOrder.careOrder.coType
if (this.selectItemList.length === 0) {
this.msgError('請選擇【' + (coType === '0' ? '葯品' : '檢查項目') + '】')
return
}
if (coType === '0') { // 葯品
this.selectItemList.filter(item => { // filter() 不會改變原始數組。抽屜選中的數組
const obj = { //構造obj
itemRefId: item.medicinesId,
itemName: item.medicinesName,
itemType: coType,
num: 1,
price: item.prescriptionPrice,
amount: 1 * item.prescriptionPrice,
remark: '請按說明服用'
}
let flag = false// 默認里面沒有加
this.submitCareOrder.careOrderItems.filter(i => {//需要往里加的葯品數組
if (i.itemRefId === obj.itemRefId) {
i.num = i.num + 1 //如果有相同的數量加1
flag = true// 說明之前加過
}
})
if (!flag) {
this.submitCareOrder.careOrderItems.push(obj)//如果符合條件追加obj
}
this.openDrawerMedicines = false
})
} else { // 檢查項目
this.selectItemList.filter(item => {
const obj = {
itemRefId: item.checkItemId,
itemName: item.checkItemName,
itemType: coType,
num: 1,
price: item.unitPrice,
amount: 1 * item.unitPrice,
remark: '按要求檢查'
}
let flag = false// 默認里面沒有加
this.submitCareOrder.careOrderItems.filter(i => {
if (i.itemRefId === obj.itemRefId) {
i.num = i.num + 1
flag = true// 說明之前加過
}
})
if (!flag) {
this.submitCareOrder.careOrderItems.push(obj)
}
this.openDrawerCheckItem = false
})
}
// 計算總價
this.computeOrderItemAllAmount()
},