<template>
    <div class="treatment">
        <div>
            <div class="warnTxt" v-if="showTxt != ''">
                {{ showTxt }}
            </div>
            <van-cell title='宣教知识' v-if="isShow('宣教知识')" :required="isShow_title('宣教知识')" @click="teachShow = true" is-link value="请选择"></van-cell>
            <van-popup v-model="teachShow" get-container="#app" class="listBoxPopup newListBoxPopupApp" style="z-index:5000">
                <div class="listBox">
                    <div @click="toTeach('')">请选择</div>
                    <div v-for="(item,index) in teach" :key="index" @click="toTeach(item.id)">{{ item.text }}</div>
                </div>
            </van-popup>
            <van-field class="bgField" v-if="isShow('宣教知识')" :required="isShow_title('宣教知识')" v-model="dialysisSummary.propagandaAndEducationContent" rows="1" autosize type="textarea" placeholder="请输入"/>
            <van-cell title='透析小结' v-if="isShow('透析小结')" :required="isShow_title('透析小结')" @click="summaryShow = true" is-link value="请选择"></van-cell>
            <div style="margin-left: 10px;margin-top: 5px;"><el-button type="primary" size="small" @click="toAuto">自动生成</el-button></div>
            <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="isShow('透析小结')" :required="isShow_title('透析小结')" v-model="dialysisSummary.summaryContent" rows="1" autosize type="textarea" placeholder="请输入"/>
          
            <van-cell title='透析护理记录' v-if="isShow('透析护理记录')" :required="isShow_title('透析护理记录')" @click="nursingRecordShow = true" is-link value="请选择"></van-cell>
            <van-popup v-model="nursingRecordShow" get-container="#app" class="listBoxPopup newListBoxPopupApp" style="z-index:5000">
                <div class="listBox">
                    <div @click="toNursingRecord('')">请选择</div>
                    <div v-for="(item,index) in nursingRecord" :key="index" @click="toNursingRecord(item.id)">{{ item.text }}</div>
                </div>
            </van-popup>
            <van-field class="bgField" v-if="isShow('透析护理记录')" :required="isShow_title('透析护理记录')" v-model="dialysisSummary.nursing_record" rows="1" autosize type="textarea" placeholder="请输入"/>
            <van-cell title='特殊记录' v-if="isShow('特殊记录')" :required="isShow_title('特殊记录')" @click="specialRecordShow = true" is-link value="请选择"></van-cell>
            <van-popup v-model="specialRecordShow" get-container="#app" class="listBoxPopup newListBoxPopupApp" style="z-index:5000">
                <div class="listBox">
                    <div @click="toSpecialRecord('')">请选择</div>
                    <div v-for="(item,index) in specialRecord" :key="index" @click="toSpecialRecord(item.id)">{{ item.text }}</div>
                </div>
            </van-popup>
            <van-field class="bgField" v-if="isShow('特殊记录')" :required="isShow_title('特殊记录')" v-model="dialysisSummary.special_record" rows="1" autosize type="textarea" placeholder="请输入"/>
        </div>
        <div class="preserveBox">
          <div @click="commitInfo" v-if="hasPermission && isCommit">保存</div>
          <div v-else class="disabled">保存</div>
        </div>

      <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 { commitTreatmentSummary,saveMobileInformation } from '@/api/dialysis'
import InforSubMenu from "../dialog/subMenu/InforSubMenu.vue"
import { Toast } from 'vant'
import { getDataConfig } from '@/utils/data'
import { uParseTime } from '@/utils/tools'
import { Dialog } from "vant";
import request from '@/utils/request'
export default {
  props: {
    record: {
      type: Object
    },
    patient_prop: {
      type: Object
    },
    prescription_prop:{
      type:Object
    },
    predialysis_evaluation:{
      type:Object
    },
    advice_groups:{
      type:Array,
    },
    dialysis_order:{
      type:Object
    },
    assessment_after_dislysis:{
      type:Object
    },
    monitor_records:{
      type:Array
    }
  },
  components: {
    InforSubMenu
  },
  data () {
    return {
      showTxt: '',
      hasPermission: true,
      dialysisSummary: {
        text: '',
        propagandaAndEducationContent: '',
        propagandaAndEducationContentSelect: '',
        text2: '',
        summaryContent: '',
        summaryContentSelect: '',
        changeMedicalNurse: '',
        treatNurse: '',
        checkStaff: '',
        deboardNurse: '',
        treatDoctor: '',
        special_record: '',
        nursing_record: '',
        nursingRecordSelect: '',
        specialRecordSelect: '',

      },
      summary: [],
      teach: [],
      nursingRecord: [],
      specialRecord: [],

      teachArr: [],
      summaryArr: [],
      nursingRecordArr: [],
      specialRecordArr: [],

      changeDialysisSummary: 0,

      teachShow: false,
      summaryShow: false,
      nursingRecordShow: false,
      specialRecordShow: false,
      isCommit: true,
      org_id: 0,
      infor_visibility:false
    }
  },
  computed: {
    newDialysisSummary () {
      return JSON.parse(JSON.stringify(this.dialysisSummary))
    }
  },
  created () {

    this.org_id = this.$store.getters.user.template_info.org_id

    this.getPermission()
    this.summary = getDataConfig('summary', 'summary')
    if(this.org_id == 10599 || this.org_id == 10597){
      this.summary.sort(this.compare('sort'))
    }
    console.log("summary=--------------------",this.summary)
    this.teach = getDataConfig('education', 'education')
    this.nursingRecord = getDataConfig('nursing_record', 'nursing_record')
    this.specialRecord = getDataConfig('special_record', 'special_record')
    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.patient.id = this.patient_prop.id
    if (this.org_id == 10340 && this.dialysisSummary.summaryContent == '' && this.record.dialysis_summary == '') {
      this.dialysisSummary.summaryContent = '安全下机'
    }
    if (this.record != null && this.record.id != '') {
      for (const key in this.record) {
        this.dialysisSummary[key] = this.record[key]
      }
      if (this.record.mission != 'undefined') {
        this.dialysisSummary.propagandaAndEducationContent = this.record.mission
      }
      if (this.record.dialysis_summary != 'undefined') {
        this.dialysisSummary.summaryContent = this.record.dialysis_summary
      }
    }
  },
  methods: {
    compare (property) {
      return function (a, b) {
        var value1 = a[property]
        var value2 = b[property]
        return value1 - value2
      }
    },
    isShow (name) {
      var filedList = this.$store.getters.user.fileds
      for (let i = 0; i < filedList.length; i++) {
        if (
          filedList[i].module == 6 &&
                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 == 6 &&
                filedList[i].filed_name_cn == name &&
                filedList[i].is_show == 1&&
          filedList[i].is_write == 1
        ) {
          return true
        }
      }
      return false
    },
    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 == 6&&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) {
          // Dialog.alert({
          //   title: "必填提示",
          //   message: `${info[i].filed_name_cn}为必填字段，不能为空`,
          // }).then(() => {
          //   // on close
          // });
          Toast.fail(`${info[i].filed_name_cn}为必填字段，不能为空`)
        }
      }
    },
    isWrite(name) {
      var filedList = this.$store.getters.user.fileds;

      for (let i = 0; i < filedList.length; i++) {
        if (
          filedList[i].module == 6 &&
          filedList[i].filed_name_cn == name &&
          filedList[i].is_write == 1 &&
          filedList[i].is_show == 1
        ) {
          return true;
        }
      }

      return false;
    },
    toTeach (val) {
      if (val >= 0) {
        this.teach.map(item => {
          if (item.id == val) {
            var theValue = item.value
            this.dialysisAfterTeachSelectChange(theValue)
          }
        })
      }
      this.teachShow = false
    },
    toSummary (val) {
 
      if (val >= 0) {
        this.summary.map(item => {
          if (item.id == val) {
            var theValue = item.value
            this.dialysisSummarySelectChange(theValue)
          }
        })
      }
      this.summaryShow = false
    },
    toNursingRecord (val) {

      if (val >= 0) {
        this.nursingRecord.map(item => {
          if (item.id == val) {
            var theValue = item.value
            this.dialysisSummaryNuserocoderChange(theValue)
          }
        })
      }
      this.nursingRecordShow = false
    },
    toSpecialRecord (val) {
      if (val >= 0) {
        this.specialRecord.map(item => {
          if (item.id == val) {
            var theValue = item.value
            this.dialysisSummarySpecialcoderChange(theValue)
          }
        })
      }
      this.specialRecordShow = false
    },

    commitInfo: function () {
      if (
        this.isWrite("宣教知识") == true &&
        this.dialysisSummary.propagandaAndEducationContent == ""
      ) {
        // Dialog.alert({
        //     title: "必填提示",
        //     message: `宣教知识为必填字段，不能为空`,
        //   }).then(() => {
        //     // on close
        //   });
        Toast.fail(`宣教知识为必填字段，不能为空`)
      }else if (this.isWrite("透析小结") == true &&
        this.dialysisSummary.summaryContent == "")
       {
        // Dialog.alert({
        //     title: "必填提示",
        //     message: `透析小结为必填字段，不能为空`,
        //   }).then(() => {
        //     // on close
        //   });
        Toast.fail(`透析小结为必填字段，不能为空`)
      }
      else if (this.isCommit == true) {

        let ParamsQuery = this.dialysisSummary
        if (this.$route.query.patient_id) {
          ParamsQuery['patient'] = this.$route.query.patient_id
        } else {
          ParamsQuery['patient'] = this.patient_prop.id
        }

        ParamsQuery['record_date'] = this.record_date
        ParamsQuery['mode'] = '1'

        if (this.record.id > 0) {
          ParamsQuery['mode'] = '2'
          if (this.record.creater != this.$store.getters.user.admin.id) {
            ParamsQuery['mode'] = '3'
          }
        }
        // 必填弹窗开始

          let result = [];
          let filedList = this.$store.getters.user.fileds;

          let new_arr = ParamsQuery
 
           if (new_arr.summaryContent != ""&&new_arr.summaryContent != undefined) {
            delete new_arr.dialysis_summary;

          }
           if (new_arr.propagandaAndEducationContent != ""&&new_arr.propagandaAndEducationContent != undefined) {
            delete new_arr.mission;
          }

          new_arr = Object.entries(new_arr);
          new_arr.forEach((el) => {
            if (el[1] === "" || el[1] == 0 || el[1] == "0") {
              result.push(el);
            }
          });
          let warnarr = [];
          warnarr = this.getArrEqual(filedList, result);

          if (warnarr.length > 0) {
            this.open_tips(warnarr);
            // 必填弹窗结束

          }else{
            this.isCommit = false
          Toast.loading({ forbidClick: true, duration: 0 })
            commitTreatmentSummary(ParamsQuery)
          .then(response => {
            if (response.data.state == 0) {
              Toast.fail(response.data.msg)
              if(response.data.code == 600000008){
                this.infor_visibility = true
              }
              this.isCommit = true
              return false
            } else {              Toast.success('提交成功')
              this.$emit('did_update', response.data.data.summary)
              for (const key in response.data.data.summary) {
                this.record[key] = response.data.data.summary[key]
              }
            }
            this.changeDialysisSummary = 0
            this.isCommit = true
          })
          .catch(err => {
            this.changeDialysisSummary = 0
            Toast.fail(err)
            this.isCommit = true
          })
          }


      }
    },
    getPermission () {
      request
        .get('/m/api/permission/get', {
          params: {
            create_url: '/m/api/dialysis/treatmentSummary?mode=1',
            modify_url: '/m/api/dialysis/treatmentSummary?mode=2',
            modify_other_url: '/m/api/dialysis/treatmentSummary?mode=3',
            module: 9
          }
        })
        .then(res => {
          if (res.data.state == 0) {
            this.hasPermission = false
          } else if (res.data.state == 1) {
            if (this.record.id != '' && this.record.creater != 0) {
              // 有数据
              if (this.record.creater == 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.creater == 0) {
              if (res.data.data.is_has_create == false) {
                this.hasPermission = false
                this.showTxt = '你没有新增治疗小结权限'
              }
            }
          }
        })
    },
    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
    },
    dialysisSummarySelectChange: function (values) {
      if (this.dialysisSummary.summaryContent == null) {
        this.dialysisSummary.summaryContent == ''
      }

      if (this.dialysisSummary.summaryContent == '') {
        this.dialysisSummary.summaryContent = values
      } else {
        if (this.dialysisSummary.summaryContent.indexOf(values) == -1) {
          if (
            this.dialysisSummary.summaryContent
              .charAt(this.dialysisSummary.summaryContent.length - 1)
              .indexOf('。') == -1
          ) {
            this.dialysisSummary.summaryContent =
                    this.dialysisSummary.summaryContent + ',' + values
          } else {
            this.dialysisSummary.summaryContent =
                    this.dialysisSummary.summaryContent + values
          }
        }
      }
    },
    dialysisAfterTeachSelectChange: function (values) {
      if (this.dialysisSummary.propagandaAndEducationContent == null) {
        this.dialysisSummary.propagandaAndEducationContent == ''
      }
      if (this.dialysisSummary.propagandaAndEducationContent == '') {
        this.dialysisSummary.propagandaAndEducationContent = values
      } else {
        if (
          this.dialysisSummary.propagandaAndEducationContent.indexOf(values) ==
                -1
        ) {
          if (
            this.dialysisSummary.propagandaAndEducationContent
              .charAt(
                this.dialysisSummary.propagandaAndEducationContent.length - 1
              )
              .indexOf('。') == -1
          ) {
            this.dialysisSummary.propagandaAndEducationContent =
                    this.dialysisSummary.propagandaAndEducationContent + ',' + values
          } else {
            this.dialysisSummary.propagandaAndEducationContent =
                    this.dialysisSummary.propagandaAndEducationContent + values
          }
        }
      }
    },
    dialysisSummaryNuserocoderChange: function (values) {
      if (this.dialysisSummary.nursing_record == null) {
        this.dialysisSummary.nursing_record == ''
      }
      if (this.dialysisSummary.nursing_record == '') {
        this.dialysisSummary.nursing_record = values
      } else {
        if (this.dialysisSummary.nursing_record.indexOf(values) == -1) {
          if (
            this.dialysisSummary.nursing_record
              .charAt(this.dialysisSummary.nursing_record.length - 1)
              .indexOf('。') == -1
          ) {
            this.dialysisSummary.nursing_record =
                        this.dialysisSummary.nursing_record + ',' + values
          } else {
            this.dialysisSummary.nursing_record =
                        this.dialysisSummary.nursing_record + values
          }
        }
      }
    },
    dialysisSummarySpecialcoderChange: function (values) {
      if (this.dialysisSummary.special_record == null) {
        this.dialysisSummary.special_record == ''
      }
      if (this.dialysisSummary.special_record == '') {
        this.dialysisSummary.special_record = values
      } else {
        if (this.dialysisSummary.special_record.indexOf(values) == -1) {
          if (
            this.dialysisSummary.special_record
              .charAt(this.dialysisSummary.special_record.length - 1)
              .indexOf('。') == -1
          ) {
            this.dialysisSummary.special_record =
                        this.dialysisSummary.special_record + ',' + values
          } else {
            this.dialysisSummary.special_record =
                        this.dialysisSummary.special_record + values
          }
        }
      }
    },

     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:10,
         remark:remark,
       }

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

    },
    toAuto(){
      
      if(this.org_id!=10090){
        var str_one = ""
      if(this.dialysis_order!=null){
        if(this.dialysis_order.puncture_nurse_id >0){
          str_one = "护士穿刺成功!"
        }
      }

      var total =0
      if(this.predialysis_evaluation!=null){
        total = (this.predialysis_evaluation.weight_before - this.predialysis_evaluation.dry_weight).toFixed(1)
      }



      var monitor_one =[]
      var monitor_two = []
      var monitor_three = []

      if(this.monitor_records!=null && this.monitor_records.length > 0){
        var monitor_one =  this.monitor_records.sort(function (a,b) {
            return b.systolic_bp - a.systolic_bp
        })
        var monitor_two =  this.monitor_records.sort(function (a,b) {
          return b.diastolic_bp - a.diastolic_bp
        })

        var monitor_three = this.monitor_records.sort(function (a,b) {
              return b.pulse_frequency - a.pulse_frequency
        })

      }

      var doc_str = ""

        if(this.advice_groups!=null && this.advice_groups.length > 0){
          var docNewArr =[]
            for(let i=0;i<this.advice_groups[0].advices.length;i++){
              docNewArr.push(this.advice_groups[0].advices[i])
            }

          for(let i=0;i<docNewArr.length;i++){
            doc_str +=docNewArr[i].advice_name +" "+docNewArr[i].prescribing_number+docNewArr[i].prescribing_number_unit+" "+docNewArr[i].delivery_way
          }
        }

        if(this.predialysis_evaluation.blood_access_part_id == -2){
          this.predialysis_evaluation.blood_access_part_id = ""
        }

        var str = " 患者今日来我科行血液透析治疗,血管通路选择:"+this.predialysis_evaluation.blood_access_part_id+ " "+this.QueryOperaById(this.predialysis_evaluation.blood_access_part_opera_id) +",透析模式:"+this.getModeId(this.prescription_prop.mode_id)+
        ",透前检查:"+this.predialysis_evaluation.internal_fistula +this.predialysis_evaluation.catheter + str_one +" "+ ",透析器:"+this.prescription_prop.dialyzer_perfusion_apparatus + ",抗凝剂:"+this.GetAnticoagulant(this.prescription_prop.anticoagulant) +",总量:"+this.prescription_prop.anticoagulant_zongliang+"iu"+
        ",透前体重:"+this.predialysis_evaluation.weight_before+"kg"+",间期体重增长:"+total +"kg"+",目标脱水量:"+this.prescription_prop.target_ultrafiltration +"ml" +",血流量:"+this.prescription_prop.blood_flow_volume+"ml/min" + ",透析开始时间:"+this.getTime(this.dialysis_order.start_time) +",透析过程中血压波动,"+"最大收缩压:"+monitor_one[0].systolic_blood_pressure+"mmHg"+",最小收缩压:"+monitor_one[monitor_one.length-1].systolic_blood_pressure
        +"mmHg" +",最小舒张压:" +monitor_two[0].diastolic_blood_pressure+"mmHg" + ",最大舒张压:" + monitor_two[monitor_two.length-1].diastolic_blood_pressure +"mmHg" + ",最大脉搏:"+monitor_three[0].pulse_frequency+"次/分"+",最小脉搏:"+monitor_three[monitor_three.length-1].pulse_frequency+"次/分"+",透析结束时间:"+this.getTime(this.dialysis_order.end_time) +
        ",实际治疗时长:"+ this.assessment_after_dislysis.actual_treatment_hour +"时"+this.assessment_after_dislysis.actual_treatment_minute+"分" +",实际超滤量:"+this.assessment_after_dislysis.actual_ultrafiltration+"ml"+",透后体重:"+this.assessment_after_dislysis.weight_after+"kg"+",透析过程顺利，安全下机" + " "
        +",今日使用药品:"+doc_str +",患者下机后测血压,"+"收缩压:"+this.assessment_after_dislysis.systolic_blood_pressure+"mmHg"+",舒张压:"+this.assessment_after_dislysis.diastolic_blood_pressure+"mmHg"+",脉搏:"+this.assessment_after_dislysis.pulse_frequency +"次/分"

        this.dialysisSummary.summaryContent = ""
        this.dialysisSummary.summaryContent = str
      }

      if(this.org_id ==10090){

          var str_one = ""
      if(this.dialysis_order!=null){
        if(this.dialysis_order.puncture_nurse_id >0){
          str_one = "护士穿刺成功!"
        }
      }

      var total =0
      if(this.predialysis_evaluation!=null){
        total = (this.predialysis_evaluation.weight_before - this.predialysis_evaluation.dry_weight).toFixed(1)
      }



      var monitor_one =[]
      var monitor_two = []
      var monitor_three = []

      if(this.monitor_records!=null && this.monitor_records.length > 0){
        var monitor_one =  this.monitor_records.sort(function (a,b) {
            return b.systolic_bp - a.systolic_bp
        })
        var monitor_two =  this.monitor_records.sort(function (a,b) {
          return b.diastolic_bp - a.diastolic_bp
        })

        var monitor_three = this.monitor_records.sort(function (a,b) {
              return b.pulse_frequency - a.pulse_frequency
        })

      }

      var doc_str = ""

        if(this.advice_groups!=null && this.advice_groups.length > 0){
          var docNewArr =[]
            for(let i=0;i<this.advice_groups[0].advices.length;i++){
              docNewArr.push(this.advice_groups[0].advices[i])
            }

          for(let i=0;i<docNewArr.length;i++){
            doc_str +=docNewArr[i].advice_name +" "+docNewArr[i].prescribing_number+docNewArr[i].prescribing_number_unit+" "+docNewArr[i].delivery_way
          }
        }

        if(this.predialysis_evaluation.blood_access_part_id == -2){
          this.predialysis_evaluation.blood_access_part_id = ""
        }

        var str = "患者今日常规进行血液透析治疗，患者透前未诉头晕乏力抽筋不适，未诉咳嗽喘憋及夜间呼吸困难，未诉牙龈出血，未见出血点及瘀斑。心肺无殊，双下肢无浮肿。目前诊断：1.尿毒症 2.肾性贫血 3.肾性骨病 4肉毒碱缺乏症 5.心功能不全，需继续使用促红素、左卡尼汀、帕立骨化醇治疗。 "+ "血管通路选择:"+this.predialysis_evaluation.blood_access_part_id+ " "+this.QueryOperaById(this.predialysis_evaluation.blood_access_part_opera_id) +",透析模式:"+this.getModeId(this.prescription_prop.mode_id)+
        ",透前检查:"+this.predialysis_evaluation.internal_fistula +this.predialysis_evaluation.catheter + str_one +" "+ ",透析器:"+this.prescription_prop.dialyzer_perfusion_apparatus +
        ",透前体重:"+this.predialysis_evaluation.weight_before+"kg"+",间期体重增长:"+total +"kg"+",目标脱水量:"+this.prescription_prop.target_ultrafiltration +"L" +",血流量:"+this.prescription_prop.blood_flow_volume+"ml/min" + ",透析开始时间:"+this.getTime(this.dialysis_order.start_time) +"透析结束时间:"+this.getTime(this.dialysis_order.end_time) +
        ",实际治疗时长:"+ this.assessment_after_dislysis.actual_treatment_hour +"时"+this.assessment_after_dislysis.actual_treatment_minute+"分" +",实际超滤量:"+this.assessment_after_dislysis.actual_ultrafiltration+"L"+",透后体重:"+this.assessment_after_dislysis.weight_after+"kg"+",透析过程顺利，安全下机" + " "
        +",患者下机后测血压,"+"收缩压:"+this.assessment_after_dislysis.systolic_blood_pressure+"mmHg"+",舒张压:"+this.assessment_after_dislysis.diastolic_blood_pressure+"mmHg"+",脉搏:"+this.assessment_after_dislysis.pulse_frequency +"次/分"

        this.dialysisSummary.summaryContent = ""
        this.dialysisSummary.summaryContent = str
      }
      
      },
      getModeId(mode_id){
        var mode_name = ""
        if(mode_id == 1){
          mode_name ="HD"
        }
        if(mode_id == 2){
          mode_name ="HDF"
        }
        if(mode_id == 3){
          mode_name ="HD+HP"
        }
        if(mode_id == 4){
          mode_name ="HP"
        }
        if(mode_id == 5){
          mode_name ="HF"
        }
        if(mode_id == 6){
          mode_name ="SCUF"
        }
        if(mode_id == 7){
          mode_name ="IUF"
        }
        if(mode_id == 8){
          mode_name ="HFHD"
        }
        if(mode_id == 9){
          mode_name ="HFHD+HP"
        }
        if(mode_id == 10){
          mode_name ="PHF"
        }
        if(mode_id == 11){
          mode_name ="HFR"
        }
        if(mode_id == 12){
          mode_name ="HDF+HP"
        }
        if(mode_id == 13){
          mode_name ="CRRT"
        }
        if(mode_id == 14){
          mode_name ="腹水回输"
        }
        if(mode_id == 19){
          mode_name ="IUF+HD"
        }
        if(mode_id == 20){
          mode_name ="UF"
        }
        if(mode_id == 21){
          mode_name ="HD+"
        }
        if(mode_id == 22){
          mode_name ="血浆胆红素吸附+HDF"
        }
        if(mode_id == 23){
          mode_name ="血浆胆红素吸附"
        }
        if(mode_id == 24){
          mode_name ="I-HDF"
        }
        if(mode_id == 25){
          mode_name ="HD高通"
        }
        if(mode_id == 26){
          mode_name ="CVVH"
        }
        if(mode_id == 27){
          mode_name ="CVVHD"
        }
        if(mode_id == 28){
          mode_name ="CVVHDF"
        }
        if(mode_id == 29){
          mode_name ="PE"
        }
        if(mode_id == 30){
          mode_name ="血浆胆红素吸附+HP"
        }
        if(mode_id == 31){
          mode_name ="HPD"
        }
        if(mode_id == 32){
          mode_name ="HDP"
        }
        return mode_name
      },
      GetAnticoagulant(id){
        var  anticoagulant_name = ""
        if(id == 1){
        anticoagulant_name = "无肝素"
        }
        if(id == 2){
          anticoagulant_name = "普通肝素"
        }
        if(id == 3){
          anticoagulant_name = "低分子肝素"
        }
        if(id == 4){
          anticoagulant_name = "阿加曲班"
        }

        if(id == 5){
        anticoagulant_name = "枸橼酸钠"
        }
        if(id == 6){
          anticoagulant_name = "低分子肝素钙"
        }
        if(id == 7){
          anticoagulant_name = "低分子肝素钠"
        }
        if(id == 8){
          anticoagulant_name = "依诺肝素"
        }

        if(id == 9){
          anticoagulant_name = "达肝素"
        }
        if(id == 10){
          anticoagulant_name = "体外抗凝"
        }

        if(id == 11){
          anticoagulant_name = "那屈肝素"
        }
        if(id == 12){
          anticoagulant_name = "无抗凝剂"
        }

        if(id == 13){
          anticoagulant_name = "那屈肝素钙"
        }
        if(id == 14){
          anticoagulant_name = "肝素钙注射液"
        }
        if(id == 15){
          anticoagulant_name = "甲磺酸萘莫司他"
        }

        return anticoagulant_name
      },
      getTime (time) {
      return uParseTime(time, '{y}-{m}-{d} {h}:{i}')
      },
      QueryOperaById: function (val) {

        let vascular_access_desc_name = ''
        let vascular_access_desc = getDataConfig('hemodialysis', 'vascular_access_desc')
        for (let i = 0; i < vascular_access_desc.length; i++) {
          if (vascular_access_desc[i].id == val) {
            vascular_access_desc_name = vascular_access_desc[i].name
          }
        }
        if(vascular_access_desc_name == -2){
          return ""
        }else{
          return vascular_access_desc_name
        }

      },
    


    },
    toAuto(){
      var str_one = ""
      if(this.dialysis_order!=null){
        if(this.dialysis_order.puncture_nurse_id >0){
          str_one = "护士穿刺成功!"
        }
      }
      var total =0
      if(this.predialysis_evaluation!=null){
        total = (this.predialysis_evaluation.weight_before - this.predialysis_evaluation.dry_weight).toFixed(1)
      }
      var monitor_one =[]
      var monitor_two = []
      var monitor_three = []
      if(this.monitor_records!=null && this.monitor_records.length > 0){
        var monitor_one =  this.monitor_records.sort(function (a,b) {
     	     return b.systolic_bp - a.systolic_bp
        })
        var monitor_two =  this.monitor_records.sort(function (a,b) {
           return b.diastolic_bp - a.diastolic_bp
        })
        var monitor_three = this.monitor_records.sort(function (a,b) {
          return b.pulse_frequency - a.pulse_frequency
        })

      }
     var doc_str = ""
      if(this.advice_groups!=null && this.advice_groups.length > 0){
        var docNewArr =[]
          for(let i=0;i<this.advice_groups[0].advices.length;i++){
            docNewArr.push(this.advice_groups[0].advices[i])
          }
        for(let i=0;i<docNewArr.length;i++){
          doc_str +=docNewArr[i].advice_name +" "+docNewArr[i].prescribing_number+docNewArr[i].prescribing_number_unit+" "+docNewArr[i].delivery_way
        }
      }
      if(this.predialysis_evaluation.blood_access_part_id == -2){
        this.predialysis_evaluation.blood_access_part_id = ""
      }
       var str = " 患者今日来我科行血液透析治疗,血管通路选择:"+this.predialysis_evaluation.blood_access_part_id+ " "+this.QueryOperaById(this.predialysis_evaluation.blood_access_part_opera_id) +",透析模式:"+this.getModeId(this.prescription_prop.mode_id)+
       ",透前检查:"+this.predialysis_evaluation.internal_fistula +this.predialysis_evaluation.catheter + str_one +" "+ ",透析器:"+this.prescription_prop.dialyzer_perfusion_apparatus + ",抗凝剂:"+this.GetAnticoagulant(this.prescription_prop.anticoagulant) +",总量:"+this.prescription_prop.anticoagulant_zongliang+"iu"+
      ",透前体重:"+this.predialysis_evaluation.weight_before+"kg"+",间期体重增长:"+total +"kg"+",目标脱水量:"+this.prescription_prop.target_ultrafiltration +"ml" +",血流量:"+this.prescription_prop.blood_flow_volume+"ml/min" + ",透析开始时间:"+this.getTime(this.dialysis_order.start_time) +",透析过程中血压波动,"+"最大收缩压:"+monitor_one[0].systolic_blood_pressure+"mmHg"+",最小收缩压:"+monitor_one[monitor_one.length-1].systolic_blood_pressure
      +"mmHg" +",最小舒张压:" +monitor_two[0].diastolic_blood_pressure+"mmHg" + ",最大舒张压:" + monitor_two[monitor_two.length-1].diastolic_blood_pressure +"mmHg" + ",最大脉搏:"+monitor_three[0].pulse_frequency+"次/分"+",最小脉搏:"+monitor_three[monitor_three.length-1].pulse_frequency+"次/分"+",透析结束时间:"+this.getTime(this.dialysis_order.end_time) +
      ",实际治疗时长:"+ this.assessment_after_dislysis.actual_treatment_hour +"时"+this.assessment_after_dislysis.actual_treatment_minute+"分" +",实际超滤量:"+this.assessment_after_dislysis.actual_ultrafiltration+"ml"+",透后体重:"+this.assessment_after_dislysis.weight_after+"kg"+",透析过程顺利，安全下机" + " "
      +",今日使用药品:"+doc_str +",患者下机后测血压,"+"收缩压:"+this.assessment_after_dislysis.systolic_blood_pressure+"mmHg"+",舒张压:"+this.assessment_after_dislysis.diastolic_blood_pressure+"mmHg"+",脉搏:"+this.assessment_after_dislysis.pulse_frequency +"次/分"

       this.dialysisSummary.summaryContent = ""
       this.dialysisSummary.summaryContent = str
    },
    getModeId(mode_id){
      var mode_name = ""
      if(mode_id == 1){
         mode_name ="HD"
      }
      if(mode_id == 2){
         mode_name ="HDF"
      }
      if(mode_id == 3){
         mode_name ="HD+HP"
      }
      if(mode_id == 4){
         mode_name ="HP"
      }
      if(mode_id == 5){
         mode_name ="HF"
      }
      if(mode_id == 6){
         mode_name ="SCUF"
      }
      if(mode_id == 7){
         mode_name ="IUF"
      }
      if(mode_id == 8){
         mode_name ="HFHD"
      }
      if(mode_id == 9){
         mode_name ="HFHD+HP"
      }
      if(mode_id == 10){
         mode_name ="PHF"
      }
      if(mode_id == 11){
         mode_name ="HFR"
      }
      if(mode_id == 12){
         mode_name ="HDF+HP"
      }
      if(mode_id == 13){
         mode_name ="CRRT"
      }
      if(mode_id == 14){
         mode_name ="腹水回输"
      }
      if(mode_id == 19){
         mode_name ="IUF+HD"
      }
      if(mode_id == 20){
         mode_name ="UF"
      }
      if(mode_id == 21){
         mode_name ="HD+"
      }
      if(mode_id == 22){
         mode_name ="血浆胆红素吸附+HDF"
      }
      if(mode_id == 23){
         mode_name ="血浆胆红素吸附"
      }
      if(mode_id == 24){
         mode_name ="I-HDF"
      }
      if(mode_id == 25){
         mode_name ="HD高通"
      }
      if(mode_id == 26){
         mode_name ="CVVH"
      }
      if(mode_id == 27){
         mode_name ="CVVHD"
      }
      if(mode_id == 28){
         mode_name ="CVVHDF"
      }
      if(mode_id == 29){
         mode_name ="PE"
      }
      if(mode_id == 30){
         mode_name ="血浆胆红素吸附+HP"
      }
      if(mode_id == 31){
         mode_name ="HPD"
      }
      if(mode_id == 32){
         mode_name ="HDP"
      }
      return mode_name
    },
    GetAnticoagulant(id){
      var  anticoagulant_name = ""
      if(id == 1){
       anticoagulant_name = "无肝素"
      }
      if(id == 2){
         anticoagulant_name = "普通肝素"
      }
      if(id == 3){
        anticoagulant_name = "低分子肝素"
      }
      if(id == 4){
        anticoagulant_name = "阿加曲班"
      }

      if(id == 5){
       anticoagulant_name = "枸橼酸钠"
      }
      if(id == 6){
         anticoagulant_name = "低分子肝素钙"
      }
      if(id == 7){
        anticoagulant_name = "低分子肝素钠"
      }
      if(id == 8){
        anticoagulant_name = "依诺肝素"
      }

      if(id == 9){
        anticoagulant_name = "达肝素"
      }
      if(id == 10){
        anticoagulant_name = "体外抗凝"
      }

      if(id == 11){
        anticoagulant_name = "那屈肝素"
      }
      if(id == 12){
        anticoagulant_name = "无抗凝剂"
      }

      if(id == 13){
        anticoagulant_name = "那屈肝素钙"
      }
      if(id == 14){
        anticoagulant_name = "肝素钙注射液"
      }
      if(id == 15){
        anticoagulant_name = "甲磺酸萘莫司他"
      }

      return anticoagulant_name
    },
    getTime (time) {
     return uParseTime(time, '{y}-{m}-{d} {h}:{i}')
    },
    QueryOperaById: function (val) {
      let vascular_access_desc_name = ''
      let vascular_access_desc = getDataConfig('hemodialysis', 'vascular_access_desc')
      for (let i = 0; i < vascular_access_desc.length; i++) {
        if (vascular_access_desc[i].id == val) {
          vascular_access_desc_name = vascular_access_desc[i].name
        }
      }
      if(vascular_access_desc_name == -2){
         return ""
      }else{
        return vascular_access_desc_name
      }
  },
  watch: {
    newDialysisSummary: {
      handler (newVal, oldVal) {
        if (!this.isObjectValueEqual(newVal, oldVal)) {
          this.changeDialysisSummary++
        }
      },
      deep: true
    }
  }

}
</script>

<style lang="scss" scoped>
.treatment{
    display: flex;
    flex-direction: column;
    height: 100%;
    >:first-child{
        flex: 1;
        overflow-y: auto;
    }
}
.van-radio-group{
    display: flex;
    flex-wrap: wrap;
    .van-radio{
        width: 50%;
        margin-bottom: .625rem;
    }
}
.van-checkbox-group{
    display: flex;
    flex-wrap: wrap;
    .van-checkbox{
        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;
    }
}
.warnTxt {
  font-size: 1rem;
  height: 1.875rem;
  line-height: 1.875rem;
  text-align: center;
  background: #faa331;
  color: #fff;
}
.disabled{
  background: #D8D8D8 !important;
}
.warn_tip{
  color: red;
}
</style>
<style lang="scss">
.treatment{
    .van-field__label{
        // width: 9.375rem;
        width: initial;
    }
    .bgField{
        .van-field__control{
            border:1px solid #ccc;
            background: #f6f6f6;
            border-radius: 4px;
            min-height: 6.25rem !important;
        }
        ::placeholder{  //通过这个设置
            color: #999 !important;
        }
    }

}
.newListBoxPopupApp{
    width: 80%;
    height: 80%;
    left: 50% !important;
    top: 50% !important;
    transform: translate3d(-50%,-50%,0) !important;
    overflow-y: auto;
    border-radius: .625rem;
    z-index: 5002 !important;
}
.newListBoxPopupApp{
    .listBox{
        >div{
            padding: 1rem .625rem;
            border-bottom: 1px solid #e5e5e5;
            font-size: .875rem;
            color:#323233;
        }
    }
}

</style>
