zoukankan      html  css  js  c++  java
  • elementui选中数据,加入另一个数据表格

      // 点击药品或检查项目抽屉页面的添加并关闭按钮
        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()
        },
  • 相关阅读:
    IT职业发展核心能力养成
    想学java的朋友们 可以来听公开课
    自学h5 来看看项目常见问题汇总及解决方案
    精准定位适合自己的工作——职业素养免费公益课
    自学前端的小伙伴们开过来 本周公益干货分享课
    java学习项目案例分享视频资源地址
    自学前端的小伙伴看过来 jQuery五角星评分小效果
    美观大气的纯JS做出黑客帝国特效 初学前端进来看
    java项目开发-大神案例分享:京东京豆项目06
    【签到有礼】课工场5月,签到的日子,春暖花开
  • 原文地址:https://www.cnblogs.com/javakangkang/p/14002955.html
Copyright © 2011-2022 走看看