<template>
  <div class="auto app-text">
    <div class="panel" style="padding: 10px 10px 5px 10px;">
      <div class="panel-body panel-self">
        <div class="col-xs-12" style="padding: 2px 0">
          <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户编号:</b></p>
          <p class="panel-title col-xs-7 text-left input-font" @click="searchHistory(userinfo.f_userinfoid)" style="color: #00b3ee;text-decoration:underline;">{{ userinfo.f_userinfo_code }}</p>
        </div>
        <div class="col-xs-12" style="padding: 2px 0">
          <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户名称:</b></p>
          <p class="panel-title col-xs-7 text-left input-font">{{ userinfo.f_user_name }}</p>
        </div>
        <div class="col-xs-12" style="padding: 2px 0">
          <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户类型:</b></p>
          <p class="panel-title col-xs-7 text-left input-font">{{ userinfo.f_check_type }}
          </p>
        </div>
        <div class="col-xs-12" style="padding: 2px 0">
          <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户电话:</b></p>
          <!--<input class="panel-title text-left input-font" style="width: 53%" value="{{ userinfo.f_user_phone2 ? userinfo.f_user_phone2 : userinfo.f_user_phone }}" v-model="userinfo.f_user_phone"/>-->
          <p class="panel-title col-xs-7 text-left input-font">{{ userinfo.f_user_phone2 ? userinfo.f_user_phone2 : userinfo.f_user_phone }}
        </div>
        <div class="col-xs-12" style="padding: 2px 0">
          <p class="panel-title col-xs-5 text-left font"  style="width: 21%;float: left"><b>用户地址:</b></p>
          <p class="panel-title text-left input-font" style="width: 79%">{{ userinfo.f_address }}</p>
        </div>
<!--        <div class="col-xs-12" style="padding: 2px 0">-->
<!--          <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>巡检状态:</b></p>-->
<!--          <p class="panel-title col-xs-7 text-left input-font">{{ userinfo.f_state }}</p>-->
<!--        </div>-->
      </div>

    </div>

  </div>
</template>

<script>
import { HttpResetClass } from 'vue-client'
import * as Util from "../Util";
import Vue from "vue";
import RadioGroup from "vue-client/src/vue-strap/src/radioGroup";
import Radio from "vue-client/src/vue-strap/src/radioBtn";

export default {
  title: "SafecheckUserInfo",
  props: ['userinfo'],
  data() {
    return this.$parent.$parent.data
  },
  created(){
    this.$set('showbModal',false)
    //tag
    this.$set('biaoxinghao','')
  },
  ready() {
    //tag
    //tag)
    // //tag)
    // this.$set('userinfo.f_meter_no',this.userinfo.planmeterss.f_meter_no)
    // //tag)
    this.$set('beforephone',this.userinfo.f_user_phone)
    this.$set('gmlist',[])
    //tag
    if(Vue.config.safecheck != undefined){
      if(Vue.config.safecheck.SafecheckUserinfo != undefined){
        if(Vue.config.safecheck.SafecheckUserinfo.updateuserphone != undefined) {
          this.$set('updateuserphone',Vue.config.safecheck.SafecheckUserinfo.updateuserphone)
        }
      }
    }
    for (let i in this.userinfo) {
      //tag + '：' + JSON.stringify(this.userinfo[i]))
    }
    this.safecheckStateReady()
  },
  methods: {
    updatebiaohao(f_meter_no,f_userinfo_id){
      this.$showMessage("将用户 "+this.userinfo.f_user_name+"的机表表号从"+this.userinfo.planmeterss.f_meter_no+"修改为"+f_meter_no,['confirm', 'cancel']).then((butt)=>{
        if(butt=="confirm"){
          let http = new HttpResetClass()
          http.load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/safecheckUpdateBiaoHao`, {
            f_meter_no:f_meter_no,
            f_userinfo_id: f_userinfo_id
          }, {resolveMsg: null, rejectMsg: null}).then((res) => {
            if(res.data.code == 200){
              this.$showMessage('修改成功！')
            }else{
              this.$showMessage('修改失败！,网络异常')
            }
          })
        }
      })
    },
    biaoxinghaook(){
      if (this.biaoxinghao==''){
        this.$showMessage("请选择表型号")
        return
      }
      //tag
      //tag
      this.$showMessage("是否确定进行修改?",['confirm', 'cancel']).then((butt)=>{
        if(butt=="confirm"){
          let http = new HttpResetClass()
          http.load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/safecheckUpdateBiaoXingHao`, {
            biaoxinghao:this.biaoxinghao,
            f_userinfo_id: this.userinfo.f_userinfoid
          }, {resolveMsg: null, rejectMsg: null}).then((res) => {
            if(res.data.code == 200){
              this.$showMessage('修改成功！')
              //tag
              this.showbModal=false
            }else{
              this.$showMessage('修改失败！,网络异常')
            }
          })
        }
      })


    },
    biaoxinghaocancel(){
      //tag
      this.showbModal=false
    },
    showbiaoxinghao(){
      this.gmlist=[]
      //tag)
      //tag
      let http1 = new HttpResetClass()
      http1.load('POST',`${this.$androidUtil.getProxyUrl()}/rs/sql/tel_singleTable_OrderBy`, {data: {
          items: 'gm.id,gm.f_meter_style',
          tablename: 't_gasbrand gb LEFT JOIN t_gasmodel gm ON gb.id= gm.f_gasbrand_id ',
          condition: `f_meter_brand  = '${this.userinfo.planmeterss.f_aliasname}'`,
         // condition: `f_meter_brand  = 'this.userinfo.planmeterss'`,
          orderitem: 'gm.id'
        }}, {resolveMsg: null, rejectMsg: null}).then((ress) => {
         ress.data.forEach(res=>{
           this.gmlist.push({
             label:res.f_meter_style,
             value:res.id
           })
         })
        //tag)
        //tag
        this.showbModal=true
      })



    },
    updatePhone(f_user_phone,f_userinfo_id){

      this.$showMessage("将用户 "+this.userinfo.f_user_name+"的电话号码从"+this.beforephone+"修改为"+f_user_phone,['confirm', 'cancel']).then((butt)=>{
        if(butt=="confirm"){
          let http = new HttpResetClass()
          http.load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/safecheckUpdatePhone`, {
            f_user_phone:f_user_phone,
            f_userinfo_id: f_userinfo_id
          }, {resolveMsg: null, rejectMsg: null}).then((res) => {
            if(res.data.code == 200){
              this.$showMessage('修改成功！')
            }else{
              this.$showMessage('修改失败！,网络异常')
            }
          })
        }
      })
    },
    searchHistory(f_userinfo_id) {
      this.$dispatch('gotoson', {
        _this: this.$parent.$parent,
        title: '购气记录',
        safe: true
      })
      this.$parent.$parent.$goto('phone-sell-info', {f_userinfo_id: f_userinfo_id})
    },
    cameraCallBack(prop, fileName) {
      HostApp.__this__.$set(prop, fileName + '?' + Math.random())
      //tag
      HostApp.__callback__ = null
      HostApp.__this__ = null
    },
    takePic(prop, title) {
      HostApp.__callback__ = this.cameraCallBack
      HostApp.__this__ = this
      //tag
      let fileName
      if (!this[prop] || this[prop].includes("nopic.png")) {
        fileName = Util.guid() + '-' + prop + '.jpg'
      } else {
        fileName = Util.getFileName(this[prop])
      }
      HostApp._open_a_page({
        type: 'boomerang',
        page: 'com.aofeng.hybrid.android.peripheral.CameraActivity',
        param: {
          file: fileName,
          requestCode: 111,
          callback: 'javascript:HostApp.__callback__("' + prop + '", "%s");',
          watermark: title + '\t时间：' + Util.toStandardTimeString() + '\t' + Vue.user.name
        }
      })
    },
    delfile(prop, fileName) {
      if (fileName == Vue.nopic)
        return
      else {
        HostApp.delfile(fileName)
        this[prop] = Vue.nopic
      }
    },
    setEntryClass(val) {
      if (val == '到访不遇') {
        this.f_usegas = ''
        this.$set('f_entry_class', 'warning')
      } else if (val == '拒检') {
        this.f_usegas = ''
        this.$set('f_entry_class', 'danger')
      } else if (val == '入户') {
        this.$set('f_entry_class', 'success')
      }
    },
    setUsegas(val) {
      if (val == '未使用')
        this.$set('f_useclass', 'default')
      if (val == '已使用')
        this.$set('f_useclass', 'success')
    },
    start() {
      this.$parent.$parent.isStrat = true
      this.$set('action', !this.action)
      this.$set('f_onsite_time', Util.toStandardTimeString())
    },
    safecheckStateReady() {
      //tag
      //tag
      //tag
      if (!this.$parent.$parent.showBack) {
        this.$parent.$parent.showBack = true
      }
      this.$set('last_check_result', '')
      this.$set('last_check_data.data', [])
      if (this.$parent.$parent.role == 'inspect' && this.f_complete != '已完成') {
        this.start()
      }
      if (this.$parent.$parent.data.f_onsite_time) {
        //tag
        this.$parent.$parent.startClick = true
      }
      this.action = true
      //tag
      if (this.f_onsite_time) {
        this.$parent.$parent.isStrat = true
        this.$parent.$parent.data.f_onsite_time = Util.toStandardTimeString()
      }
      if (this.$parent.$parent.role == 'repair') {
        this.$set('style__', 'divmask')
        this.$set('style_view_', '')
      } else if (this.$parent.$parent.role == 'view') {
        this.$set('style__', 'divmask')
        this.$set('style_view_', 'divmask')
        //tag
      } else {
        this.$set('style__', '')
        this.$set('style_view_', '')
      }
      if (!this.f_nongasuser_path)
        this.$set('f_nongasuser_path', '')
      if (!this.f_noanswer_path)
        this.$set('f_noanswer_path', '')
      if (!this.f_rejectcheck_path)
        this.$set('f_rejectcheck_path', '')


      this.$watch('f_usegas', (val) => {
        this.setUsegas(val)
      })

      this.setEntryClass(this.f_entry_status)
      this.$watch('f_entry_status', (val) => {
        this.setEntryClass(val)

        if (val == '到访不遇') {
          this.f_rejectcheck_path = Vue.nopic
        }
        if (val == '拒检') {
          this.f_noanswer_path = Vue.nopic
        }

        if (val != '入户') {
          //清理安检概括
          this.f_no_gas_device = false
          this.f_unload_battery = false
          this.f_close_valve = false
          //清理全局隐患
          this.f_defect_cramped = false
          this.f_defect_bedroom = false
          this.f_defect_longpipe = false
          this.f_defect_firesource = false
          this.f_defect_explosive = false
          this.f_defect_viacabinet = false
          this.f_defect_intermittent = false
          this.f_defect_nearfire = false
          this.f_defect_openkitchen = false
          this.f_defect_hang = false
          this.f_cramped_path = Vue.nopic
          //用户评价
          this.f_client_evaluation = null
          //清设备
          this.$set('f_meters', [])
          this.$set('f_plumbs', [])
          this.$set('f_valves', [])
          this.$set('f_inner_plumbs', [])
          this.$set('f_alarms', [])
          this.$set('f_cookers', [])
          this.$set('f_heaters', [])
          this.$set('f_furnaces', [])
        }
      })
    }
  },
  components: {
    RadioGroup,
    Radio
  },
}
</script>

<style scoped>

.font {
  font: 15px PingFang-SC-Medium;
  color: #666666;
}

.input-font {
  font: 15px PingFang-SC-Medium;
  color: #333333;
}

.app-text {
  font-size: 12px;
}

.panel-self {
  border-radius: 10px;
  border: 1px solid #499EDF;
  background-color: #F8F8F8;
}

.app-text {
  font-size: 12px;
}

.panel-self {
  border-radius: 5px;
  border: 1px solid #c5e1f7;
  background-color: #F2F6FA;
}

.font {
  font: 15px PingFang-SC-Medium;
  color: #333333;
}

.panel-self {
  border-radius: 5px;
  border: 1px solid #c5e1f7;
  background-color: #F2F6FA;
}

.text-left {
  text-align: left;
}

.font {
  font: 15px PingFang-SC-Medium;
  color: #333333;
}

.btn-photo {
  border: 0;
  border-radius: 7px;
  background-color: #7dc1f4;
  font: 15px PingFang-SC-Bold;
  height: 20%;
}

.div-photo {
  width: auto;
  height: auto;
  /* margin-top: 10px; */
  position: absolute;
  bottom: 10px;
  right: 10px;
}
</style>
