<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">
            <label style="color: #00b3ee;text-decoration:none;">{{ userinfo.f_userinfo_code }}</label>
            <label v-if="upUserinfoSta=='是'" style="color: #00b3ee;text-decoration:none;"
                   @click="upuserinfo(userinfo.f_userinfoid)">信息变更</label>
          </p>
        </div>
        <div class="col-xs-12 row" style="padding: 2px 0">
          <button type="button" name="button" class="btn btn-primary btn-photo"
                  @click="searchHistory(userinfo.f_userinfoid,'缴费记录')">缴费记录
          </button>
          <button type="button" name="button" class="btn btn-primary btn-photo"
                  @click="searchHistory(userinfo.f_userinfoid,'抄表记录')">抄表记录
          </button>
          <button type="button" name="button" class="btn btn-primary btn-photo"
                  @click="searchHistory(userinfo.f_userfiles_id,'欠费记录')">欠费记录
          </button>
          <button type="button" name="button" class="btn btn-primary btn-photo"
                  @click="searchHistory(userinfo.f_userinfoid,'保险记录')">保险记录
          </button>
        </div>
        <div class="col-xs-12 row" style="padding: 2px 0">
          <button type="button" name="button" class="btn btn-primary btn-photo"
                  @click="history(userinfo.f_userinfoid,'增值收费')">增值收费
          </button>
          <button type="button" name="button" class="btn btn-primary btn-sm" style="float: right"
                  @click="history(userinfo.f_userinfoid,'安装列表')">安装列表
          </button>
        </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"/>

        </div>
        <!--        <div class="col-xs-12" style="padding: 2px 0" v-if="updateuserphone&&(userinfo.planmeterss.f_aliasname=='机表')">-->
        <!--          <p class="panel-title text-left font" style="width: 23%;float: left"><b>机表表号:</b></p>-->
        <!--          <input class="panel-title text-left input-font" style="width: 53%" value="{{ userinfo.f_meter_no }}" v-model="userinfo.f_meter_no"/>-->

        <!--        </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_residential_area }}</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 text-left input-font" style="width: 79%;float: left">{{ 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 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">{{ f_onsite_time }}</p>
        </div>
        <div class="col-xs-12">
          <button type="button" style="width: 45%;float: left" class="btn btn-primary" v-if="updateuserphone"
                  @click="updatePhone(userinfo.f_user_phone,userinfo.f_userinfoid)">电话修改
          </button>
          <button type="button" style="width: 45%;float: right" class="btn btn-primary" v-if="updatemetermodel"
                  @click="showbiaoxinghao()">表型号修改
          </button>
        </div>
        <div class="col-xs-12">
          <button type="button" style="width: 45%;float: left" class="btn btn-primary"
                  v-if="updatemeternumber&&(userinfo.planmeterss.f_aliasname=='机表')"
                  @click="updatebiaohao(userinfo.f_meter_no,userinfo.f_userinfoid)">表号修改
          </button>
          <!--          <button  type="button"  style="width: 45%;float: right" class="btn btn-primary" v-if="updateuserphone"  @click="showbiaoxinghao()">表型号修改</button>-->
        </div>
      </div>
      <div class="panel-body">
        <div v-show="false" class="row repair-info-content auto">
          <div class="col-xs-12 col-sm-12 col-md-12 form-input-group">
            <label class="control-label">
              <nobr>到达时间：</nobr>
            </label>
            <span>{{ f_onsite_time }}</span>
          </div>
          <div class="col-xs-12 col-sm-12 col-md-12 form-input-group" v-if="data.f_date_leave">
            <label class="control-label">
              <nobr>离开时间：</nobr>
            </label>
            <span>{{ f_offsite_time }}</span>
          </div>
        </div>


        <div style="font-size: medium;" :class="style__">
          <span class="col-md-3 col-sm-4 col-xs-4  text-left"><img src="../../../assets/housestyle.png"
                                                                   style="width: 20px;margin-bottom: 5px;text-align: left"
                                                                   alt="">入户状态:</span>
          <div :class="style__" class="col-md-9 col-sm-8 col-xs-8 text-center">
            <input type="radio" name="enterstatus" v-model="f_entry_status" id="nopeople" value="到访不遇">到访不遇
            <input type="radio" name="enterstatus" v-model="f_entry_status" id="rejectchecck" value="拒检">拒检
            <input type="radio" name="enterstatus" v-model="f_entry_status" id="enterhouse" value="入户">入户
          </div>
          <div :class="style__" class="col-md-9 col-sm-8 col-xs-8 text-center">
            <input type="radio" name="enterstatus" v-model="f_entry_status" id="enterhouse" value="激光检测">激光检测
          </div>
        </div>
        <div class="form-group col-sm-12 col-xs-12" :class="style__" v-show="f_entry_status=='到访不遇'">
          <label class="text-left font">到访不遇照片：</label>
          <div class="auto">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self"
                   style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
                <div class="row" style="height: 240px;overflow: scroll;top: 1px">
                  <div class="col-xs-4 col-sm-3 col-md-2" style="margin-bottom: 35px"
                       v-for="(index,img) in f_noanswers_path">
                    <img-self :src="img.f_noanswer_path" alt="到访不遇照片" :width="130" :height="160"></img-self>
                    <img src="../../../assets/删除.png" @click="delfile('f_noanswers_path', img.f_noanswer_path,index)"
                         style="width: 15px;margin-top: -80px" alt="">
                  </div>
                </div>
                <div class="row text-right div-photo" :class="style__">
                  <button type="button" name="button" class="btn btn-primary btn-photo"
                          @click="takePic('拍照','f_noanswers_path', '到访不遇照片')">拍照
                  </button>
                  <!--                    <button type="button" name="button" class="btn btn-primary btn-photo"-->
                  <!--                            @click="takePic('相册','f_noanswers_path', '到访不遇照片')">相册-->
                  <!--                    </button>-->
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="form-group col-sm-12 col-xs-12" :class="style__" v-show="f_entry_status=='激光检测'">
          <label class="text-left font">激光检测照片：</label>
          <div class="auto">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self"
                   style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
                <div class="row" style="height: 240px;overflow: scroll;top: 1px">
                  <div class="col-xs-4 col-sm-3 col-md-2" style="margin-bottom: 35px"
                       v-for="(index,img) in f_noanswers_path">
                    <img-self :src="img.f_noanswer_path" alt="到访不遇照片" :width="130" :height="160"></img-self>
                    <img src="../../../assets/删除.png" @click="delfile('f_noanswers_path', img.f_noanswer_path,index)"
                         style="width: 15px;margin-top: -80px" alt="">
                  </div>
                </div>
                <div class="row text-right div-photo" :class="style__">
                  <button type="button" name="button" class="btn btn-primary btn-photo"
                          @click="takePic('拍照','f_noanswers_path', '激光检测照片')">拍照
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="form-group col-sm-12 col-xs-12" :class="style__" v-show="f_entry_status=='拒检'">
          <label class="text-left font">拒检照片：</label>
          <div class="auto">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self"
                   style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
                <div class="row" style="height: 240px;overflow: scroll;top: 1px">
                  <div class="col-xs-4 col-sm-3 col-md-2" style="margin-bottom: 35px"
                       v-for="(index,img) in f_rejectchecks_path">
                    <img-self :src="img.f_rejectcheck_path" alt="拒检照片" :width="130" :height="160"></img-self>
                    <img src="../../../assets/删除.png"
                         @click="delfile('f_rejectchecks_path', img.f_rejectcheck_path,index)"
                         style="width: 15px;margin-top: -80px" alt="">
                  </div>
                </div>
                <div class="row text-right div-photo" :class="style__">
                  <button type="button" name="button" class="btn btn-primary btn-photo"
                          @click="takePic('拍照','f_rejectchecks_path', '拒检照片')">拍照
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="form-group col-sm-12 col-xs-12" :class="style__" v-show="f_entry_status=='入户' && false"
             style="margin-top: 6px">
          <span class="text-left col-md-3 col-sm-4 col-xs-4"> <img src="../../../assets/enterstatus.png"
                                                                   style="width: 20px;margin-bottom: 5px;text-align: left"
                                                                   alt="">燃气使用:</span>
          <div :class="style__" class="col-md-9 col-sm-8 col-xs-8 text-center">
            <input type="radio" name="isuseed" v-model="f_usegas" id="useedgas" value="已使用">已使用&ensp;&ensp;
            <input type="radio" name="isuseed" v-model="f_usegas" id="nousegas" value="未用气">未用气
          </div>
        </div>
        <div class="form-group col-sm-12 col-xs-12" :class="style__" v-show="f_usegas == '未用气'">
          <label class="text-left font">未使用天然气照片：：</label>
          <div class="auto">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self"
                   style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
                <div class="row" style="height: 240px;overflow: scroll;top: 1px">
                  <div class="col-xs-4 col-sm-3 col-md-2" style="margin-bottom: 35px">
                    <img-self :src="f_nongasuser_path" alt="未使用天然气照片" :width="130" :height="160"></img-self>
                    <img src="../../../assets/删除.png" @click="delfile('f_nongasuser_path', this.f_nongasuser_path)"
                         style="width: 15px;margin-top: -80px" alt="">
                  </div>
                </div>
                <div class="row text-right div-photo" :class="style__">
                  <button type="button" name="button" class="btn btn-primary btn-photo"
                          @click="takePic('拍照','f_nongasuser_path', '未使用天然气照片')">拍照
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
    <!--    <div :class="style__" class="form-group" v-show="f_usegas == '未使用'">-->
    <!--      <sapn class="text-left col-md-12 col-sm-12 col-xs-12">处置方式：</sapn>-->
    <!--      <div class="col-xs-12 col-sm-12 col-md-12">-->
    <!--        <input type="checkbox" v-model="f_no_gas_device">无燃气具-->
    <!--        <input type="checkbox" v-model="f_close_valve">关闭表前阀-->
    <!--        <input type="checkbox" v-model="f_unload_battery">取下表内电池-->
    <!--      </div>-->
    <!--    </div>-->
    <div class="auto app-text" style="margin-top: 5px;" v-if="this.$parent.$parent.role != 'view'">
      <div class="panel" style="padding: 10px 7px 10px 0px;">
        <div class="panel-body panel-self">
          <div v-show="false" class="row">
            <p class="panel-title col-xs-4 text-left font">建档时间</p>
            <p class="panel-title col-xs-8 text-left input-font">{{ newfile_date }}</p>
          </div>
          <div class="row" v-if="last_check_date != null && last_check_date != ''">
            <p class="panel-title col-xs-4 text-left font">上次安检时间</p>
            <p class="panel-title col-xs-8 text-left input-font">{{ last_check_date }}</p>
          </div>
          <div class="row" v-if="last_check_date != null && last_check_date != ''">
            <p class="panel-title col-xs-4 text-left font">上次安检人员</p>
            <p class="panel-title col-xs-8 text-left input-font">
              {{ this.$parent.$parent.item.f_plan_meters[0].f_checker_name }}</p>
          </div>
          <div class="row">
            <p class="panel-title col-xs-4 text-left font">上次安检状态</p>
            <p class="panel-title col-xs-8 text-left input-font"
               v-if="last_check_date != null && last_check_date != ''">{{ last_check_state }}</p>
            <p class="panel-title col-xs-8 text-left input-font"
               v-if="last_check_date == null || last_check_date == ''">未安检</p>
          </div>
          <div class="row" v-if="last_check_date != null && last_check_date != ''">
            <p class="panel-title col-xs-4 text-left font">上次安检结果</p>
            <p class="panel-title col-xs-8 text-left input-font" :class="last_check_result=='正常'?'':'color-red'">
              {{ last_check_result }}</p>
            <div v-for="data in last_check_data.data" class="panel-title col-xs-offset-4 col-xs-8 text-left input-font">
              <p v-for="(key,item) in data">
                {{ key }}:{{ item }}
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div v-if="showbModal">
    <modal :show.sync="showbModal" v-ref:modal backdrop="false">
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          选择表型号
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <div class="col-xs-12">

          <v-select :value.sync="biaoxinghao" v-model='biaoxinghao'
                    :value-single="true"
                    class="select_list select"
                    :options='gmlist' placeholder='请选择表型号'
                    close-on-select width="100%"></v-select>
        </div>
        <div class="col-xs-12" style="height: 10px">

        </div>

      </div>
      <div slot="modal-footer" class="modal-footer">
        <button class="btn btn-default" @click="biaoxinghaook()">确认</button>
        <button class="btn btn-default" @click="biaoxinghaocancel()">取消</button>
      </div>
    </modal>
  </div>
</template>

<script>
import {HttpResetClass} from 'vue-client'
import * as Util from '../../../components/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)
        }
        if (Vue.config.safecheck.SafecheckUserinfo.updatemetermodel != undefined) {
          this.$set('updatemetermodel', Vue.config.safecheck.SafecheckUserinfo.updatemetermodel)
        }
        if (Vue.config.safecheck.SafecheckUserinfo.updatemeternumber != undefined) {
          this.$set('updatemeternumber', Vue.config.safecheck.SafecheckUserinfo.updatemeternumber)
        }
      }
    }
    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('修改失败！,网络异常')
            }
          })
        }
      })
    },
    upuserinfo(f_userinfo_id) {
      this.$dispatch('gotoson', {
        _this: this.$parent.$parent,
        title: '档案信息变更',
        safe: false
      })
      this.$parent.$parent.$goto('PhoneUpUserinfo', {f_userinfo_id: f_userinfo_id, f_source: '安检'})
    },
    searchHistory(f_userinfo_id, title) {
      this.$dispatch('gotoson', {
        _this: this.$parent.$parent,
        title: title,
        safe: true
      })
      this.$parent.$parent.$goto('phone-record-info', {f_userinfo_id: f_userinfo_id, title: title})
    },
    history(f_userinfo_id,val) {
      this.$dispatch('gotoson', {
        _this: this.$parent.$parent,
        title: val,
        safe: false
      })
      let llink = 'phone-add-value'
      this.$parent.$parent.$goto(llink, {f_userinfo_id: f_userinfo_id,user:this.userinfo,val:val})
    },
    cameraCallBack(prop, fileName) {
      if (prop == 'f_noanswers_path') {
        let f_noanswer_path = fileName + '?' + Math.random()
        HostApp.__this__.f_noanswers_path.push({
          f_noanswer_path: f_noanswer_path
        })
      } else if (prop == 'f_rejectchecks_path') {
        let f_rejectcheck_path = fileName + '?' + Math.random()
        HostApp.__this__.f_rejectchecks_path.push({
          f_rejectcheck_path: f_rejectcheck_path
        })
      } else {
        HostApp.__this__.$set(prop, fileName + '?' + Math.random())
      }
      HostApp.__callback__ = null
      HostApp.__this__ = null
    },
    takePic(type, prop, title) {
      HostApp.__callback__ = this.cameraCallBack
      HostApp.__this__ = this
      //tag
      let fileName
      if (prop == 'f_noanswers_path') {
        //tag
        if (this.f_noanswers_path.length == 3) {
          return
        }
        fileName = Util.guid() + '-' + prop + '.jpg'
      } else if (prop == 'f_rejectchecks_path') {
        //tag
        if (this.f_rejectchecks_path.length == 3) {
          return
        }
        fileName = Util.guid() + '-' + prop + '.jpg'
      } else {
        if (!this[prop] || this[prop].includes('nopic.png')) {
          fileName = Util.guid() + '-' + prop + '.jpg'
        } else {
          fileName = Util.getFileName(this[prop])
        }
      }
      let jingweidu = ''
      if (this.$parent.$parent.is_has_jingweidu == 'true') {
        const obj = HostApp.getGpsDetailAddress()
        jingweidu = '\t经度：' + obj.longitude + '\t纬度：' + obj.latitude
      }
      let page = 'com.aofeng.hybrid.android.peripheral.CameraActivity'
      if (type === '相册') {
        page = 'com.aofeng.hybrid.android.peripheral.ActionPickActivity'
      }
      HostApp._open_a_page({
        type: 'boomerang',
        page,
        param: {
          file: fileName,
          requestCode: 111,
          callback: 'javascript:HostApp.__callback__("' + prop + '", "%s");',
          watermark: title + '\t时间：' + Util.toStandardTimeString() + '\t' + Vue.user.name + jingweidu
        }
      })
    },
    delfile(prop, fileName, index) {
      if (fileName == Vue.nopic) {
        return
      } else {
        if (prop == 'f_noanswers_path') {
          this.f_noanswers_path.splice(index, 1)
          HostApp.delfile(fileName)
        } else if (prop == 'f_rejectchecks_path') {
          this.f_rejectchecks_path.splice(index, 1)
          HostApp.delfile(fileName)
        } 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)
      if (!this.f_onsite_time){
        this.$set('f_onsite_time', Util.toStandardTimeString())
      }
    },
    safecheckStateReady() {
      //tag
      //tag
      //tag
      if (!this.$parent.$parent.showBack) {
        this.$parent.$parent.showBack = true
      }
      //兼容下-如果没有通过外层查询带进来最新安检时间，就拿本地单子里存的上次安检时间
      if (this.$parent.$parent.item.f_plan_meters.length > 0) {
        this.$set('last_check_date', this.$parent.$parent.item.f_plan_meters[0].f_last_check_date)
        this.$set('last_check_state', this.$parent.$parent.item.f_plan_meters[0].f_last_check_state)
        this.$set('newfile_date', this.$parent.$parent.item.f_plan_meters[0].f_newfile_date)
        if (this.$parent.$parent.item.f_plan_meters[0].f_last_check_result) {
          let checkResult = JSON.parse(this.$parent.$parent.item.f_plan_meters[0].f_last_check_result)
          this.$set('last_check_result', checkResult.result)
          this.$set('last_check_data.data', checkResult.data)
        } else {
          this.$set('last_check_result', '')
          this.$set('last_check_data.data', [])
        }
      } else {
        this.$set('last_check_state', this.$parent.$parent.item.f_plan_meters[0].f_last_check_state)
        this.$set('last_check_date', this.$parent.$parent.item.f_last_check_date)
        if (this.$parent.$parent.item.f_last_check_result) {
          let checkResult = JSON.parse(this.$parent.$parent.item.f_last_check_result)
          this.$set('last_check_result', checkResult.result)
          this.$set('last_check_data.data', checkResult.data)
        } else {
          this.$set('last_check_result', '')
          this.$set('last_check_data.data', [])
        }
      }

      this.$set('upUserinfoSta', '否')
      this.upUserinfoSta = this.$appdata.getSingleValue('安检修改档案信息')

      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', '')
      }
      //到访多张照片
      this.$set('f_noanswers_path', [])
      if (this.f_noanswer_path) {
        this.f_noanswers_path.push({f_noanswer_path: this.f_noanswer_path})
      } else {
        this.$set('f_noanswer_path', '')
      }
      if (this.f_noanswer1_path) {
        this.f_noanswers_path.push({f_noanswer_path: this.f_noanswer1_path})
      } else {
        this.$set('f_noanswer1_path', '')
      }
      if (this.f_noanswer2_path) {
        this.f_noanswers_path.push({f_noanswer_path: this.f_noanswer2_path})
      } else {
        this.$set('f_noanswer2_path', '')
      }

      if (!this.f_rejectcheck_path) {
        this.$set('f_rejectcheck_path', '')
      }
      //拒检多张照片
      this.$set('f_rejectchecks_path', [])
      if (this.f_rejectcheck_path) {
        this.f_rejectchecks_path.push({f_rejectcheck_path: this.f_rejectcheck_path})
      } else {
        this.$set('f_rejectcheck_path', '')
      }
      if (this.f_rejectcheck1_path) {
        this.f_rejectchecks_path.push({f_rejectcheck_path: this.f_rejectcheck1_path})
      } else {
        this.$set('f_rejectcheck1_path', '')
      }
      if (this.f_rejectcheck2_path) {
        this.f_rejectchecks_path.push({f_rejectcheck_path: this.f_rejectcheck2_path})
      } else {
        this.$set('f_rejectcheck2_path', '')
      }

      this.$watch('f_noanswers_path.length', () => {
        //tag)
        for (let i = 0; i < 3; i++) {

          if (this.f_noanswers_path[i] && this.f_noanswers_path[i].f_noanswer_path) {
            //tag)
            if (i == 0) {
              this.f_noanswer_path = this.f_noanswers_path[i].f_noanswer_path
            } else {
              this['f_noanswer' + i + '_path'] = this.f_noanswers_path[i].f_noanswer_path
            }
          } else {
            //tag)
            if (i == 0) {
              this.f_noanswer_path = null
            } else {
              this['f_noanswer' + i + '_path'] = null
            }
          }
        }
        //tag
      })
      this.$watch('f_rejectchecks_path.length', () => {
        //tag)
        for (let i = 0; i < 3; i++) {

          if (this.f_rejectchecks_path[i] && this.f_rejectchecks_path[i].f_rejectcheck_path) {
            //tag)
            if (i == 0) {
              this.f_rejectcheck_path = this.f_rejectchecks_path[i].f_rejectcheck_path
            } else {
              this['f_rejectcheck' + i + '_path'] = this.f_rejectchecks_path[i].f_rejectcheck_path
            }
          } else {
            //tag)
            if (i == 0) {
              this.f_rejectcheck_path = null
            } else {
              this['f_rejectcheck' + i + '_path'] = null
            }
          }
        }
        //tag
      })

      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
          this.f_rejectcheck1_path = Vue.nopic
          this.f_rejectcheck2_path = Vue.nopic
          this.f_rejectchecks_path = []
          this.f_rejectcheck_path = Vue.nopic
          this.f_rejectcheck1_path = Vue.nopic
          this.f_rejectcheck2_path = Vue.nopic
          this.f_rejectchecks_path = []
        }
        if (val == '到访不遇') {
          this.f_rejectcheck_path = Vue.nopic
          this.f_rejectcheck1_path = Vue.nopic
          this.f_rejectcheck2_path = Vue.nopic
          this.f_rejectchecks_path = []
        }
        if (val == '拒检') {
          this.f_noanswer_path = Vue.nopic
          this.f_noanswer1_path = Vue.nopic
          this.f_noanswer2_path = Vue.nopic
          this.f_noanswers_path = []
        }
        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_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', [])
        } else {
          this.f_rejectcheck_path = Vue.nopic
          this.f_noanswer_path = Vue.nopic
          this.f_novisit_reason = null
        }
      })
    }
  },
  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>
