<template>
  <div class="doubleCheck">
      <div>
          <van-collapse v-model="activeNames" accordion>
              <div>
                  <van-cell title="透析物品核查">
                      <template #right-icon>
                          <van-radio-group v-model="doubleReview.dialysis_item_check" @change="changeRadio">
                              <van-radio name="1" style="width: 100%;">正确</van-radio>
                          </van-radio-group>
                      </template>
                  </van-cell>
                  <van-field v-model="doubleReview.dialysis_item_desc" label="差错描述"/>
                  <van-checkbox-group v-model="result" @change='toCheck'>
                      <van-checkbox name="a">透析器/灌流器/滤过器:<span v-if="prescription_prop!=null">{{prescription_prop.dialyzer_perfusion_apparatus}}{{prescription_prop.dialysis_dialyszers}}{{prescription_prop.dialysis_irrigation}}<span v-if="prescription_prop.dialysis_strainer!=''">/</span> {{prescription_prop.dialysis_strainer }}</span></van-checkbox>
                      <van-field v-model="doubleReview.dialyzer_batch_number" label="批号:" v-if="isShow('批号')" />
                      <van-checkbox name="b">穿刺针:<span v-if="predialysis!=null">{{predialysis.puncture_needle}}</span></van-checkbox>
                      <van-field v-model="doubleReview.needle_batch_number" label="批号:" v-if="isShow('批号')"/>
                      <van-checkbox name="c">透析液配方:<span v-if="prescription_prop!=null">{{GetDialysateFormulationById(prescription_prop.dialysate_formulation)}}</span></van-checkbox>
                      <van-checkbox name="d">钾:<span v-if="prescription_prop!=null">{{prescription_prop.kalium}}</span></van-checkbox>
                      <van-checkbox name="e">钙:<span v-if="prescription_prop!=null">{{prescription_prop.calcium}}</span></van-checkbox>
                  </van-checkbox-group>
              </div>
              <div>
                  <van-cell title="透析参数核查">
                      <template #right-icon>
                          <van-radio-group v-model="doubleReview.dialysis_parameter_check" @change="changeRadioOne">
                              <van-radio name="1" style="width: 100%;">正确</van-radio>
                          </van-radio-group>
                      </template>
                  </van-cell>
                  <van-field v-model="doubleReview.dialysis_parameter_desc" label="差错描述"/>
                  <van-checkbox-group v-model="resultOne" @change='toCheckOne'>
                      <van-checkbox name="a">透析模式:<span v-if="prescription_prop!=null">{{getMode(prescription_prop.mode_id)}}</span></van-checkbox>
                      <van-checkbox name="b">透析时长:<span v-if="prescription_prop!=null">{{prescription_prop.dialysis_duration_hour}}小时{{prescription_prop.dialysis_duration_minute}}分</span></van-checkbox>
                      <van-checkbox name="c" v-if="org_id!=10679">目标超滤量:<span v-if="prescription_prop!=null">{{prescription_prop.target_ultrafiltration?prescription_prop.target_ultrafiltration:""}} </span> <span v-if="org_id==10617">L</span></van-checkbox>
                      <van-checkbox name="m" v-if="org_id ==10469 || org_id ==10597 || org_id ==10679 || org_id ==10702 || org_id == 10745 || org_id == 10752 || org_id == 10757">处方脱水量:<span v-if="prescription_prop!=null">{{prescription_prop.prescription_water?prescription_prop.prescription_water:""}}</span></van-checkbox>
                      <van-checkbox name="d">抗凝剂:<span v-if="prescription_prop!=null">{{getAnticoagulant(prescription_prop.anticoagulant)}}</span></van-checkbox>
                      <van-checkbox name="e">首剂:<span v-if="prescription_prop!=null">{{prescription_prop.anticoagulant_shouji}}</span></van-checkbox>
                      <van-checkbox name="f">维持:<span v-if="prescription_prop!=null">{{prescription_prop.anticoagulant_weichi}}</span></van-checkbox>
                      <van-checkbox name="g">总量:<span v-if="prescription_prop!=null">{{prescription_prop.anticoagulant_zongliang}}</span></van-checkbox>
                      <van-checkbox name="h">置换液:<span v-if="prescription_prop!=null">
                        <span v-if="prescription_prop.displace_liqui_part==1">前稀释</span> 
                        <span v-if="prescription_prop.displace_liqui_part==2">后稀释</span> 
                      </span>
                      </van-checkbox>
                      <van-checkbox name="i">置换量:<span v-if="prescription_prop!=null">{{prescription_prop.replacement_total?prescription_prop.replacement_total:""}}</span></van-checkbox>
                      <van-checkbox name="j">处方血流量:<span v-if="prescription_prop!=null">{{prescription_prop.blood_flow_volume?prescription_prop.blood_flow_volume:""}}</span></van-checkbox>
                      <van-checkbox name="k">透析液流量:<span v-if="prescription_prop!=null">{{prescription_prop.dialysate_flow?prescription_prop.dialysate_flow:''}}</span></van-checkbox>
                      <van-checkbox name="l">置换液总量:<span v-if="prescription_prop!=null">{{prescription_prop.displace_liqui_value?prescription_prop.displace_liqui_value:''}}</span></van-checkbox>
                  </van-checkbox-group>
              </div>
              <div>
                  <van-cell title="血管通路核查">
                      <template #right-icon>
                          <van-radio-group v-model="doubleReview.vascular_access_verification" @change="changeRadioTwo">
                              <van-radio name="1" style="width: 100%;">正确</van-radio>
                          </van-radio-group>
                      </template>
                  </van-cell>
                  <van-field v-model="doubleReview.vascular_access_desc" label="差错描述"/>
                  <van-checkbox-group v-model="resultTwo" @change='toCheckTwo'>
                      <van-checkbox name="a">通路类型:<span v-if="predialysis!=null">{{predialysis.blood_access_part_id}}&nbsp;&nbsp;{{getBloodAccess(predialysis.blood_access_part_opera_id)}}</span></van-checkbox>
                      <van-checkbox name="b">动静脉接错</van-checkbox>
                      <van-checkbox name="c">渗血</van-checkbox>
                      <van-checkbox name="d">压迫</van-checkbox>
                      <van-checkbox name="e">折叠</van-checkbox>
                      <van-checkbox name="f">滑脱</van-checkbox>
                  </van-checkbox-group>
              </div>
              <div>
                  <van-cell title="管道连接核查">
                      <template #right-icon>
                          <van-radio-group v-model="doubleReview.pipeline_connection_check" @change="changeRadioThree">
                              <van-radio name="1" style="width: 100%;">正确</van-radio>
                          </van-radio-group>
                      </template>
                  </van-cell>
                  <van-field v-model="doubleReview.pipeline_connection_desc" label="差错描述"/>
                  <van-checkbox-group v-model="resultThree" @change='toCheckThree'>
                      <van-checkbox name="a">泵前补液测管未夹</van-checkbox>
                      <van-checkbox name="b">肝素管夹未开启</van-checkbox>
                      <van-checkbox name="c">透析液连接错误</van-checkbox>
                      <van-checkbox name="d">动静脉壶页面不标准</van-checkbox>
                      <van-checkbox name="e">静脉管道未夹入保护夹</van-checkbox>
                      <van-checkbox name="f">压力传感器夹未打开</van-checkbox>
                      <van-checkbox name="i">接口连接松动</van-checkbox>
                      <van-checkbox name="j">管路打折</van-checkbox>
                      <van-checkbox name="k">肝素补液口未双保险夹闭</van-checkbox>
                  </van-checkbox-group>
              </div>
              <van-field v-model="first_check_time_str" readonly @click="selectFirstCheckTimeAction" label="第一核对时间" input-align="right"v-if="org_id!=10721" />
              <van-cell title='第一核对人员' v-if="org_id!=10597">
                  <template #label>
                      <van-radio-group class="doctorList" v-model="doubleReview.creater">
                          <van-radio :name="item.id" v-for='(item,index) in admin_map' :key="index"  v-if='item.status === 1&& item.user_type ===3'>{{ item.name }}</van-radio>
                      </van-radio-group>
                  </template>
              </van-cell>
              <van-cell title='第一核对人员' v-if="org_id==10597">
                  <template #label>
                      <van-radio-group class="doctorList" v-model="doubleReview.creater">
                          <van-radio :name="item.id" v-for='(item,index) in admin_map' :key="index"  v-if='item.status === 1'>{{ item.name }}</van-radio>
                      </van-radio-group>
                  </template>
              </van-cell>
              <van-field v-if="org_id!=10629 && org_id!=10721" v-model="check_time_str" readonly @click="selectSecondCheckTimeAction" label="第二核对时间" input-align="right"/>
              <van-cell title='第二核对人员' v-if="org_id!=10597 && org_id!=10629 && org_id!=10721">
                  <template #label>
                      <van-radio-group class="doctorList" v-model="doubleReview.modifier">
                          <van-radio :name="item.id"  v-for='(item,index) in admin_map' :key="index" v-if='item.status === 1&& item.user_type ===3'>{{ item.name }}</van-radio>
                      </van-radio-group>
                  </template>
              </van-cell>
              <van-cell title='第二核对人员' v-if="org_id==10597">
                  <template #label>
                      <van-radio-group class="doctorList" v-model="doubleReview.modifier">
                          <van-radio :name="item.id"  v-for='(item,index) in admin_map' :key="index" v-if='item.status === 1'>{{ item.name }}</van-radio>
                      </van-radio-group>
                  </template>
              </van-cell>
              <div>
                  <p style="margin: 10px 0 10px 13px;font-size:.875rem" v-if="doubleReview.creater != 0&&doubleReview.id > 0">
                      {{ getFirstCheckDesc() }}
                  </p>
                  <p style="margin: 10px 0 10px 13px;font-size:.875rem" v-if="doubleReview.modifier != 0&&doubleReview.id > 0">
                      {{ getScondCheckDesc() }}
                  </p>
              </div>
              <van-field v-model="doubleReview.employee_number" label="第二核对人员工号" :required="isShow_title('第二核对人员工号')" v-if="isShow('第二核对人员工号')"/>

          </van-collapse>

      </div>
      <div class="preserveBox">
          <div @click="commitInfo" v-if="isCommit">保存</div>
          <div v-else class="disabled">保存</div>
      </div>
      <mt-datetime-picker
      class="datetimePicker"
      ref="first_check_time_picker"
      type="datetime"
      @confirm="didSelectFirstCheckTime"
      v-model="first_check_time"
      ></mt-datetime-picker>

      <mt-datetime-picker
      class="datetimePicker"
      ref="second_check_time_picker"
      type="datetime"
      @confirm="didSelectCheckTime"
      v-model="check_time"
      ></mt-datetime-picker>

     <van-popup
      v-model="infor_visibility"
      class="advicePopup"
      get-container="#today_panel"
    >
      <infor-sub-menu
      :visibility="infor_visibility"
      v-on:menu-cancle-three="menuCancleFour"
      v-on:menu-comfirm-three="menuComfirmFour"
      >
      </infor-sub-menu>
    </van-popup>
  </div>
</template>

<script>
import {commitDoubleCheck, getRoleList} from '@/api/dialysis'
import InforSubMenu from "../dialog/subMenu/InforSubMenu.vue"
import { saveMobileInformation } from '@/api/dialysis'
import {getDataConfig} from '@/utils/data'
import {Toast} from 'vant'
import { Dialog } from "vant";
import {uParseTime} from '@/utils/tools'
import {parseTime} from '@/utils'
export default {
props: {
  record: {
    type: Object,
    default: () => {
      return {id: 0}
    }
  },
  admin_map: {
    type: Object
  },
  admins: {
    type: Array
  },
  patient_prop: {
    type: Object
  },
  admin_users_prop: {
    type: Array
  },
  predialysis: {
    type: Object
  },
  prescription_prop: {
    type: Object
  }
},
components:{
  InforSubMenu
},
data () {
  return {
    activeNames: '1',
    creater: this.$store.getters.user.admin.id,
    modifier: '',
    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.user.admin.id,
      modifier: '',
      created_time: 0,
      updated_time: 0,
      check_time: 0,
      first_check_time: 0,
      employee_number: '',
      dialyzer_batch_number:"",
      needle_batch_number:"",
    },
    check_time: new Date(),
    first_check_time: new Date(),
    check_time_str: '',
    first_check_time_str: '',
    dialysateFormulationOptions: [],
    result: [],
    resultOne: [],
    resultTwo: [],
    resultThree: [],
    resultFour: [],

    changeDoubleReview: 0,
    isCommit: true,
    infor_visibility:false,
  }
},
computed: {
  newDoubleReview () {
    return JSON.parse(JSON.stringify(this.doubleReview))
  }
},
created () {
  this.org_id = this.$store.getters.user.template_info.org_id

  if (this.record.id != 0) {
    if (this.record.dialysis_item_desc.indexOf('透析器/灌流器') != -1) {
      this.result.push('a')
    }

    if (this.record.dialysis_item_desc.indexOf('穿刺针') != -1) {
      this.result.push('b')
    }
    if (this.record.dialysis_item_desc.indexOf('透析液配方') != -1) {
      this.result.push('c')
    }

    if (this.record.dialysis_item_desc.indexOf('钾') != -1) {
      this.result.push('d')
    }

    if (this.record.dialysis_item_desc.indexOf('钾') != -1) {
      this.result.push('e')
    }

    if (this.record.dialysis_parameter_desc.indexOf('透析模式') != -1) {
      this.resultOne.push('a')
    }
    if (this.record.dialysis_parameter_desc.indexOf('透析时长') != -1) {
      this.resultOne.push('b')
    }
    if (this.record.dialysis_parameter_desc.indexOf('目标超滤量') != -1) {
      this.resultOne.push('c')
    }
    if (this.record.dialysis_parameter_desc.indexOf('抗凝剂') != -1) {
      this.resultOne.push('d')
    }
    if (this.record.dialysis_parameter_desc.indexOf('首剂') != -1) {
      this.resultOne.push('e')
    }
    if (this.record.dialysis_parameter_desc.indexOf('维持') != -1) {
      this.resultOne.push('f')
    }
    if (this.record.dialysis_parameter_desc.indexOf('总量') != -1) {
      this.resultOne.push('g')
    }
    if (this.record.dialysis_parameter_desc.indexOf('置换液') != -1) {
      this.resultOne.push('h')
    }
    if (this.record.dialysis_parameter_desc.indexOf('置换总量') != -1) {
      this.resultOne.push('i')
    }
    if (this.record.dialysis_parameter_desc.indexOf('处方血流量') != -1) {
      this.resultOne.push('j')
    }
    if (this.record.dialysis_parameter_desc.indexOf('透析液流量') != -1) {
      this.resultOne.push('k')
    }
    if (this.record.dialysis_parameter_desc.indexOf('置换液总量') != -1) {
      this.resultOne.push('l')
    }

    if (this.record.vascular_access_desc.indexOf('通路类型') != -1) {
      this.resultTwo.push('a')
    }
    if (this.record.vascular_access_desc.indexOf('动静脉接错') != -1) {
      this.resultTwo.push('b')
    }
    if (this.record.vascular_access_desc.indexOf('渗血') != -1) {
      this.resultTwo.push('c')
    }
    if (this.record.vascular_access_desc.indexOf('压迫') != -1) {
      this.resultTwo.push('d')
    }
    if (this.record.vascular_access_desc.indexOf('折叠') != -1) {
      this.resultTwo.push('e')
    }
    if (this.record.vascular_access_desc.indexOf('滑脱') != -1) {
      this.resultTwo.push('f')
    }

    if (this.record.pipeline_connection_desc.indexOf('泵前补液测管未夹') != -1) {
      this.resultThree.push('a')
    }
    if (this.record.pipeline_connection_desc.indexOf('肝素管夹未开启') != -1) {
      this.resultThree.push('b')
    }
    if (this.record.pipeline_connection_desc.indexOf('透析液连接错误') != -1) {
      this.resultThree.push('c')
    }
    if (this.record.pipeline_connection_desc.indexOf('动静脉壶页面不标准') != -1) {
      this.resultThree.push('d')
    }
    if (this.record.pipeline_connection_desc.indexOf('静脉管道未夹入保护夹') != -1) {
      this.resultThree.push('e')
    }
    if (this.record.pipeline_connection_desc.indexOf('压力传感器夹未打开') != -1) {
      this.resultThree.push('f')
    }
    if (this.record.pipeline_connection_desc.indexOf('接口连接松动') != -1) {
      this.resultThree.push('i')
    }
    if (this.record.pipeline_connection_desc.indexOf('管路打折') != -1) {
      this.resultThree.push('j')
    }
    if (this.record.pipeline_connection_desc.indexOf('肝素补液口未双保险夹闭') != -1) {
      this.resultThree.push('k')
    }
  }

  this.admin_users = this.admin_users_prop
  if (this.record.id == '') {
    this.doubleReview.dialysis_item_check = '1'
    this.doubleReview.dialysis_parameter_check = '1'
    this.doubleReview.vascular_access_verification = '1'
    this.doubleReview.pipeline_connection_check = '1'
    this.doubleReview.dialysis_item_desc = ''
    this.doubleReview.dialysis_parameter_desc = ''
    this.doubleReview.vascular_access_desc = ''
    this.doubleReview.pipeline_connection_desc = ''
    this.doubleReview.needle_batch_number = ""
    this.doubleReview.dialyzer_batch_number = ""
  } else {
    this.doubleReview.dialysis_item_check =
          this.record.dialysis_item_check + ''
    this.doubleReview.dialysis_parameter_check =
          this.record.dialysis_parameter_check + ''
    this.doubleReview.vascular_access_verification =
          this.record.vascular_access_verification + ''
    this.doubleReview.pipeline_connection_check =
          this.record.pipeline_connection_check + ''
    this.doubleReview.dialysis_item_desc = this.record.dialysis_item_desc
    this.doubleReview.dialysis_parameter_desc = this.record.dialysis_parameter_desc
    this.doubleReview.vascular_access_desc = this.record.vascular_access_desc
    this.doubleReview.pipeline_connection_desc = this.record.pipeline_connection_desc

    this.doubleReview.created_time = this.record.created_time
    this.doubleReview.creater = this.record.creater
    this.doubleReview.updated_time = this.record.updated_time
    this.doubleReview.modifier = this.record.modifier

    this.doubleReview.check_time = this.record.check_time
    this.doubleReview.first_check_time = this.record.first_check_time
    this.doubleReview.employee_number = this.record.employee_number
    this.doubleReview.dialyzer_batch_number = this.record.dialyzer_batch_number
    this.doubleReview.needle_batch_number = this.record.needle_batch_number
    this.doubleReview.id = this.record.id

    this.creater = this.record.creater
    this.modifier = this.record.modifier

    this.first_check_time_str = uParseTime(this.doubleReview.first_check_time, '{y}-{m}-{d}  {h}:{i}' + ':00')

    if (this.$store.getters.user.admin.id == this.record.creater || this.record.modifier > 0) {
      if (this.doubleReview.check_time != 0) {
        this.check_time_str = uParseTime(this.doubleReview.check_time, '{y}-{m}-{d}  {h}:{i}' + ':00')
      }
    } else if (this.$store.getters.user.admin.id != this.record.creater && this.record.modifier == 0) {
      this.check_time_str = uParseTime(new Date(), '{y}-{m}-{d}  {h}:{i}' + ':00')
      this.modifier = this.$store.getters.user.admin.id
      this.doubleReview.modifier = this.$store.getters.user.admin.id
    }

  }

  var date = this.$route.query && this.$route.query.date
  date *= 1000
  var newDate = new Date(date)
  var y = newDate.getFullYear()
  var m = newDate.getMonth() + 1
  var d = newDate.getDate()
  if (isNaN(y) || isNaN(m) || isNaN(d)) {
    newDate = new Date()
    y = newDate.getFullYear()
    m = newDate.getMonth() + 1
    d = newDate.getDate()
  }
  this.record_date = y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d)
  this.dialysateFormulationOptions = getDataConfig('hemodialysis', 'dialysate_formulation')
  var obj = []
  for (let i = 0; i < this.admin_map.length; i++) {
    if (this.admin_map[i].status == 1) {
      obj.push(this.admin_map[i])
    }
  }
},
mounted () {
  if (this.record.id == 0) {
    this.first_check_time_str = parseTime(this.check_time, '{y}-{m}-{d} {h}:{i}' + ':00')
    if (this.record.creater && this.$store.getters.user.admin.id != this.record.creater) {
      this.check_time_str = parseTime(this.check_time, '{y}-{m}-{d} {h}:{i}' + ':00')
      this.modifier = this.$store.getters.user.admin.id
    }
    this.doubleReview.check_time = this.check_time_str
    this.doubleReview.first_check_time = this.first_check_time_str
  }

  if(this.org_id == 9671 || this.org_id == 10469){
    this.check_time_str = parseTime(this.check_time, '{y}-{m}-{d} {h}:{i}' + ':00')
  }
},
methods: {
  GetDialysateFormulationById: function (val) {
    let name = ''
    let dfl = this.dialysateFormulationOptions.length
    for (let index = 0; index < dfl; index++) {
      if (this.dialysateFormulationOptions[index].id == val) {
        name = this.dialysateFormulationOptions[index].name
        break
      }
    }
    return name
  },
  getBloodAccess (id) {
    let vascular_access_desc_name = ''
    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
  },
  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'
    }
    if (id == 21) {
      name = 'HD+'
    }
    if (id == 22) {
      name = '血浆胆红素吸附+HDF'
    }
    if (id == 23) {
      name = '血浆胆红素吸附'
    }
    if (id == 24) {
      name = 'I-HDF'
    }
    if (id == 25) {
      name = 'HD高通'
    }
    if (id == 26) {
      name = 'CVVH'
    }
    if (id == 27) {
      name = 'CVVHD'
    }
    if (id == 28) {
      name = 'CVVHDF'
    }
    if (id == 29) {
      name = 'PE'
    }
    if (id == 30) {
      name = '血浆胆红素吸附+HP'
    }
    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 = '低分子肝素钠'
    }
    if (id == 11) {
      name = '那屈肝素'
    }
    return name
  },
  toCheck (val) {

    var arr = []
    var str = val.join(';')

    if (str.indexOf('a') != -1 && this.prescription_prop.id != 0) {
      arr.push('透析器/灌流器/滤过器:' + this.prescription_prop.dialyzer_perfusion_apparatus + "/"+this.prescription_prop.dialysis_strainer)
    }
    if (str.indexOf('a') != -1 && this.prescription_prop.id == 0) {
      arr.push('透析器/灌流器/滤过器:')
    }
    if (str.indexOf('b') != -1 && this.predialysis != null) {
      arr.push('穿刺针:' + (this.predialysis.puncture_needle ? this.predialysis.puncture_needle : ''))
    }
    if (str.indexOf('b') != -1 && this.predialysis == null) {
      arr.push('穿刺针:')
    }
    if (str.indexOf('c') != -1 && this.GetDialysateFormulationById(this.prescription_prop.dialysate_formulation) != null) {
      arr.push('透析液配方:' + this.GetDialysateFormulationById(this.prescription_prop.dialysate_formulation))
    }
    if (str.indexOf('d') != -1 && this.prescription_prop.id != 0) {
      arr.push('钾:' + this.prescription_prop.kalium)
    }
    if (str.indexOf('d') != -1 && this.prescription_prop.id == 0) {
      arr.push('钾:')
    }
    if (str.indexOf('e') != -1 && this.prescription_prop.id != 0) {
      arr.push('钙:' + this.prescription_prop.calcium)
    }
    if (str.indexOf('e') != -1 && this.prescription_prop.id == 0) {
      arr.push('钙:')
    }
    this.doubleReview.dialysis_item_desc = arr.join(';')
    if (val.length == 0) {
      this.doubleReview.dialysis_item_check = '1'
    } else {
      this.doubleReview.dialysis_item_check = 2
    }
  },
  toCheckOne (val) {
    var arr = []
    var str = val.join(';')
    if (str.indexOf('a') != -1 && this.prescription_prop.id != 0) {
      arr.push('透析模式:' + this.getMode(this.prescription_prop.mode_id))
    }
    if (str.indexOf('a') != -1 && this.prescription_prop.id == 0) {
      arr.push('透析模式:')
    }
    if (str.indexOf('b') != -1 && this.prescription_prop.id != 0) {
      arr.push('透析时长:' + (this.prescription_prop.dialysis_duration ? this.prescription_prop.dialysis_duration : ''))
    }
    if (str.indexOf('b') != -1 && this.prescription_prop.id == 0) {
      arr.push('透析时长:')
    }

    if (str.indexOf('c') != -1 && this.prescription_prop.id != 0) {
      arr.push('目标超滤量:' + this.prescription_prop.target_ultrafiltration)
    }
    if (str.indexOf('c') != -1 && this.prescription_prop.id == 0) {
      arr.push('目标超滤量:')
    }

    if (str.indexOf('m') != -1 && this.prescription_prop.id != 0) {
        arr.push('处方脱水量:' + this.prescription_prop.prescription_water)
      }
      if (str.indexOf('m') != -1 && this.prescription_prop.id == 0) {
        arr.push('处方脱水量:')
      }

    if (str.indexOf('d') != -1 && this.prescription_prop.id != 0) {
      arr.push('抗凝剂:' + this.getAnticoagulant(this.prescription_prop.anticoagulant))
    }
    if (str.indexOf('d') != -1 && this.prescription_prop.id == 0) {
      arr.push('抗凝剂:')
    }
    if (str.indexOf('e') != -1 && this.prescription_prop.id != 0) {
      arr.push('首剂:' + (this.prescription_prop.anticoagulant_shouji ? this.prescription_prop.anticoagulant_shouji : ''))
    }
    if (str.indexOf('e') != -1 && this.prescription_prop.id == 0) {
      arr.push('首剂:')
    }
    if (str.indexOf('f') != -1 && this.prescription_prop.id != 0) {
      arr.push('维持:' + (this.prescription_prop.anticoagulant_weichi ? this.prescription_prop.anticoagulant_weichi : ''))
    }
    if (str.indexOf('f') != -1 && this.prescription_prop.id == 0) {
      arr.push('维持:')
    }
    if (str.indexOf('g') != -1 && this.prescription_prop.id != 0) {
      arr.push('总量:' + (this.prescription_prop.anticoagulant_zongliang ? this.prescription_prop.anticoagulant_zongliang : ''))
    }
    if (str.indexOf('g') != -1 && this.prescription_prop.id == 0) {
      arr.push('总量:')
    }

    if (str.indexOf('h') != -1 && this.prescription_prop.id != 0) {
      arr.push('置换液:' + (this.prescription_prop.displace_liqui_part ? this.prescription_prop.displace_liqui_part : ''))
    }
    if (str.indexOf('h') != -1 && this.prescription_prop.id == 0) {
      arr.push('置换液:')
    }
    if (str.indexOf('i') != -1 && this.prescription_prop.id != 0) {
      arr.push('置换总量:' + (this.prescription_prop.replacement_total ? this.prescription_prop.replacement_total : ''))
    }
    if (str.indexOf('i') != -1 && this.prescription_prop.id == 0) {
      arr.push('置换总量:')
    }
    if (str.indexOf('j') != -1 && this.prescription_prop.id != 0) {
      arr.push('处方血流量:' + (this.prescription_prop.blood_flow_volume ? this.prescription_prop.blood_flow_volume : ''))
    }
    if (str.indexOf('j') != -1 && this.prescription_prop.id == 0) {
      arr.push('处方血流量:')
    }
    if (str.indexOf('k') != -1 && this.prescription_prop.id != 0) {
      arr.push('透析液流量:' + (this.prescription_prop.dialysate_flow ? this.prescription_prop.dialysate_flow : ''))
    }
    if (str.indexOf('k') != -1 && this.prescription_prop.id == 0) {
      arr.push('透析液流量:')
    }
    if (str.indexOf('l') != -1 && this.prescription_prop.id != 0) {
      arr.push('置换液总量:' + (this.prescription_prop.displace_liqui_value ? this.prescription_prop.displace_liqui_value : ''))
    }
    if (str.indexOf('l') != -1 && this.prescription_prop.id == 0) {
      arr.push('置换液总量:')
    }

    this.doubleReview.dialysis_parameter_desc = arr.join(';')
    if (val.length == 0) {
      this.doubleReview.dialysis_parameter_check = '1'
    } else {
      this.doubleReview.dialysis_parameter_check = 2
    }
  },
  toCheckTwo (val) {
    var arr = []
    var str = val.join(';')
    if (str.indexOf('a') != -1) {
      arr.push('通路类型:' + this.getBloodAccess(this.predialysis.blood_access_part_opera_id))
    }
    if (str.indexOf('b') != -1) {
      arr.push('动静脉接错:')
    }
    if (str.indexOf('c') != -1) {
      arr.push('渗血')
    }
    if (str.indexOf('d') != -1) {
      arr.push('压迫')
    }
    if (str.indexOf('e') != -1) {
      arr.push('折叠')
    }
    if (str.indexOf('f') != -1) {
      arr.push('滑脱')
    }
    this.doubleReview.vascular_access_desc = arr.join(';')
    if (val.length == 0) {
      this.doubleReview.vascular_access_verification = '1'
    } else {
      this.doubleReview.vascular_access_verification = 2
    }
  },
  toCheckThree (val) {
    var arr = []
    var str = val.join(';')
    if (str.indexOf('a') != -1) {
      arr.push('泵前补液测管未夹:')
    }
    if (str.indexOf('b') != -1) {
      arr.push('肝素管夹未开启')
    }
    if (str.indexOf('c') != -1) {
      arr.push('透析液连接错误')
    }
    if (str.indexOf('d') != -1) {
      arr.push('动静脉壶页面不标准')
    }
    if (str.indexOf('e') != -1) {
      arr.push('静脉管道未夹入保护夹')
    }
    if (str.indexOf('f') != -1) {
      arr.push('压力传感器夹未打开')
    }
    if (str.indexOf('i') != -1) {
      arr.push('接口连接松动')
    }
    if (str.indexOf('j') != -1) {
      arr.push('管路打折')
    }
    if (str.indexOf('k') != -1) {
      arr.push('肝素补液口未双保险夹闭')
    }
    this.doubleReview.pipeline_connection_desc = arr.join(';')
    if (val.length == 0) {
      this.doubleReview.pipeline_connection_check = '1'
    } else {
      this.doubleReview.pipeline_connection_check = 2
    }
  },
  changeRadio (val) {
    if (val == 1) {
      this.doubleReview.dialysis_item_desc = ''
      this.result = []
    }
  },
  changeRadioOne (val) {
    if (val == 1) {
      this.doubleReview.dialysis_parameter_desc = ''
      this.resultOne = []
    }
  },
  changeRadioTwo (val) {
    if (val == 1) {
      this.doubleReview.vascular_access_desc = ''
      this.resultTwo = []
    }
  },
  changeRadioThree (val) {
    if (val == 1) {
      this.doubleReview.pipeline_connection_desc = ''
      this.resultThree = []
    }
  },
  selectFirstCheckTimeAction: function () {
    this.$refs.first_check_time_picker.open()
  },
  selectSecondCheckTimeAction: function () {
    this.$refs.second_check_time_picker.open()
  },
  didSelectFirstCheckTime: function (time) {
    this.first_check_time_str = parseTime(time, '{y}-{m}-{d} {h}:{i}' + ':00')
  },
  didSelectCheckTime: function (time) {
    this.check_time_str = parseTime(time, '{y}-{m}-{d} {h}:{i}' + ':00')
  },
  getFirstCheckDesc: function () {
    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.record.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
      }
    }
  },
getArrEqual(arr1, arr2) {

    let newArr = [];
    for (let i = 0; i < arr2.length; i++) {
      for (let j = 0; j < arr1.length; j++) {
          if (arr1[j].module == 8 &&arr1[j].is_show == 1 && arr1[j].filed_name == arr2[i][0]&&arr1[j].is_write == 1) {
            newArr.push(arr1[j]);
          }
      }
    }
    return newArr;
  },

  open_tips(info) {
    for (let i = 0; i < info.length; i++) {
      if (info[i].is_write == 1) {

        Toast.fail(`${info[i].filed_name_cn}为必填字段，不能为空`)
      }else {
        return;
      }
    }
  },
  commitInfo: function () {
      if (this.isCommit == true) {
      // this.isCommit = false
      var first_time = new Date(this.first_check_time_str).getTime()
      var second_time = new Date(this.check_time_str).getTime()

      if(this.org_id!=9671 && this.org_id!=10469){
        if (first_time >= second_time) {
          Toast.fail('第一次核对时间不能大于或等于第二次核对时间')
          this.isCommit = true
          return
        }
      }

      if (this.doubleReview.creater == this.doubleReview.modifier) {
        Toast.fail('第一次核对人和第二次核对人不能是同一个人')
        this.isCommit = true
        return
      }

      this.doubleReview.check_time = this.check_time_str
      this.doubleReview.first_check_time = this.first_check_time_str


      let ParamsQuery = this.doubleReview

      ParamsQuery['mode'] = '1'
      ParamsQuery['patient'] = this.$route.query.patient_id
      ParamsQuery['record_date'] = this.record_date
      ParamsQuery['employee_number'] = this.doubleReview.employee_number
      ParamsQuery['dialyzer_batch_number'] = this.doubleReview.dialyzer_batch_number
      ParamsQuery['needle_batch_number'] = this.doubleReview.needle_batch_number

      if (this.record.id > 0) {
        ParamsQuery['mode'] = '2'
      }
          // 必填弹窗开始
        let result = [];
        let filedList = this.$store.getters.user.fileds;
        let new_arr = Object.entries(ParamsQuery);
        new_arr.forEach((el) => {
          if (el[1] === "" || el[1] == 0 || el[1] == "0") {
            // result.push(el);
            result.unshift(el)
          }
        });

        let warnarr = [];
        warnarr = this.getArrEqual(filedList, result);
        if (warnarr.length > 0) {
           this.open_tips(warnarr);
          // 必填弹窗结束
        } else{
          Toast.loading({forbidClick: true, duration: 0})
          commitDoubleCheck(ParamsQuery).then(response => {
        if (response.data.state == 0) {
          // this.$toast({message: respons51 e.data.msg});
          Toast.fail(response.data.msg)
           if(response.data.code == 600000008){
              this.infor_visibility = true
           }
          this.isCommit = true
          return false
        } else {
          if (response.data.data.msg == 2) {
            Toast.fail('请输入正确工号!')
            this.isCommit = true
            this.doubleReview.first_check_time = response.data.data.doubleCheck.first_check_time
            this.doubleReview.check_time_str = response.data.data.doubleCheck.check_date
            return false
          } else {
            Toast.success('提交成功')
            // this.record = Object.assign({}, response.data.data.doubleCheck);
            this.doubleReview = Object.assign({}, response.data.data.doubleCheck)
            this.doubleReview['dialysis_item_check'] = this.doubleReview['dialysis_item_check'].toString()
            this.doubleReview['dialysis_parameter_check'] = this.doubleReview['dialysis_parameter_check'].toString()
            this.doubleReview['vascular_access_verification'] = this.doubleReview['vascular_access_verification'].toString()
            this.doubleReview['pipeline_connection_check'] = this.doubleReview['pipeline_connection_check'].toString()

            this.$emit('did_update', response.data.data.doubleCheck)

          }
          this.changeDoubleReview = 0
          this.isCommit = true
        }
      }).catch(error => {
        this.changeDoubleReview = 0
        Toast.fail('请求失败')
        this.isCommit = true
      })
        }

    }


  },
  isObjectValueEqual (a, b) {
    // 取对象a和b的属性名
    var aProps = Object.getOwnPropertyNames(a)
    var bProps = Object.getOwnPropertyNames(b)
    // 判断属性名的length是否一致
    if (aProps.length != bProps.length) {
      return false
    }
    // 循环取出属性名，再判断属性值是否一致
    for (var i = 0; i < aProps.length; i++) {
      var propName = aProps[i]
      if (a[propName] !== b[propName]) {
        return false
      }
    }
    return true
  },
  isShow (name) {
    var filedList = this.$store.getters.user.fileds

    for (let i = 0; i < filedList.length; i++) {
      if (filedList[i].module == 8 && filedList[i].filed_name_cn == name && filedList[i].is_show == 1) {
        return true
      }
    }
    return false
  },
  isShow_title (name) {
    var filedList = this.$store.getters.user.fileds

    for (let i = 0; i < filedList.length; i++) {
      if (filedList[i].module == 8 && filedList[i].filed_name_cn == name && filedList[i].is_show == 1&&
        filedList[i].is_write == 1) {
        return true
      }
    }
    return false
  },
  inputFocus: function (event) {
    var input = event.target
    setTimeout(function () {
      input.scrollIntoView()
    }, 0)

    if (input.setSelectionRange) {
      setTimeout(function () {
        input.setSelectionRange(0, input.value.length)
      }, 0)
    } else if (input.createTextRange) {
      var rng = input.createTextRange()
      rng.move('character', input.value.length)
      rng.select()
    }
  },
  changeRole (admin_user_id) {
    this.job_number = ''
    var params = {
      admin_user_id: admin_user_id
    }
    getRoleList(params).then(response => {
      if (response.data.state == 1) {
        var list = response.data.data.list
        this.job_number = list.job_number
      }
    })
  },

 menuComfirmFour:function(start_time,remark){
     var params = {
       patient_id:this.$route.query.patient_id,
       record_date:this.$route.query.date,
       start_time:start_time,
       module:5,
       remark:remark,
     }

    saveMobileInformation(params).then(response=>{
      if(response.data.state == 1){
         this.infor_visibility = false
         Toast.success('申请成功')
      }
    })
  },
  menuCancleFour:function(){
   this.infor_visibility = false

  },
},
watch: {
  newDoubleReview: {
    handler (newVal, oldVal) {
      if (!this.isObjectValueEqual(newVal, oldVal)) {
        this.changeDoubleReview++
      }
    },
    deep: true
  }
}
}
</script>

<style lang="scss" scoped>
.doubleCheck{
  display: flex;
  flex-direction: column;
  height: 100%;
  >:first-child{
      flex: 1;
      overflow-y: auto;
  }
  .van-checkbox-group{
      padding: 0.625rem 1rem;
      font-size: .875rem;

  }
  .van-cell__label{
      font-size: .875rem;
  }
  .van-checkbox{
      margin-bottom: .625rem;
  }
  .doctorList{
      display: flex;
      flex-wrap: wrap;
      .van-radio{
          width: 50%;
          margin-bottom: .625rem;
      }
  }
  .preserveBox{
      height: 3.125rem;
      display: flex;
      justify-content: space-between;
      padding: 0 1rem;
      align-items: center;
      font-size: 1rem;

      >:first-child{
          text-align: center;
          height: 2.5rem;
          width: 100%;
          line-height: 2.5rem;
          background: #409eff;
          color:#fff;
          border-radius: 4px;
      }
  }
  .disabled{
      background: #D8D8D8 !important;
  }
}
</style>

<style lang="scss" scoped>
.doubleCheck{
  .datetimePicker{
      z-index: 4010 !important;
       .picker{
        // background: red !important;
      }

      .picker-item{
          font-size: .875rem !important;
          height: 44px;
          line-height: 44px;
          .picker-slot{
            .picker-slot-wrapper{
              .picker-item{
                font-size: 1.125rem !important;
              }
            }
          }

      }
      .mint-datetime-action{
          font-size: .9375rem !important;
      }

  }
}

.picker-item {
  font-size: 1.125rem;
}
</style>

<style lang="less" scoped>
.doubleCheck{
  .datetimePicker{
      z-index: 4010 !important;
      /deep/ .picker{
        // background: red !important;
      }

      .picker-item{
          font-size: .875rem !important;
          height: 44px;
          line-height: 44px;
          .picker-slot{
            .picker-slot-wrapper{
              .picker-item{
                font-size: 1.125rem !important;
              }
            }
          }

      }
      .mint-datetime-action{
          font-size: .9375rem !important;
      }

  }
}
.warn_tip{
color: red;
}
</style>
