<template>
  <!--<div class="app-botton" @click="back()">-->
  <!--返回<span class="glyphicon glyphicon-menu-right"></span>-->
  <!--</div>-->
  <div class="no-close row android-repair-order" style="background-color: #f9f9f9">
    <div class="col-sm-12 col-xs-12" >
      <ul class="nav nav-tabs" style="background:#ffffff;overflow-y: hidden">
        <li v-for="row in tabs" @click="tabSelect(row,$index)" :class="{active1: row.complete === componentName}"
            v-if="$index < number+1 && $index < faultshow.number" >
          <a href="#" style="background-color: #ffffff;color: #666666;font-size: 16px;font-family:SimSun" :class="row.class">
            <span class="spanboder">{{row.header}}</span>
            <img class="butt2" :src="imgback(row.complete === componentName,row.header === header)"></a>
          <p></p>
        </li>
        <div class="col-sm-12 col-xs-12 repair-bg"  v-show="routeShow">
          <route name='repair' :reuse="false"></route>
        </div>
        <li v-for="row in tabs" @click="tabSelect(row,$index)" :class="{active1: row.complete === componentName}"
            v-if="$index > number && $index < faultshow.number ">
          <a href="#" style="background-color: #ffffff;color: #666666;font-size: 16px;font-family:SimSun" :class="row.class">
            <span class="spanboder">{{row.header}}</span>
            <img class="butt2" :src="imgback(row.complete === componentName,row.header === header)"></a>
          <p></p>
        </li>
        <div class="col-sm-12 col-xs-12 repair-bg" v-if="actionEnabled ">
          <div class="auto select-overspread form-horizontal repair-bg " style="padding-bottom:5px;">
            <div class="bq-parent">
              <blockquote class="blockquote">
                <p>安检上传</p>
              </blockquote>
            </div>
            <div class="panel panel-default auto repair-info-content">
              <div class="panel-body ">
                <div id="savebut"  class="row auto">
                  <!--<div class="col-xs-12 col-sm-12 col-md-12" :style="timeSet(this.isneedDate)?'':'display:none'">-->
                  <!--<label>请输入超期原因:</label><br/>-->
                  <!--<textarea style="width: 100%;" v-model=""></textarea>-->
                  <!--</div>-->
                  <div class="col-xs-3 col-sm-3 col-md-3">
                    <button class="col-sm-2 btn btn-primary" @click="save('temp')" >
                      临时保存
                    </button>
                  </div>
                  <div class="col-xs-3 col-sm-3 col-md-3">
                    <button class="col-sm-2 btn btn-primary" @click="save('finish')" >
                      本地缓存
                    </button>
                  </div>
                  <div class="col-xs-3 col-sm-3 col-md-3">
                    <button type="button" name="button" class="col-sm-2 btn btn-primary" @click="uploadCheckPaper" :disabled="isdisable">
                      上传
                    </button>
                  </div>
                  <div class="col-xs-3 col-sm-3 col-md-3">
                    <button type="button" name="button" class="col-sm-2 btn btn-primary" @click="showRepair" :disabled="isdisable">
                      转维修
                    </button>
                  </div>

                </div>
              </div>
            </div>
          </div>
        </div>
      </ul>
    </div>
    <modal :show.sync="showModal2" :backdrop="false">
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          转维修
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <!--      <div class="row" style="margin-top: 6px">-->
        <!--        <label style="color: red;">注:当前页面无法取消对用户的限制购气</label>-->
        <!--      </div>-->
        <div class="row" style="margin-top: 6px">
          <textarea id="el_ca_tx" v-model.trim="cremarks" style="border-radius:4px;width: 100%;" placeholder="请输入转维修备注" >
          </textarea>
        </div>
      </div>
      <div slot="modal-footer" class="modal-footer">
        <button  type="button" name="button" class="col-sm-3 btn btn-primary" @click="ToRepair">转维修</button>
        <button  type="button" name="button" class="col-sm-3 btn btn-primary" @click="cancelRepair">取消</button>
      </div>
    </modal>
  </div>
</template>

<script>
// 户内维修
import Vue from 'vue'
import * as Util from '../Util'
import $ from 'jquery'
// import DoorService from './DoorService'
// import Pipeline from './Pipeline'
// import DeviceService from './DeviceService'
// import TroubleRemoval from './TroubleRemoval'
// import FirstGasCheck from './FirstGasCheck'
// import RepairMatterInfo from './RepairMatterInfo'
// import TelChangeMatter from './TelChangeMatter'
import { HttpResetClass } from 'vue-client'
import co from 'co'
let loadParamGem = async function (self) {
  await self.$LoadParams.loadParam()
}

export default {
  title: '安检单',
  props: ['f_plan_id', 'item', 'role','source'],
  // props: ['f_plan_id', 'role'],
  data() {
    return {
      //测试数据
      // f_plan_id:'',
      // role:'inspect',
      // item:{"f_approved_time":null,"f_user_family_remarks":null,"f_street":"测试街道","f_repair_approved_time":null,
      //   "f_user_type":null,"f_approved_by":null,"f_card_id":null,"f_remark":null,"f_building":"1","f_batch_number":null,
      //   "f_idnumber":null,"f_state":"未检","id":"0EFE0EE2-B155-46F9-8DE0-38C022664A4D","f_complete":null,"f_check_state":null,"f_last_check_state":"拒检",
      //   "f_user_inhome_time":null,"f_residential_area":"测试小区1","version":1,"f_processid":null,"f_last_check_result":"{\"result\":\"正常\",\"data\":[]}",
      //   "f_area":null,"f_usegas":null,"f_user_phone":"16566546548","f_slice_area":"营业大区","f_approved":"未审核","f_upload_state":"未传","f_user_check_time":null,
      //   "f_unit":"1","f_user_spare_phone":null,"f_last_check_date":null,"f_userproperties":null,"f_userfile_id":null,"f_prearranged_date":null,"f_filialeid":"453",
      //   "f_branch":null,"f_orgstr":null,"f_plan_year":2020,"f_orgid":null,"f_approval_notified":null,"f_plan_month":4,"f_approved_note":null,"f_filialeids":null,
      //   "f_floor":"1","f_flag":null,"f_repair_approved_note":null,"f_userinfo_code":"00000002","f_create_time":"2020-05-10 18:56:03","f_meter_no":"","f_station":null,
      //   "f_repair_approved":"未审核","f_no_checkplan":"有计划安检","f_plan_name":"关于","f_repair_approved_by":null,"f_room":"1","f_office":null,"f_comments":null,
      //   "f_address":"兰山街道泰盛小区1栋1单元1层1室","id_back":null,"f_userinfoid":"2","f_subcompany":null,"f_addressid":null,"f_user_phone2":null,
      //   "f_user_equipment_remarks":null,"f_plan_id":"0819ea6707ad4d9dad217c06a87f4227","f_user_name":"用户二",
      //   "f_plan_meters":[{"f_weizhi":null,"f_flow_direction":"右表","f_metertitles":"","f_prior_reading":0,"f_meter_no":"2119035714","f_collection_type":"按金额","f_aliasname":"先锋系统结算物联网表","f_meter_type":"物联网表","version":3,"f_maker":null,"f_metergasnums":0,"f_total_fee":100,"f_diaphgram_size":"G2.5","f_total_gas":0,"id":18663},{"f_weizhi":null,"f_flow_direction":"右表","f_metertitles":"","f_prior_reading":0,"f_meter_no":"2118999901","f_collection_type":"按金额","f_aliasname":"先锋系统结算物联网表","f_meter_type":"物联网表","version":1,"f_maker":null,"f_metergasnums":0,"f_total_fee":0,"f_diaphgram_size":"G2.5","f_total_gas":0,"id":18663}]
      // },

      data: {
        f_devices: [],
        f_defect_content:''
      },
      showModal2:false,
      deviceinfo:{},
      cremarks:"",
      isUpload:false,
      onlySave:true, //判断保存还是保存并上传
      livedispose:'',
      startClick:false, //开始安检按钮是否可点击
      isStrat: false, //是否开始安检
      checkResult:{},//查询结果
      newcheckResult:{},
      timer: null,
      showModal: false,
      pic_to_be_viewed: '',
      showBack:true,
      devices: [],
      isdisable:false,
      f_devices : [],
      isToRepair:false,
      clickBack:true, //是否点击返回按钮
      isSafeCheckToRepair:false,//是否转维修
      Url:this.$androidUtil.getProxyUrl(),
      detail:{},
      defectDevice:{},
      user:{},
      model: {  //转维修数据
        // 一次派单
        serviceacitivity: [{
          f_service_acitivity_type: '派单'
        }],
        f_source:'安检',
        f_service_id: '',
        f_contact_phone: '',
        f_meetunit: '',
        f_phone: '',
        f_user_name: '',
        f_address: '',
        f_repair_date: Util.toStandardTimeString(),
        f_card_id: '',
        // f_department: '', 站点选择
        f_reciever:'',
        f_remarks: '',
        f_user_type: '',
        f_area: '',
        f_unit_name:'',
        f_street: '',
        f_residential_area: '',
        f_building: '',
        f_unit: '',
        f_floor: '',
        f_room: '',
        aState: null,
        f_repairtype: '',
        f_repairitems:{},
      },
      repairitems:[],
      meading:'转站点',
      config: {
        "燃气表":{
          "checkmust":true,
          "index":1,
          "items":{
            //"燃气表照片":{"index":1,"type":"picture","remark":"(拍摄清晰的表具编号、字轮数、剩余气量等)"},
            "基表编号":{"index":1,"type":"string","readonly":false,"checkmust":true},
            "气表型号":{"index":2,"type":"string","readonly":true},
            "气表品牌":{"index":3,"type":"string","readonly":true},
            "进气方向":{"index":4,"type":"selector",
              "multiple": false,
              "checkmust":true,
              "options": [
                {
                  "data": "左表",
                  "isdefect": false,
                  "isdefault": false
                },
                {
                  "data": "右表",
                  "isdefect": false,
                  "isdefault": false
                }
              ]
            },
            "初始表底":{"index":5,"type":"number","isshow":false,"readonly":true},
            "上期表读数":{"index":6,"type":"number","readonly":true,"isshow":true},
            "本期表读数":{"index":7,"type":"number","checkmust":true},
            "累购气量":{"index":8,"type":"number","readonly":true},
            "累购金额":{"index":8,"type":"number","readonly":true},
            "已用气量":{"index":9,"type":"number","checkmust": false},//基表数
            "已用金额":{"index":9,"type":"number","checkmust": false,"isshow":false},
            "剩余气量":{"index":10,"type":"number","checkmust": false},//累购-已用
            //显示屏数  --实际剩余气量
            "剩余金额":{"index":10,"type":"number","checkmust": false},
            "气量异常差值":{"index":11,"type":"number","readonly": true,"isshow":false},
            "金额异常差值":{"index":11,"type":"number","readonly": true,"isshow":false}
          }
          // 注意，配置项的index必须与上面的固定配置保持'顺序'
        },
        // "燃气表2":{
        //   "checkmust":true,
        //   "index":2,src
        //   "items":{
        //     "燃气表照片":{"index":1,"type":"picture"},
        //     "表品牌":{"index":2,"type":"string","readonly":true},
        //     "表号":{"index":3,"type":"string","readonly":true},
        //     "表封号":{"index":4,"type":"number","readonly":true},
        //     "表型号":{"index":5,"type":"string","readonly":true},
        //     "位置":{"index":6,"type":"string","readonly":true},
        //     "表底数":{"index":7,"type":"number","readonly":true},
        //     "累购气量":{"index":8,"type":"number","readonly":true},
        //     "累购金额":{"index":8,"type":"number","readonly":true}
        //   }
        // }
      },
      // 维修项
      isneedDate:'',
      routeShow:true,
      number:0,
      shupingshow:false,
      pipeline: {},
      details: [],
      ids: '',
      savevalid: {
        uservalid: false,
        doorvalid: true,
        changetable: false
      },
      doordetails: {},
      devicedetails: {},
      cookdetails: {},
      componentName: 'safecheck-userinfo',
      header:'客户信息',
      tabs: [

        // 参数全部设置成空，在ready时，等model处理好了，再添加
        {
          header: '客户信息',complete:'safecheck-userinfo',class: 'repair-info-class', props: null
        },
        {
          header: '拍照签名',complete:'paper-feedback', class: 'outlay-class', props: null
        }
      ],
      changeinfo:'',
      faultshow:{
        number : 8
      }     // 控制 故障汇总 在 菜单里显示与否,
    }
  },
  computed: {
    actionEnabled: {
      get() {
        return this.role == 'inspect'
      }
    }
  },
  methods: {
    saveNoclick() {
      // 禁用点击事件
      $("#savebut").addClass("noclickbut");
      //tag

      // 5秒后启用点击事件
      setTimeout(function(){
        $("#savebut").removeClass("noclickbut");
      },5000);
    },
    showRepair(){
      this.showModal2=true
    },
    cancelRepair(){
      this.showModal2=false
    },
    ToRepair(){
      this.isToRepair=true
      //this.data.f_repaired='未派维修单'
      this.uploadCheckPaper()
    },
    timeSet(val){
      if (!val){
        return
      }
      let time =new Date(val).getTime()
      let time2=new Date().getTime()
      if (time2>time) {
        return true
      }
    },
    imgback(val,isheader){
      if(val && this.routeShow && isheader){
        return require('../../assets/xiangxia1.png')
      }else{
        return require('../../assets/xiangyou1.png')
      }
    },
    changediv(val){
      //tag
      return val
    },
    // 选择tab
    tabSelect (item,number) {
      this.header = item.header
      //tag
      //tag
      //tag
      //tag
      // 处理关闭/显示 内容
      if(this.number == number && !this.routeShow ){
        this.routeShow = true
      }else if(this.number == number && this.routeShow){
        this.routeShow = false
      }else if(this.number != item.complete){
        this.routeShow = true
      }
      this.number = number
      this.componentName = item.complete
      //tag
      if(item.complete == 'safecheck-devices'){
        //tag
        if(item.header != '燃气表' && this.data['device'+item.number].length == 0){
          this.data['device' + item.number].push({})
        }
        //tag
        //tag)
        let idx=this.data['device' + item.number].length - 1
        let itemprops = {
          config:this.config,
          device:this.devices[item.number-1],
          idx:idx,
          item:this.item,
          role:'inspect'
        }
        //tag
        //tag)
        //tag)
        //tag
        if(this.routeShow){
          this.$goto(item.complete, itemprops, 'repair')
          //tag
        }
      }else{
        //tag
        if(this.routeShow){
          this.$goto(item.complete, {userinfo:this.data}, 'repair')
        }
      }
      this.shupingshow = true
    },
    // 给组件添加参数
    getImgPath() {
      for (var i = 0; i < this.model.serviceacitivity[0].imgs.length; i++) {
        this.ids += this.model.serviceacitivity[0].imgs[i].imgid + ','
      }
      this.ids = this.ids.substring(0, this.ids.length - 1)
      if(this.ids){
        this.getImgGen();
      }
    },
    getImgGen(){
      let http = new HttpResetClass()
      http.load('POST','rs/sql/tel_singleTable_OrderBy', {data: {
          items: '*',
          tablename: 't_files',
          condition: `id in (${this.ids})`,
          orderitem: 'id'
        }}, {resolveMsg: null, rejectMsg: null}).then((res) => {
        for (let i = 0; i < res.data.length; i++) {
          for (let j = 0; j < this.model.serviceacitivity[0].imgs.length; j++) {
            //tag)
            //tag
            if (res.data[i].id.toString() === this.model.serviceacitivity[0].imgs[j].imgid) {
              this.model.serviceacitivity[0].imgs[j] = Object.assign({}, res.data[i], this.model.serviceacitivity[0].imgs[j])
            }
          }

        }
      })
    },

    sortDetails(){
      for (let i = 0; i < this.details.length; i++) {
        if (this.details[i].details.length) {
          for (let j = 0; j < this.details[i].details.length; j++) {
            if (this.details[i].details[j].f_type === 'a') {
              this.doordetails = {details: this.details[i].details}
              break
            }
            if (this.details[i].details[j].f_type === 'b') {
              this.devicedetails = {details: this.details[i].details}
              break
            }
            if (this.details[i].details[j].f_type === 'c') {
              this.cookdetails = {details: this.details[i].details}
              break
            }
          }
        }
      }
    },
    // 复制数据
    back () {
      let _this = this
      if(this.issee){
        _this.$back()
        return
      }
      this.$showMessage('所填写内容将不可恢复！', ['confirm', 'cancel']).then((res) => {
        if (res === 'confirm') {
          _this.$back()
        }
      })
    },
    confirm(){
      this.$dispatch('confirm')
    },
    tick() {
      this.timer = null
      this.data.f_offsite_time = Util.toStandardTimeString()
      this.timer = window.setTimeout(this.tick, 1000)
    },
    getRepairState() {
      let repaired = true
      this.data.f_defects.forEach((defect) => {
        repaired = repaired & (defect.f_ratification == '已处理')
      })
      return repaired
    },
    verifyRepairDefects() {
      this.data.f_repair_date = Util.toStandardTimeString()
      this.data.f_repaired = this.getRepairState() ? '已修' : '在修'
    },
    errorVerify() {
      let hasError = this.verifyState()
      if(hasError)
        return hasError

      if(this.data.f_entry_status != '入户')
        return null
      /*hasError = this.verifyUser()
      if(hasError)
        return hasError*/
      hasError = this.verifyDevices()
      if(hasError)
        return hasError
      hasError = this.verifyFeedback()
      if(hasError)
        return hasError
    },
    verifyState() {
      if(Vue.android && this.data.f_entry_status == '未使用天然气' && this.data.f_nongasuser_path == Vue.nopic)
        return '未使用天然气则必须拍照'
      if(Vue.android && this.data.f_entry_status == '到访不遇' && this.data.f_noanswer_path == Vue.nopic)
        return  '到访不遇必须拍照'

      if(Vue.android && this.data.f_entry_status == '激光检漏' && this.data.f_detection_path == Vue.nopic)
        return  '激光检漏必须拍照'
      if(Vue.android && this.data.f_entry_status == '立杠保压' && this.data.f_pressure_path == Vue.nopic)
        return  '立杠保压必须拍照'
      if(Vue.android && this.data.f_entry_status == '室外关阀' && this.data.f_outdoor_path == Vue.nopic)
        return  '室外关阀必须拍照'

    },
    verifyUser() {
      let prefix = '用户基本信息：'
      if(Util.required(this.data.f_user_name))
        return prefix + '用户名必须输入'
      if(Util.required(this.data.f_user_phone))
        return prefix + '用户电话必须输入'
      // if(Util.required(this.data.f_residential_area))
      //   return prefix + '小区名称必须输入'
      if(Util.required(this.data.f_address))
        return prefix + '地址必须输入'
    },
    verifyDevices() {
      for (let dev in this.config) {
        if (this.config[dev].checkmust == true) {
          let error = true
          for(let device in this.data) {
            if (device.startsWith("device")) {
              for (let item in this.data[device]) {
                if (this.data[device].length != 0 && this.data[device][item].f_device_type == dev) {
                  error = false
                }
              }
            }
          }
          if (error) {
            return "请检查" + dev
          }
        }
      }

      for (let dev in this.config) {
        for(let device in this.data) {
          if (device.startsWith("device")) {
            for (let item in this.data[device]) {
              //检查每一条安检结果
              if (this.data[device].length != 0 && this.data[device][item].f_device_type == dev) {
                for (let i in this.data[device][item].f_items) {
                  for (let it in this.config[dev].items) {
                    if (it == this.data[device][item].f_items[i].f_item_name) {
                      if (this.config[dev].items[it].checkmust == true && !this.data[device][item].f_items[i].f_item_value && parseFloat(this.data[device][item].f_items[i].f_item_value).toString() == "NaN") {
                        return dev + (this.data[device].indexOf(this.data[device][item]) + 1) + this.data[device][item].f_items[i].f_item_name + "未检查"
                      }
                    }
                  }
                  //检查安检下拉结果
                  if (this.data[device][item].f_items[i].type == 'selector' || this.data[device][item].f_items[i].type == 'radio') {
                    if (this.data[device][item].f_items[i].f_is_defect == true && this.data[device][item].f_items[i].f_path == Vue.nopic) {
                      return dev + (this.data[device].indexOf(this.data[device][item]) + 1) + this.data[device][item].f_items[i].f_item_name + this.data[device][item].f_items[i].f_item_value + "选中必须拍照"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },


    verifyFeedback() {
      let prefix = '拍照签名：'
      //tag)
      if(Vue.android && (!this.data.f_overall_imgs || this.data.f_overall_imgs.length == 0) && this.data.f_entry_status == '入户')
        return prefix + '必须有安检总体照片'
      /*if(Vue.android && (!this.data.f_sign_path || this.data.f_sign_path.length == 0) && this.data.f_entry_status == '入户')
        return prefix + '必须有用户签名'*/
      if(Vue.android && this.data.f_defect_notified && this.data.f_notified_path == Vue.nopic)
        return prefix + '下发安检通知书则必须给通知书拍照'
      /*if(!this.data.f_client_evaluation && this.data.f_entry_status == '入户')
        return  prefix + '请选择服务评价'*/
    },

    getAllDefect() {
      let checkResults = {
        result: '正常',
        data: []
      }
      let f_fist_count=0
      let f_fist_content=''
      let f_second_count=0
      let f_second_content=''
      let f_third_count=0
      let f_third_content=''
      let f_defect_text=''
      let value = ''
      let codata = JSON.parse(JSON.stringify(this.data))
      //tag)
      //tag)
      codata.f_devices = []
      this.f_devices = []
      for (let device in codata) {
        let f_device_type
        if (device.startsWith("device")) {
          //tag)
          let hasOther = ''
          let otherValue = null
          for (let item in codata[device]) {
            codata[device][item].f_create_time = Util.toStandardTimeString()
            // if (codata[device].length > 1) {
            //     let j = Number.parseInt(item) + 1
            //     f_device_type = `${codata[device][item].f_device_type}${j}`
            // } else {
            //     f_device_type = codata[device][item].f_device_type
            // }
            // //tag
            for (let i = 0; i < codata[device][item].f_items.length ; i++) {
              //tag
              if(i == 'sum'){
                continue
              }
              //tag)
              var items = codata[device][item].f_items[i]
              items.f_create_time = Util.toStandardTimeString()
              //tag)
              items.f_item_lists = []
              //tag)
              // //tag)
              // //tag} name => ${JSON.stringify(items.f_item_name)} value => ${JSON.stringify(items.f_item_value)}`)
              // console.log(`f_is_defect => ${this.config[codata[device][item]
              //     .f_device_type]
              //     .items[items.f_item_name]
              //     .options
              //     .find((option)=>option.data === items.f_item_value)
              //     .map((option)=>option.f_is_defect)}`)
              // if (items.f_is_defect && (items.f_is_defect == true || items.f_is_defect == 'true')) {
              //     //tag
              //     checkResults.result = '有隐患'
              //     //tag)
              //     //tag)
              //     // this.$set('checkResult.' + items.f_item_name, items.f_item_value)
              //       this.checkResult[items.f_item_name] = items.f_item_value
              //     //tag)
              //     // this.$set('checkResultsss.' + items.f_item_name, `${f_device_type}${items.f_item_value}`)
              //     // //tag)
              // }
              if (items.type == 'selector') {
                items.selected = []
              } else if (items.type == 'inputSelector') {
                items.selected = ''
              }
              //遍历配置项 将所选隐患项的配置信息放入保存的数据中
              let f_is_defect   //是否是隐患
              let f_defect_level   //是否是隐患
              let f_item_name = items.f_item_name
              let f_item_value
              let f_is_eliminate //隐患是否消除
              let f_meternumber = ''
              let f_user_defects = [] // 用户所有隐患
              //tag
              //tag
              if (items.type == 'selector' || items.type == 'checkbox') {
                for (let i in items.f_item_value) {
                  let configItems = this.config[codata[device][item].f_device_type].items[f_item_name]
                  //tag)
                  for (let k in configItems.options) {
                    //tag)
                    if (items.f_item_value[i] === configItems.options[k].data) {

                      f_is_defect = configItems.options[k].isdefect
                      f_item_value = items.f_item_value[i]
                      f_defect_level = configItems.options[k].level

                      //tag
                      //tag
                      //tag

                      if (f_is_defect) {
                        if (checkResults.result !== '有隐患') {
                          checkResults.result = '有隐患'
                        }
                        if (!this.checkResult.hasOwnProperty(f_item_name)) {
                          //tag
                          this.checkResult[f_item_name] = []
                        }

                        //tag
                        this.checkResult[f_item_name].push(f_item_value)
                        if(codata[device][item].f_device_type == '一级隐患'){
                          f_fist_content += `${f_item_name}:${f_item_value},`
                          f_fist_count = f_fist_count+1
                        }else if(codata[device][item].f_device_type == '二级隐患'){
                          f_second_content += `${f_item_name}:${f_item_value},`
                          f_second_count = f_second_count+1
                        }else if(codata[device][item].f_device_type == '三级隐患'){
                          f_third_content += `${f_item_name}:${f_item_value},`
                          f_third_count = f_third_count+1
                        }
                        f_defect_text += `${f_item_name}:${f_item_value},`
                      }

                      let items_list = {
                        f_is_defect: f_is_defect,
                        f_item_value: f_item_value,
                        f_defect_level: f_defect_level,
                        f_is_eliminate: null,
                        f_create_time: Util.toStandardTimeString()
                      }
                      if (!items.f_item_lists) {
                        //tag
                        items.f_item_lists = []
                        //tag)
                        if (JSON.stringify(items_list) !== '{}') {
                          //tag
                          items.f_item_lists.push(items_list)
                        }
                      } else {
                        //tag)
                        if (JSON.stringify(items_list) !== '{}') {
                          //tag
                          items.f_item_lists.push(items_list)
                        }
                      }
                    }
                  }
                }
              } else {
                let configItems = this.config[codata[device][item].f_device_type].items[items.f_item_name]
                //tag)
                f_is_defect = configItems.isdefect
                f_defect_level = configItems.level
                f_item_value = items.f_item_value
                //tag
                //tag
                //tag
                let items_list = {
                  f_is_defect: f_is_defect,
                  f_item_value: f_item_value,
                  f_defect_level: f_defect_level,
                  f_create_time: Util.toStandardTimeString()
                }
                if (f_is_defect && f_item_value) {
                  items.f_is_defect = true
                  if (checkResults.result !== '有隐患') {
                    checkResults.result = '有隐患'
                  }
                  if (!this.checkResult.hasOwnProperty(items.f_item_name)) {
                    //tag
                    this.checkResult[items.f_item_name] = []
                  }

                  //tag
                  this.checkResult[items.f_item_name].push(f_item_value)

                }
                //tag)
                //tag)
                if (!items.f_item_lists) {
                  //tag
                  items.f_item_lists = []
                  if (JSON.stringify(items_list) != '{}') {
                    //tag
                    items.f_item_lists.push(items_list)
                  }
                } else {
                  // items.f_item_lists[0].f_item_value = f_item_value
                  if (JSON.stringify(items_list) != '{}') {
                    //tag
                    //tag)
                    //tag)
                    //tag
                    items.f_item_lists.push(items_list)
                  }
                }
              }
              if (hasOther !== '' && otherValue !== null) {
                //tag
                this.checkResult[hasOther].push(otherValue)
                hasOther = ''
                otherValue = null
              }
              items.f_item_value = ''
            }
            //tag)
            this.f_devices.push(codata[device][item])
          }
        }
      }
      if (this.checkResult) {
        for (let key in this.checkResult) {
          // 上次安检结果数据组织
          //tag
          //tag
          let temp = {}
          temp[key] = this.checkResult[key].join(',')
          checkResults.data.push(temp)
          // this.newcheckResult[key] = this.checkResult[key]
          // checkResults.data.push(this.newcheckResult)
          //tag)
          // this.newcheckResult = {}
        }
        this.checkResult = {}
      }
      //tag
      //tag)
      codata.f_fist_count = f_fist_count
      codata.f_fist_content = f_fist_content
      codata.f_second_count = f_second_count
      codata.f_second_content = f_second_content
      codata.f_third_count = f_third_count
      codata.f_third_content = f_third_content
      codata.f_defect_text = f_defect_text
      codata.f_defect_content = JSON.stringify(checkResults)
      this.data.f_defect_content = JSON.stringify(checkResults)
      //tag
      return codata
    },
    uploadCheckPaper(){
      //tag
      this.saveNoclick()
      let errString = this.errorVerify()
      this.isdisable = true
      if (errString) {
        //tag
        //tag
        //tag
        if (Vue.android){
          // if(this.isUpload){
          //   this.isUpload = false
          // }
          this.$showMessage(errString)
        }
        this.isdisable = false
        return
      } else {
        this.$set('data.f_offsite_time', Util.toStandardTimeString())
        this.$set('data.f_upload_time', Util.toStandardTimeString())
        this.$set('data.f_upload_date', Util.toStandardTimeString())
        //tag
        this.data.f_complete = '已完成'
        this.disableTimer()
      }
      if(this.item.f_user_type=='民用' && this.item.f_plan_meters[0].f_meter_type=='机表' && this.data.f_entry_status=='入户' && this.data.f_is_meterreadding=='未抄表'){
        /*this.$showMessage('该用户为机表用户，未进行抄表！', ['confirm', 'cancel']).then((res) => {
          if (res !== 'confirm') {
            this.baseinfo.base.f_user_state = ['正常']
          }
        })*/
        this.$showMessage("检测到当前机表用户未进行抄表，请先进行抄表再上传！")
        this.isdisable = false
        return
      }
      //tag
      this.onlySave = false
      let res =  this.save()
      // if(res) {
      //   try {
      //     let codata = this.getAllDefect()
      //     //获取微信推送内容
      //     let WxResult = this.getWeixin(codata)
      //     let haslivedispose = this.$androidUtil.bzLogic('getLiveDispose', {
      //       f_check_item_id: this.data.f_check_item_id
      //     })
      //     //如果是转维修上传，则不做校验，上传完成后自动转维修
      //     //tag
      //     //tag
      //     if(!this.isToRepair){
      //       if(haslivedispose.data.length > 0 && (this.livedispose == 'true' || this.livedispose == true)){
      //         //tag
      //         //tag
      //         if(!this.isSafeCheckToRepair){
      //           this.$showMessage('有未处理的隐患，请前往拍照上传中将安检转为维修单！')
      //           return
      //         }
      //       }
      //     }
      //     //tag
      //     for (let key in codata){
      //       if(key.startsWith("device")){
      //         codata[key] = []
      //       }
      //     }
      //     //tag}`)
      //
      //     //tag
      //     let isStart = true
      //     let res
      //     for (let i in this.f_devices){
      //       res = HostApp.organizeJSON({isStart:isStart,isDevice:true,device:this.f_devices[i]})
      //       if(res.code == 200){
      //         isStart = false
      //       }else{
      //         this.$showMessage("保存失败!")
      //       }
      //     }
      //     let result = HostApp.organizeJSON({
      //       isStart:false,
      //       isJSON:true,
      //       jsonstr:{
      //         f_check_item_id: this.data.f_check_item_id,
      //         f_checker_id: this.data.f_checker_id,
      //         row: codata
      //       }
      //     })
      //     if(result.code == 200){
      //       HostApp.__this__ = this
      //       this.runSyncLogic('上传安检信息','javascript:HostApp.__this__.uploadCallBack()',1)
      //     }
      //
      //
      //     // let response = this.$androidUtil.bzLogic('上传安检信息', {
      //     //   f_check_item_id: this.data.f_check_item_id,
      //     //   f_checker_id: this.data.f_checker_id,
      //     //   row: codata
      //     // })
      //     // if (response.code == 200) {
      //     //   //tag
      //     //   //tag)
      //     //   let f_paper_id
      //     //   if(response.data != '' && response.data != null){
      //     //     f_paper_id = JSON.parse(response.data).id
      //     //   }
      //     //   this.$set('data.f_paper_id', f_paper_id)
      //     //   //tag
      //     //   //tag)
      //     //   //tag
      //     //   //tag)
      //     //   for (let device in this.data){
      //     //     //tag
      //     //     //tag)
      //     //     if(device.startsWith("device")){
      //     //       for(let devices of this.data[device]) {
      //     //         devices.f_paper_id = f_paper_id
      //     //         let ret = this.$androidUtil.bzLogic('UpCheckPaperDevices', {
      //     //           row: devices
      //     //         })
      //     //         //tag}`)
      //     //         if(ret.code == 200){
      //     //           //tag
      //     //           devices.f_device_id = JSON.parse(ret.data.f_device_id).id
      //     //         }
      //     //         //tag
      //     //         //tag)
      //     //         if (ret.code != 200) {
      //     //           //TODO 失败后处理
      //     //           // this.isUpload = false
      //     //           this.$showMessage("上传失败!")
      //     //           return false
      //     //         }
      //     //       }
      //     //     }
      //     //   }
      //     //   // for (let device of this.f_devices) {
      //     //   //   device.f_paper_id = f_paper_id
      //     //   //   //tag
      //     //   //   //tag)
      //     //   //   let ret = this.$androidUtil.bzLogic('UpCheckPaperDevices', {
      //     //   //     row: device
      //     //   //   })
      //     //   //   //tag
      //     //   //   if (ret.code != 200) {
      //     //   //     //TODO 失败后处理
      //     //   //     HostApp.alert("上传失败!")
      //     //   //     return false
      //     //   //   }
      //     //   // }
      //     //   let result = this.$androidUtil.bzLogic('FinishUpload',
      //     //     {
      //     //       f_check_item_id: this.data.f_check_item_id,
      //     //       f_userinfo_id: codata.f_userinfoid,
      //     //       f_last_check_result: codata.f_defect_content
      //     //     })
      //     //   if(result.code == 200){
      //     //     // this.$showAlert('上传成功!', 'success', 2000)
      //     //     this.$showMessage('上传成功!')
      //     //     this.isStrat=false
      //     //     if(url != "" ){
      //     //       this.$resetpost(`${url}`,{data:WxResult})
      //     //     }
      //     //     return true
      //     //   }else{
      //     //     // this.isUpload = false
      //     //     this.$showMessage("上传失败!")
      //     //     return false
      //     //   }
      //     // }else{
      //     //   // this.isUpload = false
      //     //   this.$showMessage("上传失败!")
      //     //   return false
      //     // }
      //   }catch (e) {
      //     //tag)
      //     // this.isUpload = false
      //     this.$showMessage("上传失败!")
      //   }
      // }
    },
    save(type) {
      this.saveNoclick()
      //tag
      if(type == 'temp'){
        this.data.f_complete = '未完成'
        this.disableTimer()
      }else {
        let errString = this.errorVerify()
        if (errString) {
          //tag
          //tag
          //tag
          if (Vue.android){
            this.$showMessage(errString)
          }
          return
        } else {
          this.data.f_complete = '已完成'
          this.$set('data.f_offsite_time', Util.toStandardTimeString())
          this.disableTimer()
        }
      }
      if (this.data.f_entry_status == '入户') {
        this.data.f_rejectcheck_path = null
        this.data.f_noanswer_path = null
        this.data.f_noanswertwo_path = null
      }else if (this.data.f_entry_status == '到访不遇') {
        this.data.f_rejectcheck_path = null
      }else if (this.data.f_entry_status == '拒检') {
        this.data.f_noanswer_path = null
        this.data.f_noanswertwo_path = null
      }
      // try {
      let codata = this.getAllDefect()
      if(this.isToRepair && JSON.parse(this.data.f_defect_content).result != '有隐患'){
        this.$showMessage("未发现隐患，请点击上传")
        this.isToRepair=false
        this.isdisable = false
        return
      }
      //tag
      //tag}`)
      for (let key in codata) {
        if (key.startsWith("device")) {
          //tag)
          codata[key] = []
        }
      }
      //tag}`)
      //tag}`)
      //tag
      if (Vue.android) {
        //tag
        let value = this.$androidUtil.path({
          alias: 'getUserinfomation',
          data: {condition: "f_userinfoid = '" + this.item.f_userinfoid + "' and f_no_checkplan = '无计划安检'"}
        })
        //tag)
        if (this.item.f_no_checkplan == '无计划安检'  && this.item.f_no_checkplan != '打回') {
          // let result = this.$androidUtil.bzLogic('SafeSaveNoPaper', {
          //   f_check_item_id: this.data.f_check_item_id,
          //   f_checker_id: this.data.f_checker_id,
          //   f_upload_state:'未传',
          //   row: codata
          // })
          //tag
          let isStart = true
          // let res
          // for (let i in this.f_devices) {
          //   res = HostApp.organizeJSON({isStart: isStart, isDevice: true, device: this.f_devices[i]})
          //   if (res.code == 200) {
          //     isStart = false
          //   } else {
          //     this.$showMessage("保存失败!")
          //   }
          // }
          // let result = HostApp.organizeJSON({
          //   isStart: false,
          //   isJSON: true,
          //   jsonstr: {
          //     f_check_item_id: this.data.f_check_item_id,
          //     f_checker_id: this.data.f_checker_id,
          //     f_upload_state: '未传',
          //     row: codata
          //   }
          // })
          codata.f_devices = this.f_devices
          this.changeinfo=codata
          let param = {
            f_check_item_id: this.data.f_check_item_id,
            f_checker_id: this.data.f_checker_id,
            f_upload_state: '未传',
            row: codata
          }
          //tag)
          let paramStr = JSON.stringify(param)
          // 多长截断一次
          let subLength = 800
          for (let i = 0; i < paramStr.length; i += subLength) {
            HostApp.param_cache(paramStr.substr(i, subLength))
          }
          HostApp.__this__ = this
          HostApp.syncLogic({
            // logic别名，key必须为logic
            'logic': 'SafeSaveNoPaper',
            // 回调执行方法名，key必须为callback
            'callback': 'javascript:HostApp.__this__.saveCallBack()',
            // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
            // 执行回调方法传入key为backresult
            // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
            'backresult': 1
          })
        } else {
          //tag
          let isStart = true
          let res
          //tag)
          // for (let i in this.f_devices) {
          //   //tag)
          //   for (let j = 0; j < this.f_devices[i].f_items.length; j++) {
          //     //tag)
          //   }
          //   res = HostApp.organizeJSON({isStart: isStart, isDevice: true, device: this.f_devices[i]})
          //   //tag)
          //   if (res.code == 200) {
          //     isStart = false
          //   } else {
          //     this.$showMessage("保存失败!")
          //   }
          // }
          //tag)
          //tag)
          //tag)
          // let result = HostApp.organizeJSON({
          //   isStart: false,
          //   isJSON: true,
          //   jsonstr: {
          //     f_check_item_id: this.data.f_check_item_id,
          //     f_checker_id: this.data.f_checker_id,
          //     row: codata
          //   }
          // })
          codata.f_devices = this.f_devices
          this.changeinfo=codata
          let param = {
            f_check_item_id: this.data.f_check_item_id,
            f_checker_id: this.data.f_checker_id,
            row: codata
          }
          //tag)
          let paramStr = JSON.stringify(param)
          // 多长截断一次
          let subLength = 800
          for (let i = 0; i < paramStr.length; i += subLength) {
            HostApp.param_cache(paramStr.substr(i, subLength))
          }
          HostApp.__this__ = this
          HostApp.syncLogic({
            // logic别名，key必须为logic
            'logic': '保存安检单信息',
            // 回调执行方法名，key必须为callback
            'callback': 'javascript:HostApp.__this__.saveCallBack()',
            // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
            // 执行回调方法传入key为backresult
            // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
            'backresult': 1
          })
        }

      } else {
        //tag
        let value = this.$androidUtil.path({
          alias: 'getUserinfomation',
          data: {condition: "f_userinfoid = '" + this.item.f_userinfoid + "' and f_no_checkplan = '无计划安检'"}
        })

        if (this.item.f_no_checkplan == '无计划安检' && value.data.length == 0 && this.item.f_no_checkplan != '打回') {
          this.$androidUtil.bzLogic('SafeSaveNoPaper', {
            f_check_item_id: this.data.f_check_item_id,
            f_checker_id: this.data.f_checker_id,
            f_upload_state: '未传',
            row: codata
          }).then((res) => {
            if (res.data.code == 200) {
              //保存devices
              this.$androidUtil.bzLogic('getPaperInfo', {
                f_check_item_id: this.data.f_check_item_id
              }).then((res) => {
                //tag
                if (res.data.code == 200) {

                  let f_paper_id = res.data.data[0].id
                  for (let device of this.f_devices) {
                    device.f_paper_id = f_paper_id
                    //tag
                    this.$androidUtil.bzLogic('saveDevice', {
                      row: device
                    }).then((ret) => {
                      //tag
                      if (ret.code != 200) {
                        // if(this.isUpload){
                        //   this.isUpload = false
                        // }
                        //TODO 失败后处理
                        this.$showMessage("保存失败!")
                        return false
                      }
                    })
                  }
                }
              })
              // this.$showAlert('保存成功!', 'success', 2000)
              this.$showMessage('保存成功!')
              return true
            } else {
              // if(this.isUpload){
              //   this.isUpload = false
              // }
              this.$showMessage("保存失败!")
              return false
            }
          })
        } else {
          this.$androidUtil.bzLogic('保存安检单信息', {
            f_check_item_id: this.data.f_check_item_id,
            f_checker_id: this.data.f_checker_id,
            row: codata
          }).then((res) => {
            //tag
            if (res.data.code == 200) {
              //保存devices
              this.$androidUtil.bzLogic('getPaperInfo', {
                f_check_item_id: this.data.f_check_item_id
              }).then((res) => {
                //tag
                if (res.data.code == 200) {

                  let f_paper_id = res.data.data[0].id
                  for (let device of this.f_devices) {
                    device.f_paper_id = f_paper_id
                    //tag
                    this.$androidUtil.bzLogic('saveDevice', {
                      row: device
                    }).then((ret) => {
                      //tag
                      if (ret.code != 200) {
                        // if(this.isUpload){
                        //   this.isUpload = false
                        // }
                        //TODO 失败后处理
                        this.$showMessage("保存失败!")
                        return false
                      }
                    })
                  }
                }
              })
              // this.$showAlert('保存成功!', 'success', 2000)
              this.$showMessage('保存成功!')
              return true
            } else {
              // if(this.isUpload){
              //   this.isUpload = false
              // }
              this.$showMessage("保存失败!")
              return false
            }
          })
        }
      }
      // }catch (e) {
      //   //tag)
      //   // this.isUpload = false
      //   this.$showMessage("保存失败!")
      // }
    },
    runSyncLogic(logic,callback,backresult){
      HostApp.runSyncLogic({
        // logic别名，key必须为logic
        'logic': logic,
        // 回调执行方法名，key必须为callback
        'callback': callback,
        // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
        // 执行回调方法传入key为backresult
        // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
        'backresult':backresult
      })
    },
    logicWithHint(logic,data,callback,backresult){
      HostApp.logicWithHint({
        // logic别名，key必须为logic
        'logic': logic,
        // 回调执行方法名，key必须为callback
        'callback': callback,
        // logic执行需要的业务参数
        'data': data,
        // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
        // 执行回调方法传入key为backresult
        // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
        'backresult':backresult
      })
    },
    changeinfos(){
      this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/changeuserinfo`, {data:this.changeinfo
      }).then(res4 =>{
      })
    },
    saveCallBack(jo){
      //tag)
      this.isdisable = false
      if(jo.state == 'ok'){
        let res = JSON.parse(jo.result)
        //tag)
        if(res.code == 200){
          //tag
          this.changeinfos()
          if(!this.onlySave){
            let codata = this.getAllDefect()
            //获取微信推送内容
            // let WxResult = this.getWeixin(codata)
            let haslivedispose = this.$androidUtil.bzLogic('getLiveDispose', {
              f_check_item_id: this.data.f_check_item_id
            })
            //如果是转维修上传，则不做校验，上传完成后自动转维修
            //tag
            //tag
            if(!this.isToRepair){
              if(haslivedispose.data.length > 0 && (this.livedispose == 'true' || this.livedispose == true)){
                //tag
                //tag
                if(!this.isSafeCheckToRepair){

                }
              }
            }
            //tag
            for (let key in codata){
              if(key.startsWith("device")){
                codata[key] = []
              }
            }
            //tag}`)

            //tag
            // let isStart = true
            // let res
            // for (let i in this.f_devices){
            //   res = HostApp.organizeJSON({isStart:isStart,isDevice:true,device:this.f_devices[i]})
            //   if(res.code == 200){
            //     isStart = false
            //   }else{
            //     this.$showMessage("上传失败!")
            //     return
            //   }
            // }
            // let result = HostApp.organizeJSON({
            //   isStart:false,
            //   isJSON:true,
            //   jsonstr:{
            //     f_check_item_id: this.data.f_check_item_id,
            //     f_checker_id: this.data.f_checker_id,
            //     row: codata
            //   }
            // })
            codata.f_devices = this.f_devices
            codata.isTorepair = this.isToRepair
            codata.cremarks=this.cremarks
            let param = {
              f_check_item_id: this.data.f_check_item_id,
              f_checker_id: this.data.f_checker_id,
              row: codata
            }
            //tag)
            let paramStr = JSON.stringify(param)
            // 多长截断一次
            let subLength = 800
            for (let i = 0; i < paramStr.length; i += subLength) {
              HostApp.param_cache(paramStr.substr(i, subLength))
            }
            HostApp.__this__ = this
            HostApp.syncLogic({
              // logic别名，key必须为logic
              'logic': 'rc_upCheckPaper',
              // 回调执行方法名，key必须为callback
              'callback': 'javascript:HostApp.__this__.uploadCallBack()',
              // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
              // 执行回调方法传入key为backresult
              // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
              'backresult': 1
            })
          }else{
            this.$showMessage('保存成功！')
            if(this.clickBack){
              this.isStrat = false
              this.$dispatch('confirm')
              //this.$back()
            }
          }
        }else{
          this.$showMessage('保存失败！')
          return
        }
      }else{
        this.$showMessage('服务器内部错误,保存失败！')
        return
      }

    },
    uploadCallBack(jo){
      //获取微信推送路径
      let url = ""
      if(Vue.config.safecheck != undefined) {
        if (Vue.config.safecheck.ApproveConfig != undefined) {
          if (Vue.config.safecheck.ApproveConfig.weixinurl != undefined) {
            url = Vue.config.safecheck.ApproveConfig.weixinurl
          }
        }
      }
      //tag)
      //tag)
      this.isdisable = false
      if(jo.state == 'ok'){
        let res = JSON.parse(jo.result)
        //tag)
        //tag)
        if(res.code == 200){
          //上传抄表信息
          if(this.item.f_user_type=='民用' && this.item.f_safecheck_type=='年度普检' && this.data.f_entry_status=='入户' && this.data.f_is_meterreadding=='未抄表'){
            //let codata = this.getAllDefect()
            let res3= this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/sql/safe_singleTable_OrderBy`,{
              data:{
                items:" f_userfiles_id",
                tablename:"t_userfiles",
                condition:`f_userinfo_id=${this.item.f_userinfoid}  and (f_table_state='正常' or f_table_state='停用')`,
                orderitem:"f_userfiles_id"
              }
            }).then(res3 => {
              //tag)
              let f_tablebase1=''
              this.f_devices.forEach(row=>{
                if(row.f_device_type=='燃气表'){
                  row.f_items.forEach(item =>{
                    if(item.f_item_name=='本期表读数'){
                      f_tablebase1=item.f_item_lists[0].f_item_value
                    }
                  })
                }
              })

              //tag
              this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/handCommonEnter`, {data:{
                  f_userfiles_id:res3.data[0].f_userfiles_id,
                  f_operator:this.data.f_checker_name,
                  f_operatorid:this.data.f_checker_id,
                  f_inputtor:this.data.f_checker_name,
                  f_tablebase:f_tablebase1,
                  isAudit:false,f_meter_source:''
                }
              }).then(res4 =>{
                //tag)
                if(res4.data.status==200){
                  //tag
                  let param={
                    itemid:res.id
                  }
                  this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/rc_UpPaperHandMeterState`, {data:param})
                }
              })

            })
          }
          this.$set('data.f_paper_id', res.id)
          this.isStrat=false
          if(url != ""){
            this.$resetpost(`${url}`,{data:WxResult})
          }
          //tag
          if(this.isToRepair){
            /*let defect=JSON.parse(this.data.f_defect_content)
            let repairContent=''
            defect.data.forEach(de =>{
              let arr=Object.keys(de)
              //tag)
              arr.forEach(key=>{
                repairContent += key+':'+de[key]+' '
              })
            })
            //tag
            let repair={
              "sn": res.id,
              "caseType": "客户问题",
              "callerPhone": "",
              "caseTime":  Util.toStandardTimeString(),
              "orderSource": "安检转维修",
              "orderSourceUserID": "",
              "customerNo": this.item.f_userinfo_code,
              "customerName": this.item.f_user_name,
              "customerAddress": this.item.f_address,
              "customerDistrictCode": "",
              "customerDistrict": "",
              "callerName": this.item.checker,
              "callerSex": "",
              "phone": this.item.f_user_phone,
              "repairAddress": this.item.f_address,
              "repairContent": repairContent,
              "company": Vue.user.orgs,
              "orderType": "报修",
              "faultCategory": "安检隐患",
              "processingLevel": "普通",
              "remarks": "" }*/
            /*//tag)
            new HttpResetClass().load('POST','http://39.101.182.117:8909/api/cc/workorder.ashx?sign=5F27F9CA-2793-40CE-9834-0F033F71EDD2&method=postpreorder',repair,{resolveMsg: null, rejectMsg: null}).then(res =>{
              //tag)
              if(res.data.success){
                //tag)
                let param={
                  itemid:res.id,
                  gid:res.data.gid
                }
                new HttpResetClass().load('POST',`${this.$androidUtil.getProxyUrl()}/rs/logic/rc_UpPaperRepairState`,{data:param},{resolveMsg: null, rejectMsg: null})
                this.$showMessage('转维修成功!')
              }else{
                this.$showMessage('转维修失败!')
              }
              this.isToRepair=false
              this.$dispatch('confirm')
            })*/
            this.$showMessage('转维修成功!')
            this.isToRepair=false
            this.$dispatch('confirm')
            //this.todo()
          }else{
            this.$showMessage('上传成功!')
            //tag
            this.$dispatch('confirm')
            // this.$back()
          }
        }else if(res.code == 309){
          this.$showMessage('该安检单已作废!')
          //tag
          this.$dispatch('confirm')
        }else if(res.code == 310){
          this.$showMessage('该安检单已上传，请勿重复上传!')
          //tag
          this.$dispatch('confirm')
        }else if(res.code == 500){
          this.$showMessage('图片上传失败，请检查图片，确认无误后再次进行上传！')
          this.onlySave = true
          this.isToRepair=false
        }else{
          this.$showMessage('上传失败,请检查手机本地网络是否正常,如无问题请再次尝试上传（多次失败请联系管理员）!')
          this.onlySave = true
          this.isToRepair=false
        }
      }else {
        this.$showMessage('服务器内部错误,上传失败！')
        this.onlySave = true
        this.isToRepair=false
      }
    },
    safecheckToRepairCallBack(jo){
      //获取微信推送路径
      if(jo.state == 'ok'){
        let res = JSON.parse(jo.result)
        //tag)
        if(res.code == 200){
          //tag
          if(res.data.code == 200){
            this.$showMessage('上传并转维修成功！')
          }else{
            this.$showMessage('上传并转维修成功，回写安检单失败！')
          }
          this.$dispatch('confirm')
          // this.$back()
        }else{
          this.$showMessage('上传失败！')
          this.onlySave = true
        }
      }else{
        this.$showMessage('遇到意外错误！'+JSON.stringify(jo))
        this.onlySave = true
      }
    },
    todo(){
      let gen = getRepairParam(this)
      co(gen)
    },
    undo(){
      this.showCheckToRepair = !this.showCheckToRepair
      this.model.serviceacitivity[0].f_reciever = ''
      this.model.serviceacitivity[0].f_meetunit = ''
      this.model.f_repairtype = ''
      this.meading = '转站点'
    },
    disableTimer() {
      if(this.timer) {
        window.clearTimeout(this.timer)
        this.timer = null
      }
    },
    loaded(paper) {
      if(!paper.hasOwnProperty('id')) {
        this.$showMessage("该安检单在手机上已经不存在，可能是卸载过程序。可以进入重新安检，或返回安检计划。")
        this.init()
      } else {
        Util.booleanFilter(paper)
        HostApp.__this__.$set('data', paper)
        HostApp.__this__.$goto('safecheck-userinfo', {}, 'paper-router')
        // 如果打回重检则重新计时
        //tag
        if(HostApp.__this__.role == 'inspect'
          && HostApp.__this__.data.f_approved
          && HostApp.__this__.data.f_approved == '打回') {
          //tag
          HostApp.__this__.data.f_onsite_time = Util.toStandardTimeString()
          HostApp.__this__.tick()
        }
      }
      HostApp.__callback__ = null
      HostApp.__this__ = null
    },
    S4() {
      return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
    },
    extend(initalObj, finalObj) {
      var obj = finalObj || {};
      for (var i in initalObj) {
        var prop = initalObj[i];

        // 避免相互引用对象导致死循环，如initalObj.a = initalObj的情况
        if (prop === obj) {
          continue;
        }

        if (typeof prop === 'object') {
          if (obj[i]) {
            this.extend(obj[i], prop)
          } else {
            obj[i] = prop;
          }
        }
      }
      return obj;
    },
    async isoverDate(){
      //tag
      let res= await this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/sql/androidGetuserinfo`, {data:{
          condition:"ti.id='"+this.item.id+"'"
        }
      })

      this.isneedDate=res.data.length>0?res.data[0]["f_subscribe_date"]:''
    },
    putDevices() {
      //tag)
      //tag)
      this.$set('data.approve', "true")
      this.$set('data.writeback', "false")
      if (Vue.config.safecheck != undefined) {
        if (Vue.config.safecheck.ApproveConfig != undefined) {
          if (Vue.config.safecheck.ApproveConfig.approve != undefined) {
            this.$set('data.approve', Vue.config.safecheck.ApproveConfig.approve)
          }
          if (Vue.config.safecheck.ApproveConfig.writeback != undefined) {
            this.$set('data.writeback', Vue.config.safecheck.ApproveConfig.writeback)
          }
          if (Vue.config.safecheck.ApproveConfig.livedispose != undefined) {
            this.livedispose = Vue.config.safecheck.ApproveConfig.livedispose
          }
        }
        //tag
        //tag)
        //tag)
        //tag
        if(this.item.f_user_type == '民用'){
          // 民用户

          if (Vue.config.safecheck.DevicesConfig != undefined){
            if(this.item.f_safecheck_type == undefined || this.item.f_safecheck_type == '' || Vue.config.safecheck.SafecheckType == undefined) {
              this.config = this.extend(this.config, Vue.config.safecheck.DevicesConfig)
            }else{
              this.config = this.extend(this.config, Vue.config.safecheck[Vue.config.safecheck.SafecheckType[this.item.f_safecheck_type][this.item.f_user_type]])
            }


            // this.config = this.extend(this.config, Vue.config.safecheck.DevicesConfig)
          }
        }else {
          // 非民用
          if (Vue.config.safecheck.DevicesSetConfig != undefined){

            if(this.item.f_safecheck_type == undefined || this.item.f_safecheck_type == '' || Vue.config.safecheck.SafecheckType == undefined) {
              this.config = this.extend(this.config, Vue.config.safecheck.DevicesSetConfig)
            }else{
              this.config = this.extend(this.config, Vue.config.safecheck[Vue.config.safecheck.SafecheckType[this.item.f_safecheck_type][this.item.f_user_type]])
            }
            let dev={
              index: 3,
              items:{}}
            if(this.deviceinfo.data.length>0){
              for (let i=0;i<this.deviceinfo.data.length;i++){
                dev.items[this.deviceinfo.data[i].f_devices_model+(i+1)+'数量']={index: i*3+1,type:"number",f_item_value: this.deviceinfo.data[i].f_devices_num}
                dev.items[this.deviceinfo.data[i].f_devices_model+(i+1)+'品牌']={index: i*3+2,type:"string",f_item_value: this.deviceinfo.data[i].f_brand}
                dev.items[this.deviceinfo.data[i].f_devices_model+(i+1)+'检查情况']={index: i*3+3,type:"string"}
              }
            }
            //tag)
            this.config["燃气具检查"]=dev
            //this.config = this.extend(this.config, Vue.config.safecheck.DevicesSetConfig)
          }
        }

      }
      //tag)
      // 预留设备项位置
      for (let i in this.config) {
        this.tabs.splice(1,0,null)
      }
      //遍历安检项配置
      for (let i in this.config) {
        //取得安检项索引值
        let n = this.config[i].index
        //tag
        this.devices[n - 1] = {device: i, n: n, checkmust: this.config[i].checkmust}
        this.$set('data.' + 'device' + n, [])
        //tag
        // this.tabs.splice(2 + n - 1, 0,
        //   {
        //     header:i,
        //     complete:'safecheck-devices',
        //     class:'repair-details-class',
        //     number:n
        //   })
        this.tabs[n] = {
          header: i,
          complete: 'safecheck-devices',
          class: 'repair-details-class',
          number: n
        }

        if(this.config[i].quantity &&  this.config[i].quantity >0){
          let items = []
          for (let it in this.config[i].items) {
            //赋值下拉选项
            if (this.config[i].items[it].type == 'selector') {
              for (let op in this.config[i].items[it].options) {
                if (this.config[i].items[it].options[op].isdefault == true) {
                  items.push({
                    f_defect_level: this.config[i].items[it].options[op].level,
                    f_is_defect: this.config[i].items[it].options[op].isdefect,
                    f_item_name: it,
                    f_item_value: this.config[i].items[it].options[op].data,
                    f_path: "",
                    type: "selector"
                  })
                }
              }
            }
          }
          for(let q =0;q<this.config[i].quantity;q++) {
            this.data['device' + n].push(
              {f_device_type: i, f_items:items}
            )
          }
        }
        // this.data['device' + n].push(
        //   {f_device_type: i, f_items: items}
        // )
        n = n + 1
      }
      //tag
      this.faultshow.number = this.tabs.length
    },
    init () {
      //tag
      // this.data.f_noplan_item_id =  this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()
      this.data.ename = Vue.user.ename
      this.data.f_outlets = Vue.user.f_parentname
      this.data.f_meetunit = Vue.user.orgpathnames
      this.data.orgpathstr = Vue.user.orgpathstr
      this.data.f_check_item_id = this.item.id
      this.data.f_check_plan_id = this.f_plan_id
      this.data.f_checker_id = Vue.user.id
      this.data.f_checker_name = Vue.user.name
      this.data.f_check_type = this.item.f_user_type
      this.data.f_safecheck_type = this.item.f_safecheck_type ? this.item.f_safecheck_type:'年度普检'
      //this.data.f_exceed_reason = ''//存放送气超期原因
      //tag
      this.data.f_subcompany = this.item.f_subcompany
      this.data.f_approved = this.item.f_approved
      this.data.f_repair_approved = this.item.f_repair_approved
      this.data.f_no_checkplan = this.item.f_no_checkplan
      this.data.f_approved = this.item.f_approved
      this.data.f_filialeid = this.item.f_filialeid
      this.data.f_orgstr = this.item.f_orgstr
      this.data.version = this.item.version
      this.$set('data.f_meters', this.item.f_plan_meters)
      this.$set('data.f_userinfo_code', this.item.f_userinfo_code)
      // 安检状态
      this.$set('data.f_entry_status', '入户')
      this.$set('data.f_laser_check', null)
      this.$set('data.f_is_meterreadding', '未抄表')
      this.$set('data.f_usegas', '已使用')
      this.$set('data.f_state',this.item.f_state)
      //tag
      // 用户信息
      this.$set('data.f_user_name', this.item.f_user_name)
      this.$set('data.f_user_phone', this.item.f_user_phone)
      this.$set('data.f_used_name', this.item.f_plan_meters[0].f_used_name)
      this.$set('data.f_rent_phone',this.item.f_rent_phone)
      this.$set('data.f_remark', '')
      this.$set('data.f_user_phone2',this.item.f_plan_meters[0].f_user_phone2)
      this.$set('data.f_userinfoid', this.item.f_userinfoid)
      this.$set('data.f_address', this.item.f_address)
      this.$set('data.f_small_area', this.item.f_small_area)
      this.$set('data.f_card_id', this.item.f_card_id)
      this.$set('data.f_area', this.item.f_area)
      this.$set('data.f_street', this.item.f_street)
      this.$set('data.f_room', this.item.f_room)
      this.$set('data.f_building', this.item.f_building)
      this.$set('data.f_unit', this.item.f_unit)
      //tag
      this.$set('data.f_floor', this.item.f_floor)
      this.$set('data.f_residential_area' , this.item.f_residential_area)
      this.$set('data.f_idnumber', this.item.f_idnumber)
      this.$set('data.f_comments', this.item.f_comments)
      this.$set('data.f_userproperties', this.item.f_userproperties)
      this.$set('data.f_usetype', this.item.f_plan_meters[0].f_usetype)
      // this.$set('data.f_user_inhome_time', this.item.f_user_inhome_time)
      // this.$set('data.f_user_check_time', this.item.f_user_check_time)
      // this.$set('data.f_user_spare_phone', this.item.f_user_spare_phone)
      // this.$set('data.f_user_family_remarks', this.item.f_user_family_remarks)
      // this.$set('data.f_user_equipment_remarks', this.item.f_user_equipment_remarks)
      // 处置方式
      //tag
      this.$set('data.f_no_gas_device', false)
      this.$set('data.f_close_valve', false)
      this.$set('data.f_unload_battery', false)
      //tag
      if (this.data.f_check_item_id == '' && this.item.f_no_checkplan == '无计划安检') {
        this.data.f_check_item_id = this.S4() + "" + this.S4() + "" + this.S4() + "" + this.S4() + "" + this.S4() + "" + this.S4() + "" + this.S4() + "" + this.S4()
      }
      //tag
      if(this.item.f_plan_meters) {
        for (let de in this.devices) {
          this.$set('data.device' + this.devices[de].n, [])
          for (let i = 0; i < this.item.f_plan_meters.length; i++) {
            if (this.item.f_plan_meters[i].f_meter_type) {
              //tag+"------------"+this.devices[de].device)
              if (this.devices[de].device == "燃气表" && this.item.f_plan_meters[i].f_meter_type.indexOf('机表') > 0) {
                //tag
                this.data['device' + this.devices[de].n].push({
                  f_device_type: "燃气表",
                  f_items: [
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "基表编号",
                      f_item_value: this.item.f_plan_meters[i].f_meter_no,
                      f_path: "",
                      type: "string"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "气表型号",
                      f_item_value: this.item.f_plan_meters[i].f_diaphgram_size,
                      f_path: "",
                      type: "string"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "气表品牌",
                      f_item_value: this.item.f_plan_meters[i].f_aliasname,
                      f_path: "",
                      type: "string"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "进气方向",
                      f_item_value: this.item.f_plan_meters[i].f_flow_direction,
                      f_path: "",
                      type: "selector"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "上期表读数",
                      f_item_value: this.item.f_plan_meters[i].f_prior_reading,
                      f_path: "",
                      type: "number"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "本期表读数",
                      f_item_value: '',
                      f_path: "",
                      type: "number"
                    }
                  ]
                })
              } else if (this.devices[de].device == "燃气表") {
                //tag
                // delete this.config['燃气表']['items']['表底数']
                this.data['device' + this.devices[de].n].push({
                  f_device_type: "燃气表",
                  f_items: [
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "基表编号",
                      f_item_value: this.item.f_plan_meters[i].f_meter_no,
                      f_path: "",
                      type: "string"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "气表型号",
                      f_item_value: this.item.f_plan_meters[i].f_diaphgram_size,
                      f_path: "",
                      type: "string"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "气表品牌",
                      f_item_value: this.item.f_plan_meters[i].f_aliasname,
                      f_path: "",
                      type: "string"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "进气方向",
                      f_item_value: this.item.f_plan_meters[i].f_flow_direction,
                      f_path: "",
                      type: "selector"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "上期表读数",
                      f_item_value: this.item.f_plan_meters[i].f_prior_reading,
                      f_path: "",
                      type: "number"
                    },
                    {
                      f_defect_level: null,
                      f_device_id: "",
                      f_is_defect: "",
                      f_item_name: "本期表读数",
                      f_item_value: '',
                      f_path: "",
                      type: "number"
                    }
                  ]
                })
              }
              if (this.devices[de].device == "燃气表" && this.item.f_plan_meters[i].f_collection_type) {
                //tag
                this.data['device' + this.devices[de].n].forEach(device => {
                  //tag)
                  //tag)
                  /*
                    "累购气量":{"index":8,"type":"number","readonly":true},
                    "累购金额":{"index":8,"type":"number","readonly":true},
                    "字轮读数":{"index":9,"type":"number","checkmust": true},
                    "已用金额":{"index":9,"type":"number","checkmust": true},
                    "剩余气量":{"index":10,"type":"number","checkmust": true},
                    "剩余金额":{"index":10,"type":"number","checkmust": true},
                    "气量异常差值":{"index":11,"type":"number","readonly": true},
                    "金额异常差值":{"index":11,"type":"number","readonly": true}
                  */
                  if (this.item.f_plan_meters[i].f_collection_type == '按金额') {
                    if (!this.data.f_collection_type) {
                      this.data.f_collection_type = this.item.f_plan_meters[i].f_collection_type
                      delete this.config['燃气表']['items']['累购气量']
                      delete this.config['燃气表']['items']['已用气量']
                      delete this.config['燃气表']['items']['剩余气量']
                      delete this.config['燃气表']['items']['气量异常差值']
                      device.f_items.push(
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "初始表底",
                          isshow: false,
                          f_item_value: '',
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "累购金额",
                          f_item_value: this.item.f_plan_meters[i].f_total_fee,
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "已用金额",
                          f_item_value: null,
                          isshow:false,
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "剩余金额",
                          f_item_value: null,
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "金额异常差值",
                          isshow:false,
                          f_item_value: null,
                          f_path: "",
                          type: "number"
                        }
                      )
                      //tag)
                    }
                  } else if (this.item.f_plan_meters[i].f_collection_type == '按气量') {
                    if (!this.data.f_collection_type) {
                      this.data.f_collection_type = this.item.f_plan_meters[i].f_collection_type
                      delete this.config['燃气表']['items']['累购金额']
                      delete this.config['燃气表']['items']['已用金额']
                      delete this.config['燃气表']['items']['剩余金额']
                      delete this.config['燃气表']['items']['金额异常差值']
                      device.f_items.push(
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "初始表底",
                          isshow: true,
                          f_item_value: this.item.f_plan_meters[i].f_initial_base,
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "累购气量",
                          f_item_value: this.item.f_plan_meters[i].f_total_gas,
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "已用气量",
                          f_item_value: this.item.f_plan_meters[i].f_meter_base,
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "剩余气量",
                          f_item_value: '',
                          f_path: "",
                          type: "number"
                        },
                        {
                          f_defect_level: null,
                          f_device_id: "",
                          f_is_defect: "",
                          f_item_name: "气量异常差值",
                          isshow:false,
                          f_item_value: null,
                          f_path: "",
                          type: "number"
                        }
                      )
                      //tag)
                    }
                  }
                })
              }else if(this.devices[de].device == "燃气表"){
                //tag
                this.data['device' + this.devices[de].n].forEach(device => {
                  //tag)
                  if (!this.data.f_collection_type) {
                    this.data.f_collection_type = this.item.f_plan_meters[i].f_collection_type
                    delete this.config['燃气表']['items']['累购金额']
                    delete this.config['燃气表']['items']['已用金额']
                    delete this.config['燃气表']['items']['剩余金额']
                    delete this.config['燃气表']['items']['金额异常差值']
                    device.f_items.push(
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "初始表底",
                        isshow: true,
                        f_item_value: this.item.f_plan_meters[i].f_initial_base,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "累购气量",
                        f_item_value: this.item.f_plan_meters[i].f_total_gas,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "已用气量",
                        f_item_value: this.item.f_plan_meters[i].f_meter_base,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "剩余气量",
                        f_item_value: '',
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "气量异常差值",
                        isshow:false,
                        f_item_value: null,
                        f_path: "",
                        type: "number"
                      }
                    )
                    //tag)
                  }
                })
              }
            }
          }
          //工商户安检设备添加值
          if(this.devices[de].device == "燃气具检查"){
            //tag)
            //tag)
            this.data['device' + this.devices[de].n].forEach((device)=>{
              for (let i=0;i<this.deviceinfo.data.length;i++){
                device.f_items.push(
                  {
                    f_defect_level: null,
                    f_device_id: "",
                    f_is_defect: "",
                    f_item_name: this.deviceinfo.data[i].f_devices_model+'数量',
                    isshow:false,
                    f_item_value: this.deviceinfo.data[i].f_devices_num,
                    f_path: "",
                    type: "string"
                  },
                  {
                    f_defect_level: null,
                    f_device_id: "",
                    f_is_defect: "",
                    f_item_name: this.deviceinfo.data[i].f_devices_model+'品牌',
                    isshow:false,
                    f_item_value: this.deviceinfo.data[i].f_brand,
                    f_path: "",
                    type: "string"
                  }
                )
              }
            })
            //tag)
          }
        }
      }
      var pardate = {
        _this:this,
        tittle:'安检详情',
        safe:true
      }
      // this.$dispatch('gotoson',pardate)
      //tag
      this.$goto('safecheck-userinfo', {userinfo:this.data}, 'repair')
    }
  },
  watch: {
    'row' () {
      //tag
      this.copy()
    }
  },
  async ready () {
    await this.isoverDate()
    if(this.item.f_user_type == '非民用'){
      this.deviceinfo=await new HttpResetClass().load('post',`${this.$androidUtil.getProxyUrl()}/rs/sql/safe_singleTable_OrderBy`,{
        data:{
          items:" de.* ",
          tablename:"t_devices de join t_userfiles uf on uf.f_userfiles_id=de.f_userfiles_id",
          condition:`de.f_state='有效' and uf.f_userinfo_id=${this.item.f_userinfoid}`,
          orderitem:"de.id"
        }
      },{resolveMsg: null, rejectMsg: null})
    }
    this.putDevices()
    //如果已检，则提取安检单
    if (this.item.f_state != '未检') {
      if (this.role == 'inspect' || this.role == 'androidview') {
        HostApp.__callback__ = this.loaded
        HostApp.__this__ = this
        let that = this
        let value = {}
        //tag
        if (this.role == 'inspect') {
          //tag
          if (this.item.f_no_checkplan == '无计划安检') {
            value = this.$androidUtil.path({
              alias: 'getUserinfomation',
              data: {condition: "f_check_item_id = '" + this.item.id + "' and f_no_checkplan = '无计划安检'"}
            })
          } else {
            value = this.$androidUtil.bzLogic('FetchCheckPaper', {id: this.item.id})
          }
        } else {
          value = await this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/path/getUserinfomation`, {data: {condition: `id = '${this.item.f_paper_id}'`}})
        }
        Util.replaceFalse(value)
        //tag)
        if (value.data.length != 0) {
          that.$set('data', value.data[0])
          //tag)
          if (this.item.f_plan_meters[0].f_meter_type=='机表' || this.data.f_collection_type == '按气量') {
            delete this.config['燃气表']['items']['累购金额']
            delete this.config['燃气表']['items']['已用金额']
            delete this.config['燃气表']['items']['剩余金额']
            delete this.config['燃气表']['items']['金额异常差值']
          } else if (this.data.f_collection_type == '按金额') {
            delete this.config['燃气表']['items']['累购气量']
            delete this.config['燃气表']['items']['已用气量']
            delete this.config['燃气表']['items']['剩余气量']
            delete this.config['燃气表']['items']['气量异常差值']
          }
          //tag)
          if (value.data[0].f_devices) {
            for (let da in that.devices) {
              that.$set('data.device' + that.devices[da].n, [])
            }
            value.data[0].f_devices.forEach((item) => {
              //tag)
              for (let i in item.f_items) {
                // if (item.f_items[i].f_path != '' && item.f_items[i].f_path != null) {
                //   this.picture.push({f_path: item.f_items[i].f_path, name: item.f_items[i].f_item_name})
                // }
                for (let de in that.config[item.f_device_type].items) {
                  if (item.f_items[i].f_item_name == de) {
                    if (that.config[item.f_device_type].items[de].type == 'selector' || that.config[item.f_device_type].items[de].type == 'checkbox') {
                      item.f_items[i].f_item_value = []
                    } else {
                      item.f_items[i].f_item_value = ''
                    }
                  }
                }
                //tag)
                for (let j in item.f_items[i].f_item_lists) {
                  //tag)
                  if (item.f_items[i].f_item_value instanceof Array) {
                    item.f_items[i].f_item_value.push(item.f_items[i].f_item_lists[j].f_item_value)
                  } else {
                    item.f_items[i].f_item_value = item.f_items[i].f_item_lists[j].f_item_value
                  }

                }
              }
              for (let de in that.devices) {
                if (that.devices[de].device == item.f_device_type) {
                  that.data['device' + that.devices[de].n].push({
                    f_device_type: item.f_device_type,
                    f_items: item.f_items
                  })
                  //tag)
                }
              }
            })
            if (this.role == 'androidview') {
              Util.androidRatifyPics(that.data, this.$androidUtil.getProxyUrl())
              Util.androidRatifyPics(that.picture, this.$androidUtil.getProxyUrl())
              Util.booleanFilter(that.data)
            }
            //tag)
          }
        } else {
          //tag
          this.init()
        }
        //tag
        var pardate = {
          _this:this,
          tittle:'安检详情',
          safe:true
        }
        // this.$dispatch('gotoson',pardate)getImgPath
        this.$goto('safecheck-userinfo', {userinfo:this.data}, 'repair')
      } else {
        let that = this
        let id
        if (this.role == 'view') {
          id = this.item.id
        }
        this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/path/getUserinfomation`, {data:{condition:`id = '${id}'`}}).then((respanse)=> {
            if (respanse.data.length != 0) {
              that.data = Object.assign(that.data,respanse.data[0])
              if(respanse.data[0].f_devices) {
                for (let da in that.devices) {
                  that.$set('data.device' + that.devices[da].n, [])
                }
                respanse.data[0].f_devices.forEach((item) => {
                  for (let de in that.devices) {
                    if (that.devices[de].device == item.f_device_type) {
                      that.data['device' + that.devices[de].n].push({
                        f_device_type: item.f_device_type,
                        f_items: item.f_items
                      })
                    }
                  }
                })
              }
              Util.replaceFalse(that.data)
              Util.booleanFilter(that.data)
              if(this.role == 'view'){
                Util.ratifyPics(that.data)
              }else{
                Util.androidRatifyPics(that.data,this.$androidUtil.getProxyUrl())
              }
              //tag
            } else {
              alert("该安检单可能已不在本地!")
              this.init()
            }
            var pardate = {
              _this:this,
              tittle:'安检详情',
              safe:true
            }
            // this.$dispatch('gotoson',pardate)
            this.$goto('safecheck-userinfo', {userinfo:this.data}, 'paper-router')
          }
        ).catch(
          (respanse) => {
            alert('查找安检单失败')
          })
      }
    }else{
      this.init()
    }
    // tbs合并数组
    // if( this.model.serviceacitivity[0].servicerepair.length > 0){
    //   for(let i = 0;i < this.model.serviceacitivity[0].servicerepair.length;i++ ){
    //
    //   }
    // }
  },
  components: {
    // 'door-service': DoorService,
    // 'repair-info': RepairInfo,
    // 'repair-user-info': RepairUserInfo,
    // 'outlay': Outlay,
    // 'fault-all': FaultAll,
    // 'repair-details':RepairDetails
    // 'pipeline': Pipeline,
    // 'device-service': DeviceService,
    // 'trouble-removal': TroubleRemoval,
    // 'cooking-utensils': CookingUtensils,
    // 'repair-matter-info': RepairMatterInfo,
    // 'first-gas-check': FirstGasCheck,
    // 'tel-change-matter': TelChangeMatter/
  },
  events: {
    'tijiao': function () {
      // 事件回调内的 `this` 自动绑定到注册它的实例上
      this.confirm()
    }
  }
}
</script>
<style lang="less">
@import "../../../src/bootstrap/less/variables.less";
.noclickbut {
  pointer-events: none;
}
.tab-befor-img (@url) {
  content: '';
  background-image: url("@{url}");
  background-size: 20px;
  display: inline-block;
  margin-right: 8px;
  margin-top: 0.3em;
  height: 1.3em;
  width: 1.3em;
  vertical-align: -35%;
}

@media screen and (min-width: 768px) {
  .android-repair-order > div > ul a {
    font-size: @font-size-h2;
    margin: 0.3em 0;
  }
}
.repair-details-class{
  &::before {
    .tab-befor-img("../../assets/huneiweixiu1.png");
  }
}
.repair-info-class {
  &::before {
    .tab-befor-img("../../assets/baoxiuxinxi1.png");
  }
}
.repair-user-info-class {
  &::before {
    .tab-befor-img("../../assets/jibenxinxi1.png")
  }
}

.door-service-class {
  &::before {
    .tab-befor-img("../../assets/huneiweixiu1.png")
  }
}

.pipeline-class {
  &::before {
    .tab-befor-img("../../assets/guandao1.png")
  }
}

.device-service-class {
  &::before {
    .tab-befor-img("../../assets/shebeiweixiu1.png")
  }
}

.trouble-removal-class {
  &::before {
    .tab-befor-img("../../assets/shiguchuli.png")
  }
}

.cooking-utensils-class {
  &::before {
    .tab-befor-img("../../assets/zaoju1.png")
  }
}

.outlay-class {
  &::before {
    .tab-befor-img("../../assets/feiyong1.png")
  }
}

.fault-all-class {
  &::before {
    .tab-befor-img("../../assets/guzhanghuizong1.png")
  }
}
.photo-write-class {
  &::before {
    .tab-befor-img("../../assets/zaoju.png")
  }
}
.delay-apply-class {
  &::before {
    .tab-befor-img("../../assets/yonghubaoxiu.png")
  }
}

.repair-back-class {
  &::before {
    .tab-befor-img("../../assets/fanhui.png")
  }
}
.butt2 {
  display: inline;
  float: right;
  width: 10px;
  text-align: center;
  align-items:center;
  position: absolute;
  top:50%;

  left:90%;
  transform: translate(-50%,-50%);
}
.linesty{
  display: inline-block;
  height:1px;
  width:100%;
  background:#d0d0d0;
  overflow:hidden;
  vertical-align: middle;
}
.spanboder{
  border-bottom:2px solid #499edf;
  padding-bottom: 8px
}
.app-botton {
  position:fixed;
  background: #87b2dd;
  right:8px;
  color: #FFF;
  padding: 8px;
  text-align: center;
  font-size: 1.2em;
  z-index: 10;
  opacity:0.5;
  bottom: 50px;
  margin-top: -10px;
  height: 40px;
}
.android-repair-order > div > ul a {
  font-size: 12px;
  color: #333333;
  padding: 13px 16px;
}
</style>
