<template>
  <el-dialog title="双人核对"
             :visible.sync="isVisibility"
             :modal-append-to-body="false"
             width="854px">

    <el-form :inline="true" class="demo-form-inline newInline" :model="doubleReview" label-width="105px">
      
      <el-form-item label="透析物品核查 : ">
        <el-radio v-model="doubleReview.dialysis_item_check" label="1" @change="changeRadio">正确</el-radio>
        <!-- <el-radio v-model="doubleReview.dialysis_item_check" label="2">错误</el-radio> -->
      </el-form-item>
      <el-form-item class="newItem" label="差错描述 : " label-width="90px">
        <el-input v-model="doubleReview.dialysis_item_desc"></el-input>
      </el-form-item>
    </el-form>
   
   <el-form :inline="true" class="demo-form-inline newCheckBox" :model="doubleReview" label-width="110px">
       <el-checkbox-group v-model="checkList" @change="changeBox">
          <el-checkbox :label="diazes"></el-checkbox>
          <el-checkbox :label="puncture_needle"></el-checkbox>
          <el-checkbox :label="dialysate_formulation"></el-checkbox>
          <el-checkbox :label="kalium"></el-checkbox>
          <el-checkbox :label="calcium"></el-checkbox>
       </el-checkbox-group>
    </el-form>
    <el-form :inline="true" class="demo-form-inline newInline" :model="doubleReview" label-width="105px">
      <el-form-item label="透析参数核查 : ">
        <el-radio v-model="doubleReview.dialysis_parameter_check" label="1" @change="changeRadioTwo">正确</el-radio>
        <!-- <el-radio v-model="doubleReview.dialysis_parameter_check" label="2">错误</el-radio> -->
      </el-form-item>
      <el-form-item class="newItem" label="差错描述 : " label-width="90px">
        <el-input v-model="doubleReview.dialysis_parameter_desc"></el-input>
      </el-form-item>
    </el-form>
    <el-form class="newCheckBox">
     <el-checkbox-group v-model="checkListOne" @change="changeBoxOne" >
        <el-checkbox :label="dialys_mode"></el-checkbox>
        <el-checkbox :label="long_time"></el-checkbox>
        <el-checkbox :label="target_ultrafiltration"></el-checkbox>
        <el-checkbox :label="anticoagulant" ></el-checkbox>
        <el-checkbox :label="anticoagulant_shouji"></el-checkbox>
        <el-checkbox :label="anticoagulant_weichi"></el-checkbox>
        <el-checkbox :label="anticoagulant_zongliang"></el-checkbox>
        <el-checkbox :label="displace_liqui_part"></el-checkbox>
        <el-checkbox :label="replacement_total"></el-checkbox>
        <el-checkbox :label="blood_flow_volume"></el-checkbox>
        <el-checkbox :label="dialysate_flow"></el-checkbox>
     </el-checkbox-group>
    </el-form>
    <el-form :inline="true" class="demo-form-inline newInline" :model="doubleReview" label-width="105px">
      <el-form-item label="血管通路核查 : ">

        <el-radio v-model="doubleReview.vascular_access_verification" label="1" @change="changeRadioThree">正确</el-radio>
        <!-- <el-radio v-model="doubleReview.vascular_access_verification" label="2">错误</el-radio> -->

      </el-form-item>
      <el-form-item class="newItem" label="差错描述 : " label-width="90px">
        <el-input v-model="doubleReview.vascular_access_desc"></el-input>
      </el-form-item>
    </el-form>
    <el-form class="newCheckBox">
       <el-checkbox-group v-model="checkListTwo" @change="changeBoxTwo">
        <el-checkbox :label="blood_access_part_opera_id">

        </el-checkbox>
        <el-checkbox label="动静脉接错"></el-checkbox>
        <el-checkbox label="渗血"></el-checkbox>
        <el-checkbox label="压迫" ></el-checkbox>
        <el-checkbox label="折叠"></el-checkbox>
        <el-checkbox label="滑脱"></el-checkbox>
     </el-checkbox-group>
    </el-form>
    <el-form :inline="true" class="demo-form-inline newInline" :model="doubleReview" label-width="105px">
      <el-form-item label="管道连接核查 : ">
        <el-radio v-model="doubleReview.pipeline_connection_check" label="1" @change="changeRadioFour">正确</el-radio>
        <!-- <el-radio v-model="doubleReview.pipeline_connection_check" label="2">错误</el-radio> -->
      </el-form-item>
      <el-form-item class="newItem" label="差错描述 : " label-width="90px">
        <el-input v-model="doubleReview.pipeline_connection_desc"></el-input>
      </el-form-item>
    </el-form>
    <el-form class="newCheckBox">
      <el-checkbox-group v-model="checkListThree" @change="changeBoxThree">
        <el-checkbox label="泵前补液测管未夹"></el-checkbox>
        <el-checkbox label="肝素管夹未开启"></el-checkbox>
        <el-checkbox label="透析器连接错误"></el-checkbox>
        <el-checkbox label="动静脉壶页面不标准" ></el-checkbox>
        <el-checkbox label="静脉管路未卡入保护夹"></el-checkbox>
        <el-checkbox label="压力传感器夹未打开"></el-checkbox>
        <el-checkbox label="接口连接松动"></el-checkbox>
        <el-checkbox label="管路打折"></el-checkbox>
     </el-checkbox-group>
    </el-form>
    <el-form :inline="true" class="demo-form-inline" :model="doubleReview" label-width="120px">
      <el-form-item label="第一核对时间:">
        <el-time-picker
          v-model="first_check_time"
          format='HH:mm'
          value-format="HH:mm"
          placeholder="请输入核对时间">
        </el-time-picker>
      </el-form-item>

      <el-form-item label="第一核对人员">
        <el-select v-model="doubleReview.creater" placeholder="请选择核对人">
          <el-option v-for="(admin, index) in admin_users" :key="index" :value="admin.id"
                     :label="admin.name"></el-option>
        </el-select>
      </el-form-item>


      <el-form-item label="第二核对时间:">
        <el-time-picker
          v-model="check_time"
          format='HH:mm'
          value-format="HH:mm"
          placeholder="请输入核对时间">
        </el-time-picker>
      </el-form-item>

      <el-form-item label="第二核对人员">
        <el-select v-model="doubleReview.modifier" placeholder="请选择核对人">
          <el-option v-for="(admin, index) in admin_users" :key="index" :value="admin.id"
                     :label="admin.name"></el-option>
        </el-select>
      </el-form-item>

    </el-form>


    <el-form :inline="true" class="demo-form-inline" :model="doubleReview" label-width="110px">
      <p style="margin-left: 13px;margin-top: 10px" v-if="doubleReview.creater != 0">{{getFirstCheckDesc()}}</p>
      <p style="margin-left: 13px;margin-top: 10px" v-if="doubleReview.modifier != 0">{{getScondCheckDesc()}}</p>
    </el-form>


    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancle">取 消</el-button>
      <el-button type="primary" @click="handleComfirm">保 存</el-button>
    </div>
  </el-dialog>


</template>

<script>
  import { postDoubleCheck } from '@/api/dialysis'
  import { uParseTime } from '@/utils/tools'
  import { parseTime } from '@/utils'
  import { getDataConfig } from '@/utils/data'
  export default {
    name: 'doubleCheckDialog',
    data() {
      return {
        isVisibility: false,
        time: '',
        isClose: false,
        check_time: 0,
        first_check_time: 0,

        doubleReview: {
          dialysis_item_check: '1',
          dialysis_parameter_check: '1',
          vascular_access_verification: '1',
          pipeline_connection_check: '1',
          dialysis_item_desc: '',
          dialysis_parameter_desc: '',
          vascular_access_desc: '',
          pipeline_connection_desc: '',
          collator: '',

          creater: this.$store.getters.xt_user.user.id,
          modifier: '',
          created_time: 0,
          updated_time: 0,
          check_time: 0,
          first_check_time: 0
        },
        dialysate_formulation_options:[],
        record_date: '',
        checkList: [],
        checkListOne:[],
        checkListTwo:[],
        checkListThree:[],
        diazes:"透析器/灌流器:",
        puncture_needle:"穿刺针:",
        dialysate_formulation:"透析液配方:",
        kalium:"钾:",
        calcium:"钙:",
        dialys_mode:"透析模式:",
        long_time:"透析时长:",
        target_ultrafiltration:"目标超滤量:",
        anticoagulant:"抗凝剂:",
        anticoagulant_shouji:"首剂:",
        anticoagulant_weichi:"维持:",
        anticoagulant_zongliang:"总量:",
        displace_liqui_part:"置换液:",
        replacement_total:"置换总量:",
        blood_flow_volume:"处方血流量:",
        dialysate_flow:"透析液流量:",
        blood_access_part_opera_id:"通路类型:"
      }
    }, methods: {
      show() {
        console.log(this.double_check)

        this.isVisibility = true
        if (this.double_check.id > 0) {

          this.first_check_time = uParseTime(
            this.double_check.first_check_time,
            '{y}-{m}-{d} {h}:{i}'
          ).split(' ')[1]


          if(this.$store.getters.xt_user.user.id == this.double_check.creater || this.double_check.modifier > 0){
            if(this.double_check.modifier > 0){
                this.check_time = uParseTime(
                this.doubleReview.check_time,
                  '{y}-{m}-{d} {h}:{i}'
                ).split(' ')[1]

                console.log('真性感')
            }

          }else if(this.$store.getters.xt_user.user.id != this.double_check.creater && this.double_check.modifier == 0){
            this.check_time = uParseTime(
              new Date(),
              '{y}-{m}-{d} {h}:{i}'
            ).split(' ')[1]
            this.doubleReview.modifier = this.$store.getters.xt_user.user.id
          }
          if(this.doubleReview.modifier == 0){
            this.doubleReview.modifier = ""
          }
          console.log( this.first_check_time )
          console.log( this.check_time )


        } else {
          var nowDate = new Date()
          var nowHours = nowDate.getHours()
          var nowMinutes = nowDate.getMinutes()
          if(this.$store.getters.xt_user.user.id != this.double_check.creater && this.double_check.modifier == 0){
            this.check_time = (nowHours < 10 ? '0' + nowHours : nowHours) + ':' + (nowMinutes < 10 ? '0' + nowMinutes : nowMinutes)
          }
          this.first_check_time = (nowHours < 10 ? '0' + nowHours : nowHours) + ':' + (nowMinutes < 10 ? '0' + nowMinutes : nowMinutes)
          console.log( this.first_check_time )
          console.log( this.check_time )

        }
      },
      hide() {
        this.isVisibility = false
      },
      handleCancle: function() {
        this.isVisibility = false

      }, 
      handleComfirm: function() {

        if (this.patient.id <= 0) {
          this.$message.error('没有选择患者')
          return
        }
        var first_check_time = this.record_date + ' ' + this.first_check_time
        var check_time = this.record_date + ' ' + this.check_time

        var first_time = new Date(first_check_time).getTime()
        var second_time = new Date(check_time).getTime()




        if (first_time >= second_time) {
          this.$message.error('第一次核对时间不能大于或者等于第二次核对时间')
          return
        }

        if (this.doubleReview.creater == this.doubleReview.modifier) {
          this.$message.error('第一次核对人不能与第二次核对人相同')
          return
        }

        let ParamsQuery = this.doubleReview
        ParamsQuery['patient'] = this.patient.id
        ParamsQuery['record_date'] = this.record_date
        if(this.check_time){
          ParamsQuery['check_time'] = this.record_date + ' ' + this.check_time
        }
        // ParamsQuery['check_time'] = this.record_date + ' ' + this.check_time
        if(this.first_check_time){
          ParamsQuery['first_check_time'] = this.record_date + ' ' + this.first_check_time
        }
        
        ParamsQuery['creater'] = this.doubleReview.creater
        ParamsQuery['modifier'] = this.doubleReview.modifier


        postDoubleCheck(ParamsQuery).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.$notify({
              title: '成功',
              message: '提交成功',
              type: 'success',
              duration: 2000
            })

            this.doubleReview.creater = response.data.data.doubleCheck.creater
            this.doubleReview.check_time =
              response.data.data.doubleCheck.check_time
            this.doubleReview.first_check_time =
              response.data.data.doubleCheck.first_check_time
            this.doubleReview.modifier = response.data.data.doubleCheck.modifier

            this.first_check_time = uParseTime(
              this.doubleReview.first_check_time,
              '{y}-{m}-{d}  {h}:{i}'
            ).split(' ')[1]

            // if(this.$store.getters.xt_user.user.id != this.double_check.creater && this.double_check.modifier == 0){
            //   this.check_time = uParseTime(
            //     this.doubleReview.check_time,
            //     '{y}-{m}-{d}  {h}:{i}'
            //   ).split(' ')[1]
            // }

            let doublecheck_resp = response.data.data.doubleCheck
         
            var doubleCheck = this.double_check
            for (var index in doublecheck_resp) {
              // doubleCheck[index] = doublecheck_resp[index];
              this.$set(doubleCheck, index, doublecheck_resp[index])
            }
            this.hide()
          }
        })

      },
      getFirstCheckDesc: function () {
        if(this.double_check.creater > 0){
          if (
            this.doubleReview.first_check_time > 0 &&
            this.doubleReview.check_time > 0
          ) {
            if (this.doubleReview.first_check_time < this.doubleReview.check_time) {
              let time = uParseTime(
                this.doubleReview.first_check_time,
                "{y}-{m}-{d}  {h}:{i}:{s}"
              );
              if (this.doubleReview.creater <= 0) {
                return "";
              }

              var desc = "";
              if (
                this.admin_users == null ||
                typeof this.admin_users.length == "undefined"
              ) {
                return "";
              }

              var leng = this.admin_users.length;
              if (leng == 0) {
                return "";
              }

              for (let index = 0; index < leng; index++) {
                if (this.admin_users[index].id == this.doubleReview.creater) {
                  let name = this.admin_users[index].name;
                  desc = "第一核对人员:" + name + " 第一核对时间:" + time;

                  break;
                }
              }
              return desc;
            } else {
              let time = uParseTime(
                this.doubleReview.check_time,
                "{y}-{m}-{d}  {h}:{i}:{s}"
              );
              if (this.doubleReview.modifier <= 0) {
                return "";
              }

              var desc = "";
              if (
                this.admin_users == null ||
                typeof this.admin_users.length == "undefined"
              ) {
                return "";
              }

              var leng = this.admin_users.length;
              if (leng == 0) {
                return "";
              }

              for (let index = 0; index < leng; index++) {
                if (this.admin_users[index].id == this.doubleReview.modifier) {
                  let name = this.admin_users[index].name;
                  desc = "第一核对人员:" + name + " 第一核对时间:" + time;

                  break;
                }
              }
              return desc;
            }
          } else {
            let time = uParseTime(
              this.doubleReview.first_check_time,
              "{y}-{m}-{d}  {h}:{i}:{s}"
            );
            if (this.doubleReview.creater <= 0) {
              return "";
            }

            var desc = "";
            if (
              this.admin_users == null ||
              typeof this.admin_users.length == "undefined"
            ) {
              return "";
            }

            var leng = this.admin_users.length;
            if (leng == 0) {
              return "";
            }

            for (let index = 0; index < leng; index++) {
              if (this.admin_users[index].id == this.doubleReview.creater) {
                let name = this.admin_users[index].name;
                desc = "第一核对人员:" + name + " 第一核对时间:" + time;

                break;
              }
            }
            return desc;
          }
        }
      },
      getScondCheckDesc: function () {
        if(this.double_check.modifier > 0){

          if (
            this.doubleReview.first_check_time > 0 &&
            this.doubleReview.check_time > 0
          ) {
            if (this.doubleReview.first_check_time < this.doubleReview.check_time) {
              let time = uParseTime(
                this.doubleReview.check_time,
                "{y}-{m}-{d} {h}:{i}:{s}"
              );
              if (this.doubleReview.modifier <= 0) {
                return "";
              }
              var desc = "";
              if (
                this.admin_users == null ||
                typeof this.admin_users.length == "undefined"
              ) {
                return desc;
              }
              var leng = this.admin_users.length;
              if (leng == 0) {
                return desc;
              }
              for (let index = 0; index < leng; index++) {
                if (this.admin_users[index].id == this.doubleReview.modifier ) {
                  let name = this.admin_users[index].name;
                  desc = "第二核对人员:" + name + " 第二核对时间:" + time;
                  break;
                }
              }
              return desc;
            } else {
              let time = uParseTime(
                this.doubleReview.first_check_time,
                "{y}-{m}-{d} {h}:{i}:{s}"
              );
              if (this.doubleReview.creater <= 0) {
                return "";
              }
              var desc = "";
              if (
                this.admin_users == null ||
                typeof this.admin_users.length == "undefined"
              ) {
                return desc;
              }
              var leng = this.admin_users.length;
              if (leng == 0) {
                return desc;
              }
              for (let index = 0; index < leng; index++) {
                if (this.admin_users[index].id == this.doubleReview.creater) {
                  let name = this.admin_users[index].name;
                  desc = "第二核对人员:" + name + " 第二核对时间:" + time;
                  break;
                }
              }
              return desc;
            }
          } else {
            let time = uParseTime(
              this.doubleReview.check_time,
              "{y}-{m}-{d} {h}:{i}:{s}"
            );
            if (this.doubleReview.modifier <= 0) {
              return "";
            }
            var desc = "";
            if (
              this.admin_users == null ||
              typeof this.admin_users.length == "undefined"
            ) {
              return desc;
            }
            var leng = this.admin_users.length;
            if (leng == 0) {
              return desc;
            }
            for (let index = 0; index < leng; index++) {
              if (this.admin_users[index].id == this.doubleReview.modifier) {
                let name = this.admin_users[index].name;
                desc = "第二核对人员:" + name + " 第二核对时间:" + time;
                break;
              }
            }
            return desc;
          }
        }
      },
      changeBox(val){
         
         var arr = []
         var str = val.join(';')
         console.log("strw222222222",str)
        if(str.indexOf('透析器/灌流器')!=-1 && this.prescription!=null){
            arr.push("透析器/灌流器:"+(this.prescription.dialyzer_perfusion_apparatus?this.prescription.dialyzer_perfusion_apparatus:""))
        }

       if(str.indexOf('透析器/灌流器')!=-1 && this.prescription==null){
            arr.push("透析器/灌流器:")
        }
       
        if(str.indexOf('穿刺针')!=-1 && this.predialysis_evaluation.id!=0){
           arr.push("穿刺针:"+this.predialysis_evaluation.puncture_needle)
        }

         if(str.indexOf('穿刺针')!=-1 && this.predialysis_evaluation.id==0){
           arr.push("穿刺针:")
        }
        
        if(str.indexOf('透析液配方')!=-1 && this.prescription!=null){
           arr.push("透析液配方:"+this.GetDialysateFormulationById(this.prescription.dialysate_formulation))
        }

       if(str.indexOf('透析液配方')!=-1 && this.prescription==null){
           arr.push("透析液配方:")
        }
        if(str.indexOf('钾')!=-1 && this.prescription!=null ){
          arr.push("钾:"+(this.prescription.kalium?this.prescription.kalium:""))
        }
        if(str.indexOf('钾')!=-1 && this.prescription==null ){
          arr.push("钾:")
        }
        if(str.indexOf('钙')!=-1 && this.prescription!=null ){
          arr.push("钙:"+(this.prescription.calcium?this.prescription.calcium:""))
        }
        if(str.indexOf('钙')!=-1 && this.prescription==null ){
          arr.push("钙:")
        }
        console.log("arr",arr)
        this.doubleReview.dialysis_item_desc = arr.join(";")
        if(val.length > 0){
          this.doubleReview.dialysis_item_check = 2
        }else{
          this.doubleReview.dialysis_item_check = "1"
        }
      },
      changeBoxOne(val){
         var arr = []
         var str = val.join(';')
         console.log("strw222222222",str)
        if(str.indexOf('透析模式')!=-1 && this.prescription!=null){
            arr.push("透析模式:"+(this.getMode(this.prescription.mode_id)?this.getMode(this.prescription.mode_id):""))
        }
         if(str.indexOf('透析模式')!=-1 && this.prescription==null){
            arr.push("透析模式:")
         } 

         if(str.indexOf('透析时长')!=-1 && this.prescription!=null){
            arr.push("透析时长:"+(this.prescription.dialysis_duration?this.prescription.dialysis_duration:""))
         }

        if(str.indexOf('透析时长')!=-1 && this.prescription==null){
            arr.push("透析时长:")
         }
        
        if(str.indexOf("目标超滤量")!=-1 && this.prescription!=null){
           arr.push("目标超滤量:"+(this.prescription.target_ultrafiltration?this.prescription.target_ultrafiltration:""))
        }
        if(str.indexOf("目标超滤量")!=-1 && this.prescription==null){
           arr.push("目标超滤量:")
        }
        if(str.indexOf("抗凝剂")!=-1 && this.prescription!=null){
           arr.push("抗凝剂:"+(this.prescription.anticoagulant?this.prescription.anticoagulant:""))
        }
       if(str.indexOf("抗凝剂")!=-1 && this.prescription==null){
           arr.push("抗凝剂:")
        }
        if(str.indexOf("首剂")!=-1 && this.prescription!=null){
           arr.push("首剂:"+(this.prescription.anticoagulant_shouji?this.prescription.anticoagulant_shouji:""))
        }
        if(str.indexOf("首剂")!=-1 && this.prescription==null){
           arr.push("首剂:")
        }
       if(str.indexOf("维持")!=-1 && this.prescription!=null){
           arr.push("维持:"+(this.prescription.anticoagulant_weichi?this.prescription.anticoagulant_weichi:""))
        }

        if(str.indexOf("维持")!=-1 && this.prescription==null){
           arr.push("维持:")
        }

        if(str.indexOf("总量")!=-1 && this.prescription!=null){
           arr.push("总量:"+(this.prescription.anticoagulant_zongliang?this.prescription.anticoagulant_zongliang:""))
        }
        
        if(str.indexOf("总量")!=-1 && this.prescription==null){
           arr.push("总量:")
        }

       if(str.indexOf("置换液")!=-1 && this.prescription!=null){
           arr.push("置换液:"+(this.prescription.displace_liqui_part?this.prescription.displace_liqui_part:""))
        } 

       if(str.indexOf("置换液")!=-1 && this.prescription==null){
           arr.push("置换液:")
        } 
      
       if(str.indexOf("置换总量")!=-1 && this.prescription!=null){
           arr.push("置换总量:"+(this.prescription.replacement_total?this.prescription.replacement_total:""))
        } 

        if(str.indexOf("置换总量")!=-1 && this.prescription==null){
           arr.push("置换总量:")
        } 

       if(str.indexOf("处方血流量")!=-1 && this.prescription!=null){
           arr.push("处方血流量:"+(this.prescription.blood_flow_volume?this.prescription.blood_flow_volume:""))
        } 

       if(str.indexOf("处方血流量")!=-1 && this.prescription==null){
           arr.push("处方血流量:")
        } 
       
       if(str.indexOf("透析液流量")!=-1 && this.prescription!=null){
           arr.push("透析液流量:"+(this.prescription.dialysate_flow?this.prescription.dialysate_flow:""))
        } 

       if(str.indexOf("透析液流量")!=-1 && this.prescription==null){
           arr.push("透析液流量:")
        } 
        console.log("arr",arr)
        this.doubleReview.dialysis_parameter_desc = arr.join(";")
        if(val.length>0){
          this.doubleReview.dialysis_parameter_check = 2
        }else{
          this.doubleReview.dialysis_parameter_check = "1"
        }
      },
      changeBoxTwo(val){
         var arr = []
         var str = val.join(';')
         console.log("strw222222222",str)
 
          if(str.indexOf('通路类型')!=-1 && this.predialysis_evaluation.id!=0){
            arr.push("通路类型:"+this.getBloodAccess(this.predialysis_evaluation.blood_access_part_opera_id))
          
          }

          if(str.indexOf('通路类型')!=-1 && this.predialysis_evaluation.id==0){
            arr.push("通路类型:")
          }
          if(str.indexOf('动静脉接错')!=-1){
             arr.push("动静脉接错:")
          }
          if(str.indexOf('渗血')!=-1){
             arr.push("渗血:")
          }
         if(str.indexOf('压迫')!=-1){
             arr.push("压迫:")
          }
          if(str.indexOf('折叠')!=-1){
             arr.push("折叠:")
          }
          if(str.indexOf('滑脱')!=-1){
             arr.push("滑脱:")
          }
        console.log("arr",arr)
        this.doubleReview.vascular_access_desc = arr.join(";")
        if(val.length>0){
          this.doubleReview.vascular_access_verification = 2
        }else{
          this.doubleReview.vascular_access_verification = "1"
        }
      },
      changeBoxThree(val){
         var arr = []
         var str = val.join(';')
         console.log("strw222222222",str)
         if(str.indexOf('泵前补液测管未夹')!=-1){
           arr.push("泵前补液测管未夹:")
         }
         if(str.indexOf('肝素管夹未开启')!=-1){
           arr.push("肝素管夹未开启:")
         }
         if(str.indexOf('透析器连接错误')!=-1){
           arr.push("透析器连接错误:")
         }
        if(str.indexOf('动静脉壶页面不标准')!=-1){
           arr.push("动静脉壶页面不标准:")
         }
          if(str.indexOf('静脉管路未卡入保护夹')!=-1){
           arr.push("静脉管路未卡入保护夹:")
         }
         if(str.indexOf("压力传感器夹未打开")!=-1){
           arr.push("压力传感器夹未打开")
         }
         if(str.indexOf('接口连接松动')!=-1){
            arr.push("接口连接松动")
         }
         if(str.indexOf("管路打折")!=-1){
           arr.push("管路打折")
         }
         this.doubleReview.pipeline_connection_desc = arr.join(";")
         if(val.length > 0){
          this.doubleReview.pipeline_connection_check = 2
         }else{
           this.doubleReview.pipeline_connection_check = "1"
         }
      },

      changeRadio(val){
        if(val == 1){
         this.doubleReview.dialysis_item_desc = ""
         this.checkList =[]
        }
      },
      changeRadioTwo(val){
        if(val == 1){
          this.doubleReview.dialysis_parameter_desc = ""
          this.checkListOne = []
        }
      },
      changeRadioThree(val){
         if(val == 1){
           this.doubleReview.vascular_access_desc = ""
           this.checkListTwo = []
         }
      },
      changeRadioFour(val){
         if(val == 1){
           this.doubleReview.pipeline_connection_desc = ""
           this.checkListThree = [] 
         }
      },

      GetDialysateFormulationById(val) {
         this.dialysate_formulation_options = getDataConfig('hemodialysis','dialysate_formulation')
         console.log("透析液配方",this.dialysate_formulation_options)
        let name = ''
        let dfl = this.dialysate_formulation_options.length
        for (let index = 0; index < dfl; index++) {
          if (this.dialysate_formulation_options[index].id == val) {
            name = this.dialysate_formulation_options[index].name
            break
          }
        }
        return name
     },
      getMode(id){
       var name = ""
        if(id == 1){
          name = "HD"
        }
        if(id == 2){
          name = "HDF"
        }

        if(id == 3){
          name = "HD+HP"
        }

        if(id == 4){
          name = "HP"
        }
        if(id == 5){
          name = "HF"
        }
       if(id == 6){
          name = "SCUF"
        }
       if(id == 7){
          name = "IUF"
        }
       if(id == 8){
          name = "HFHD"
        }

       if(id == 9){
          name = "HFHD+HP"
        }
       if(id == 10){
          name = "PHF"
        }

       if(id == 11){
          name = "HFR"
        }

        if(id == 12){
          name = "HDF+HP"
        }

        if(id == 13){
          name = "CRRT"
        }

        if(id == 14){
          name = "腹水回输"
        }
        if(id == 19){
          name = "IUF+HD"
        }
        if(id == 20){
          name = "UF"
        }
        return name
     },

     getAnticoagulant(id){
       var name = ""
       if(id == 1){
         name = "无肝素"
       }
       if(id == 2){
         name = "普通肝素"
       }
       if(id == 3){
         name = "低分子肝素"
       }
       if(id == 4){
         name = "阿加曲班"
       }
       if(id == 5){
         name = "枸橼酸钠"
       }
       if(id == 6){
         name ="低分子肝素钙"
       }
       if(id == 7){
         name = "低分子肝素钠"
       }
       return name
     },
     getBloodAccess(id){
       
        let vascular_access_desc = getDataConfig(
          'hemodialysis',
          'vascular_access_desc'
        )
        var name = ""
        for(let i=0;i<vascular_access_desc.length;i++){
          if(vascular_access_desc[i].id == id){
             name = vascular_access_desc[i].name
          }
        }
        return name
     }
    },

    props: {
      admin_users: { //系统用户列表
        type: Array,
        default: () => {
          return []
        }
      },

      double_check: { // 双人核对
        type: Object,
        default: () => {
          return { id: 0 }
        }
      },
      patient: { // 患者信息
        type: Object,
        default: () => {
          return { id: 0 }
        }
      },
      predialysis_evaluation: { // 透前评估
        type: Object,
        default: () => {
          return { id: 0 }
        }
      },
      prescription: {
        // 透析处方
        type: Object,
        default: () => {
          return { id: 0 }
        }
      },

    },
    watch: {
      isVisibility(val) {
      
        if(this.prescription!=null && this.prescription.id!=0){
          this.diazes = this.diazes + this.prescription.dialyzer_perfusion_apparatus
          this.dialysate_formulation = this.dialysate_formulation + this.GetDialysateFormulationById(this.prescription.dialysate_formulation)
         
          this.kalium = this.kalium + (this.prescription.kalium?this.prescription.kalium:"")
         
          this.calcium = this.calcium + (this.prescription.calcium?this.prescription.calcium:"")
          this.dialys_mode = this.dialys_mode + this.getMode(this.prescription.mode_id)
          this.long_time = this.long_time + (this.prescription.dialysis_duration?this.prescription.dialysate_formulation:"")
          this.target_ultrafiltration = this.target_ultrafiltration + (this.prescription.target_ultrafiltration?this.prescription.target_ultrafiltration:"")
          this.anticoagulant = this.anticoagulant + this.getAnticoagulant(this.prescription.anticoagulant)
          this.anticoagulant_shouji = this.anticoagulant_shouji + (this.prescription.anticoagulant_shouji?this.prescription.anticoagulant_shouji:"")
          this.anticoagulant_weichi = this.anticoagulant_weichi + (this.prescription.anticoagulant_weichi?this.prescription.anticoagulant_weichi:"")
          this.anticoagulant_zongliang = this.anticoagulant_zongliang+(this.prescription.anticoagulant_zongliang?this.prescription.anticoagulant_zongliang:"")
          this.displace_liqui_part = this.displace_liqui_part + (this.prescription.displace_liqui_part?this.prescription.displace_liqui_part:"")
          this.replacement_total = this.replacement_total + (this.prescription.replacement_total?this.prescription.replacement_total:"")
          this.dialysate_flow = this.dialysate_flow + (this.prescription.dialysate_flow?this.prescription.dialysate_flow:"")
        }
        if(this.predialysis_evaluation!=null && this.predialysis_evaluation.id!=0){
          this.puncture_needle = this.puncture_needle + this.predialysis_evaluation.puncture_needle
          this.blood_access_part_opera_id = this.blood_access_part_opera_id + this.getBloodAccess(this.predialysis_evaluation.blood_access_part_opera_id)
        } 
        if(this.double_check !=null && this.double_check.id!=0){
           console.log("双人核对",this.double_check)
           if(this.double_check.dialysis_item_desc.indexOf("透析器/灌流器")!=-1){
             this.checkList.push("透析器/灌流器:"+this.prescription.dialyzer_perfusion_apparatus)
             console.log("222222",this.checkList)
           }
           if(this.double_check.dialysis_item_desc.indexOf("穿刺针")!=-1){
              this.checkList.push("穿刺针:"+(this.predialysis_evaluation.puncture_needle?this.predialysis_evaluation.puncture_needle:""))
           }
           if(this.double_check.dialysis_item_desc.indexOf("透析液配方:")!=-1){
              this.checkList.push("透析液配方:"+this.GetDialysateFormulationById(this.prescription.dialysate_formulation))
           }
           if(this.double_check.dialysis_item_desc.indexOf("钾:")!=-1){
              this.checkList.push("钾:"+(this.prescription.kalium?this.prescription.kalium:""))
           }
           if(this.double_check.dialysis_item_desc.indexOf("钙:")!=-1){
               this.checkList.push("钙:"+(this.prescription.calcium?this.prescription.calcium:""))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("透析模式:")!=-1){
              this.checkListOne.push("透析模式:"+this.getMode(this.prescription.mode_id))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("透析时长")!=-1){
              this.checkListOne.push("透析时长:"+(this.prescription.dialysis_duration?this.prescription.dialysate_formulation:""))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("目标超滤量")!=-1){
              this.checkListOne.push("目标超滤量:"+(this.prescription.target_ultrafiltration?this.prescription.target_ultrafiltration:""))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("抗凝剂")!=-1){
              this.checkListOne.push("抗凝剂:"+this.getAnticoagulant(this.prescription.anticoagulant))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("首剂")!=-1){
              this.checkListOne.push("首剂:"+(this.prescription.anticoagulant_shouji?this.prescription.anticoagulant_shouji:""))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("维持")!=-1){
              this.checkListOne.push("维持:"+(this.prescription.anticoagulant_weichi?this.prescription.anticoagulant_weichi:""))
           }
          if(this.double_check.dialysis_parameter_desc.indexOf("总量")!=-1){
              this.checkListOne.push("总量:"+(this.prescription.anticoagulant_zongliang?this.prescription.anticoagulant_zongliang:""))
           }
          if(this.double_check.dialysis_parameter_desc.indexOf("置换液")!=-1){
              this.checkListOne.push("置换液:"+(this.prescription.displace_liqui_part?this.prescription.displace_liqui_part:""))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("置换总量")!=-1){
             this.checkListOne.push("置换总量:"+(this.prescription.replacement_total?this.prescription.replacement_total:""))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("处方血流量")!=-1){
             this.checkListOne.push("处方血流量:"+(this.prescription.blood_flow_volume?this.prescription.blood_flow_volume:""))
           }
           if(this.double_check.dialysis_parameter_desc.indexOf("透析液流量")!=-1){
             this.checkListOne.push("透析液流量:"+(this.prescription.dialysate_flow?this.prescription.dialysate_flow:""))
           }
           if(this.double_check.vascular_access_desc.indexOf("通路类型")!=-1){
             this.checkListTwo.push("通路类型:"+this.getBloodAccess(this.predialysis_evaluation.blood_access_part_opera_id))
           }

           if(this.double_check.vascular_access_desc.indexOf("动静脉接错")!=-1){
             this.checkListTwo.push("动静脉接错")
           }
           if(this.double_check.vascular_access_desc.indexOf("渗血")!=-1){
             this.checkListTwo.push("渗血")
           }
           if(this.double_check.vascular_access_desc.indexOf("压迫")!=-1){
             this.checkListTwo.push("压迫")
           }
          if(this.double_check.vascular_access_desc.indexOf("折叠")!=-1){
             this.checkListTwo.push("折叠")
           }
          if(this.double_check.vascular_access_desc.indexOf("滑脱")!=-1){
             this.checkListTwo.push("滑脱")
           }

           if(this.double_check.pipeline_connection_desc.indexOf("泵前补液测管未夹")!=-1){
             this.checkListThree.push("泵前补液测管未夹")
           }
           if(this.double_check.pipeline_connection_desc.indexOf("肝素管夹未开启")!=-1){
             this.checkListThree.push("肝素管夹未开启")
           }
           if(this.double_check.pipeline_connection_desc.indexOf("透析器连接错误")!=-1){
             this.checkListThree.push("透析器连接错误")
           }
           if(this.double_check.pipeline_connection_desc.indexOf("动静脉壶页面不标准")!=-1){
             this.checkListThree.push("动静脉壶页面不标准")
           }
           if(this.double_check.pipeline_connection_desc.indexOf("静脉管路未卡入保护夹")!=-1){
             this.checkListThree.push("静脉管路未卡入保护夹")
           }
           if(this.double_check.pipeline_connection_desc.indexOf("压力传感器夹未打开")){
              this.checkListThree.push("压力传感器夹未打开")
           }
           if(this.double_check.pipeline_connection_desc.indexOf("接口连接松动")){
              this.checkListThree.push("接口连接松动")
           }
           if(this.double_check.pipeline_connection_desc.indexOf("管路打折")){
             this.checkListThree.push("管路打折")
           }
           console.log("hhh",this.checkListOne)
        }
      }, 
      'double_check.id': function() {
        if (this.double_check.id > 0) {
          for (var index in this.doubleReview) {
            this.doubleReview[index] = this.double_check[index] + ''
          }
          this.doubleReview.created_time = this.double_check['created_time']
          this.doubleReview.creater = this.double_check['creater']
          this.doubleReview.updated_time = this.double_check['updated_time']
          this.doubleReview.modifier = this.double_check['modifier']

          this.doubleReview.dialysis_item_desc = this.double_check['dialysis_item_desc']
          this.doubleReview.dialysis_parameter_desc = this.double_check['dialysis_parameter_desc']
          this.doubleReview.vascular_access_desc = this.double_check['vascular_access_desc']
          this.doubleReview.pipeline_connection_desc = this.double_check['pipeline_connection_desc']

          this.doubleReview.created_time = this.double_check['created_time']
          this.doubleReview.creater = this.double_check['creater']
          this.doubleReview.updated_time = this.double_check['updated_time']
          this.doubleReview.modifier = this.double_check['modifier']
          this.doubleReview.check_time = this.double_check['check_time']
          this.doubleReview.first_check_time = this.double_check['first_check_time']

          this.first_check_time = uParseTime(
            this.doubleReview.first_check_time,
            '{y}-{m}-{d}  {h}:{i}'
          ).split(' ')[1]

          if(this.$store.getters.xt_user.user.id == this.double_check.creater || this.double_check.modifier > 0){
            this.check_time = uParseTime(
              this.doubleReview.check_time,
              '{y}-{m}-{d}  {h}:{i}'
            ).split(' ')[1]
          }else if(this.$store.getters.xt_user.user.id != this.double_check.creater && this.double_check.modifier == 0){
            this.check_time = uParseTime(
              new Date(),
              '{y}-{m}-{d}  {h}:{i}'
            ).split(' ')[1]
            this.doubleReview.modifier = this.$store.getters.xt_user.user.id
          }

        } else {
          this.dialysis_item_check = '1'
          this.dialysis_parameter_check = '1'
          this.vascular_access_verification = '1'
          this.pipeline_connection_check = '1'

          this.doubleReview.dialysis_item_desc = ''
          this.doubleReview.dialysis_parameter_desc = ''
          this.doubleReview.vascular_access_desc = ''
          this.doubleReview.pipeline_connection_desc = ''

          var nowDate = new Date()
          var nowYear = nowDate.getFullYear()
          var nowMonth = nowDate.getMonth() + 1
          var nowDay = nowDate.getDate()
          var nowHours = nowDate.getHours()
          var nowMinutes = nowDate.getMinutes()
          if(this.$store.getters.xt_user.user.id != this.double_check.creater && this.double_check.modifier == 0){
            this.check_time = (nowHours < 10 ? '0' + nowHours : nowHours) + ':' + (nowMinutes < 10 ? '0' + nowMinutes : nowMinutes)
          }
          this.first_check_time = (nowHours < 10 ? '0' + nowHours : nowHours) + ':' + (nowMinutes < 10 ? '0' + nowMinutes : nowMinutes)

        }
      }

    },
    created() {
     
      var date = this.$route.query && this.$route.query.date
      this.record_date = uParseTime(date, '{y}-{m}-{d}')

      var nowDate = new Date()
      var nowYear = nowDate.getFullYear()
      var nowMonth = nowDate.getMonth() + 1
      var nowDay = nowDate.getDate()
      var nowHours = nowDate.getHours()
      var nowMinutes = nowDate.getMinutes()
      if(this.$store.getters.xt_user.user.id != this.double_check.creater && this.double_check.modifier == 0){
        this.check_time = (nowHours < 10 ? '0' + nowHours : nowHours) + ':' + (nowMinutes < 10 ? '0' + nowMinutes : nowMinutes)
      }
      this.first_check_time = (nowHours < 10 ? '0' + nowHours : nowHours) + ':' + (nowMinutes < 10 ? '0' + nowMinutes : nowMinutes)
     
    }

  }
</script>

<style lang="scss">
.newInline{
  display: flex;
}
.newItem{
  flex: 1;
  display: flex !important;
  .el-form-item__content{
    width: 100%;
  }
}
.newCheckBox{
  margin-bottom: 10px;
  .el-checkbox{
    margin-bottom: 10px;
  }
}
</style>

