<template>
    <div>
      <div class="print_btn">
      <el-button type="primary" @click="printtpage">打印</el-button>
    </div>
        <div id="list-print" class="list-print">
        <div class="listTitle">{{$store.getters.xt_user.org.org_name}}费用发票</div>
        <div class="listTitle_1">{{$store.getters.xt_user.org.org_name}}发票联<span>收</span></div>
         <div class="listInfo">
            <div>收费日期：{{this.$route.query.end_time}}</div>
            <div style="width:400px">发票代码：
             <span>{{orderInfo.fa_piao_code}}</span> 
            </div>
        </div>
        <table class="listTable" table border rules=none cellspacing=0 align=center>
            <tr>
                <td>姓名：{{patient.name}}</td>
                <td>科室：
                    <span v-if="this.$store.getters.xt_user.org.id!=10215"> {{getDepartment(his_patient.departments)}}</span>

                   {{ getDepartment(his_record_patient.departments) }}
                </td>
                <td></td>
            </tr>
            <tr>
                <td>费用类别：
                  <!-- <span v-if="his_patient.balance_accounts_type == 2">自费</span>
                  <span v-if="his_patient.balance_accounts_type != 2">医保</span> -->

                  <span v-if="his_record_patient.balance_accounts_type == 2">自费</span>
                  <span v-if="his_record_patient.balance_accounts_type != 2">医保</span>
                </td>
                <td>金额（元）：{{getAllPice()}}</td>
                <td></td>
            </tr>
            <tr>
                <td>西药：{{getWesternMedicineCostTotal()}}</td>
                <td>中成药：{{getChineseTraditionalMedicineCostTotal()}}</td>
                <td>中草药：{{getChineseTotal()}}</td>
            </tr>
            <tr>
                <td>检查费：{{getCheckCostTotal()}}</td>
                <td>输氧费：{{getOxygen()}}</td>
                <td>手术费：{{getOperation()}}</td>
            </tr>
            <tr>
                <td>化验费：{{getLaboratoryCostTotal()}}</td>
                <td>输血费：{{getBlood()}}</td>
                <td>诊断费：{{getZhenChaCostTotal()}}</td>
            </tr>
            <tr>
                <td>治疗费：{{getTreatement()}}</td>
                <td>护理费：{{getNursing()}}</td>
                <td>床位费：{{getBedCostTotal()}}</td>
            </tr>
            <tr>
                <td>麻醉费：{{getAnesthesia()}}</td>
                <td>材料费：：{{getMaterialCostTotal()}}</td>
                <td>其他：{{getOtherCostTotal()}}</td>
            </tr>
           <tr style="border: 1px solid;">
                <td>合计金额（大写）：{{smalltoBIG(getAllPice())}}</td>
               <td>人民币￥：{{getAllPice()}}</td>
               <td></td>
            </tr>
            <tr style="height: 65px;">
                <td colspan="3">
                    附  注
                </td>
            </tr>
        </table>
        <div class="listInfo">
            <div>
                收款单位（章）：
            </div>
            <div style="width:300px">
                收费员：{{getAdminRole(admin_user_id)}}
            </div>
            <div style="width:300px">
               {{printDate}}
            </div>
        </div>
        </div>
    </div>
</template>

<script>
  import print from "print-js";
  import { uParseTime } from '@/utils/tools'
  import { getGatherDetailList } from '@/api/his/his_tools'
  export default {
    data(){
        return{
          patient:{},
          tableData:[],
          list:[],
          order:[],
          his_patient:{},
          hisDepatment:[],
          chineseTraditionalMedicineCostTotal:"",//中成药
          checkCostTotal:"",//检查费
          materialCostTotal:"",//材料费
          laboratoryCostTotal:"",//化验费
          bedCostTotal:"",//床位费,
          operationCostTotal:"",//材料费
          zhenChaCostTotal:"",//诊查费
          otherCostTotal:"",//其他费用
          printDate:"",
          tableList:[],
          order_info_list:[],
          balanceAccountsType:0,
          medicalInsuranceLevelList:[],
          balanceAccountsType:0,
          doctorlist:[],
          orderInfo:{},
          his_record_patient:{},
        }
    },
    methods:{
      printtpage() {
      const style =
        '@media print {.list-print{width:960px;margin:0 auto} .listTitle {font-size: 24px;text-align: center;font-weight: bold;margin-bottom: 10px;}.listInfo {display: flex;font-size: 16px;justify-content: space-between;margin: 10px 0;}.listTable {width: 100%;text-align: center;border-collapse: collapse;line-height: 25px;font-size: 14px;border-color: #000;text-align: left;} .listTable tr td {padding: 0 5px;}.tableBottom {font-size: 16px;display: flex;margin-top: 20px;}.tableBottomOne {margin-right: 40px;} .listTitle_1{font-size: 18px;text-align: center;margin-bottom: 10px;}';
      printJS({
        printable: "list-print",
        type: "html",
        style: style,
        scanStyles: false,
      });
    },

      getNowTime: function () {
        let dateTime;
        let yy = new Date().getFullYear();
        let mm = new Date().getMonth() + 1;
        let dd = new Date().getDate();
        let hh = new Date().getHours();
        let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes()
          :
          new Date().getMinutes();
        let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds()
          :
          new Date().getSeconds();
        dateTime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
        return dateTime
      },
      getTimes(time) {
        return uParseTime(time, '{y}-{m}-{d}')
      },
      getGatherDetailList() {
      let start_time = this.$route.query.start_time
      let end_time =  this.$route.query.end_time
      let params = {
        patient_id:this.$route.query.patient_id,
        start_time: start_time,
        end_time: end_time,
        type: this.$route.query.type,
        keyword: this.$route.query.keyword
      }
     getGatherDetailList(params).then(response=>{
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
          this.drugTypeList =response.data.data.drugTypeList
          this.costClassifyList = response.data.data.costClassifyList 
          this.doctorlist = response.data.data.doctorlist
          var list = response.data.data.list
          console.log("listw3232323223",list)

          var new_arr = []

          for(let i=0;i<list.length;i++){
            for(let j=0;j<list[i].orders.length;j++){
               new_arr.push(list[i].orders[j])
            }
          }
          console.log("new_arr2332323232",new_arr)

          var order_info = []
          for(let i=0;i<new_arr.length;i++){
            for(let j=0;j<new_arr[i].order_info.length;j++){
                order_info.push(new_arr[i].order_info[j])
            }
          }

           for(let i=0;i<order_info.length;i++){
            if(order_info[i].advice_id > 0){
              order_info[i].item_id = order_info[i].advice.drug.id +"_" + order_info[i].pric
            }
            if(order_info[i].project_id > 0){
              if(order_info[i].project.type == 2){
                order_info[i].item_id = order_info[i].project.project.id + "_"+order_info[i].pric
              }
              if(order_info[i].project.type == 3){
                order_info[i].item_id = order_info[i].project.good_info.id + "_"+order_info[i].pric
              }
            }
          }
          console.log("order_info222222222222",order_info)
          
          //合并，相同的合并在一起

          let dataInfo = {}
          order_info.forEach((item, index) => {
            let { item_id } = item
            if (!dataInfo[item_id]) {
              dataInfo[item_id] = {
                item_id,
                child: [],
                count_number:0,
                record_date:"",
                cost_type:"",
                name:"",
                pric:item.pric,
                chrgitm_lv:"",
                advice_id:item.advice_id,
                project_id:item.project_id,
                type:0,
                spec:"",
                unit:"",
                medical_insurance_level:"",
                cost_type:"",
                is_total:2,
              }
            }
            dataInfo[item_id].child.push(item)
          })
          let arr = Object.values(dataInfo) 
          
          for(let i=0;i<arr.length;i++){
            for(let j=0;j<arr[i].child.length;j++){
               if(arr[i].advice_id >0){
                  arr[i].record_date = arr[i].child[0].advice.advice_date
                  arr[i].type = 1
                  arr[i].name = arr[i].child[0].advice.advice_name
                  arr[i].spec = arr[i].child[0].advice.drug.dose + arr[i].child[0].advice.drug.dose_unit + "*"+arr[i].child[0].advice.drug.min_number + arr[i].child[0].advice.drug.min_unit+"/"+arr[i].child[0].advice.drug.max_unit
                  arr[i].unit = arr[i].child[0].advice.prescribing_number_unit
                  arr[i].cost_type = arr[i].child[0].advice.drug.drug_type
                  arr[i].medical_insurance_level = arr[i].child[0].advice.drug.medical_insurance_level
                 
                 
               }
               if(arr[i].project_id > 0){
                  arr[i].record_date = arr[i].child[0].project.record_date
                  arr[i].type = arr[i].child[0].project.type
                  if(arr[i].child[0].project.type == 2){
                    arr[i].name = arr[i].child[0].project.project.project_name
                    arr[i].spec = arr[i].child[0].project.project.project_name
                    arr[i].unit = arr[i].child[0].project.project.unit
                    arr[i].medical_insurance_level = arr[i].child[0].project.project.medical_coverage
                    arr[i].cost_type = arr[i].child[0].project.project.cost_classify
                  }
                  if(arr[i].child[0].project.type == 3){
                    arr[i].name = arr[i].child[0].project.good_info.good_name
                    arr[i].spec = arr[i].child[0].project.good_info.specification_name
                    arr[i].unit = arr[i].child[0].project.good_info.packing_unit
                    arr[i].medical_insurance_level = arr[i].child[0].project.good_info.medical_insurance_level
                    arr[i].cost_type = "材料费"
                  }
               }
               arr[i].count_number +=arr[i].child[j].cnt
            }
          }
          console.log("arr2323233232322332",arr)
          var obj = {is_total:1,total:0}
          obj.total = this.getAllPiceTwo(arr)
          for(let i=0;i<arr.length;i++){
            if(arr[i].advice_id >0){
               arr[i].cost_type = this.getDrugType(arr[i].cost_type)
            }
            if(arr[i].type ==2){
              arr[i].cost_type = this.getCostType(arr[i].cost_type)
            }
          }
          arr.push(obj)

          this.tableList = arr
          console.log("打印",this.tableList)
          this.patient = response.data.data.patient
          console.log("patinet",this.patient)
          this.his_patient = response.data.data.his_patient
          this.hisDepatment =  response.data.data.hisDepatment
          this.order =  response.data.data.order
          this.his_record_patient = response.data.data.his_record_patient
          this.medicalInsuranceLevelList = response.data.data.medicalInsuranceLevelList  
          this.orderInfo = response.data.data.orderInfo
          if(this.$route.query.id == 1){
             var new_arr = []
             for(let i=0;i<this.tableList.length;i++){
                if(this.tableList[i].type == 1){
                  new_arr.push(this.tableList[i])
                }  
             }
             this.tableList = []
             this.tableList = new_arr
            }
            if(this.$route.query.id  == 2){
             var new_arr = []
             for(let i=0;i<this.tableList.length;i++){
                if(this.tableList[i].type == 2){
                  new_arr.push(this.tableList[i])
                }  
             }
             this.tableList = []
             this.tableList = new_arr
            }
            if(this.$route.query.id  == 3){
             var new_arr = []
             for(let i=0;i<this.tableList.length;i++){
                if(this.tableList[i].type == 3){
                  new_arr.push(this.tableList[i])
                }  
             }
             this.tableList = []
             this.tableList = new_arr
            }
        }
     })
    },
     getAdviceName(id){
      var drug_name = ""
      for(let i= 0;i<this.tableData.length;i++){
         if(id == this.tableData[i].advice_id){
           drug_name = this.tableData[i].advice.advice_name
         }
      }
      return drug_name
    },
    getProjectName(id){
     var project_name = ""
     for(let i=0;i<this.tableData.length;i++){
       if(id == this.tableData[i].project_id){
         project_name = this.tableData[i].project.project.project_name
       }
     }
     return project_name
    },
    setNewData(details) {
        let drug_ids = []
        let project_ids = []

        for (let i = 0; i < details.length; i++) {
          if (details[i].advice && details[i].advice.id > 0 && details[i].advice.prescription && details[i].advice.prescription.type == 1) { //药品
            let obj = {
              id: details[i].advice.drug_id,
              price: details[i].advice.price,
              record_date:details[i].advice.advice_date
            }
            drug_ids.push(obj)
          } else if (details[i].project && details[i].project.id > 0 && details[i].project.prescription && details[i].project.prescription.type == 2) { //项目
            let obj = {
              id: details[i].project.project_id,
              price: details[i].project.price,
              record_date:details[i].advice.record_date
            }
            project_ids.push(obj)

          }

        }
      
        let new_drug_ids = this.unique(drug_ids)
        let new_project_ids = this.unique(project_ids)
       
        let list = []
        if (new_drug_ids.length > 0 && new_project_ids.length == 0) {
          for (let i = 0; i < new_drug_ids.length; i++) {
            let obj = {}
            let count = 0
            for (let a = 0; a < details.length; a++) {
              if (new_drug_ids[i].id == details[a].advice.drug_id && new_drug_ids[i].price == details[a].advice.price) {
                obj['name'] = details[a].advice.advice_name
                obj['spec'] =   details[a].advice.drug.dose +   details[a].advice.drug.dose_unit+"*" +  details[a].advice.drug.min_number +   details[a].advice.drug.min_unit+"/"+ details[a].advice.drug.max_unit
                obj['unit'] = details[a].advice.drug.min_unit
                obj['medicine_insurance_kind'] = this.getMedicineInsuranceType(details[a].chrgitm_lv)
                obj['med_chrgitm_type'] = this.getType(details[a].med_chrgitm_type)
                obj['price'] = parseFloat(details[a].pric)
                obj['is_total'] = 2
                obj['record_date'] = details[a].advice.record_date
                obj['chrgitm_lv'] = details[a].chrgitm_lv
                count = count + details[a].cnt
              }
            }
            obj['count'] = count
            list.push(obj)

          }
        }
        if (new_drug_ids.length == 0 && new_project_ids.length > 0) {
          for (let i = 0; i < new_project_ids.length; i++) {
            let obj = {}
            let count = 0
            for (let a = 0; a < details.length; a++) {
              if (new_project_ids[i].id == details[a].project.project_id && new_project_ids[i].price == details[a].project.price) {
               if( details[a].project.type == 2){
                 obj['name'] = details[a].project.project.project_name
                 obj['spec'] = ''
                 obj['unit'] = details[a].project.project.unit
                

               }else if(details[a].project.type == 3){
                 obj['name'] = details[a].project.good_info.good_name
                 obj['spec'] = ''
                 obj['unit'] = details[a].project.good_info.packing_unit
               

               }
                obj['medicine_insurance_kind'] = this.getMedicineInsuranceType(details[a].chrgitm_lv)
                obj['med_chrgitm_type'] = this.getType(details[a].med_chrgitm_type)
                obj['price'] = parseFloat(details[a].pric)
                obj['is_total'] = 2
                obj['chrgitm_lv'] = details[a].chrgitm_lv

                count = count + details[a].cnt
              }
            }
            obj['count'] = count
            list.push(obj)
          
          }
        }

         if (new_drug_ids.length > 0 && new_project_ids.length > 0) {
           for (let i = 0; i < new_drug_ids.length; i++) {
            let obj = {}
            let count = 0
            for (let a = 0; a < details.length; a++) {
              if (new_drug_ids[i].id == details[a].advice.drug_id && new_drug_ids[i].price == details[a].advice.price) {
                obj['name'] = details[a].advice.advice_name
                obj['spec'] =   details[a].advice.drug.dose +   details[a].advice.drug.dose_unit+"*" +  details[a].advice.drug.min_number +   details[a].advice.drug.min_unit+"/"+ details[a].advice.drug.max_unit
                obj['unit'] = details[a].advice.drug.min_unit
                obj['medicine_insurance_kind'] = this.getMedicineInsuranceType(details[a].chrgitm_lv)
                obj['med_chrgitm_type'] = this.getType(details[a].med_chrgitm_type)
                obj['price'] = parseFloat(details[a].pric)
                obj['is_total'] = 2
                obj['record_date'] = details[a].advice.record_date
                obj['chrgitm_lv'] = details[a].chrgitm_lv
                count = count + details[a].cnt
              }
            }
            obj['count'] = count
            list.push(obj)

          }
         
          for (let i = 0; i < new_project_ids.length; i++) {
            let obj = {}
            let count = 0
            for (let a = 0; a < details.length; a++) {
             if (new_project_ids[i].id == details[a].project.project_id && new_project_ids[i].price == details[a].project.price) {
              if( details[a].project.type == 2){
                 obj['name'] = details[a].project.project.project_name
                 obj['spec'] = ''
                 obj['unit'] = details[a].project.project.unit

               }else if(details[a].project.type == 3){
                 obj['name'] = details[a].project.good_info.good_name
                 obj['spec'] = ''
                 obj['unit'] = details[a].project.good_info.packing_unit
               }
                obj['medicine_insurance_kind'] = this.getMedicineInsuranceType(details[a].chrgitm_lv)
                obj['med_chrgitm_type'] = this.getType(details[a].med_chrgitm_type)
                obj['price'] = parseFloat(details[a].pric)
                obj['is_total'] = 2
                obj['record_date'] = details[a].project.record_date
                 obj['chrgitm_lv'] = details[a].chrgitm_lv
                count = count + details[a].cnt
              }
            }
            obj['count'] = count
            list.push(obj)
          
          }
         }
         console.log("list232332322323332233223232323",list)
        return list
      }, 
    
      getMedicineInsuranceType(type) {
        switch (type) {
          case "01":
            return '甲类'
            break
          case "02":
            return '乙类'

            break
          case "03":
            return '自费'
            break

        }

      },
       getType(med_chrgitm_type){
        switch (med_chrgitm_type) {
          case '01':
            return '床位费'
            break
          case '02':
            return '诊察费'

            break
          case '03':
            return '检查费'

            break
          case '04':
            return '化验费'
            break
          case '05':
            return '治疗费'

            break
          case '06':
            return '手术费'

            break
          case '07':
            return '护理费'

            break
          case '08':
            return '材料费'

            break
          case '09':
            return '西药费'

            break
          case '10':
            return '中药饮片费'

            break
          case '11':
            return '中成药费'

            break
          case '12':
            return '一般诊疗费'

            break
          case '13':
            return '挂号费'

            break
          case '14':
            return '其他费'

            break

        }
      },
      unique(array) {
        // res用来存储结果
        var res = []
        for (var i = 0, arrayLen = array.length; i < arrayLen; i++) {
          for (var j = 0, resLen = res.length; j < resLen; j++) {
            if (array[i].id === res[j].id && array[i].price === res[j].price) {
              break
            }
          }
          // 如果array[i]是唯一的，那么执行完循环，j等于resLen
          if (j === resLen) {
            res.push(array[i])
          }
        }
        return res
      },
      getTotal:function(items){
        let total = 0
        for(let i = 0; i < items.length; i++){
          total = Number(total) + Number((parseFloat(items[i].count) * parseFloat(items[i].price)).toFixed(2))
        }
        return total.toFixed(2)
      },
      getTimes(time) {
       if(time < 0){
         return ""
       }else{
        return uParseTime(time, '{y}-{m}-{d}')
       }
     },
    getDepartment(id){
      var name = ""
      for(let i=0;i<this.hisDepatment.length;i++){
        if(id == this.hisDepatment[i].id){
           name = this.hisDepatment[i].name
        }
      }
      return name
    },
     smalltoBIG(n) {
           
        if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n)){
            return "数据非法";  //判断数据是否大于0
        }

        var unit = "仟佰拾亿仟佰拾万仟佰拾元角分", str = "";
        n += "00";

        var indexpoint = n.indexOf('.');  // 如果是小数，截取小数点前面的位数

        if (indexpoint >= 0){

            n = n.substring(0, indexpoint) + n.substr(indexpoint+1, 2);   // 若为小数，截取需要使用的unit单位
        }

        unit = unit.substr(unit.length - n.length);  // 若为整数，截取需要使用的unit单位
        for (var i=0; i < n.length; i++){
            str += "零壹贰叁肆伍陆柒捌玖".charAt(n.charAt(i)) + unit.charAt(i);  //遍历转化为大写的数字
        }

        this.zhongwen =  str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|壹(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
        return this.zhongwen
     },
 
     getTotalPrice(val){
      var total_price = 0
      for(let i=0;i<val.length;i++){
         total_price +=val[i].count * val[i].price
      }
      return total_price.toFixed(2)
    },
    getAdviceMedChrgintmType(name){
      var med_chrgitm_type = ""
      for(let i=0;i<this.order_info_list.length;i++){
        if(name == this.order_info_list[i].advice.advice_name){
          med_chrgitm_type = this.order_info_list[i].med_chrgitm_type
        }
      }
      return med_chrgitm_type
    },
    getProjectMedChrgintmType(project_id){
      var med_chrgitm_type = ""
      for(let i=0;i<this.order_info_list.length;i++){
        if(project_id == this.order_info_list[i].project_id){
          med_chrgitm_type = this.order_info_list[i].med_chrgitm_type
        }
      }
      return med_chrgitm_type
    },
    getChrgitmLv(value){
      var name = ""
      for(let i=0;i<this.medicalInsuranceLevelList.length;i++){
        if(value == this.medicalInsuranceLevelList[i].value){
           name = this.medicalInsuranceLevelList[i].name
        }
      }
      return name
    },
    getAdviceMedChrgintmLv(advice_id){
     var chrgitm_lv = ""
      for(let i=0;i<this.order_info_list.length;i++){
        if(advice_id == this.order_info_list[i].advice_id){
          chrgitm_lv = this.order_info_list[i].chrgitm_lv
        }
      }
      return chrgitm_lv
    },
    getProjectMedChrgintmLv(advice_id){
     var chrgitm_lv = ""
      for(let i=0;i<this.order_info_list.length;i++){
        if(advice_id == this.order_info_list[i].advice_id){
          chrgitm_lv = this.order_info_list[i].chrgitm_lv
        }
      }
      return chrgitm_lv
    },
    getWesternMedicineCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "西药"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      
      return total_price.toFixed(2)
    },
    getChineseTraditionalMedicineCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "中成药"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getChineseTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "中草药"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getCheckCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "检验费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getOxygen(){
     var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "输氧费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getOperation(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "手术费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getLaboratoryCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "化验费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getBlood(){
     var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "输血费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getZhenChaCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "诊断费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getTreatement(){
     var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "治疗费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getNursing(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "护理费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getBedCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "床位费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getAnesthesia(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "麻醉费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getMaterialCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "材料费"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getOtherCostTotal(){
      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
         if(this.tableList[i].cost_type == "其他"){
            total_price += this.tableList[i].count_number * this.tableList[i].pric
         }
      }
      return total_price.toFixed(2)
    },
    getDrugType(id){
      console.log("id2332323232233232232323",id)
      var name = ""
      for(let i=0;i<this.drugTypeList.length;i++){
         if(id == this.drugTypeList[i].value){
          name = this.drugTypeList[i].name
         }
      }
      return name
    },
    getCostType(id){
     var name = ""
     for(let i=0;i<this.costClassifyList.length;i++){
       if(id == this.costClassifyList[i].value){
         name = this.costClassifyList[i].name
       }
     }
     return name
    },
    getDrugType(id){
      console.log("id2332323232233232232323",id)
      var name = ""
      for(let i=0;i<this.drugTypeList.length;i++){
         if(id == this.drugTypeList[i].value){
          name = this.drugTypeList[i].name
         }
      }
      return name
    },
    getCostType(id){
     var name = ""
     for(let i=0;i<this.costClassifyList.length;i++){
       if(id == this.costClassifyList[i].value){
         name = this.costClassifyList[i].name
       }
     }
     return name
    },
    getAllPice(){

      var total_price = 0
      for(let i=0;i<this.tableList.length;i++){
        if(this.tableList[i].is_total ==2){
          total_price += (this.tableList[i].pric * parseInt(this.tableList[i].count_number))
        }
      }
      if(total_price > 0){
        return total_price.toFixed(2)
      }else{
        return total_price
      }
     
    },
    getAllPiceTwo(arr){

      var total_price = 0
      for(let i=0;i<arr.length;i++){
        if(arr[i].is_total ==2){
          total_price += (arr[i].pric * parseInt(arr[i].count_number))
        }
      }
      if(total_price > 0){
        return total_price.toFixed(2)
      }else{
        return total_price
      }
     
    },
    getAdminRole(id){
      var user_name = ""
      for(let i=0;i<this.doctorlist.length;i++){
       if(id == this.doctorlist[i].admin_user_id){
         user_name = this.doctorlist[i].user_name
       }
      }
      return user_name
    }
    },
    created(){
      this.admin_user_id = this.$store.getters.xt_user.user.id
      console.log("admin_user_id23323232323",this.admin_user_id)
      this.getGatherDetailList()   
      var data = new Date();
      var month =data.getMonth() < 9 ? "0" + (data.getMonth() + 1) : data.getMonth() + 1;
      var date = data.getDate() <= 9 ? "0" + data.getDate() : data.getDate();
      this.printDate = data.getFullYear() + "年" + month + "月" + date+"日";
    }

  }


</script>

<style lang="scss" scoped>
.list-print{
    -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 60px rgba(0, 0, 0, 0.06) inset;
    -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
    margin-bottom: 20px;
    padding:20px 10px;
    width:960px;
    margin: 0 auto;
    height: 565px;
}
.listTitle{
    font-size: 24px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
}
.listTitle_1{
    font-size: 18px;
    text-align: center;
    margin-bottom: 10px;
    span{
        font-size: 15px;
        padding: 0 10px;
    }
}
.listInfo{
    display: flex;
    font-size: 16px;
    justify-content: space-between;
    margin: 10px 0;
}
.listTable{
    width: 100%;
    text-align: center;
    border-collapse: collapse;
    line-height: 40px;
    font-size: 14px;
    border-color: #000;
    text-align: left;
}
.listTable tr td {
    padding: 0 5px;
}
.tableBottom{
    font-size: 16px;
    display: flex;
    margin-top: 20px;
}
.tableBottomOne{
    margin-right: 40px;
}
.print_btn {
  display: flex;
  justify-content: flex-end;
}
</style>
