<template>
    <div class="main-contain outpatientChargesManagement">
        <div class="position">
            <bread-crumb :crumbs='crumbs'></bread-crumb>
        </div>
        <div>
            <div style="display: flex;justify-content: space-between;margin-bottom:10px;">
                <div>
                    <el-input  style="width:150px;" v-model="keywords" @input="searchAction"
                              @keyup.enter.native='searchAction'
                              placeholder="请输入患者姓名"
                              class="filter-item"/>
                    <el-select  v-model="item_type" placeholder="请选择"
                               style="width:150px;" @change="changeItem">
                        <el-option
                                label="全部"
                                value="0">
                        </el-option>
                        <el-option
                                v-for="item,index in items"
                                :key="index"
                                :label="item.name"
                                :value="item.id">
                        </el-option>
                    </el-select>
                    <el-date-picker
                            v-model="chargeDate"
                            type="date"
                            format="yyyy-MM-dd"
                            value-format="yyyy-MM-dd"
                            @change="changeDate"
                    >
                    </el-date-picker>

                    <el-select v-model="tube_color" style="width:160px;" placeholder="请选择" @change="changeItemTwo">
                      <el-option
                        label="全部"
                        value="0">
                      </el-option>
                      <el-option
                        v-for="(item,index) in getDictionaryDataConfig('system','tube_color')"
                        :key="index"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                  <el-button @click="printThree()">批量打印</el-button>
                  <el-checkbox v-model="is_combination_print">是否组合打印</el-checkbox>

<!--                  <el-checkbox @click="printTwo()">批量打印</el-checkbox>-->
                  <el-button v-if="!is_combination_print && $store.getters.xt_user.org.id == 10138" @click="printTwo()">组合打印</el-button>

                </div>
            </div>
            <el-table :data="isShow?tableData:tableDataTwo" border :row-style="{ color: '#303133' }" ref="table"
                      :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
                      @selection-change="handleSelectionChange"
                      highlight-current-row>
              <el-table-column align="center" type="selection" width="55"></el-table-column>

                <el-table-column align="center" prop="name" label="患者名字">
                    <template slot-scope="scope">{{ scope.row.patient_name }}</template>
                </el-table-column>

                <el-table-column align="center" prop="name" label="处方号">
                    <template slot-scope="scope">{{scope.row.number}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="创建时间">
                    <template slot-scope="scope">
                      <div v-if="isShow">{{getTime(scope.row.record_date, '{y}-{m}-{d}')}}</div>
                      <div v-if="!isShow">{{scope.row.record_date}}</div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="创建医生">
                    <template slot-scope="scope">{{scope.row.doctor_name}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="项目名称">
                    <template slot-scope="scope">
                        <div>{{scope.row.project_name}}</div>
                    </template>
                </el-table-column>

                <el-table-column
                        align="center"
                        label="操作"
                        width="180"
                        class-name="small-padding fixed-width"
                >
                    <template slot-scope="scope">
                        <el-tooltip class="item" effect="dark" content="打印" placement="top">
                            <el-button
                                    type="primary"
                                    size="small"
                                    icon="el-icon-printer"
                                    @click="Print(scope.row, scope.$index)"
                            >

                            <!-- icon="el-icon-edit-outline" -->
                            </el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>


            </el-table>


            <el-pagination
              v-if="isShow"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :page-sizes="[10, 50, 100]"
                    :page-size="10"
                    background
                    style="margin-top:20px;float: right"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total"
            >
            </el-pagination>
        </div>

        <el-dialog title="打印" :visible.sync="labelVisible">
            <div>
                <el-row style="float:right;">
                    <el-col :span="24">
                        <el-button size="small" icon="el-icon-printer" type="primary" @click="printAction">打印
                        </el-button>
                    </el-col>
                </el-row>
                  <div id="sign" class="signPrint" style="width: 500px;height: 250px;">
                      <div style="display:flex;margin-bottom:0px;">
                          <div style="margin-left:15px;">
                              <div style="font-weight:bold;font-size:24px;"  v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217&& $store.getters.xt_user.org.id != 10278&& $store.getters.xt_user.org.id != 10610&& $store.getters.xt_user.org.id != 0">C</div>
                              <div>{{getTime(current_ctime,'{m}-{d} {h}:{i}')}}</div>
                              <div style="font-size:18px;margin-left:20px;font-weight: bold;max-width: 100%;">{{current_name}}</div>
                          </div>
                          <img style="" v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217&& $store.getters.xt_user.org.id != 10278&& $store.getters.xt_user.org.id != 10610&& $store.getters.xt_user.org.id != 0"  id="barcode">
                      </div>
                      <div style="margin-bottom:0px;">{{current_number}}</div>
                      <div style="display:flex;flex-wrap: wrap; word-wrap: break-word; overflow-wrap: break-word;">
                        
                          <div style="font-size:18px;padding-left:20px;font-weight: bold;max-width:5cm;">{{current_project_name}}</div>
                      </div>
                  </div>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button @click="labelVisible = false">取 消</el-button>
                <el-button type="primary" @click="labelVisible = false">确 定</el-button>
            </div>
        </el-dialog>


      <el-dialog title="批量打印" :visible.sync="batchLabelVisible">
        <div>
          <el-row style="float:right;">
            <el-col :span="24">
              <el-button size="small" icon="el-icon-printer" type="primary" @click="printAction">打印
              </el-button>
            </el-col>
          </el-row>
            <div id="sign" class="signPrint">
              <div v-for="item in selecting_schs">
               <div style="display:flex;margin-bottom:10px;" >
              <div style="margin-left:15px;">
                <div style="font-weight:bold;font-size:24px;">C</div>
                <div>{{getTime(item.ctime,'{m}-{d}')}}</div>
                <div>{{getTime(item.ctime,'{h}:{i}')}}</div>
              </div>
              <img   v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217"  id="barcode">
            </div>
                <div style="margin-bottom:5px;">{{item.number}}</div>
               <div style="display:flex;">
              <div style="font-size:24px;padding-left:20px;">{{item.project_name}}</div>
              <div style="font-size:24px;margin-left:20px;">{{item.patient_name}}</div>
              </div>
              </div>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="batchLabelVisible = false">取 消</el-button>
<!--          <el-button type="primary" @click="labelVisible = false">确 定</el-button>-->
        </div>
      </el-dialog>
    </div>

</template>


<script>
  import BreadCrumb from '@/xt_pages/components/bread-crumb'
  import { GetLabelList,getColorTubeLablePrints,createPrintLable,getPrintLable } from '@/api/his/his'
  import { uParseTime } from '@/utils/tools'
  import SignPrint from '../dialysis/signPrint'
  import JsBarcode from 'jsbarcode'
  import { getDictionaryDataConfig } from '@/utils/data'
  // import NewStatementPrint from './newStatementPrint'
  const moment = require('moment')
  export default {
    components: {
      SignPrint,
      BreadCrumb

    },
    data() {
      return {
        isShow:true,
        tube_color:"0",
        tube_color_two:"0",
        is_combination_print:false,
        current_ctime: 0,
        current_number: '',
        current_project_name: '',
        current_name: '',
        selecting_schs:[],
        labelVisible: false,
        crumbs: [
          { path: false, name: 'HIS工具' },
          { path: false, name: '标签打印' }
        ],
        detail_loading: false,
        tempArr: [],
        pos: 0,
        page: 1,
        limit: 10,
        total: 0,
        current_id: 0,
        sameRowArr: [],
        keywords: '',
        tableData: [],
        tableDataTwo: [],
        current_params:{},
        chargeDate: moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
        item_type: '0',
        items: [
          { id: 1, name: '已打印' },
          { id: 2, name: '未打印' }
        ],
        batchLabelVisible:false,


      }
    },
    methods: {
      printThree(){
      this.batchLabelVisible = true
      },
      printTwo(){
        if(this.selecting_schs.length == 0){
          this.$message.error("请选择需要组合打印的记录")
          return
        }
        let patient_ids = []
        for(let i = 0; i < this.selecting_schs.length; i++){
          patient_ids.push(this.selecting_schs[i].patient_id)
        }
        patient_ids =  this.uniqueTwo(patient_ids)
        if(patient_ids.length != 0 && patient_ids.length > 1){
          this.$message.error("请选择同一患者打印")
          return
        }else{
          var name = ""
          var patient_name = ""
          var team_ids = ""
          var ids = ""

          var project_ids = ""
          for(let i = 0; i < this.selecting_schs.length; i++){
            if(ids.length == 0){
                ids = this.selecting_schs[i].id
            }else{
                ids = ids + "," + this.selecting_schs[i].id
            }
            patient_name = this.selecting_schs[0].patient_name
            if(name.length == 0){
              name = this.selecting_schs[i].project_name
            }else{
              name = name + "," + this.selecting_schs[i].project_name
            }
            if(team_ids.length == 0){
              if(this.selecting_schs[i].item_id > 0) {
                team_ids = this.selecting_schs[i].item_id
              }
            }else{
              if(this.selecting_schs[i].item_id > 0) {
                team_ids = team_ids + "," + this.selecting_schs[i].item_id
              }
            }

            if(project_ids.length == 0){
              console.log(this.selecting_schs[i])
              if(this.selecting_schs[i].item_id == 0) {
                project_ids = this.selecting_schs[i].project_id
                console.log(project_ids)

              }
            }else{
              if(this.selecting_schs[i].item_id == 0) {
                project_ids = project_ids + "," + this.selecting_schs[i].project_id
                console.log(project_ids)

              }
            }
          }
          console.log(project_ids)

          let params = {
            patient_id: patient_ids[0],
            ids: ids,
            record_date:this.chargeDate,
          }
          getPrintLable(params).then(response => {
            if (response.data.state == 0) {
              this.$message.error(response.data.msg)
              return false
            } else {
              this.labelVisible = true
              if(response.data.data.labels.id > 0){
                this.current_ctime = response.data.data.labels.ctime
                this.current_number = ""
                this.current_project_name =name
                this.current_name = patient_name
                this.$nextTick(() => {
                  JsBarcode('#barcode',response.data.data.labels.id, {
                    format: 'CODE39',
                    lineColor: '#000',
                    background: '#EBEEF5',
                    width: 3,
                    height: 100,
                    displayValue: true,
                    text:response.data.data.labels.id,
                    fontOptions:"bold italic",//使文字加粗体或变斜体
                    font:"fantasy",//设置文本的字体
                    textAlign:"left",//设置文本的水平对齐方式
                    textPosition:"top",//设置文本的垂直位置
                    textMargin:5,//设置条形码和文本之间的间距
                    fontSize:15,//设置文本的大小
                    margin:15//设置条形码周围的空白边距
                  })
                });

              }else{
                let params = {
                  is_combination_print:this.is_combination_print,
                  patient_id: patient_ids[0],
                  ids:ids,
                  team_ids:team_ids,
                  project_ids:project_ids,
                  doctor_id:0,
                  is_team:0,
                  record_date:this.chargeDate,
                }

                this.current_params = params
                console.log(this.current_params)
                if(!this.current_params.is_combination_print){
                  if(this.current_params.project_ids.toString().length > 0 && this.current_params.team_ids.toString().length == 0){
                    this.current_params.is_team = 0
                  }else if(this.current_params.project_ids.toString().length == 0 && this.current_params.team_ids.toString().length > 0){
                    this.current_params.is_team= 1
                  }
                }else{
                  this.current_params.is_team = 0
                }
                if(!this.isShow){
                  createPrintLable(this.current_params).then(response => {
                    if (response.data.state == 0) {
                      this.$message.error(response.data.msg)
                      return false
                    } else {
                      this.current_ctime = response.data.data.hlpsi.ctime
                      this.current_number = ""
                      this.current_project_name = name
                      this.current_name = patient_name
                      this.$nextTick(() => {
                        JsBarcode('#barcode',response.data.data.hlpsi.id, {
                          format: 'CODE39',
                          lineColor: '#000',
                          background: '#EBEEF5',
                          width: 3,
                          height: 200,
                          displayValue: false,
                          fontOptions:"bold italic",//使文字加粗体或变斜体
                          font:"fantasy",//设置文本的字体
                          textAlign:"left",//设置文本的水平对齐方式
                          textPosition:"top",//设置文本的垂直位置
                          textMargin:5,//设置条形码和文本之间的间距
                          fontSize:15,//设置文本的大小
                          margin:15//设置条形码周围的空白边距
                        })

                      });
                    }
                  })

                }else{
                  createPrintLable(this.current_params).then(response => {
                    if (response.data.state == 0) {
                      this.$message.error(response.data.msg)
                      return false
                    } else {
                      this.current_ctime =  response.data.data.hlpsi.ctime
                      this.current_number =""
                      this.current_project_name = name
                      this.current_name = patient_name
                      this.$nextTick(() => {
                        JsBarcode('#barcode',response.data.data.hlpsi.id, {
                          format: 'CODE39',
                          lineColor: '#000',
                          background: '#EBEEF5',
                          width: 5,
                          height: 300,
                          displayValue: false,
                          fontOptions:"bold italic",//使文字加粗体或变斜体
                          font:"fantasy",//设置文本的字体
                          textAlign:"left",//设置文本的水平对齐方式
                          textPosition:"top",//设置文本的垂直位置
                          textMargin:5,//设置条形码和文本之间的间距
                          fontSize:15,//设置文本的大小
                          margin:15//设置条形码周围的空白边距
                        })
                      });
                    }
                  })
                }
              }
            }
          })
        }
      },
      handleSelectionChange(val) {
        this.selecting_schs = val
        console.log(this.selecting_schs)
      },
      getDictionaryDataConfig(module, filed_name) {
        return getDictionaryDataConfig(module, filed_name)

      },
      printAction: function() {
        const style = '@media print { .sign{width:500px;margin: 0 auto;text-align: center;border-collapse: collapse;}.order_title_panl {text-align: center;.main_title {font-size: 18px;line-height: 40px;font-weight: 500;}}.dialysisTable tr{padding: 10px 0;}.dialysisTable th {color: #000;padding: 0;margin: 0;height: 30px;}.dialysisTable tr td {padding: 12px 0;}.subadvice_content {text-align: left;padding-left: 25px !important;padding-right: 5px !important;}.advice_content {text-align: left;padding-left: 5px !important;padding-right: 5px !important;padding: 15px 5px !important;} }'
        printJS({
          printable: 'sign',
          type: 'html',
          documentTitle: '  ',
          style: style,
          scanStyles: false
        })
        // createPrintLable(this.current_params).then(response => {
        //   if (response.data.state == 0) {
        //     this.$message.error(response.data.msg)
        //     return false
        //   } else {
        //     const style = '@media print { .sign{width:960px;margin: 0 auto;text-align: center;border-collapse: collapse;}.order_title_panl {text-align: center;.main_title {font-size: 18px;line-height: 40px;font-weight: 500;}}.dialysisTable tr{padding: 10px 0;}.dialysisTable th {color: #000;padding: 0;margin: 0;height: 30px;}.dialysisTable tr td {padding: 12px 0;}.subadvice_content {text-align: left;padding-left: 25px !important;padding-right: 5px !important;}.advice_content {text-align: left;padding-left: 5px !important;padding-right: 5px !important;padding: 15px 5px !important;} }'
        //     printJS({
        //       printable: 'sign',
        //       type: 'html',
        //       documentTitle: '  ',
        //       style: style,
        //       scanStyles: false
        //     })
        //   }
        // })
      },
      getTime(value, temp) {
        if (value != undefined) {
          return uParseTime(value, temp)
        }
        return ''
      },
      Print(row, index) {
        let params = {
          patient_id: row.patient_id,
          ids: row.ids,
          record_date:this.chargeDate,
        }
        getPrintLable(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            console.log('vvvvvv',response.data.data);
            this.labelVisible = true
            if(response.data.data.labels.id > 0){
              console.log('内容1');
              
              this.current_ctime = row.ctime
              this.current_number = row.number
              this.current_project_name = row.project_name
              this.current_name = row.patient_name
              this.$nextTick(() => {
                JsBarcode('#barcode',response.data.data.labels.id, {
                  format: 'CODE39',
                  lineColor: '#000',
                  background: '#EBEEF5',
                  width: 3,
                  height: 200,
                  // width: 1,
                  // height: 90,
                  displayValue: false,
                  fontOptions:"bold italic",//使文字加粗体或变斜体
                  font:"fantasy",//设置文本的字体
                  textAlign:"left",//设置文本的水平对齐方式
                  textPosition:"top",//设置文本的垂直位置
                  textMargin:5,//设置条形码和文本之间的间距
                  fontSize:15,//设置文本的大小
                  margin:0,//设置条形码周围的空白边距
                  marginTop:0
                })
              });

            }else{
              console.log('内容2');
              let params = {
                is_combination_print:this.is_combination_print,
                patient_id: row.patient_id,
                ids: row.ids,
                team_ids: row.team_ids,
                project_ids:row.project_ids,
                doctor_id:row.doctor_id,
                is_team:0,
                record_date:this.chargeDate,
              }
              this.current_params = params
              console.log(this.current_params)
              if(!this.current_params.is_combination_print){
                if(this.current_params.project_ids.toString().length > 0 && this.current_params.team_ids.toString().length == 0){
                  this.current_params.is_team = 0
                }else if(this.current_params.project_ids.toString().length == 0 && this.current_params.team_ids.toString().length > 0){
                  this.current_params.is_team= 1
                }
              }else{
                this.current_params.is_team = 0

              }


              if(!this.isShow){
                createPrintLable(this.current_params).then(response => {
                  if (response.data.state == 0) {
                    this.$message.error(response.data.msg)
                    return false
                  } else {
                    this.current_ctime = row.ctime
                    this.current_number = row.number
                    this.current_project_name = row.project_name
                    this.current_name = row.patient_name
                    this.$nextTick(() => {
                      JsBarcode('#barcode',response.data.data.hlpsi.id, {
                        format: 'CODE39',
                        lineColor: '#000',
                        background: '#EBEEF5',
                        width: 3,
                        height: 200,
                        displayValue: false,
                        fontOptions:"bold italic",//使文字加粗体或变斜体
                        font:"fantasy",//设置文本的字体
                        textAlign:"left",//设置文本的水平对齐方式
                        textPosition:"top",//设置文本的垂直位置
                        textMargin:5,//设置条形码和文本之间的间距
                        fontSize:15,//设置文本的大小
                        margin:0,//设置条形码周围的空白边距
                        marginTop:0
                      })

                    });
                  }
                })

              }else{
                createPrintLable(this.current_params).then(response => {
                  if (response.data.state == 0) {
                    this.$message.error(response.data.msg)
                    return false
                  } else {
                    this.current_ctime = row.ctime
                    this.current_number = row.number
                    this.current_project_name = row.project_name
                    this.current_name = row.patient_name
                    this.$nextTick(() => {
                      JsBarcode('#barcode',response.data.data.hlpsi.id, {
                        format: 'CODE39',
                        lineColor: '#000',
                        background: '#EBEEF5',
                        width: 5,
                        height: 300,
                        displayValue: false,
                        fontOptions:"bold italic",//使文字加粗体或变斜体
                        font:"fantasy",//设置文本的字体
                        textAlign:"left",//设置文本的水平对齐方式
                        textPosition:"top",//设置文本的垂直位置
                        textMargin:5,//设置条形码和文本之间的间距
                        fontSize:15,//设置文本的大小
                        margin:15//设置条形码周围的空白边距
                      })

                    });
                  }
                })

              }
            }
          }
        })
      },
      handleCurrentChange(page) {
        this.isShow = true
        this.is_combination_print =false

        this.page = page
        this.getList()

      },

      handleSizeChange(limit) {
        this.isShow = true
        this.is_combination_print =false

        this.limit = limit
        this.getList()

      },

      changeDate() {
        this.page = 1
        this.limit = 10
        this.isShow = true
        this.is_combination_print =false

        this.getList()
      },changeItemTwo(){
        this.isShow = true
        this.is_combination_print =false
        this.page = 1
        this.limit = 10
        this.getList()
      },
      changeItem() {
        this.isShow = true
        this.is_combination_print =false

        this.page = 1
        this.limit = 10
        this.getList()
      },
      searchAction() {
        this.isShow = true
        this.is_combination_print =false
        this.page = 1
        this.limit = 10
        this.getList()
      },
      getList() {
        let params = {
          record_date: this.chargeDate,
          is_print: this.item_type,
          keyword: this.keywords,
          page: this.page,
          limit: this.limit,
          tube_color:this.tube_color,
        }
        GetLabelList(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.tableData = response.data.data.labels
            this.total = response.data.data.total


            for(var i = 0; i <  this.tableData.length; i++){
              this.tableData[i]["ids"] =  this.tableData[i].id
              if( this.tableData[i].team.id > 0 ){
                this.tableData[i]["project_ids"] = ""
                this.tableData[i]["team_ids"] =  this.tableData[i].team.id


              }
              if( this.tableData[i].team.id == 0 ){
                this.tableData[i]["project_ids"] =  this.tableData[i].project_id
                this.tableData[i]["team_ids"] = ""
              }
            }


          }

        })
      }, 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].patient_id === res[j].patient_id && array[i].tube_color === res[j].tube_color) {
              break
            }
          }
          // 如果array[i]是唯一的，那么执行完循环，j等于resLen
          if (j === resLen) {
            res.push(array[i])
          }
        }
        return res
      },uniqueTwo(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] === res[j]) {
              break
            }
          }
          // 如果array[i]是唯一的，那么执行完循环，j等于resLen
          if (j === resLen) {
            res.push(array[i])
          }
        }
        return res
      },
      getListTwo() {
        let params = {
          record_date: this.chargeDate,
          is_print: this.item_type,
          keyword: this.keywords,
          page: this.page,
          limit: this.limit,
          tube_color:this.tube_color_two,
        }
        getColorTubeLablePrints(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.tableDataTwo = []
            var tableDataOne = [] //有设置试管颜色的数组
            var tableDataTwo = [] //没有设置试管颜色的数组
            for(let i = 0; i < response.data.data.labels.length; i++){
              if(response.data.data.labels[i].team.tube_color == 0){
                tableDataTwo.push(response.data.data.labels[i])
              }
            }
            for(let i = 0; i < response.data.data.labels.length; i++){
              if(response.data.data.labels[i].team.tube_color > 0){
                tableDataOne.push(response.data.data.labels[i])
              }
            }

            for(var i = 0; i < tableDataTwo.length; i++){
              tableDataTwo[i]["ids"] = tableDataTwo[i].id
              if(tableDataTwo[i].team.id > 0 ){
                tableDataTwo[i]["team_ids"] = tableDataTwo[i].team.id
                tableDataTwo[i]["project_ids"] = ""

              }else if(tableDataTwo[i].team.id == 0 ){
                tableDataTwo[i]["team_ids"] = ""
                tableDataTwo[i]["project_ids"] = tableDataTwo[i].project_id

              }
            }
            var patients = []
            for(var i = 0; i < tableDataOne.length; i++){
              let obj = {
                patient_id:tableDataOne[i].patient_id,
                patient_name:tableDataOne[i].patient_name,
                tube_color: tableDataOne[i].team.tube_color,
              }
              patients.push(obj)
            }
            patients = this.unique(patients)
            for(let b = 0; b < patients.length; b++){
              var obj = {
                patient_id:patients[b].patient_id,
                patient_name:patients[b].patient_name,
                tube_color:patients[b].tube_color,
                record_date:"",
                doctor:"",
                project_name:"",
                ids:"",
                project_ids:"",
                team_ids:"",
              }
              for(let c = 0; c < tableDataOne.length;c++){
                if(patients[b].patient_id == tableDataOne[c].patient_id && patients[b].tube_color == tableDataOne[c].team.tube_color){
                  obj["number"] = tableDataOne[c].number
                  obj["team"] = tableDataOne[c].team
                  obj.record_date = this.getTime(tableDataOne[c].record_date,'{y}-{m}-{d}')
                  if(obj.project_name.length == 0){
                    obj.project_name = tableDataOne[c].project_name
                  }else{
                    obj.project_name =  obj.project_name +"," + tableDataOne[c].project_name
                  }
                  if (obj.ids.length == 0) {
                    obj.ids = tableDataOne[c].id
                  } else {
                    obj.ids = obj.ids + "-" + tableDataOne[c].id
                  }

                  if(obj.team.id > 0) {
                    if (obj.team_ids.length == 0) {
                      obj.team_ids = tableDataOne[c].team.id
                    } else {
                      obj.team_ids = obj.team_ids + "-" + tableDataOne[c].team.id
                    }
                  }else if(obj.team.id == 0) {
                    if(obj.project_ids.length == 0){
                      obj.project_ids = tableDataOne[c].project_id
                    }else{
                      obj.project_ids =  obj.project_ids +"-" + tableDataOne[c].project_id
                    }
                  }
                }
              }
              this.tableDataTwo.push(obj)
            }
            console.log(this.tableDataTwo)
            this.tableDataTwo =  this.tableDataTwo.concat(tableDataTwo)
            console.log(this.tableDataTwo)
            this.total = response.data.data.total
          }
        })
      }

    },
    created() {
      this.getList()

    }, mounted() {

    },watch:{
      is_combination_print:function(){
        if(this.is_combination_print){
          this.isShow = false
          this.getListTwo()
        }else{
          this.isShow = true

        }


      }

    }
  }
</script>
