<template>
  <div>
    <div class="Dialog" v-show="!selecting">
      <div class="DialogTit">
        <span @click="close()" class="iconfont">&#xe6e9;</span>
        <h1 class="name" style="flex: 2;">透析上机</h1>
        <!-- <span class="success" v-if="this.record.id == 0"></span>
        <span class="success" @click="modify()" v-else>修改</span> -->
      </div>
      <div class="warnTxt" v-if="showTxt != ''">
        {{ showTxt }}
      </div>

      <div class="DialogContent newDialogContent">
 
        <van-collapse v-model="activeNames" accordion @change="showSubMenu">
          <van-collapse-item v-if="isShowFiled('班次')" title="班次" name="1">
            <template #value>
              <div>{{ getSchedualType(schedual_type) }}</div>
            </template>
            <van-radio-group v-model="schedual_type" @change="selectType">
              <van-radio
                :name="item.id"
                v-for="(item, index) in schedules_type"
                :key="index"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('上机床位')"
            title="上机分区"
            name="2"
          >
            <template #value>
              <div
                v-if="item.zone_id == zoneId"
                v-for="(item, index) in zoneData"
              >
                {{ item.zone_name }}
              </div>
              <div v-if="zoneId == 0">{{ getBedId(bed_id) }}</div>
            </template>
            <van-radio-group v-model="zoneId" @change="changeZone">
              <van-radio
                :name="item.zone_id"
                v-for="(item, index) in zoneData"
                :key="index"
              >
                {{ item.zone_name }}
              </van-radio>
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('上机床位')"
            title="上机床位"
            name="9"
          >
            <template #value>
              <div v-if="device_number_map[bedId]">
                {{ device_number_map[bedId].number }}
              </div>
            </template>
            <van-radio-group v-model="bedId" @change="changeBed">
              <van-radio
                :name="item.id"
                v-for="(item, index) in bedData"
                :key="index"
                >{{ item.number }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('上机护士') && org_id!=10721"
            title="上机护士"
            name="3"
          >
            <template #value>
              <div v-if="admin_map[nurse_id]">
                {{ admin_map[nurse_id].name }}
              </div>
            </template>
            <van-radio-group v-model="nurse_id">
              <van-radio
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>

          <van-collapse-item
            v-if="isShowFiled('上机护士') && org_id == 10721"
            title="治疗护士"
            name="3"
          >
            <template #value>
              <div v-if="admin_map[nurse_id]">
                {{ admin_map[nurse_id].name }}
              </div>
            </template>
            <van-radio-group v-model="nurse_id">
              <van-radio
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('穿刺者')"
            title="穿刺者"
            name="4"
          >
            <template #value>
              <div v-if="admin_map[puncture_nurse_id]">
                {{ admin_map[puncture_nurse_id].name }}
              </div>
            </template>
            <van-radio-group v-model="puncture_nurse_id">
              <van-radio name="-2" key="-2">请选择</van-radio>
              <van-radio
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('质控护士')"
            title="质控护士"
            name="20"
          >
            <template #value>
              <div v-if="admin_map[quality_nurse_id]">
                {{ admin_map[quality_nurse_id].name }}
              </div>
            </template>
            <van-radio-group v-model="quality_nurse_id">
              <van-radio name="-2" key="-2">请选择</van-radio>
              <van-radio
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('换药护士')"
            title="换药护士"
            name="5"
          >
            <template #value>
              <div v-if="admin_map[change_nurse]">
                {{ admin_map[change_nurse].name }}
              </div>
            </template>
            <van-radio-group v-model="change_nurse">
              <van-radio name="-2" key="-2">请选择</van-radio>
              <van-radio
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            class="newBorder"
            v-if="isShowFiled('冲管护士')"
            title="冲管护士"
            name="6"
          >
            <template #value>
              <div v-if="admin_map[washpipe_nurse]">
                {{ admin_map[washpipe_nurse].name }}
              </div>
            </template>
            <van-radio-group v-model="washpipe_nurse">
              <van-radio name="-2" key="-2">请选择</van-radio>
              <van-radio
                @click="changeToggle(item.id)"
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('疑难穿刺护士')"
            title="疑难穿刺护士"
            name="7"
          >
            <template #value>
              <div v-if="admin_map[difficult_puncture_nurse]">
                {{ admin_map[difficult_puncture_nurse].name }}
              </div>
            </template>
            <van-radio-group v-model="difficult_puncture_nurse">
              <van-radio name="-2" key="-2">请选择</van-radio>
              <van-radio
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('新开瘘护士')"
            title="新开瘘护士"
            name="8"
          >
            <template #value>
              <div v-if="admin_map[new_fistula_nurse]">
                {{ admin_map[new_fistula_nurse].name }}
              </div>
            </template>
            <van-radio-group v-model="new_fistula_nurse">
              <van-radio name="-2" key="-2">请选择</van-radio>
              <van-radio
                :name="item.id"
                v-for="(item, index) in admins"
                :key="index"
                v-if="item.status == 1"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>

          <van-collapse-item
            v-if="isShowFiled('穿刺针')"
            title="穿刺针"
            name="puncture_needle"
          >
            <template #value>
              <div>{{ puncture_needle }}</div>
            </template>

            <checkBoxMenu
              v-if="checkBoxShow"
              v-on:menu-comfirm="getString"
              :propsForm="propForm"
            ></checkBoxMenu>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('穿刺方式')"
            title="穿刺方式"
            name="puncture_way"
          >
            <template #value>
              <div>{{ puncture_way }}</div>
            </template>
            <checkBoxMenu
              v-if="checkBoxShow"
              v-on:menu-comfirm="getString"
              :propsForm="propForm"
            ></checkBoxMenu>
          </van-collapse-item>

          <van-collapse-item
            v-if="isShowFiled('透析器')"
            title="透析器"
            name="15"
          >
            <template #value>
              <div>{{ dialysis_dialyszers }}</div>
            </template>
            <van-radio-group v-model="dialysis_dialyszers">
              <van-radio name="" key="-2">请选择</van-radio>
              <van-radio
                :name="item.specification_name"
                v-for="(item, index) in dialysisDialyszers"
                :key="index"
                >{{ item.specification_name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>
          <van-collapse-item
            v-if="isShowFiled('灌流器')"
            title="灌流器"
            name="16"
          >
            <template #value>
              <div>{{ dialysis_irrigation }}</div>
            </template>
            <van-radio-group v-model="dialysis_irrigation">
              <van-radio name="" key="-2">请选择</van-radio>
              <van-radio
                :name="item.specification_name"
                v-for="(item, index) in dialysisIrrigation"
                :key="index"
                >{{ item.specification_name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>

          <van-collapse-item
            v-if="isShowFiled('血管通路')"
            title="血管通路"
            name="10"
          >
            <template #value>
              <div>{{ getBloodAccessTwo(blood_access_id) }}</div>
            </template>
            <van-radio-group v-model="blood_access_id">
              <van-radio name="-2" key="-2">请选择</van-radio>
              <van-radio
                :name="item.id"
                v-for="(item, index) in bloodAccessOptions"
                :key="index"
                >{{ item.name }}</van-radio
              >
            </van-radio-group>
          </van-collapse-item>


          <van-cell title='导管备注' v-if="isShowFiled('导管备注')" @click="summaryShow = true" is-link value="请选择"></van-cell>
            <van-popup v-model="summaryShow" get-container="#app" class="listBoxPopup newListBoxPopupApp" style="z-index:5000">
                <div class="listBox">
                    <div @click="toSummary('')">请选择</div>
                    <div v-for="(item,index) in summary" :key="index" @click="toSummary(item.id)">{{ item.text }}</div>
                </div>
            </van-popup>
          <van-field class="bgField" v-if="isShowFiled('导管备注')" v-model="catheter_operation" rows="1" autosize type="textarea" placeholder="请输入"/>



          <van-field
            v-model="blood_drawing"
            v-if="isShowFiled('引血')"
            label="引血"
            input-align="right"
          />

          <van-field
            v-if="isShowFiled('核酸检测日期')"
            v-model="nuclein_date_str"
            readonly
            @click="selectNucleinDateAction"
            label="核酸检测日期"
            input-align="right"
          />

         <van-field v-model="schedule_remark" @focus="inputFocus" v-if="isShowFiled('排班备注')" label="排班备注"  input-align="right"/>
         <van-field v-model="order_remark" @focus="inputFocus" v-if="isShowFiled('上机备注')" label="上机备注"  input-align="right"/>

          <van-field
            v-model="start_time_str"
            readonly
            @click="selectStartTimeAction"
            label="上机时间"
            input-align="right"
          />
        </van-collapse>
      </div>
    </div>

   <div class="perform" v-show="!selecting">
          <button
            @click="commitInfo"
            v-if="(record == null || record.id == '')"
          >
            执行上机
          </button>
         <!-- <button @click="modify" v-if="this.record.id != 0">修改上机</button> -->
     </div>

    <two-menu ref="selector"></two-menu>
    <mt-datetime-picker
      class="datetimePicker double_check_dialog"
      ref="start_time_picker"
      type="datetime"
      @confirm="didSelectStartTime"
      v-model="start_time"
    ></mt-datetime-picker>

    <mt-datetime-picker
      class="datetimePicker double_check_dialog"
      ref="nuclein_date_picker"
      type="date"
      @confirm="didNucleinDateTime"
      v-model="nuclein_date"
    ></mt-datetime-picker>
    <!-- <check-box-sub-menu
      v-on:menu-cancle="menuCancle"
      v-on:menu-comfirm="menuComfirm"
      v-on:menu-empty="menuEmpty"
      :propsForm="propForm"
    ></check-box-sub-menu> -->

   <infor-sub-menu
      :visibility="infor_visibility"
      v-on:menu-cancle-three="menuCancleFour"
      v-on:menu-comfirm-three="menuComfirmFour"
      >
     </infor-sub-menu>
  </div>
</template>

<script>
import axios from 'axios'
import { getDataConfig } from '@/utils/data'
import CheckBoxSubMenu from './subMenu/checkBoxSubMenu'
import {GetSchedualNumber, PostModifyStartDialysis, startDialysis,saveMobileInformation} from '@/api/dialysis'
import {Dialog, Toast} from 'vant'
import {parseTime} from '@/utils'
import InforSubMenu from './subMenu/InforSubMenu'
import TwoMenu from './TwoMenu'
import request from '@/utils/request'
import checkBoxMenu from './components/checkBoxMenu'
import { setRem } from '@/libs/functionRem'
import { getToken } from '@/api/qiniu'
import { uParseTime } from '@/utils/tools'
import {checkSch} from '../../../api/dialysis'
const moment = require('moment')

export default {
  name: 'ComputerDialog',
  components: {
    TwoMenu,
    CheckBoxSubMenu,
    checkBoxMenu,
    InforSubMenu
  },
  data () {
    return {
      showTxt: '',
      checkBoxShow: false,
      hasPermission: true,
      start_time: new Date(),
      selecting: false,
      start_time_str: '',
      bed_id: 0,
      isShow: false,
      nurse_id: 0,
      puncture_nurse_id: 0,
      washpipe_nurse: 0,
      change_nurse: 0,
      difficult_puncture_nurse: 0,
      new_fistula_nurse: 0,
      zone_beds: [], // 该排班的区里的床位
      creator: 0,
      template_id: 0,
      temp_device_numbers: [],
      blood_drawing: 100,
      schedual_type: 0,
      schedules_type: [
        { id: 1, name: '上午' },
        { id: 2, name: '下午' },
        { id: 3, name: '晚上' }
      ], // 该排班的区里的床位
      punctureNeedleOptions: [],
      punctureWayOptions: [],
      puncture_needle: '',
      puncture_way: '',
      propForm: {
        title: '',
        list: [],
        optionList: [],
        isMultiple: 2,
        result: [], // 选中的值
        type: 1, // 用来区分不同子菜单，方便对返回值进行赋值
        selectId: 0,
        isHasOther: 1 // 是否有其他选项  1是 2否
      },
      visibility: false,
      dialysis_dialyszers: '',
      dialyszers: [],
      irrigation: [],
      dialysis_irrigation: '',
      blood_access_id: '',
      vascularAccessDescList: [],
      nuclein_date_str: moment(new Date()).format('YYYY-MM-DD'),
      nuclein_date: new Date(),
      electronicsignature: '',
      quality_nurse_id: '',
      zone_id: '',
      zoneData: [],
      zoneId: 0,
      bedId: 0,
      org_id: 0,
      zoneList: [],
      bedData: [],
      bloodAccessOptions: [],
      dialysisDialyszers: [],
      dialysisIrrigation: [],
      activeNames: '',
      uptoken: '',
      schedule_remark: '',
      order_remark: '',
      summary:[],
      catheter_operation:"",
      summaryShow:false,
      infor_visibility:false,
    }
  },
  props: {
    schedule: {
      type: Object
    },
    patient_prop: {
      type: Object
    },
    record: {
      type: Object
    },
    admins: {
      type: Array
    },
    device_numbers: {
      type: Array
    },
    admin_map: {
      type: Object
    },
    device_number_map: {
      type: Object
    },
    special_premission: {
      type: Array
    },
    admin_staff: {
      type: Object
    },
    stockType: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    last_order: {
      type: Object
    },
    patient_index: {
      type: Number
    }
  },
  mounted () {},
  created () {

    // this.getToken()
    // this.getPatientSign()
    this.getPermission()
    this.temp_device_numbers = this.device_numbers

    if (this.record.id == 0) {
      this.isShow = false
      this.start_time_str = parseTime(this.start_time, '{y}-{m}-{d} {h}:{i}') + ':00'
      let now = new Date()
      let hour = now.getHours()

      if (hour >= 6 && hour < 11) {
        this.schedual_type = 1
      } else if (hour >= 11 && hour < 18) {
        this.schedual_type = 2
      } else if (hour >= 18) {
        this.schedual_type = 3
      }
      this.blood_access_id = this.last_order.blood_access_id
      this.puncture_needle = this.last_order.puncture_needle
      this.puncture_way = this.last_order.puncture_way
      this.dialysis_dialyszers = this.last_order.dialysis_dialyszers
      this.dialysis_irrigation = this.last_order.dialysis_irrigation
      this.schedule_remark = this.last_order.schedule_remark
      this.order_remark = this.last_order.order_remark
      if(this.last_order.blood_drawing>0){
        this.blood_drawing = this.last_order.blood_drawing
      }else{
        this.blood_drawing = 100
      }
     
      this.electronicsignature = this.last_order.url

      if (this.last_order.nuclein_date == 0) {
        this.nuclein_date_str = moment(new Date()).format('YYYY-MM-DD')
      } else {
        this.nuclein_date_str = this.getTimeOne(this.last_order.nuclein_date)
      }
    } else {
      this.isShow = true

      if (this.record.start_time == 0) {
        this.start_time_str = parseTime(this.start_time, '{y}-{m}-{d} {h}:{i}') + ':00'
        this.schedual_type = this.record.schedual_type
      } else {
        this.start_time_str = parseTime(this.record.start_time, '{y}-{m}-{d} {h}:{i}') + ':00'
        this.schedual_type = this.record.schedual_type
      }
    }

    this.template_id = this.$store.getters.user.template_info.template_id
    this.org_id = this.$store.getters.user.template_info.org_id
    var date = this.$route.query && this.$route.query.date
    this.patient_id = this.$route.query.patient_id
    this.record_time = 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.bed_id = this.record == null || this.record.id == '' ? this.schedule.bed_id : this.record.bed_id
    console.log('this.bed_id', this.bed_id)

    this.nurse_id =
      this.record == null || this.record.id == ''
        ? this.$store.getters.user.admin.id
        : this.record.start_nurse
    this.puncture_nurse_id =
      this.record == null || this.record.id == ''
        ? this.$store.getters.user.admin.id
        : this.record.puncture_nurse
    this.washpipe_nurse =
      this.record == null || this.record.id == ''
        ? this.$store.getters.user.admin.id
        : this.record.washpipe_nurse
    if (this.org_id == 10340) {
      this.change_nurse =
        this.record == null || this.record.id == ''
          ? this.$store.getters.user.admin.id
          : this.record.change_nurse
      this.difficult_puncture_nurse =
        this.record == null || this.record.id == ''
          ? this.$store.getters.user.admin.id
          : this.record.difficult_puncture_nurse
      this.new_fistula_nurse =
        this.record == null || this.record.id == ''
          ? this.$store.getters.user.admin.id
          : this.record.difficult_puncture_nurse
    }

    if (this.puncture_nurse_id == 0) {
      this.puncture_nurse_id = this.$store.getters.user.admin.id
    }
    this.quality_nurse_id = this.record == null || this.record.id == '' ? this.$store.getters.user.admin.id : this.record.quality_nurse_id
    if (this.record.id > 0) {
      this.change_nurse = this.record.change_nurse
      this.difficult_puncture_nurse = this.record.difficult_puncture_nurse
      this.new_fistula_nurse = this.record.new_fistula_nurse
      this.zone_id = this.record.zone_id
      this.bed_id = this.record.bed_id
      this.schedual_type = this.record.schedual_type
      this.puncture_needle = this.record.puncture_needle
      this.puncture_way = this.record.puncture_way
      this.dialysis_dialyszers = this.record.dialysis_dialyszers
      this.dialysis_irrigation = this.record.dialysis_irrigation
      this.blood_drawing = this.record.blood_drawing
      this.blood_access_id = this.record.blood_access_id

      this.nuclein_date_str = this.getTimeOne(this.record.nuclein_date)
    }

    for (let index = 0; index < this.temp_device_numbers.length; index++) {
      const device_number = this.temp_device_numbers[index]
      this.temp_device_numbers[index]['zoneNumber'] =
        device_number['zone_name'] + '-' + device_number['number']
    }
    this.zone_beds = this.temp_device_numbers
    // console.log('this.zone_beds',this.temp_device_numbers)

    if (this.record.id > 0) {
      if (this.record.creator == 0) {
        this.creator = this.record.start_nurse
      } else {
        this.creator = this.record.creator
      }
    }

    this.schedual_type = this.schedule.schedule_type
    var obj = {id: 0, name: '请选择'}
    this.punctureNeedleOptions.push(obj)

    var arrlist = getDataConfig('hemodialysis', 'puncture_needle')

    for (let i = 0; i < arrlist.length; i++) {
      this.punctureNeedleOptions.push(arrlist[i])
    }

    var arr = []
    var arrTwo = []
    var dialyzer = []
    var irrigation = []
    if (this.stockType.length > 0) {
      for (let i = 0; i < this.stockType.length; i++) {
        if (this.stockType[i].stock_attribute == 2) {
          arr.push(this.stockType[i])
        }
        if (this.stockType[i].stock_attribute == 3) {
          arrTwo.push(this.stockType[i])
        }
      }

      for (let i = 0; i < arr.length; i++) {
        for (let j = 0; j < arr[i].GoodInfo.length; j++) {
          dialyzer.push(arr[i].GoodInfo[j])
        }
      }

      for (let i = 0; i < arrTwo.length; i++) {
        for (let j = 0; j < arrTwo[i].GoodInfo.length; j++) {
          irrigation.push(arrTwo[i].GoodInfo[j])
        }
      }
      this.dialysisDialyszers = dialyzer
      this.dialysisIrrigation = irrigation

      this.bloodAccessOptions = getDataConfig('hemodialysis', 'vascular_access_desc')
    }
    this.summary = getDataConfig('catheter_operation', 'catheter_operation')
    this.GetSchedualNumber()
  },
  methods: {
    getTimeOne (time) {
      return uParseTime(time, '{y}-{m}-{d}')
    },
    isShowFiled (name) {
      var filedList = this.$store.getters.user.fileds

      for (let i = 0; i < filedList.length; i++) {
        if (
          filedList[i].module == 7 &&
          filedList[i].filed_name_cn == name &&
          filedList[i].is_show == 1
        ) {
          return true
        }
      }
      return false
    },
    getSchedualType: function (type) {
      for (let i = 0; i < this.schedules_type.length; i++) {
        if (this.schedules_type[i].id == type) {
          return this.schedules_type[i].name
        }
      }
    },
    select_type: function () {
      if (this.record.id != 0) {
        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          this.schedules_type,
          this.schedual_type,
          '选择班次',
          'name',
          'id',
          function (select_id) {
            t.schedual_type = select_id

            let ParamsQuery = {}
            ParamsQuery['schedual_type'] = select_id
            GetSchedualNumber(ParamsQuery).then((response) => {
              if (response.data.state == 0) {
                Toast.fail(response.data.msg)
                return false
              } else {
                t.temp_device_numbers = response.data.data.number
                for (
                  let index = 0;
                  index < t.temp_device_numbers.length;
                  index++
                ) {
                  const device_number = t.temp_device_numbers[index]
                  t.temp_device_numbers[index]['number'] =
                    device_number['zone_name'] + '-' + device_number['number']
                }
                t.zone_beds = t.temp_device_numbers
                t.bed_id = t.zone_beds[0].id
              }
            })
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        this.schedules_type,
        this.schedual_type,
        '选择班次',
        'name',
        'id',
        function (select_id) {
          t.schedual_type = select_id
          let ParamsQuery = {}
          ParamsQuery['schedual_type'] = select_id
          GetSchedualNumber(ParamsQuery).then((response) => {
            if (response.data.state == 0) {
              Toast.fail(response.data.msg)
              return false
            } else {
              t.zone_beds = []
              t.temp_device_numbers = response.data.data.number
              for (
                let index = 0;
                index < t.temp_device_numbers.length;
                index++
              ) {
                const device_number = t.temp_device_numbers[index]
                t.temp_device_numbers[index]['number'] =
                  device_number['zone_name'] + '-' + device_number['number']
              }
              t.zone_beds = t.temp_device_numbers
              t.bed_id = t.zone_beds[0].id
            }
          })
        },
        function () {
          t.selecting = false
        }
      )
      this.$refs.selector.showSingleSelect(this.schedules_type, this.schedual_type, '选择班次', 'name', 'id', function (select_id) {
        t.schedual_type = select_id
        let ParamsQuery = {}
        ParamsQuery['schedual_type'] = select_id
        GetSchedualNumber(ParamsQuery).then(response => {
          if (response.data.state == 0) {
            Toast.fail(response.data.msg)
            return false
          } else {
            t.zone_beds = []
            t.temp_device_numbers = response.data.data.number
            for (let index = 0; index < t.temp_device_numbers.length; index++) {
              const device_number = t.temp_device_numbers[index]
              t.temp_device_numbers[index]['number'] = device_number['zone_name'] + '-' + device_number['number']
            }
            t.zone_beds = t.temp_device_numbers
            t.bed_id = t.zone_beds[0].id
          }
        })
      }, function () {
        t.selecting = false
      })
    },
    GetSchedualNumber: function () {
      let ParamsQuery = {}
      ParamsQuery['schedual_type'] = this.schedual_type
      ParamsQuery['record_date'] = this.$route.query.date
      GetSchedualNumber(ParamsQuery).then((response) => {
        if (response.data.state == 0) {
          Toast.fail(response.data.msg)
          return false
        } else {
          this.temp_device_numbers = response.data.data.number
          var zonelist = response.data.data.list
          console.log('zonelist33232233232', zonelist)
          this.zoneList = zonelist
          for (
            let index = 0;
            index < this.temp_device_numbers.length;
            index++
          ) {
            const device_number = this.temp_device_numbers[index]
            this.temp_device_numbers[index]['zoneNumber'] =
              device_number['zone_name'] + '-' + device_number['number']
          }
          this.zone_beds = this.temp_device_numbers

          let number = response.data.data.number

          this.zonebedNumber = number
          let zoneData = []
          let bedData = []

          number.map((item) => {
            let status = zoneData.some(
              (it) =>
                it['zone_id'] == item['zone_id'] &&
                it['zone_name'] == item['zone_name']
            )
            if (!status) {
              let obj = {
                zone_id: '',
                zone_name: ''
              }
              obj.zone_id = item.zone_id
              obj.zone_name = item.zone_name
              zoneData.push(obj)
            }
          })

          this.zoneData = zoneData

          number.map((item) => {
            if (
              this.device_number_map[this.bed_id].zone_id == item.zone_id &&
              this.device_number_map[this.bed_id].zone_name == item.zone_name
            ) {
              bedData.push(item)
              this.zoneId = this.device_number_map[this.bed_id].zone_id
            }
          })
          this.bedId = this.device_number_map[this.bed_id].id
          this.bedData = bedData
        }
      })
    },

    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()
      }
    },
    modify () {
      if (this.bedId == 0) {
        Toast.fail('请选择床位号')
        return false
      }
      let ParamsQuery = {}
      if (this.$store.getters.user.admin.id == this.record.creator) {
        ParamsQuery['mode'] = '2'
      } else {
        ParamsQuery['mode'] = '3'
      }
      ParamsQuery['schedual_type'] = this.schedual_type
      ParamsQuery['id'] = this.record.id
      ParamsQuery['start_nurse'] = this.nurse_id
      ParamsQuery['bed'] = this.bed_id
      ParamsQuery['start_time'] = this.start_time_str
      ParamsQuery['puncture_nurse'] = this.puncture_nurse_id
      ParamsQuery['washpipe_nurse'] = this.washpipe_nurse
      ParamsQuery['change_nurse'] = this.change_nurse
      ParamsQuery['difficult_puncture_nurse'] = this.difficult_puncture_nurse
      ParamsQuery['new_fistula_nurse'] = this.new_fistula_nurse
      ParamsQuery['quality_nurse_id'] = this.quality_nurse_id
      ParamsQuery['patient_id'] = this.patient_prop.id
      ParamsQuery['record_date'] = this.record_date
      ParamsQuery['puncture_needle'] = this.puncture_needle
      ParamsQuery['puncture_way'] = this.puncture_way
      ParamsQuery['dialysis_dialyszers'] = this.dialysis_dialyszers
      ParamsQuery['dialysis_irrigation'] = this.dialysis_irrigation
      ParamsQuery['blood_access_id'] = this.blood_access_id
      ParamsQuery['nuclein_date_str'] = this.nuclein_date_str
      ParamsQuery['schedule_remark'] = this.order_remark
      ParamsQuery['order_remark'] = this.order.schedule_remark
      ParamsQuery['catheter_operation'] = this.catheter_operation
      ParamsQuery['blood_drawing'] = this.blood_drawing
      console.log('ParamsQuery', ParamsQuery)

      PostModifyStartDialysis(ParamsQuery)
        .then((response) => {
          if (response.data.state == 0) {
            Toast.fail(response.data.msg)
            if(response.data.code == 600000008){
              this.selecting = true
           
              this.infor_visibility = true
             
             }
            return false
          } else {
            Toast.success('修改成功')
            console.log('修改', response.data.data.dialysis_order)
            this.$emit('did_start', response.data.data.dialysis_order)
            var record = this.record
            console.log('record', this.record)
            for (const key in response.data.data.dialysis_order) {
              this.$set(record, key, response.data.data.dialysis_order[key])
            }
          }
        })
        .catch((error) => {
          Toast.fail('请求失败')
        })
    },
    didSelectStartTime: function (time) {
      this.start_time_str = parseTime(time, '{y}-{m}-{d} {h}:{i}') + ':00'
    },
    selectStartTimeAction: function () {
      if (this.record.id != 0) {
        var creator = 0
        if (this.record.creator == 0) {
          creator = this.record.start_nurse
        } else {
          creator = this.record.creator
        }

        this.$refs.start_time_picker.open()
      }
      this.$refs.start_time_picker.open()
    },
    selectNucleinDateAction () {
      if (this.record.id != 0) {
        var creator = 0
        if (this.record.creator == 0) {
          creator = this.record.start_nurse
        } else {
          creator = this.record.creator
        }

        this.$refs.nuclein_date_picker.open()
      }
      this.$refs.nuclein_date_picker.open()
    },
    selecai: function () {
      if (this.record.id != 0) {
        var creator = 0
        if (this.record.creator == 0) {
          creator = this.record.start_nurse
        } else {
          creator = this.record.creator
        }

        this.$refs.start_time_picker.open()
      }
      this.$refs.start_time_picker.open()
    },
    commitInfo: function () {
      // Toast.loading({forbidClick: true, duration: 0})

      // Toast.loading({forbidClick: true, duration: 0})
      let ParamsQuery = {}
      ParamsQuery['mode'] = '1'
      ParamsQuery['schedual_type'] = this.schedual_type
      ParamsQuery['patient_id'] = this.patient_prop.id
      ParamsQuery['record_date'] = this.record_date
      ParamsQuery['start_nurse'] = this.nurse_id
      ParamsQuery['bed'] = this.bed_id
      ParamsQuery['start_time'] = this.start_time_str
      ParamsQuery['puncture_nurse'] = this.puncture_nurse_id
      ParamsQuery['blood_drawing'] = this.blood_drawing
      ParamsQuery['washpipe_nurse'] = this.washpipe_nurse
      ParamsQuery['change_nurse'] = this.change_nurse
      ParamsQuery['difficult_puncture_nurse'] = this.difficult_puncture_nurse
      ParamsQuery['new_fistula_nurse'] = this.new_fistula_nurse
      ParamsQuery['quality_nurse_id'] = this.quality_nurse_id
      ParamsQuery['zone_id'] = this.zoneId
      ParamsQuery['puncture_needle'] = this.puncture_needle
      ParamsQuery['puncture_way'] = this.puncture_way
      ParamsQuery['dialysis_dialyszers'] = this.dialysis_dialyszers
      ParamsQuery['dialysis_irrigation'] = this.dialysis_irrigation
      ParamsQuery['blood_access_id'] = this.blood_access_id
      ParamsQuery['url'] = this.electronicsignature
      ParamsQuery['nuclein_date_str'] = this.nuclein_date_str
      ParamsQuery['order_remark'] = this.order_remark
      ParamsQuery['schedule_remark'] = this.schedule_remark
      ParamsQuery['catheter_operation'] = this.catheter_operation
      console.log('paras', ParamsQuery)

      console.log('record_date', this.record_date)
    

      if (this.bedId == 0) {
        Toast.fail('请选择床位号')
        return false
      }

      if (this.schedual_type == 0) {
        Toast.fail('请选择班次')
        return false
      }
      if (this.zoneId == 0) {
        Toast.fail('请选择分区')
        return false
      }

      checkSch(ParamsQuery).then(response => {
        if (response.data.state == 0) {
          Toast.fail(response.data.msg)
          return false
        } else {
          if (response.data.data.status == 1) {
            Dialog.confirm({
              message: response.data.data.msg
            }).then(() => {
              startDialysis(ParamsQuery)
                .then((response) => {
                  if (response.data.state == 0) {
                    Toast.fail(response.data.msg)
                   if(response.data.code == 600000008){
                     this.selecting = true
                   
                     this.infor_visibility = true
                    }
                    return false
                  } else {
                    if (this.org_id == 10340 || this.org_id == 3877 || this.org_id == 10164) {
                      this.getPatientSign()
                    }
                    Toast.success('上机成功')
                    var monitor = response.data.data.monitor
                    console.log('监测数据', monitor)
                    var did_start = response.data.data.dialysis_order
                    console.log('did_start', did_start)
                    this.$emit('did_add_monitor', monitor)
                    this.$emit('did_start', did_start)
                    var record = this.record
                    console.log('上机233223', response.data.data.dialysis_order)
                    // this.$parent.newRequestDialysisRecord()
                    for (const key in response.data.data.dialysis_order) {
                      this.$set(record, key, response.data.data.dialysis_order[key])
                    }

                    this.selecting = true
                    console.log('patient_index2oo3o3o23o23o23', this.patient_index)
                    this.$emit('close')
                    this.$emit('open', this.patient_index)
                  }
                }).catch((error) => {
                  Toast.fail('保存成功!')
                  this.selecting = true
                  this.$emit('close')
                // this.$parent.newRequestDialysisRecord()
                })
            })
          } else if (response.data.data.status == 2) {
            Dialog.confirm({
              message: response.data.data.msg
            }).then(() => {

            })
          } else {
            startDialysis(ParamsQuery)
              .then((response) => {
                if (response.data.state == 0) {
                  Toast.fail(response.data.msg)
                   if(response.data.code == 600000008){
                     this.selecting = true
                    
                     this.infor_visibility = true
                    }
                  return false
                } else {
                  if (this.org_id == 10340 || this.org_id == 3877 || this.org_id == 10164) {
                    this.getPatientSign()
                  }
                  Toast.success('上机成功')
                  var monitor = response.data.data.monitor
                  console.log('监测数据', monitor)
                  var did_start = response.data.data.dialysis_order
                  console.log('did_start', did_start)
                  this.$emit('did_add_monitor', monitor)
                  this.$emit('did_start', did_start)
                  var record = this.record
                  console.log('上机233223', response.data.data.dialysis_order)
                  // this.$parent.newRequestDialysisRecord()
                  for (const key in response.data.data.dialysis_order) {
                    this.$set(record, key, response.data.data.dialysis_order[key])
                  }

                  this.selecting = true
                  console.log('patient_index2oo3o3o23o23o23', this.patient_index)
                  this.$emit('close')
                  this.$emit('open', this.patient_index)
                }
              }).catch((error) => {
                Toast.fail('保存成功!')
                this.selecting = true
                this.$emit('close')
              // this.$parent.newRequestDialysisRecord()
              })
          }
        }
      }).catch(error => {
        startDialysis(ParamsQuery)
          .then((response) => {
            if (response.data.state == 0) {
              Toast.fail(response.data.msg)
               if(response.data.code == 600000008){
                  this.infor_visibility = true
               }
              return false
            } else {
              if (this.org_id == 10340 || this.org_id == 3877 || this.org_id == 10164) {
                this.getPatientSign()
              }

              var monitor = response.data.data.monitor
              console.log('监测数据', monitor)
              var did_start = response.data.data.dialysis_order
              console.log('did_start', did_start)
              this.$emit('did_add_monitor', monitor)
              this.$emit('did_start', did_start)
              var record = this.record
              console.log('上机233223', response.data.data.dialysis_order)
              for (const key in response.data.data.dialysis_order) {
                this.$set(record, key, response.data.data.dialysis_order[key])
              }
              Toast.success('上机成功')
            }
          }).catch((error) => {
            console.log('error', error)
            Toast.fail('请求失败')
          })
      })

      // console.log("paras",ParamsQuery)
    },
    close: function () {
      this.$emit('close')
    },
    select_bed: function () {
      if (this.record.id != 0) {
        var creator = 0
        if (this.record.creator == 0) {
          creator = this.record.start_nurse
        } else {
          creator = this.record.creator
        }
        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          this.zone_beds,
          this.bed_id,
          '选择床位号',
          'number',
          'id',
          function (select_id) {
            t.bed_id = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }

      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        this.zone_beds,
        this.bed_id,
        '选择床位号',
        'number',
        'id',
        function (select_id) {
          t.bed_id = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },
    select_nurse: function () {
      if (this.record.id != 0) {
        var creator = 0
        if (this.record.creator == 0) {
          creator = this.record.start_nurse
        } else {
          creator = this.record.creator
        }

        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          this.admins,
          this.nurse_id,
          '选择上机护士',
          'name',
          'id',
          function (select_id) {
            t.nurse_id = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        this.admins,
        this.nurse_id,
        '选择上机护士',
        'name',
        'id',
        function (select_id) {
          t.nurse_id = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },
    select_puncture_nurse: function () {
      var admin_roles = [{ id: 0, name: '请选择' }]
      for (let i = 0; i < this.admins.length; i++) {
        admin_roles.push(this.admins[i])
      }
      if (this.record.id != 0) {
        var creator = 0
        if (this.record.creator == 0) {
          creator = this.record.start_nurse
        } else {
          creator = this.record.creator
        }

        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          admin_roles,
          this.puncture_nurse_id,
          '选择穿刺护士',
          'name',
          'id',
          function (select_id) {
            t.puncture_nurse_id = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        admin_roles,
        this.puncture_nurse_id,
        '选择穿刺护士',
        'name',
        'id',
        function (select_id) {
          t.puncture_nurse_id = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },
    select_washpipe_nurse_nurse: function () {
      var admin_roles = [{ id: 0, name: '请选择' }]
      for (let i = 0; i < this.admins.length; i++) {
        admin_roles.push(this.admins[i])
      }
      if (this.record.id != 0) {
        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          admin_roles,
          this.washpipe_nurse,
          '选择冲管护士',
          'name',
          'id',
          function (select_id) {
            t.washpipe_nurse = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        admin_roles,
        this.washpipe_nurse,
        '选择冲管护士',
        'name',
        'id',
        function (select_id) {
          t.washpipe_nurse = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },

    select_change_nurse_nurse: function () {
      var admin_roles = [{ id: 0, name: '请选择' }]
      for (let i = 0; i < this.admins.length; i++) {
        admin_roles.push(this.admins[i])
      }
      if (this.record.id != 0) {
        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          admin_roles,
          this.change_nurse,
          '选择冲管护士',
          'name',
          'id',
          function (select_id) {
            t.change_nurse = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        admin_roles,
        this.change_nurse,
        '选择冲管护士',
        'name',
        'id',
        function (select_id) {
          t.change_nurse = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },

    select_difficult_puncture_nurse: function () {
      var admin_roles = [{ id: 0, name: '请选择' }]
      for (let i = 0; i < this.admins.length; i++) {
        admin_roles.push(this.admins[i])
      }
      if (this.record.id != 0) {
        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          admin_roles,
          this.difficult_puncture_nurse,
          '选择冲管护士',
          'name',
          'id',
          function (select_id) {
            t.difficult_puncture_nurse = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        admin_roles,
        this.difficult_puncture_nurse,
        '选择冲管护士',
        'name',
        'id',
        function (select_id) {
          t.difficult_puncture_nurse = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },
    select_new_fistula_nurse: function () {
      var admin_roles = [{ id: 0, name: '请选择' }]
      for (let i = 0; i < this.admins.length; i++) {
        admin_roles.push(this.admins[i])
      }
      if (this.record.id != 0) {
        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          admin_roles,
          this.new_fistula_nurse,
          '选择冲管护士',
          'name',
          'id',
          function (select_id) {
            t.new_fistula_nurse = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        admin_roles,
        this.new_fistula_nurse,
        '选择冲管护士',
        'name',
        'id',
        function (select_id) {
          t.new_fistula_nurse = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },
    quality_nurse_id_nurse: function () {
      var admin_roles = [{ id: 0, name: '请选择' }]
      for (let i = 0; i < this.admins.length; i++) {
        admin_roles.push(this.admins[i])
      }
      if (this.record.id != 0) {
        this.selecting = true
        var t = this
        this.$refs.selector.showSingleSelect(
          admin_roles,
          this.quality_nurse_id,
          '选择质控护士',
          'name',
          'id',
          function (select_id) {
            t.quality_nurse_id = select_id
          },
          function () {
            t.selecting = false
          }
        )
      }
      this.selecting = true
      var t = this
      this.$refs.selector.showSingleSelect(
        admin_roles,
        this.quality_nurse_id,
        '选择质控护士',
        'name',
        'id',
        function (select_id) {
          t.quality_nurse_id = select_id
        },
        function () {
          t.selecting = false
        }
      )
    },
    open: function () {
      this.selecting = false
      this.$refs.selector.hide()
    },
    getPermission () {
      request
        .get('/m/api/permission/get', {
          params: {
            create_url: '/m/api/dialysis/start?mode=1',
            modify_url: '/m/api/startOrder/edit?mode=2',
            modify_other_url: '/m/api/startOrder/edit?mode=3',
            module: 0
          }
        })
        .then((res) => {
          console.log(res)
          // console.log('上机', this.record)
          if (res.data.state == 0) {
            this.hasPermission = false
          } else if (res.data.state == 1) {
            if (this.record.id != '' && this.record.creator != 0) {
              // 有数据
              if (this.record.creator == this.$store.getters.user.admin.id) {
                // 创建人是自己
                if (res.data.data.is_has_modify == false) {
                  this.hasPermission = false
                  this.showTxt = '你没有修改执行上机权限'
                }
              } else {
                // 创建人不是自己
                if (res.data.data.is_has_modify_other == false) {
                  this.hasPermission = false
                  this.showTxt = '你没有修改他人执行上机权限'
                }
              }
            } else if (this.record.id == '' || this.record.creator == 0) {
              if (res.data.data.is_has_create == false) {
                this.hasPermission = false
                this.showTxt = '你没有执行上机权限'
              }
            }
          }
        })
    },
    getPunctureNeedle: function (val) {
      let name = ''
      let names = this.punctureNeedleOptions
      for (let i = 0; i < names.length; i++) {
        if (names[i].id == val) {
          name = names[i].name
        }
      }
      return name
    },
    getPunctureWay: function (val) {
      let name = ''
      let names = this.punctureWayOptions
      for (let i = 0; i < names.length; i++) {
        if (names[i].id == val) {
          name = names[i].name
        }
      }
      return name
    },
    getDialysis: function (val) {
      let name = ''
      let names = this.dialyszers
      for (let i = 0; i < names.length; i++) {
        if (names[i].id == val) {
          name = names[i].name
        }
      }
      return name
    },
    getDialysisIrrigation (val) {
      let name = ''
      let names = this.irrigation
      for (let i = 0; i < names.length; i++) {
        if (names[i].id == val) {
          name = names[i].name
        }
      }
      return name
    },

    // showSubMenu: function (val) {
    //   console.log("999999", val);
    //   switch (val) {
    //     case "puncture_needle":
    //       this.propForm.type = 21;
    //       this.isShowDialog = false;
    //       this.propForm.title = "穿刺针";
    //       this.visibility = true;
    //       this.propForm.list = [];
    //       this.propForm.optionList = this.punctureNeedleOptions;
    //       this.propForm.isMultiple = 1;
    //       this.propForm.selectId = this.puncture_needle;
    //       this.propForm.click_ref = "puncture_needle";
    //       break;

    //     case "puncture_way":
    //       this.propForm.type = 26;
    //       this.isShowDialog = false;
    //       this.propForm.title = "穿刺方式";
    //       this.visibility = true;
    //       this.propForm.list = [];
    //       this.propForm.optionList = this.punctureWayOptions;
    //       this.propForm.isMultiple = 1;
    //       this.propForm.selectId = this.puncture_way;
    //       this.propForm.click_ref = "puncture_way";
    //       break;
    //     case "dialysis_dialyszers":
    //       this.propForm.type = 27;
    //       this.isShowDialog = false;
    //       this.propForm.title = "透析器";
    //       this.visibility = true;
    //       this.propForm.list = [];
    //       this.propForm.optionList = this.dialyszers;
    //       this.propForm.isMultiple = 1;
    //       this.propForm.selectId = this.dialysis_dialyszers;
    //       this.propForm.click_ref = "dialysis_dialyszers";
    //       break;

    //     case "dialysis_irrigation":
    //       this.propForm.type = 28;
    //       this.isShowDialog = false;
    //       this.propForm.title = "灌流器";
    //       this.visibility = true;
    //       this.propForm.list = [];
    //       this.propForm.optionList = this.irrigation;
    //       this.propForm.isMultiple = 1;
    //       this.propForm.selectId = this.dialysis_irrigation;
    //       this.propForm.click_ref = "dialysis_irrigation";
    //       break;
    //     case "blood_access_id":
    //       this.propForm.type = 29;
    //       this.isShowDialog = false;
    //       this.propForm.title = "血管通路";
    //       this.visibility = true;
    //       this.propForm.list = [];
    //       this.propForm.optionList = this.vascularAccessDescList;
    //       this.propForm.isMultiple = 1;
    //       this.propForm.selectId = this.blood_access_id;
    //       this.propForm.click_ref = "blood_access_id";
    //       break;
    //   }
    // },

    showSubMenu: function (val) {
      this.checkBoxShow = true
      switch (val) {
        case 'puncture_needle':
          this.propForm.type = 18
          this.isShowDialog = false
          this.propForm.title = '穿刺针'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.punctureNeedleOptions
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.puncture_needle != undefined ||
            this.puncture_needle != null
          ) {
            if (this.puncture_needle.length > 0) {
              this.propForm.result = this.puncture_needle.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'puncture_needle'

          break

        case 'puncture_way':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.type = 26
          this.isShowDialog = false
          this.propForm.title = '穿刺方式'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'puncture_method')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2

          if (this.puncture_way != undefined || this.puncture_way != null) {
            if (this.puncture_way.length > 0) {
              this.propForm.result = this.puncture_way.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'puncture_way'
          break

        case 'dialysis_dialyszers':
          for (let i = 0; i < this.dialysisDialyszers.length; i++) {
            this.dialysisDialyszers[i].name =
              this.dialysisDialyszers[i].specification_name
          }
          this.propForm.type = 14
          this.isShowDialog = false
          this.propForm.title = '透析器'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.dialysisDialyszers
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          var apparatus = this.dialysis_dialyszers.split(',')

          var newArr = []
          for (let i = 0; i < this.dialysisDialyszers.length; i++) {
            for (let j = 0; j < apparatus.length; j++) {
              var name = this.dialysisDialyszers[i].name.toUpperCase()
              var app = apparatus[j].toUpperCase()
              if (name == app) {
                newArr.push(this.dialysisDialyszers[i].name)
              }
            }
          }

          if (
            this.dialysis_dialyszers != undefined ||
            this.dialysis_dialyszers != null
          ) {
            if (this.dialysis_dialyszers.length > 0) {
              this.propForm.result = newArr
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'dialysis_dialyszers'
          break

        case 'dialysis_irrigation':
          for (let i = 0; i < this.dialysisIrrigation.length; i++) {
            this.dialysisIrrigation[i].name =
              this.dialysisIrrigation[i].specification_name
          }

          this.propForm.type = 15
          this.isShowDialog = false
          this.propForm.title = '灌流器'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.dialysisIrrigation
          this.propForm.optionList = []
          this.propForm.isMultiple = 2

          var apps = this.dialysis_irrigation.split(',')

          var newArr = []
          for (let i = 0; i < this.dialysisIrrigation.length; i++) {
            for (let j = 0; j < apps.length; j++) {
              var name = this.dialysisIrrigation[i].name.toUpperCase()
              var app = apps[j].toUpperCase()
              if (name == app) {
                newArr.push(this.dialysisIrrigation[i].name)
              }
            }
          }

          if (
            this.dialysis_irrigation != undefined ||
            this.dialysis_irrigation != null
          ) {
            if (this.dialysis_irrigation.length > 0) {
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.result = newArr
          this.propForm.click_ref = 'dialysis_irrigation'
          break

        case 'blood_access_id':
          this.propForm.type = 10
          this.isShowDialog = false
          this.propForm.title = '血管通路'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.bloodAccessOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.blood_access
          this.propForm.click_ref = 'blood_access'
          break
      }
    },
    // menuComfirm: function (val) {
    //   console.log('88888888828282828', val)
    //   this.visibility = false
    //   this.isShowDialog = true
    //   this.$nextTick(() => {
    //     if (
    //       this.$refs[this.propForm.click_ref] != undefined &&
    //       this.$refs[this.propForm.click_ref] != null
    //     ) {
    //       this.$refs[this.propForm.click_ref].scrollIntoView()
    //     }
    //   })
    //   console.log('woowowo', val)
    //   switch (val.type) {
    //     case 26:
    //       this.puncture_way = val.selectId
    //       break
    //     case 21:
    //       this.puncture_needle = val.selectId
    //       break
    //     case 27:
    //       this.dialysis_dialyszers = val.selectId
    //       break
    //     case 28:
    //       this.dialysis_irrigation = val.selectId
    //       break
    //     case 29:
    //       this.blood_access_id = val.selectId
    //       break
    //   }
    // },
    menuCancle: function () {
      this.visibility = false
      this.isShowDialog = true
      this.$nextTick(() => {
        if (
          this.$refs[this.propForm.click_ref] != undefined &&
          this.$refs[this.propForm.click_ref] != null
        ) {
          this.$refs[this.propForm.click_ref].scrollIntoView()
        }
      })
    },
    // menuEmpty: function (val) {
    //   this.visibility = false
    //   this.isShowDialog = true
    //   switch (val.type) {
    //     case 21:
    //       this.puncture_needle = ''
    //       break
    //     case 26:
    //       this.puncture_way = ''
    //       break
    //     case 27:
    //       this.dialysis_dialyszers = ''
    //       break
    //     case 28:
    //       this.dialysis_irrigation = ''
    //       break
    //     case 29:
    //       this.blood_access_id = ''
    //       break
    //   }
    // },
    getBloodAccessTwo: function (val) {
      let blood_access_name = ''
      for (let i = 0; i < this.bloodAccessOptions.length; i++) {
        if (val == this.bloodAccessOptions[i].id) {
          blood_access_name = this.bloodAccessOptions[i].name
        }
      }
      return blood_access_name
    },
    didNucleinDateTime: function (time) {
      this.nuclein_date_str = parseTime(time, '{y}-{m}-{d}')
    },
    getBedId (id) {
      var zone_name = ''
      for (let i = 0; i < this.zoneList.length; i++) {
        if (id == this.zoneList[i].id) {
          zone_name = this.zoneList[i].zone.name
        }
      }
      return zone_name
    },
    changeBed (obj) {
      this.temp_device_numbers.map((item, index) => {
        if (item.id == obj) {
          this.bed_id = obj
          this.bedId = obj
          console.log('index', index)
        }
      })
    },
    selectType () {
      let ParamsQuery = {}
      ParamsQuery['schedual_type'] = this.schedual_type
      ParamsQuery['record_date'] = this.$route.query.date
      GetSchedualNumber(ParamsQuery).then((response) => {
        if (response.data.state == 0) {
          Toast.fail(response.data.msg)
          return false
        } else {
          this.temp_device_numbers = response.data.data.number
          var zonelist = response.data.data.list
          this.zoneList = zonelist
          for (
            let index = 0;
            index < this.temp_device_numbers.length;
            index++
          ) {
            const device_number = this.temp_device_numbers[index]
            this.temp_device_numbers[index]['zoneNumber'] =
              device_number['zone_name'] + '-' + device_number['number']
          }
          this.zone_beds = this.temp_device_numbers

          let number = response.data.data.number
          this.zonebedNumber = number
          let zoneData = []
          let bedData = []
          number.map((item) => {
            let status = zoneData.some(
              (it) =>
                it['zone_id'] == item['zone_id'] &&
                it['zone_name'] == item['zone_name']
            )
            if (!status) {
              let obj = {
                zone_id: '',
                zone_name: ''
              }
              obj.zone_id = item.zone_id
              obj.zone_name = item.zone_name
              zoneData.push(obj)
            }
          })
          this.zoneData = zoneData
          console.log(
            'this.device_number_map[this.bed_id]',
            this.device_number_map[this.bed_id]
          )
          number.map((item) => {
            if (
              this.device_number_map[this.bed_id].zone_id == item.zone_id &&
              this.device_number_map[this.bed_id].zone_name == item.zone_name
            ) {
              bedData.push(item)
              this.zoneId = this.device_number_map[this.bed_id].zone_id
            }
          })
          this.bedId = this.device_number_map[this.bed_id].id
          this.bedData = bedData
        }
      })
    },
    changeZone (zone_id) {
      let zone_name = ''
      this.zoneData.map((item) => {
        if (item.zone_id == zone_id) {
          zone_name = item.zone_name
        }
      })
      this.zoneId = zone_id
      let bedData = []
      this.zonebedNumber.map((item) => {
        if (zone_id == item.zone_id && zone_name == item.zone_name) {
          bedData.push(item)
        }
      })
      this.bedData = bedData
      this.bedId = 0
    },

    getString (val) {
      console.log('val32233223', val)
      switch (val.type) {
        case 18:
          this.puncture_needle = val.result.join(',')
          break
        case 26:
          this.puncture_way = val.result.join(',')
          break
        case 10:
          this.blood_access_id = val.result.join(',')
          break
      }
    },
    getToken () {
      getToken().then((response) => {
        if (response.data.state == 1) {
          this.uptoken = response.data.data.uptoken
        }
      })
    },
  

    toSummary (val) {
      if (val >= 0) {
        this.summary.map(item => {
          if (item.id == val) {
            var theValue = item.value
            this.dialysisSummarySelectChange(theValue)
          }
        })
      }
      this.summaryShow = false
    },
    dialysisSummarySelectChange: function (values) {
      if (this.catheter_operation == null) {
        this.catheter_operation == ''
      }

      if (this.catheter_operation == '') {
        this.catheter_operation = values
      } else {
        if (this.catheter_operation.indexOf(values) == -1) {
          if (
            this.catheter_operation
              .charAt(this.catheter_operation.length - 1)
              .indexOf('。') == -1
          ) {
            this.catheter_operation =
                    this.catheter_operation+ ',' + values
          } else {
            this.catheter_operation = this.catheter_operation+ values
          }
        }
      }
    },
    menuCancleFour:function(){
     this.infor_visibility = false
     
    },
   menuComfirmFour:function(start_time,remark){
       var params = {
         patient_id:this.patient_prop.id,
         record_date:this.switchMsec(this.record_date),
         start_time:start_time,
         module:6,
         remark:remark,
       }
      
      saveMobileInformation(params).then(response=>{
        if(response.data.state == 1){
          this.selecting = true
          this.$emit('close')
           this.infor_visibility = false
           Toast.success('申请成功')
        }
      })
    },
   switchMsec (time){ // 日期转换成毫秒
      let date = new Date(time);
      // 有三种方式获取
      let time1 = date.getTime(); // 精确到毫秒;
      return (time1/1000)-28800
    },
  },
  watch: {
    'record.id': function (val) {
      if (val > 0) {
        if (this.record.creator == 0) {
          this.creator = this.record.start_nurse
        } else {
          this.creator = this.record.creator
        }
      }
    }
  }
}
</script>

<style style="stylesheet/scss" lang="scss" scoped>
.perform {
  text-align: center;
  font-size: 0.3rem;
  padding-top: 2rem;
  .crew {
    color: $pgh-color;
  }
  button {
    background: $main-color;
    color: #fff;
    font-size: 0.45rem;
    text-align: center;
    width: 3rem;
    height: 1.2rem;
    line-height: 1.2rem;
    border-radius: 4px;
    margin-top: 10px;
  }
}
.newDialogContent {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  > :first-child {
    flex: 1;
    overflow: auto;
  }
}
.warnTxt {
  font-size: 0.5rem;
  height: 1rem;
  line-height: 1rem;
  text-align: center;
  background: #faa331;
  color: #fff;
}
</style>
<style lang="scss">
.DialogTit {
  .newButton {
    background: #258ffc;
    padding: 0 0.2rem;
    height: 0.85rem;
    line-height: 0.85rem;
    border-radius: 5px;
    color: #fff;
    margin-right: -2.5rem;
  }

  .PrescSubmit {
    position: fixed;
    bottom: 0;
  }
}

.Dialog {
  .van-collapse {
    .van-collapse-item {
      .van-cell {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.5rem !important;
        .van-cell__right-icon {
          font-size: 0.5rem;
        }
      }
      .van-collapse-item__wrapper {
        .van-collapse-item__content {
          padding: 0.25rem 0.5rem;
          font-size: 0.5rem;
          .van-radio-group {
            .van-radio {
              .van-radio__icon {
                font-size: 0.8rem !important;
              }
            }
          }
          .van-checkbox-group{
            .van-checkbox{
              .van-checkbox__label{
                font-size: .5rem;
              }
            }
          }
        }
      }
    }
    .van-cell {
      padding: 0.25rem 0.5rem !important;
      font-size: 0.5rem !important;
      .van-cell__right-icon {
        font-size: 0.5rem;
      }
      .van-cell__value {
        .van-field__body {
          .van-field__control--right {
            padding-right: 0;
          }
        }
      }
    }
  }
}
.van-radio-group {
  display: flex;
  flex-wrap: wrap;
  .van-radio {
    width: 50%;
    margin-bottom: 0.625rem;
  }
}
</style>

<style  scoped>
.double_check_dialog >>> .picker-item{font-size: .475rem ; }
</style>
