<style>
.divmask {
  pointer-events: none;
}
</style>

<template>
  <div class="auto">
    <work-busy :is-busy="seaching" v-show="seaching"></work-busy>
    <!--<a href="#" class="btn btn-primary" @click="$back('items')">&lt;&lt;</a>-->
    <!--<a href="#" v-show="actionEnabled" class="btn btn-primary" @click="savePaper(true)" v-if="item.f_upload_state != '已传'">保存</a>-->
    <!--<a id="upload" href="# " v-show="actionEnabled" class="btn btn-primary" @click="uploadPaper" v-if="item.f_upload_state != '已传'">上传</a>-->
    <radio-group :value.sync="selector" type="info" buttons="false">
      <radio value="paper-state-noncivil">安检概况</radio>
      <radio value="paper-user-noncivil">用户信息</radio>
      <radio value="devices-noncivil">安检选项</radio>
      <radio value="paper-feedback-nocivil" :deviceresult="deviceresult" :deviceCollects="deviceCollects"
             :hasDevice="hasDevice">拍照上传
      </radio>
    </radio-group>
    <route :comp="{name: 'void-page'}" name="paper-router"></route>
    <modal :show.sync="showModal">
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          照片浏览
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <img :src="pic_to_be_viewed" width="420" height="560">
      </div>
      <div slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-default" @click="showModal = false">确认</button>
      </div>
    </modal>
    <back-page :need-back='true' @flag="back()" v-show="showBack"></back-page>
  </div>
</template>

<script>
import RadioGroup from 'vue-client/src/vue-strap/src/radioGroup'
import Radio from 'vue-client/src/vue-strap/src/radioBtn'
import Vue from 'vue'
import * as Util from '../Util'
import co from 'co'
//  长安安检APP只有民用
let getRepairParam = function* (self) {
  self.model.f_remarks = self.data.f_remarks
  let data = {
    model: self.model, loginUser: {
      name: Vue.user.name,
      ename: Vue.user.ename
    }, user: self.user, callObj: self.callObj
  }
  // if(self.meading == '转维修员'){
  //   data.toRepair = '一级派单'
  // }
  data.model.f_attendant = data.loginUser.name
  console.log('===================')
  console.log(data)
  let res
  let errString = self.errorVerify()
  if (errString) {
    console.log(errString)
    if (Vue.android) {
      self.undo()
    }
    self.$showMessage(errString)
    return
  } else {
    if (self.role == 'inspect') {
      // if(self.meading == '转维修员' && (self.model.serviceacitivity[0].f_reciever == '' || self.model.serviceacitivity[0].f_reciever == undefined)){
      //   this.$showMessage("请选择维修员!")
      //   return
      // }
      // if(self.meading == '转站点' && (self.model.serviceacitivity[0].f_reciever == '' || self.model.serviceacitivity[0].f_reciever == undefined)){
      //   this.$showMessage("请选择站点!")
      //   return
      // }
      // if(self.model.f_repairtype == ''){
      //   this.$showMessage("请选择报修类型!")
      //   return
      // }
      console.log('安检组转维修数据1：==》' + JSON.stringify(data))
      let checkResult = '正常'
      let value = ''
      let codata = JSON.parse(JSON.stringify(self.data))
      let SafeCheck = []
      for (let device in self.data) {
        let f_device_type
        if (device.startsWith('device')) {
          for (let item in self.data[device]) {
            if (self.data[device].length > 1) {
              let j = Number.parseInt(item) + 1
              f_device_type = `${self.data[device][item].f_device_type}${j}`
            } else {
              f_device_type = self.data[device][item].f_device_type
            }
            // console.log('codata[device][item]=>',codata[device][item])
            for (let i in self.data[device][item].f_items) {
              let items = self.data[device][item].f_items[i]
              console.log('转维修items' + JSON.stringify(items))
              console.log('self.data[device][item].f_device_type' + self.data[device][item].f_device_type)
              if (true) {
                // console.log('self.config[self.data[device][item].f_device_type]' + JSON.stringify(self.config[self.data[device][item].f_device_type]))
                // console.log('self.config[self.data[device][item].f_device_type].f_items' + JSON.stringify(self.config[self.data[device][item].f_device_type].items))
                if (self.config[self.data[device][item].f_device_type].items[items.f_item_name].type == 'selector') {
                  let options = self.config[self.data[device][item].f_device_type].items[items.f_item_name].options
                  console.log('options' + JSON.stringify(options))
                  for (let value in items.f_item_value) {
                    for (let i in options) {
                      let option = options[i]
                      if (option.data == items.f_item_value[value] && (option.level && (option.level.indexOf('工商大表组') > -1))) {
                        SafeCheck.push(items.f_item_value[value])
                      }
                    }
                  }
                  console.log('安检组结果==》' + JSON.stringify(SafeCheck))
                  if (SafeCheck.length != 0) {
                    self.$set('defectDevice.f_failure_type', items.f_item_name)
                    console.log('defectDevice' + JSON.stringify(self.defectDevice))
                    self.$set('defectDevice.failurecase', SafeCheck)
                    self.model.failure.push(JSON.parse(JSON.stringify(self.defectDevice)))
                    console.log('self.model.failure' + JSON.stringify(self.model.failure))
                    self.defectDevice = {}
                    SafeCheck = []
                  }
                }
              }
              // let value = items.f_item_lists.filter(item => {
              //     return item.f_is_defect == 'true' || item.f_is_defect == true
              // })
              // console.log('安检组结果==》' + JSON.stringify(value))
              // let SafeCheck = value.filter(item =>{
              //   return item.f_defect_level === '安检维修' || item.f_defect_level === '安装组维修'
              // }).map(item => {
              //     return item.f_item_value
              // }).join(',')
            }
          }
        }
      }

      console.log('安检组转维修数据：==》' + JSON.stringify(data))
      HostApp.__this__ = self
      self.logicWithHint('safecheckToRepair', {
        data: data,
        f_paper_id: self.data.f_paper_id
      }, 'javascript:HostApp.__this__.safecheckToRepairCallBack()', 1)
    }
    // console.log('res==========')
    // console.log(res.code)
    // console.log(res.data)
    // if(res.code == 200){
    //   self.isSafeCheckToRepair = true
    //   // self.undo()
    //   // self.$set('paper.f_SafeToRepair_id',res.data.f_service_id)
    //   // console.log('更新维修单id')
    //   // self.$resetpost(`${self.Url}/rs/logic/updatePaperRepair`,{data:{f_paper_id:self.data.f_paper_id,f_SafeToRepair_id:res.data.f_service_id}}).then((ret)=>{
    //   //   console.log('ret==>'+ret)
    //   //   if(ret.data.code ==200){
    //   console.log('维修单id修改成功')
    //   self.$showMessage('上传并转维修成功！')
    //   self.$back()
    //     // }else{
    //     //   self.$showMessage('安检转维修失败！')
    //     // }
    //   // }).catch(v=>{
    //   //   console.log('v=>'+JSON.stringify(v))
    //   //   self.$showMessage('安检转维修失败！')
    //   // })
    // }else{
    //   self.$showMessage('安检转维修失败！')
    // }
  }
}

export default {
  title: '安检单',
  /**
   * f_plan_id: 为该安检单的id，无计划安检不传这个
   * item：为从currentCreate 查询出来的结果 （工商无计划安检 item.f_no_checkplan为无计划安检）
   * role：inspect
   * defects:
   */
  props: ['f_plan_id', 'item', 'role', 'defects'],
  data() {
    return {
      seaching: false,
      seachTime: null,
      data: {
        f_devices: [],
        f_defect_content: '',
        f_collection_type: '', //按金额还是气量计费
        f_number_change_reason: '',
        f_title_change_reason: '',
        f_noanswer_path: '',
        f_noanswer1_path: '',
        f_noanswer2_path: '',
        f_rejectcheck_path: '',
        f_rejectcheck1_path: '',
        f_rejectcheck2_path: ''
      },
      meter_type:'',
      f_price: 0,
      //转移后累购
      changegas: 0,
      changefee: 0,
      hasChange: '否',
      isSearchUser: false,
      isUpload: false,
      onlySave: true, //判断保存还是保存并上传
      livedispose: '',
      startClick: false, //开始安检按钮是否可点击
      isStrat: false, //是否开始安检
      checkResult: {},//查询结果
      newcheckResult: {},
      timer: null,
      deviceresult: '正常',
      deviceCollects: [],
      hasDevice: false,
      picture: [],
      showModal: false,
      pic_to_be_viewed: '',
      showBack: true,
      devices: [],
      f_devices: [],
      isToRepair: false,
      clickBack: true, //是否点击返回按钮
      isSafeCheckToRepair: false,//是否转维修
      Url: this.$androidUtil.getProxyUrl(),
      detail: {},
      defectDevice: {},
      user: {},
      model: {  //安检维修组转维修数据
        // 一次派单
        serviceacitivity: [{
          f_service_acitivity_type: '派单',
          f_reciever: '工商大表组'
        }],
        f_source: '安检',
        f_order_type: '安检转单',
        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_userinfo_id: '',
        f_unit: '',
        f_floor: '',
        f_room: '',
        aState: null,
        f_repairtype: '',
        f_repairitems: {},
        failure: []
      },
      model1: {  //散户安装组转维修数据
        // 一次派单
        serviceacitivity: [{
          f_service_acitivity_type: '派单',
          f_reciever: '散户安装组'
        }],
        f_source: '安检',
        f_service_id: '',
        f_contact_phone: '',
        f_meetunit: '',
        f_phone: '',
        f_user_name: '',
        f_address: '',
        f_repair_date: Util.toStandardTimeString(),
        // 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: '',
        f_card_id: '',
        aState: null,
        f_repairtype: '',
        f_repairitems: {},
        failure: []
      },
      f_no_checkplan: '',
      repairitems: [],
      meading: '转站点',
      f_user_defects: [], //该用户之前的隐患项
      f_user_suc_defects: [], //该用户之前的隐患项，在本次安检中完成了的
      f_user_err_defects: [], //该用户之前的隐患项，在本次安检中未完成的
      f_new_defects: [], //本次安检新的隐患项
      config: {
        /*'燃气表': {
          'checkmust': true,
          'items': {
            '卡号': {'index': 1, 'type': 'number'},
            '表型': {
              'index': 2,
              'type': 'selector',
              'options': [
                {'data': '莱德物联网表', 'isdefect': false},
                {'data': '莱德非接触', 'isdefect': false},
                {'data': '秦港', 'isdefect': false},
                {'data': '秦港民用无线', 'isdefect': false},
                {'data': '秦川', 'isdefect': false},
                {'data': '067非接触', 'isdefect': false},
                {'data': '秦港工业无线', 'isdefect': false},
                {'data': '赛福', 'isdefect': false},
                {'data': '天庆', 'isdefect': false},
                {'data': '秦港工业', 'isdefect': false},
                {'data': '手抄表', 'isdefect': false},
                {'data': '秦岭山水莱德普表', 'isdefect': false},
                {'data': '华捷普通(10)', 'isdefect': false},
                {'data': '华捷加密(12)', 'isdefect': false},
                {'data': '华捷加密(10)', 'isdefect': false},
                {'data': '华捷普通(12)', 'isdefect': false},
                {'data': '工业无线', 'isdefect': false},
                {'data': '天然气无线', 'isdefect': false},
                {'data': '致力老表', 'isdefect': false},
                {'data': '其他', 'isdefect': false}
              ]
            },
            '表编号': {'index': 3, 'type': 'string'},
            '表编号修正原因': {
              'index': 4,
              'type': 'selector',
              'options': [{'data': '新增表编号'}, {
                'data': '表号已更改，确认无误',
                'isdefect': false
              }, {'data': '表编号不符，无法核实', 'isdefect': false}]
            },
            '左右表': {
              'index': 5,
              'type': 'selector',
              'options': [{'data': '左表', 'isdefect': false}, {'data': '右表', 'isdefect': false}]
            },
            '生产时间': {'index': 6, 'type': 'date'},
            '基表读数': {'index': 7, 'type': 'number'},
            '新表底数': {'index': 8, 'type': 'number'},
            '总购气量': {'index': 9, 'type': 'number'},
            '换表后累购': {'index': 10, 'type': 'number'},
            'IC卡表类型': {
              'index': 11,
              'type': 'selector',
              'isshow': false,
              'options': [{'data': '102卡', 'isdefect': false}, {
                'data': '射频卡',
                'isdefect': false
              }, {'data': '067射频卡', 'isdefect': false}]
            },
            '剩余气量参考': {'index': 12, 'type': 'number'},
            '剩余金额参考': {'index': 13, 'type': 'number'},
            '剩余气量': {'index': 14, 'type': 'number'},
            '剩余金额': {'index': 15, 'type': 'number'},
            '表封': {
              'index': 16,
              'type': 'selector',
              'options': [{'data': '无', 'isdefect': false}, {
                'data': '钢质',
                'isdefect': false
              }, {'data': '塑质', 'isdefect': false}]
            },
            '表封号': {'index': 17, 'type': 'number'},
            '表封号修正原因': {
              'index': 18,
              'type': 'selector',
              'options': [{'data': '新增表封号'}, {
                'data': '表封号已更改，确认无误',
                'isdefect': false
              }, {'data': '表封号不符，无法核实', 'isdefect': false}]
            }
          }
        }*/
        '燃气表': {
          'checkmust': true,
          'items': {
            '卡号': {'index': 1, 'type': 'number'},
          }
        }
      },
      templateInfo: [],
      firstEnter: false,
      hasZJ: false,    //是否安装灶具
      hasBgl: false,   //是否安装壁挂炉
      hasRsq: false    //是否安装热水器
    }
  },
  components: {
    RadioGroup,
    Radio
  },
  computed: {
    selector: {
      get() {
        return 'paper-state-noncivil'
      },
      set(val) {
        console.log('当前的this.data.f_entry_status==》' + this.data.f_entry_status)
        if (this.data.f_entry_status == '入户') {
          // if (this.isStrat) {
          this.$goto(val, {userinfo: this.data}, 'paper-router')
          // } else {
          //     this.$showMessage('未开始安检！')
          // }
        } else {
          this.$goto(val, {userinfo: this.data}, 'paper-router')
        }
      }
    },
    actionEnabled: {
      get() {
        return this.role == 'inspect'
      }
    }
  },
  methods: {
    // 全局返回
    back() {
      // if (this.role == 'inspect') {
      //     if (!this.isStrat) {
      //         this.$back()
      //         return
      //     } else {
      //         this.clickBack = true
      //         this.save()
      //     }
      // } else {
      this.$showMessage('是否确认退出？', ['confirm', 'cancel']).then((res) => {
          console.log('res=====>' + res)
          if (res === 'confirm') {
            this.$back()
          }
        }
      )
      // }
    },
    viewPic(fileName) {
      console.log('view pic: ' + fileName)
      if (this.role == 'view') {
        if (!fileName.endsWith('nopic.png')) {
          this.pic_to_be_viewed = fileName
          this.showModal = true
        }
      } else {
        HostApp.viewPic(fileName)
      }
    },
    // 初始化离开时间
    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
    },
    // 根据配置项获取设备信息
    getDevices(f_items, f_device_type, newDevices) {
      console.log('赋值前newDevices======>' + JSON.stringify(newDevices))
      console.log('传入设备信息==>f_items' + JSON.stringify(f_items))
      console.log('获取设备信息==>f_device_type' + f_device_type)
      let brand = ''
      let f_input_date = ''
      for (let i = 0; i < f_items.length; i++) {
        let items = f_items[i]
        let f_item_name = items.f_item_name
        let f_item_value = items.f_item_value
        if (f_item_name == '有否' && f_item_value == '否') {
          return
        }
        if (f_item_name == '品牌') {
          brand = f_item_value
        }
        if (f_item_name == '安装时间') {
          f_input_date = f_item_value
        }
      }
      let device = {
        f_devices_type: f_device_type,
        f_brand: brand,
        f_input_date: `${f_input_date}`,
        f_user_id: this.data.f_user_id,
        f_userinfo_id: this.data.f_userinfoid,
        f_devices_state: '有效'
      }
      newDevices.push(device)
    },

    getAllDefect() {
      this.f_new_defects = []
      this.f_user_suc_defects = []
      this.f_user_err_defects = []

      let checkResults = {
        result: '正常',
        data: []
      }
      let f_meternumber = ''
      let f_metertitles = ''
      let codata = JSON.parse(JSON.stringify(this.data))
      //物联网表发送指令需要参数
      let year = Util.toStandardTimeString().substr(2, 2)
      let month = Util.toStandardTimeString().substr(5, 2)
      let parseMonth = parseInt(Util.toStandardTimeString().substr(5, 2))
      let day = Util.toStandardTimeString().substr(8, 2)
      let parseDay = parseInt(Util.toStandardTimeString().substr(8, 2))
      let param = {
        month: month,
        parseDay: parseDay,
        parseMonth: parseMonth,
        year: year,
        f_perform_date: Util.toStandardTimeString(),
        day: day
      }
      codata['f_new_devices'] = [] //新增设备
      codata['param'] = param
      codata['f_change_price'] = '否'
      codata.f_devices = []
      this.f_devices = []
      // 循环使用已填写的安检项
      for (let device in codata) {
        // 安检类型------
        let f_device_type
        if (device.startsWith('device')) {
          let hasOther = ''
          let otherValue = null
          for (let item in codata[device]) {
            codata[device][item].f_create_time = Util.toStandardTimeString()
            f_device_type = codata[device][item].f_device_type
            // 热水器或壁挂炉或灶具有新增则给f_new_devices添加数据
            if (f_device_type === '热水器' || f_device_type === '灶具' || f_device_type === '壁挂锅炉') {
              this.getDevices(codata[device][item].f_items, f_device_type, codata.f_new_devices)
              console.log('codata.f_new_devices新增设备===>' + JSON.stringify(codata.f_new_devices))
            }
            console.log('codata[device][item].f_items' + JSON.stringify(codata[device][item].f_items))
            for (let i in codata[device][item].f_items) {
              var items = codata[device][item].f_items[i]
              console.log('items====',items)
              items.f_create_time = Util.toStandardTimeString()
              if (items.item_default != undefined) {
                items.item_default = [] //将devicesItem添加的备份默认数据的字段item_default，置为空否则保存安检单到本地会报错
              }
              items.f_item_lists = []
              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
              // 安检隐患照片
              const f_defect_path = items.f_path
              const f_defect1_path = items.f_p1_path
              const f_defect2_path = items.f_p2_path
              if (f_item_name == '表编号') {
                f_meternumber = items.f_item_value
                codata['f_meternumber'] = items.f_item_value
              }
              if (f_item_name == '表封号') {
                f_metertitles = items.f_item_value
              }
              if (f_item_name == '表型') {
                codata['f_meter_type'] = items.f_item_value[0]
              }
              if (f_item_name == '表编号修正原因') {
                codata['f_number_change_reason'] = items.f_item_value[0]
              }
              if (f_item_name == '表封号修正原因') {
                codata['f_title_change_reason'] = items.f_item_value[0]
              }
              if (f_device_type == '报警器' && f_item_name == '安装时间') {
                codata['f_bjq_install_time'] = items.f_item_value
              }
              if (f_device_type == '灶具' && f_item_name == '安装时间') {
                codata['f_zj_install_time'] = items.f_item_value
              }
              if (f_device_type == '热水器' && f_item_name == '安装时间') {
                codata['f_rsq_install_time'] = items.f_item_value
              }
              if (f_device_type == '壁挂锅炉' && f_item_name == '安装时间') {
                codata['f_bggl_install_time'] = items.f_item_value
              }
              if (f_device_type == '抽油机' && f_item_name == '安装时间') {
                codata['f_cyj_install_time'] = items.f_item_value
              }
              //获取设备信息
              if (items.type === 'selector') {
                for (let i in items.f_item_value) {
                  // 所有配置项
                  let configItems = this.config[f_device_type].items[f_item_name]
                  for (let k in configItems.options) {
                    // 是否存在新的隐患
                    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
                      if (f_is_defect) {
                        // 上次安检隐患记录不存在
                        if (this.f_user_defects && this.f_user_defects.length === 0) {
                          this.f_new_defects.push({
                            id: this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4(),
                            f_card_id: codata.f_card_id,
                            f_meter_number: f_meternumber,
                            f_defect: `${f_device_type}:${f_item_name}:${f_item_value}`,
                            f_defect_address: this.data.f_address,
                            f_defect_type: f_device_type,
                            f_defect_name: f_item_name,
                            f_data_sources: '工商安检',
                            f_defect_img_path: f_defect_path, // 新增隐患的隐患照片
                            f_defect_img1_path: f_defect1_path, // 新增隐患的隐患照片
                            f_defect_img2_path: f_defect2_path, // 新增隐患的隐患照片
                            f_defect_value: f_item_value,
                            f_defect_level: f_defect_level,
                            f_is_eliminate: '未处理',
                            f_discover_time: codata.f_onsite_time,
                            f_distinct: codata.f_distinct,
                            f_rectify_mode: null, //整改方式
                            f_report_man: Vue.user.name, // 发现人
                            f_revise_date:items.f_revise_date
                          })
                        } else {
                          let isExist = false
                          let defects
                          for (let defect in this.f_user_defects) {
                            defects = this.f_user_defects[defect]
                            // 当前单子存在的隐患在上次安检单中也存在
                            if (Util.isnull(defects.f_defect_name, '').indexOf(f_item_name) != -1
                              && Util.isnull(defects.f_defect_value, '').indexOf(f_item_value) != -1) {
                              isExist = true
                              break
                            }
                          }
                          if (isExist) {
                            //当前单子存在的隐患在上次安检单中也存在，但是本次处理上次的时候选为了已处理
                            if (defects.f_is_eliminate == '已处理') {
                              this.$showMessage(`${defects.f_defect_type}${defects.f_defect_name}${defects.f_defect_value}，该隐患仍存在，请将处理情况置为未处理！`)
                              this.f_new_defects = []
                              this.f_user_suc_defects = []
                              this.f_user_err_defects = []
                              return 'nok'
                            }
                          } else {
                            // 本次存在上次不存在的为新增
                            this.f_new_defects.push({
                              id: this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4(),
                              f_card_id: codata.f_card_id,
                              f_meter_number: f_meternumber,
                              f_defect: `${f_device_type}:${f_item_name}:${f_item_value}`,
                              f_defect_address: this.data.f_address,
                              f_defect_type: f_device_type,
                              f_defect_name: f_item_name,
                              f_data_sources: '工商安检',
                              f_defect_img_path: f_defect_path, // 新增隐患的隐患照片
                              f_defect_img1_path: f_defect1_path, // 新增隐患的隐患照片
                              f_defect_img2_path: f_defect2_path, // 新增隐患的隐患照片
                              f_defect_value: f_item_value,
                              f_defect_level: f_defect_level,
                              f_is_eliminate: '未处理',
                              f_discover_time: codata.f_onsite_time,
                              f_distinct: codata.f_distinct,
                              f_rectify_mode: null, //整改方式
                              f_report_man: Vue.user.name, // 发现人
                              f_revise_date:items.f_revise_date
                            })
                          }
                        }

                        if (checkResults.result !== '有隐患') {
                          checkResults.result = '有隐患'
                        }
                        if (!this.checkResult.hasOwnProperty(f_item_name)) {
                          // console.log(`The ${f_item_name} initialized`)
                          this.checkResult[f_item_name] = []
                        }
                        if (f_item_value === '其他') {
                          hasOther = f_item_name
                        } else {
                          this.checkResult[f_item_name].push(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_revise_date:items.f_revise_date,
                        f_is_eliminate: null,
                        f_create_time: Util.toStandardTimeString()
                      }
                      if (configItems.options[k].level && configItems.options[k].level.indexOf('一级隐患') > -1) {
                        items_list.f_is_eliminate = '未消除'
                      }
                      if (!items.f_item_lists) {
                        // console.log('f_item_lists未定义')
                        items.f_item_lists = []
                        // console.log('items_list=========>' + JSON.stringify(items_list))
                        if (JSON.stringify(items_list) !== '{}') {
                          items.f_item_lists.push(items_list)
                        }
                      } else {
                        if (JSON.stringify(items_list) !== '{}') {
                          items.f_item_lists.push(items_list)
                        }
                      }
                    }
                  }
                }
              } else {
                let configItems = this.config[f_device_type].items[items.f_item_name]
                f_is_defect = configItems.isdefect
                f_defect_level = configItems.level
                f_item_value = items.f_item_value
                // 从配置文件获取当前安检项是否是隐患
                if (f_is_defect) {
                  // 如果是隐患，并且上次安检隐患的数据为空就代表所有的都行新的隐患
                  if (this.f_user_defects && this.f_user_defects.length === 0) {
                    this.f_new_defects.push({
                      id: this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4(),
                      f_card_id: codata.f_card_id,
                      f_meter_number: f_meternumber,
                      f_defect: `${f_device_type}:${f_item_name}:${f_item_value}`,
                      f_defect_address: this.data.f_address,
                      f_defect_type: f_device_type,
                      f_defect_name: f_item_name,
                      f_data_sources: '工商安检',
                      f_defect_img_path: f_defect_path, // 新增隐患的隐患照片
                      f_defect_img1_path: f_defect1_path, // 新增隐患的隐患照片
                      f_defect_img2_path: f_defect2_path, // 新增隐患的隐患照片
                      f_defect_value: f_item_value,
                      f_defect_level: f_defect_level,
                      f_is_eliminate: '未处理',
                      f_discover_time: codata.f_onsite_time,
                      f_distinct: codata.f_distinct,
                      f_rectify_mode: null, //整改方式
                      f_report_man: Vue.user.name, // 发现人
                      f_revise_date:items.f_revise_date
                    })
                  } else {
                    // 如果是隐患，并且上次安检有隐患数据
                    let isExist = false
                    let defects
                    // 循环所有上次隐患数据
                    for (let defect in this.f_user_defects) {
                      defects = this.f_user_defects[defect]
                      // 如果上次安检的隐患数据在本次也存在则向下执行
                      if (Util.isnull(defects.f_defect_name, '').indexOf(f_item_name) == -1 && Util.isnull(defects.f_defect_value, '').indexOf(f_item_value) == -1) {
                        isExist = true
                        break
                      }
                      if (isExist) {
                        // 上次安检隐患标记为已处理了，但是在本次安检单重又存在了该隐患则提醒
                        if (defects.f_is_eliminate == '已处理') {
                          this.$showMessage(`${defects.f_defect_type}${defects.f_defect_name}${defects.f_defect_value}，该隐患仍存在，请将处理情况置为未处理！`)
                          this.f_new_defects = []
                          this.f_user_suc_defects = []
                          this.f_user_err_defects = []
                          return 'nok'
                        }

                      } else {
                        // 本次存在上次不存在的为新增
                        this.f_new_defects.push({
                          id: this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4() + '' + this.S4(),
                          f_card_id: codata.f_card_id,
                          f_meter_number: f_meternumber,
                          f_defect: `${f_device_type}:${f_item_name}:${f_item_value}`,
                          f_defect_address: this.data.f_address,
                          f_defect_type: f_device_type,
                          f_defect_name: f_item_name,
                          f_data_sources: '工商安检',
                          f_defect_img_path: f_defect_path, // 新增隐患的隐患照片
                          f_defect_img1_path: f_defect1_path, // 新增隐患的隐患照片
                          f_defect_img2_path: f_defect2_path, // 新增隐患的隐患照片
                          f_defect_value: f_item_value,
                          f_defect_level: f_defect_level,
                          f_is_eliminate: '未处理',
                          f_discover_time: codata.f_onsite_time,
                          f_distinct: codata.f_distinct,
                          f_rectify_mode: null, //整改方式
                          f_report_man: Vue.user.name, // 发现人
                          f_revise_date:items.f_revise_date
                        })
                      }
                    }
                  }
                }
                if (f_item_name === '其他') {
                  otherValue = 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_revise_date:items.f_revise_date,
                  f_create_time: Util.toStandardTimeString()
                }
                if (!items.f_item_lists) {
                  items.f_item_lists = []
                  if (JSON.stringify(items_list) != '{}') {
                    items.f_item_lists.push(items_list)
                  }
                } else {
                  if (JSON.stringify(items_list) != '{}') {
                    items.f_item_lists.push(items_list)
                  }
                }
              }
              if (hasOther !== '' && otherValue !== null) {
                this.checkResult[hasOther].push(otherValue)
                hasOther = ''
                otherValue = null
              }
              items.f_item_value = ''
            }
            console.log('安检结果checkResult' + JSON.stringify(this.checkResult))
            this.f_devices.push(codata[device][item])
          }
        }
      }

      // 循环所有上次隐患
      let defects
      for (let defect in this.f_user_defects) {
        let isExist = false
        defects = this.f_user_defects[defect]
        let hasDefect = false
        // 循环所有上次隐患，如果上次隐患是未处理，但是本次没有这个隐患，那么这个隐患就是已处理，需要提醒安检员修改为已处理
        if (defects.f_is_eliminate == '未处理') {
          for (let i = 0; i < this.deviceCollects.length; i++) {
            if (this.deviceCollects[i].deviceInfos.indexOf(defects.f_defect_name) !== -1
              && this.deviceCollects[i].deviceInfos.indexOf(defects.f_defect_value) !== -1) {
              // 本次存在上次也存在 hasdefect就为true
              hasDefect = true
              break
            }
          }
          // 上次存在本次不存在的就为已处理，提示将上次的改为已处理
          if (!hasDefect) {
            this.$showMessage(`${defects.f_defect_type}${defects.f_defect_name}${defects.f_defect_value}，该隐患不存在，请将处理情况置为已处理！`)
            this.f_new_defects = []
            this.f_user_suc_defects = []
            this.f_user_err_defects = []
            return 'nok'
          }
          // console.log('本次未选择上次未处理的隐患，说明已处理')
          defects.f_discover_time = codata.f_onsite_time
          defects.f_task_time = codata.f_onsite_time
          defects.f_task_man = Vue.user.name
          defects.f_report_man = Vue.user.name
          defects.f_distinct = codata.f_distinct
          // defects.f_defect_img_path = defects.f_defect_img_path // 隐患跟进照片
          this.f_user_err_defects.push(defects)
        } else if (defects.f_is_eliminate == '已处理') {
          defects.f_task_time = codata.f_onsite_time
          defects.f_task_man = Vue.user.name
          defects.f_rectify_mode = '安检' // 整改状态
          // defects.f_defect_img_path  //隐患跟进记录
          // 当前隐患是已处理的添加到已处理列表中
          this.f_user_suc_defects.push(defects)
        }
      }

      // 处理本次安检的 f_defect_content
      if (this.checkResult) {
        for (let key in this.checkResult) {
          //TODO  上次安检结果数据组织
          let temp = {}
          temp[key] = this.checkResult[key].join(',')
          checkResults.data.push(temp)
          console.log('checkResults.data==>' + JSON.stringify(checkResults))
        }
        this.checkResult = {}
      }

      codata.f_defect_content = JSON.stringify(checkResults)
      this.data.f_defect_content = JSON.stringify(checkResults)
      codata.f_user_defects = []
      codata['f_iskeyuser'] = '否'
      codata['f_metertitles'] = f_metertitles
      codata['f_meternumber'] = f_meternumber

      codata['f_new_defects'] = this.f_new_defects // 新增隐患
      codata['f_user_defects'] = this.f_user_defects // 以前隐患中心数据
      codata['f_user_suc_defects'] = this.f_user_suc_defects // 已处理的隐患中心数据
      codata['f_user_err_defects'] = this.f_user_err_defects // 未处理的隐患中心数据
      // 循环使用隐患项
      for (let i = 0; i < this.deviceCollects.length; i++) {
        // console.log('this.deviceCollects[i].deviceInfos'+this.deviceCollects[i].deviceInfos)
        if (this.deviceCollects[i].name == '一级隐患') {
          codata.f_iskeyuser = '是'
          codata['f_level_one_discover_time'] = codata.f_onsite_time
          codata.f_level_one = JSON.stringify(this.deviceCollects[i].deviceInfos)
          break
        }
      }
      return codata
    },
    // 获取推送给微信的内容，暂时无用
    getWeixin(backData) {
      console.log('backData' + JSON.stringify(backData))
      let result = {
        f_user_name: backData.f_user_name,
        checker: Vue.user.name,
        f_check_date: Util.toStandardDateString(),
        f_userinfo_id: backData.f_userinfoid,
        f_address: backData.f_address
      }

      let Resultstr = ''

      for (let dev in this.config) {
        for (let device in backData) {
          if (device.startsWith('device')) {
            console.log('12222222321314113343')
            for (let item in backData[device]) {
              //遍历结果
              if (backData[device].length != 0 && backData[device][item].f_device_type == dev) {
                let error = true
                let n = 0
                let level = ''
                for (let i in backData[device][item].f_items) {
                  if (backData[device][item].f_items[i].f_is_defect == true || backData[device][item].f_items[i].f_is_defect == 'true') {
                    error = false
                    n += 1
                    if (level == '') {
                      level = backData[device][item].f_items[i].f_defect_level
                    }
                    let le = backData[device][item].f_items[i].f_defect_level
                    console.log('AAA')
                    if (le) {
                      if (le.startsWith('A')) {
                        let i = parseInt(le.substring(1))
                        if (i < parseInt(le.substring(level))) {
                          level = le
                        }
                      } else if (le.startsWith('B')) {
                        let i = parseInt(le.substring(1))
                        if (i < parseInt(le.substring(level))) {
                          level = le
                        }
                      } else if (le.startsWith('C')) {
                        let i = parseInt(le.substring(1))
                        if (i < parseInt(le.substring(level))) {
                          level = le
                        }
                      }
                    }
                    console.log('BBB')
                  }
                }
                if (error) {
                  Resultstr += dev + (backData[device].indexOf(backData[device][item]) + 1) + ':正常;'
                } else {
                  Resultstr += dev + (backData[device].indexOf(backData[device][item]) + 1) + ':有隐患;'
                }
                result['f_err_number'] = n
                result['f_danger_lever'] = level
              }
            }
          }
        }
      }
      for (let dev in this.config) {
        for (let device in backData) {
          console.log('又是一个device' + device)
          if (device.startsWith('device')) {
            for (let item in backData[device]) {
              if (backData[device].length != 0 && backData[device][item].f_device_type == dev) {
                for (let i in backData[device][item].f_items) {
                  if (backData[device][item].f_items[i].f_is_defect == true || backData[device][item].f_items[i].f_is_defect == 'true') {
                    //todo
                    Resultstr += dev + (backData[device].indexOf(backData[device][item]) + 1) + backData[device][item].f_items[i].f_item_name + ' ' + backData[device][item].f_items[i].f_item_value + ';'

                  }
                }
              }
            }
          }
        }
      }

      return result
    },
    // 安检转维修回调
    async uploadCheckPaper() {
      console.log('进入上传')
      let isReturn = false
      if(this.data.f_price_name && this.data.f_user_equipmen){
        if(!this.data.f_price_name.includes('锅炉') && this.data.f_user_equipmen.includes('锅炉')){
          // 弹出确认弹窗
          await this.$showMessage('用气设备与阶梯气价不符，请确认是否继续？', ['confirm', 'cancel']).then((res) => {
              console.log('res=====>' + res)
              if (res === 'confirm') {
                console.log("用户点击确认，继续执行");
              }else {
                isReturn = true;
              }
            }
          )
        }
        if(this.data.f_price_name.includes('锅炉') && !this.data.f_user_equipmen.includes('锅炉')){
          // 弹出确认弹窗
          await this.$showMessage('用气设备与阶梯气价不符，请确认是否继续？', ['confirm', 'cancel']).then((res) => {
              console.log('res=====>' + res)
              if (res === 'confirm') {
                console.log("用户点击确认，继续执行");
              }else {
                isReturn = true;
              }
            }
          )
        }
      }
      const onsiteTimeStr = this.data.f_onsite_time;
      const onsiteTime = new Date(onsiteTimeStr);
      const now = new Date();
      const timeDiff = now.getTime() - onsiteTime.getTime();
      if (timeDiff < 12 * 60 * 1000 && this.data.f_entry_status == '入户') {
        // 弹出确认弹窗
        await this.$showMessage('时间小于12分钟，请确认是否继续？', ['confirm', 'cancel']).then((res) => {
            console.log('res=====>' + res)
            if (res === 'confirm') {
              console.log("用户点击确认，继续执行");
            }else {
              isReturn = true;
            }
          }
        )
      }
      if (isReturn) return
      let errString = this.errorVerify()
      if (errString) {
        console.log(errString)
        console.log('Vue.android', Vue.android)
        console.log('this.isUpload', this.isUpload)
        if (Vue.android) {
          this.$showMessage(errString)
        }
        return
      } else {
        this.$set('data.f_upload_time', Util.toStandardTimeString())
        this.$set('data.f_create_time', Util.toStandardTimeString())
        console.log('赋值后', this.data)
        this.data.f_complete = '已完成'
        this.disableTimer()
      }
      console.log('uploadCheckPaper-->isUpload' + this.isUpload)
      this.onlySave = false
      let res = this.save(false)
    },
    // 数据保存
    async save(check) {
      this.$set('data.f_operator_op_id', Vue.user.op_id ? Vue.user.op_id : null)
      this.$set('data.f_operator_op_spot', Vue.user.op_spot ? Vue.user.op_spot : null)
      this.$set('data.f_filiale_record', Vue.user.op_company)
      this.$set('data.f_outlets_record', Vue.user.op_dep)
      this.$set('data.f_orgstr_record', Vue.user.orgpathstr)
      this.$set('data.f_filialeids_record', Vue.user.f_orgids)
      this.$set('data.f_filialeid_record', this.data.f_filialeids_record.split('.')[this.data.f_filialeids_record.split('.').length - 2])
      // this.$set('data.f_offsite_time', Util.toStandardTimeString())
      console.log('进入保存')
      let isReturn = false
      if (check){
        if(this.data.f_price_name && this.data.f_user_equipmen){
          if(!this.data.f_price_name.includes('锅炉') && this.data.f_user_equipmen.includes('锅炉')){
            // 弹出确认弹窗
            await this.$showMessage('用气设备与阶梯气价不符，请确认是否继续？', ['confirm', 'cancel']).then((res) => {
                console.log('res=====>' + res)
                if (res === 'confirm') {
                  console.log("用户点击确认，继续执行");
                }else {
                  isReturn = true;
                }
              }
            )
          }
          if(this.data.f_price_name.includes('锅炉') && !this.data.f_user_equipmen.includes('锅炉')){
            // 弹出确认弹窗
            await this.$showMessage('用气设备与阶梯气价不符，请确认是否继续？', ['confirm', 'cancel']).then((res) => {
                console.log('res=====>' + res)
                if (res === 'confirm') {
                  console.log("用户点击确认，继续执行");
                }else {
                  isReturn = true;
                }
              }
            )
          }
        }
        const onsiteTimeStr = this.data.f_onsite_time;
        const onsiteTime = new Date(onsiteTimeStr);
        const now = new Date();
        const timeDiff = now.getTime() - onsiteTime.getTime();
        if (timeDiff < 12 * 60 * 1000 && this.data.f_entry_status == '入户') {
          // 弹出确认弹窗
          await this.$showMessage('时间小于12分钟，请确认是否继续？', ['confirm', 'cancel']).then((res) => {
              console.log('res=====>' + res)
              if (res === 'confirm') {
                console.log("用户点击确认，继续执行");
              }else {
                isReturn = true;
              }
            }
          )
        }
      }
      if (isReturn) return
      let errString = this.errorVerify()
      if (errString) {
        return this.$showMessage(errString)
      } else {
        this.$set('data.f_create_time', Util.toStandardTimeString())
        console.log('赋值后', this.data)
        this.data.f_complete = '已完成'
        this.disableTimer()
      }

      this.seaching = true //开启logging
      const that = this
      this.seachTime = window.setTimeout(() => {
        that.seaching = false
        if (that.seachTime) {
          window.clearTimeout(that.seachTime)
          that.seachTime = null
        }
      }, 3000)

      // try {
      // 获取所有隐患
      let codata = this.getAllDefect()
      console.log('获取所有隐患返回值', codata)
      if (codata == 'nok') {
        return
      }
      for (let key in codata) {
        if (key.startsWith('device')) {
          codata[key] = []
        }
      }
      console.log(`codata内容-->${JSON.stringify(codata)}`)
      // console.log(`codata内容-->${JSON.stringify(codata.f_user_defects)}`)
      if (Vue.android) {
        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 == '工商无计划安检' || this.item.f_no_checkplan == '工商隐患跟进') && this.item.f_no_checkplan != '打回') {
          codata.f_devices = this.f_devices
          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
          }
          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 {
          console.log('非无计划安检保存')
          codata.f_devices = this.f_devices
          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
          }
          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 {
        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) => {
                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
                    this.$androidUtil.bzLogic('saveDevice', {
                      row: device
                    }).then((ret) => {
                      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) => {
            if (res.data.code == 200) {
              //保存devices
              this.$androidUtil.bzLogic('getPaperInfo', {
                f_check_item_id: this.data.f_check_item_id
              }).then((res) => {
                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
                    this.$androidUtil.bzLogic('saveDevice', {
                      row: device
                    }).then((ret) => {
                      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) {
      //   console.log('保存失败==='+JSON.stringify(e))
      //   // this.isUpload = false
      //   this.$showMessage("保存失败!")
      // }
    },
    // 本地保存安检单信息回调函数
    saveCallBack(jo) {
      console.log(JSON.stringify(jo))
      if (jo.state == 'ok') {
        let res = JSON.parse(jo.result)
        if (res.code == 200) {
          if (!this.onlySave) {
            let codata = this.getAllDefect()
            if (codata == 'nok') {
              return
            }
            for (let key in codata) {
              if (key.startsWith('device')) {
                codata[key] = []
              }
            }
            console.log('遮挡上传')
            codata.f_devices = this.f_devices
            let param = {
              f_check_item_id: this.data.f_check_item_id,
              f_checker_id: this.data.f_checker_id,
              row: codata
            }
            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__.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.$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
          }
        }
      }
      console.log(JSON.stringify(jo))
      if (jo.state == 'ok') {
        let res = JSON.parse(jo.result)
        console.log('上传结果===》' + JSON.stringify(res))
        console.log('上传结果的f_paper_id===》' + JSON.stringify(res.id))
        if (res.code == 200) {
          this.$set('data.f_paper_id', res.id)
          // this.isStrat = false
          // if (url != "") {
          //   this.$resetpost(`${url}`, {data: WxResult})
          // }
          console.log('this.isToRepair==============>' + this.isToRepair)
          if (this.isToRepair) {
            // for (let device in this.data) {
            // if (device.startsWith("device")) {
            //     this.data[device] = []
            //     if (res.data.length > 0) {
            //         for (let i in res.data[0].f_devices) {
            //             if (this.data[device].length > 0) {
            //                 if (this.data[device][0].f_device_type == res.data[0].f_devices[i].f_device_type) {
            //                     this.data[device].push(res.data[0].f_devices[i])
            //                     res.data[0].f_devices.splice(i, 1)
            //                 }
            //             } else {
            //                 this.data[device].push(res.data[0].f_devices[i])
            //                 res.data[0].f_devices.splice(i, 1)
            //             }
            //         }
            //     }
            // }
            // }
            this.todo()
          } else {
            this.$showMessage('上传成功!')
            this.$back()
          }
        } else if (res.code == 500) {
          this.$showMessage(`${res.msg}`)
          this.onlySave = true
        } else {
          this.$showMessage(`服务内部错误上传失败`)
          this.onlySave = true
        }
      } else {
        this.$showMessage('本地服务内部错误,上传失败！')
        this.onlySave = true
      }
    },
    //安检组转维修数据
    safecheckToRepairCallBack(jo) {
      //获取微信推送路径
      if (jo.state == 'ok') {
        let res = JSON.parse(jo.result)
        console.log('安检转维修===》' + JSON.stringify(res))
        console.log('安检转维修成功')
        if (res.data.code == 200) {
          this.$showMessage('上传并转维修成功！')
          this.$back()
        } else {
          this.onlySave = true
          this.isToRepair = false
          // this.isStrat = true
          this.$showMessage('上传并转维修成功，回写安检单失败！')
        }
      } else {
        this.$showMessage('服务器内部错误,上传失败！')
        this.onlySave = true
        this.isToRepair = false
        // this.isStrat = true
      }
    },
    // 调用安检转维修
    todo() {
      let gen = getRepairParam(this)
      co(gen)
    },
    // 安检转维修转站点
    undo() {
      this.showCheckToRepair = !this.showCheckToRepair
      this.model.f_repairtype = ''
      this.meading = '转站点'
    },
    // 保存数据后结束定时器（防重复提交）
    disableTimer() {
      if (this.timer) {
        window.clearTimeout(this.timer)
        this.timer = null
      }
      if (this.seachTime) {
        window.clearTimeout(this.seachTime)
        this.seachTime = null
      }
    },
    loaded(paper) {
      if (!paper.hasOwnProperty('id')) {
        this.$showMessage('该安检单在手机上已经不存在，可能是卸载过程序。可以进入重新安检，或返回安检计划。')
        this.init()
      } else {
        Util.booleanFilter(paper)
        HostApp.__this__.$set('data', paper)
        HostApp.__this__.$goto('paper-state-noncivil', {}, 'paper-router')
        // 如果打回重检则重新计时
        console.log('HostApp.__this__.role' + HostApp.__this__.role + ' HostApp.__this__.f_approved:' + HostApp.__this__.data.f_approved)
        if (HostApp.__this__.role == 'inspect'
          && HostApp.__this__.data.f_approved
          && HostApp.__this__.data.f_approved == '打回') {
          console.log('打回')
          HostApp.__this__.data.f_onsite_time = Util.toStandardTimeString()
          HostApp.__this__.tick()
        }
      }
      HostApp.__callback__ = null
      HostApp.__this__ = null
    },
    // 获取模板值
    getTemplateInfoValue(type, name) {
      let value = null
      this.templateInfo.forEach((info) => {
        if (info.f_type === type && info.f_name === name) {
          value = info.f_value
        }
      })
      return value
    },
    // 返回初始化值
    chooseInit(type, name, dataValue) {
      let templateValue = this.getTemplateInfoValue(type, name)
      if (templateValue == null || templateValue == '') return dataValue
      if (dataValue == null || dataValue == '') return templateValue
      return dataValue
    },
    // 初始化安检数据
    init() {
      console.log('this.item.worhercontent=======>' + this.item.worhercontent)
      this.data.ename = Vue.user.ename
      this.data.f_outlets = Vue.user.f_parentname
      this.data.f_level_one = ''
      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_subcompany = this.item.f_subcompany
      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_filialeids = this.item.f_filialeids
      this.data.f_orgstr = this.item.f_orgstr
      this.data.version = this.item.version
      this.data.f_mark = false // 用来标记当前户是否为工商主户  如果是 用气环境项就必须检查
      let deps=Vue.user.orgpathnames.split('.')
      if(deps.length>1){
        this.data.f_sub_dep = deps[1]
      }
      // this.data.distributetime = this.item.f_create_time
      //TODO
      this.$set('data.workorderguid', this.item.workorderguid) //工单编号
      this.$set('data.worhercontent', this.item.worhercontent) // 工单内容
      this.$set('data.workersource', this.item.workersource) //工单来源
      this.$set('data.distributetime', this.item.f_create_time) //派单时间
      this.$set('data.f_meters', this.item.f_plan_meter)
      this.$set('data.f_latchingvalve_state', this.item.f_latchingvalve_state) //自锁阀状态
      this.$set('data.f_userinfo_code', this.item.f_userinfo_code) // 用户编号
      // 上次隐患记录
      this.$set('data.f_user_defects', [])
      this.$set('data.f_focususer_type', this.item.f_focususer_type)
      // 安检状态
      this.$set('data.f_entry_status', '入户')
      this.$set('data.f_verify_result', '未通过')

      if (this.item.f_no_checkplan == '一级隐患跟进单') {
        this.$set('data.f_followup_way', '上门跟进')
      }

      this.$set('data.f_usegas', '已使用')
      this.$set('data.f_state', this.item.f_state)
      this.$set('data.f_onsite_time', Util.toStandardTimeString())
      this.$set('data.f_offsite_time', Util.toStandardTimeString())
      console.log('this.item.f_user_type===>' + this.item.f_user_type)
      // 用户信息
      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_user_type', this.item.f_user_type ? this.item.f_user_type : '民用')
      this.$set('data.f_userinfoid', this.item.f_userinfoid ? this.item.f_userinfoid : '')
      this.$set('data.f_address', this.item.f_address)
      this.$set('data.f_card_id', this.item.f_card_id)
      this.$set('data.f_plumb_id', this.item.f_plumb_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)
      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_safeagreement_id', this.item.f_safeagreement_id?'0':this.item.f_safeagreement_id)
      console.log('打印JM处理后的值:' + Util.isReturnJM(this.item.f_safeagreement_id))
      this.$set('data.f_safeagreement_id', Util.isReturnJM(this.item.f_safeagreement_id))
      this.$set('data.f_contract_id', '0')
      this.$set('data.f_comments', this.item.f_comments)
      this.$set('data.f_order_checker_name', '')
      this.$set('data.f_emphasis_user', '')
      this.$set('data.f_source_type', '')
      this.$set('data.f_allow_open', '')
      this.$set('data.f_promise_user', '否')
      this.$set('data.f_remarks', '')
      this.$set('data.f_indoor_circumstance', '')
      //保存是否可以修改用户姓名的标记
      this.$set('data.f_allow_change_name', '否')
      // this.$set('data.f_userproperties', this.item.f_userproperties)
      // 处置方式
      this.$set('data.f_no_gas_device', false)
      this.$set('data.f_close_valve', false)
      this.$set('data.f_unload_battery', false)
      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()
      }
      console.log('准备初始化' + this.templateInfo)
      console.log('this.item-------------',this.item)
      this.tick()
      //房屋结构
      // this.$set('data.f_room_style', '多层')
      //供暖方式
      //  this.$set('data.f_heating_style', '热力公司集中供暖')
      for (let de in this.devices) {
        this.$set('data.device' + this.devices[de].n, [])
        if (this.devices[de].device == '燃气表') {
          console.log('燃气表复赋值')
          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_card_id,
              f_path: '',
              type: 'number'
            }
            ]
          })
        }
        else if (this.devices[de].device == '报警器') {
          console.log('报警器赋值')
          this.data['device' + this.devices[de].n].push({
            f_device_type: '报警器',
            f_items: [{
              f_defect_level: null,
              f_device_id: '',
              f_item_name: '有否',
              f_item_value: this.chooseInit('报警器', '有否', ''),
              f_path: '',
              type: 'selector'
            },
              {
                f_defect_level: null,
                f_device_id: '',
                f_item_name: '厂家',
                f_item_value: this.chooseInit('报警器', '厂家', ''),
                f_path: '',
                type: 'selector'
              },
              {
                f_defect_level: null,
                f_device_id: '',
                f_is_defect: '',
                f_item_name: '是否通电',
                f_item_value: this.chooseInit('报警器', '是否通电', ''),
                f_path: '',
                type: 'selector'
              },
              {
                f_defect_level: null,
                f_device_id: '',
                f_is_defect: '',
                f_item_name: '安装渠道',
                f_item_value: this.chooseInit('报警器', '安装渠道', ''),
                f_path: '',
                type: 'selector'
              },
              {
                f_defect_level: null,
                f_device_id: '',
                f_is_defect: '',
                f_item_name: '电磁阀接口漏气',
                f_item_value: this.chooseInit('报警器', '电磁阀接口漏气', ''),
                f_path: '',
                type: 'selector'
              },
              {
                f_defect_level: null,
                f_device_id: '',
                f_is_defect: '',
                f_item_name: '安装时间',
                f_item_value: this.chooseInit('报警器', '安装时间', ''),
                f_path: '',
                type: 'date'
              },
              {
                f_defect_level: null,
                f_device_id: '',
                f_is_defect: '',
                f_item_name: '到期时间',
                f_item_value: this.chooseInit('报警器', '到期时间', ''),
                f_path: '',
                type: 'date'
              }
            ]
          })
        }
        console.log('燃气表赋值完毕this.data = > ' + JSON.stringify(this.data))
      }
    },
    // 从数据库查询数据并赋值
    setGasMeterData(data, totalgas, newmeterbase, changegas, changefee, hasChange, devices) {
      this.meter_type=data.f_meter_type?'data.f_meter_type':'未知类型'
      console.log('this.data = > ' + JSON.stringify(this.data))
      console.log('setGasMeterData的data:' + JSON.stringify(data))
      console.log('devices = > ' + JSON.stringify(devices))
      console.log('newmeterbase = > ' + newmeterbase)
      console.log('changegas = > ' + changegas)
      console.log('hasChange = > ' + hasChange)
      if (data && data.f_collection_type) {
        console.log('打印计费类型：' + data.f_collection_type)
        this.data.f_collection_type = data.f_collection_type
      }
      for (let de in this.devices) {
        console.log('遍历设备===')
        // this.$set('data.device' + this.devices[de].n, [])
        if(this.devices[de].device == '用气设备'){
          this.$set('data.device' + this.devices[de].n, [])
          for (let i = 0; i < devices.length; i++) {
            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: [devices[i].f_device_type],
                f_path: '',
                type: 'selector'
              },
                {
                  f_defect_level: null,
                  f_device_id: '',
                  f_is_defect: '',
                  f_item_name: '备注',
                  f_item_value: devices[i].f_remark,
                  f_path: '',
                  type: 'string'
                }
              ]
            })
          }
          console.log('this.data[\'device\' + this.devices[de].n]===', this.data['device' + this.devices[de].n])
        }
      }
      //devices 当前用户旧设备信息，如果存在，写入安检项中
      /*for (let i = 0; i < devices.length; i++) {
        let device = devices[i]
        for (let de in this.devices) {
          // this.$set('data.device' + this.devices[de].n, [])
          if (this.devices[de].device == device.f_devices_type) {
            console.log(`${device.f_devices_type}赋值`)
            if (this.data['device' + this.devices[de].n].length === 0) {
              console.log('device:PaperSet修改之前' + JSON.stringify(device))
              if (device.f_devices_type == '壁挂锅炉') {
                console.log('壁挂锅炉111')
                this.data['device' + this.devices[de].n].push(
                  {
                    f_device_type: device.f_devices_type,
                    f_items: [{
                      f_defect_level: null,
                      f_device_id: '',
                      f_is_defect: '',
                      f_item_name: '是否安装',
                      f_item_value: '是',
                      f_path: '',
                      type: 'selector'
                    },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '品牌',
                        f_item_value: device.f_brand,
                        f_path: '',
                        type: 'inputSelector'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '安装时间',
                        f_item_value: device.f_input_date ? device.f_input_date.substring(0, 10) : '',
                        f_path: '',
                        type: 'date'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '到期时间',
                        f_item_value: device.f_input_date ? Util.addYear(device.f_input_date) : '',
                        f_path: '',
                        type: 'date'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: 'true',
                        f_item_name: '壁挂锅炉隐患类型',
                        f_item_value: device.f_input_date ? (Util.compare(Util.addYear(device.f_input_date)) ? '超期使用' : '') : '',
                        f_path: '',
                        type: 'selector'
                      }
                    ]
                  })
              }
              else if (device.f_devices_type == '热水器') {
                console.log('热水器111')
                this.data['device' + this.devices[de].n].push(
                  {
                    f_device_type: device.f_devices_type,
                    f_items: [{
                      f_defect_level: null,
                      f_device_id: '',
                      f_is_defect: '',
                      f_item_name: '是否安装',
                      f_item_value: '是',
                      f_path: '',
                      type: 'selector'
                    },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '品牌',
                        f_item_value: device.f_brand,
                        f_path: '',
                        type: 'inputSelector'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '安装时间',
                        f_item_value: device.f_input_date ? device.f_input_date.substring(0, 10) : '',
                        f_path: '',
                        type: 'date'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '到期时间',
                        f_item_value: device.f_input_date ? Util.addYear(device.f_input_date) : '',
                        f_path: '',
                        type: 'date'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '热水器隐患类型',
                        f_item_value: device.f_input_date ? (Util.compare(Util.addYear(device.f_input_date)) ? '超期使用' : '') : '',
                        f_path: '',
                        type: 'selector'
                      }
                    ]
                  })
              }
              else if (device.f_devices_type == '灶具') {
                console.log('灶具111')
                this.data['device' + this.devices[de].n].push(
                  {
                    f_device_type: device.f_devices_type,
                    f_items: [{
                      f_defect_level: null,
                      f_device_id: '',
                      f_is_defect: '',
                      f_item_name: '是否安装',
                      f_item_value: '是',
                      f_path: '',
                      type: 'selector'
                    },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '品牌',
                        f_item_value: device.f_brand,
                        f_path: '',
                        type: 'inputSelector'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '安装时间',
                        f_item_value: device.f_input_date ? device.f_input_date.substring(0, 10) : '',
                        f_path: '',
                        type: 'date'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '到期时间',
                        f_item_value: device.f_input_date ? Util.addYear(device.f_input_date) : '',
                        f_path: '',
                        type: 'date'
                      },
                      {
                        f_defect_level: null,
                        f_device_id: '',
                        f_is_defect: '',
                        f_item_name: '灶具隐患类型',
                        f_item_value: device.f_input_date ? (Util.compare(Util.addYear(device.f_input_date)) ? '超期使用' : '') : '',
                        f_path: '',
                        type: 'selector'
                      }
                    ]
                  })
              }
              else {
                this.data['device' + this.devices[de].n].push({
                  f_device_type: device.f_devices_type,
                  f_items: [{
                    f_defect_level: null,
                    f_device_id: '',
                    f_is_defect: '',
                    f_item_name: '是否安装',
                    f_item_value: '是',
                    f_path: '',
                    type: 'selector'
                  },
                    {
                      f_defect_level: null,
                      f_device_id: '',
                      f_is_defect: '',
                      f_item_name: '品牌',
                      f_item_value: device.f_brand,
                      f_path: '',
                      type: 'inputSelector'
                    },
                    {
                      f_defect_level: null,
                      f_device_id: '',
                      f_is_defect: '',
                      f_item_name: '安装时间',
                      f_item_value: device.f_input_date ? device.f_input_date.substring(0, 10) : '',
                      f_path: '',
                      type: 'date'
                    },
                    {
                      f_defect_level: null,
                      f_device_id: '',
                      f_is_defect: '',
                      f_item_name: '到期时间',
                      f_item_value: device.f_input_date ? Util.addYear(device.f_input_date) : '',
                      f_path: '',
                      type: 'date'
                    }
                  ]
                })
              }
              console.log('device:PaperSet修改之后' + JSON.stringify(device))
            }
          }
        }
      }*/

      for (let dataItem in this.data) {
        if (dataItem.startsWith('device')) {
          let deviceN = this.data[dataItem]
          for (let deviceItem in deviceN) {
            if (deviceN[deviceItem].f_device_type === '燃气表') {
              this.changegas = changegas
              this.changefee = changefee
              this.hasChange = hasChange
              this.f_price = data.f_price
              if (this.f_price == 0) {
                this.$showMessage('暂无气价信息！')
              }
              let f_items = deviceN[deviceItem].f_items
              console.log('f_items = > ' + JSON.stringify(f_items))
              for (let item in f_items) {
                let itemData = f_items[item]
                let name = itemData.f_item_name
                let value = ''
                switch (name) {
                  case '卡号':
                    value = data.f_card_id
                    break
                  /*case '表编号':
                    value = data.f_meternumber
                    break
                  case '左右表':
                    value = data.f_flow_direction
                    break
                  case '生产时间':
                    value = data.f_making_date
                    break
                  case '总购气量':
                    value = totalgas
                    break
                  case '新表底数':
                    value = newmeterbase
                    break
                  case '换表后累购':
                    value = changegas
                    break
                  case '剩余气量参考':
                    value = 0
                    break
                  case '表封号':
                    value = data.f_metertitles ? data.f_metertitles : 'CA'
                    break
                  case '表封':
                    value = '钢质'
                    break
                  case '表型':
                    value = data.f_meter_style
                    break
                  case 'IC卡表类型':
                    value = data.f_size_card
                    break*/
                }
                itemData.f_item_value = value
              }
            }
          }
        }
      }
    },
    // 合并数据
    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
    },
    // 合并安检配置项
    putDevices() {
      console.log('Vue.config => ' + JSON.stringify(Vue.config))
      console.log('Vue.config => ' + JSON.stringify(Vue.config))
      // console.log('Vue.config.DevicesConfig => ' + JSON.stringify(Vue.config.DevicesConfig))
      this.$set('data.approve', 'true')
      this.$set('data.writeback', 'false')
      if (Vue.config.safecheck != undefined) {
        console.log(Vue.config)
        console.log('Vue.config.safecheck.DevicesConfig=>' + JSON.stringify(Vue.config.safecheck.DevicesSetConfig))
        console.log('赋值前的config=>' + JSON.stringify(this.config))
        if (Vue.config.safecheck.DevicesSetConfig != undefined) {
          this.config = this.extend(this.config, Vue.config.safecheck.DevicesSetConfig)
        }
      }
      console.log('赋值后的config=>' + JSON.stringify(this.config))
      //遍历安检项配置
      for (let i in this.config) {
        //取得安检项索引值
        let n = this.config[i].index
        this.devices[n - 1] = {device: i, n: n, checkmust: this.config[i].checkmust}
        this.$set('data.' + 'device' + n, [])
        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.f_no_checkplan === '点火通气单' && this.config[i].items[it].options[op].isdefault == true) {
                if (i === '报警器' && it === '有否' && this.config[i].items[it].options[op].data === '有') {
                  for (let tempItem in this.config[i].items) {
                    console.log('tempItem:' + JSON.stringify(tempItem))
                    if (tempItem !== '有否') {
                      this.config[i].items[tempItem].isshow = 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'
                })
              }
            }
          }
        }
        this.data['device' + n].push(
          {f_device_type: i, f_items: items}
        )
        n = n + 1
      }
    },
    //获取当前时间
    getNowFormatDate() {
      var date = new Date()
      var seperator1 = '-'
      var seperator2 = ':'
      var month = date.getMonth() + 1
      var strDate = date.getDate()
      if (month >= 1 && month <= 9) {
        month = '0' + month
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = '0' + strDate
      }
      var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + ' ' + date.getHours() + seperator2 + date.getMinutes()
        + seperator2 + date.getSeconds()
      return currentdate
    },
    async initAll() {
      console.log('this.f_no_checkplan 计划类型=======>>>>>' + this.f_no_checkplan)
      // 合并安检配置项
      this.putDevices()
      //如果已检，则提取安检单
      // this.updateAlarmTemplate()
      let f_user_defects = []
      console.log('this.item.f_upload_state==安检单是否上传》' + this.item.f_upload_state)
      console.log('this.item.f_state==安检单状态》' + this.item.f_state)
      // 已检
      if (this.item.f_state != '未检') {
        console.log('隐患中心数据====》' + JSON.stringify(f_user_defects))
        if (this.role == 'inspect' || this.role == 'androidview') {
          HostApp.__callback__ = this.loaded
          HostApp.__this__ = this
          let that = this
          let value = {}
          if (this.role == 'inspect') {
            console.log('this.item.f_no_checkplan', this.item.f_no_checkplan)
            //  已办数据回写
            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/logic/getCheckPaperInfo`, {data: {id: this.item.f_paper_id}})
          }
          // 将查询出来的false替换为null
          Util.replaceFalse(value)
          console.log('value:' + JSON.stringify(value))
          console.log('this.item===========>_>_>_>>>>:' + JSON.stringify(this.item))
          // 当从已办进来的并且有数据，将数据赋值
          if (value.data.length != 0) {
            that.$set('data', value.data[0])
            //查本地隐患中心
            let defectInfo = this.$androidUtil.bzLogic('getLocalDefectInfo', {
              id: this.item.f_paper_id
            })
            console.log('查询本地隐患中心数据====》' + JSON.stringify(defectInfo))
            that.f_user_defects = defectInfo.result.data
            // 是否允许修改姓名
            that.f_allow_change_name = value.data[0].f_allow_change_name
            // 该单子在隐患中心的隐患
            that.f_new_defects = []

            console.log('f_devices:' + JSON.stringify(value.data[0].f_devices))
            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) => {
                console.log('回写数据=>' + JSON.stringify(item))
                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') {
                        item.f_items[i].f_item_value = []
                      } else {
                        item.f_items[i].f_item_value = ''
                      }
                    }
                  }
                  console.log('回写数据item.f_items[i]=======>' + JSON.stringify(item.f_items[i]))
                  for (let j in item.f_items[i].f_item_lists) {
                    console.log('回写数据item.f_items.f_item_lists[j]=======>' + JSON.stringify(item.f_items[i].f_item_lists[j]))
                    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
                    })
                    console.log('device:' + JSON.stringify(that.data['device' + that.devices[de].n]))
                  }
                }
              })
              if (this.role == 'androidview') {
                await Util.androidRatifyPics(that.data, this.$androidUtil.getProxyUrl())
                await Util.androidRatifyPics(that.picture, this.$androidUtil.getProxyUrl())
                await Util.booleanFilter(that.data)
              }
              console.log(that.data)
            }
          } else {
            console.log('该安检单可能已不在本地!')
            this.init()
          }
          that.$goto('paper-state-noncivil', {}, 'paper-router')
        } else {
          let that = this
          let id
          if (this.role == 'view') {
            id = this.item.id
          }
          // else if (this.role == 'androidview') {
          //     id = this.item.f_paper_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())
                }
                console.log('that.data:', that.data)
              } else {
                alert('该安检单可能已不在本地!')
                this.init()
              }
              that.$goto('paper-state-noncivil', {}, 'paper-router')
            }
          ).catch(
            (respanse) => {
              alert('查找安检单失败')
            })
        }
      } else {
        // 未检
        this.init()
        this.$goto('paper-state-noncivil', {}, 'paper-router')
      }
      console.log('this.data.worhercontent=======>' + this.data.worhercontent)
      console.log('init finish:' + JSON.stringify(this.data))
    },
    devicesCollect() {
      console.log('devicesCollect')
      console.log('data => ' + JSON.stringify(this.data))
      this.deviceCollects = []
      // this.result = '正常'
      let codata = JSON.parse(JSON.stringify(this.data))

      let levelOne = {name: '一级隐患', deviceInfos: ''}
      let levelTwo = {name: '二级隐患', deviceInfos: ''}
      let levelThree = {name: '三级隐患', deviceInfos: ''}
      let levelOther = {name: '其他', deviceInfos: ''}

      let levelOneDeviceInfos = []
      let levelTwoDeviceInfos = []
      let levelThreeDeviceInfos = []
      let levelOtherDeviceInfos = []

      let content = this.firstEnter ? 'device' : 'f_devices'
      console.log('content => ' + JSON.stringify(content))

      for (let device in this.data) {
        let f_device_type

        if (device.startsWith(content)) {
          for (let item in this.data[device]) {
            if (this.data[device].length > 1) {
              let j = Number.parseInt(item) + 1
              f_device_type = `${this.data[device][item].f_device_type}${j}`
            } else {
              f_device_type = this.data[device][item].f_device_type
            }
            // console.log('codata[device][item]=>',codata[device][item])
            console.log('this.data[device][item].f_items => ' + JSON.stringify(this.data[device][item].f_items))

            let levelOneArr = []
            let levelTwoArr = []
            let levelThreeArr = []
            let levelOtherArr = []

            for (let i in this.data[device][item].f_items) {
              let items = this.data[device][item].f_items[i]
              if (items.type === 'selector' && items.f_item_value != null && items.f_item_value instanceof Array) {

                let levelOneInfos = `${items.f_item_name}:`
                let levelTwoInfos = `${items.f_item_name}:`
                let levelThreeInfos = `${items.f_item_name}:`
                let levelOtherInfos = `${items.f_item_name}:`

                for (let i in items.f_item_value) {
                  let f_item_value = items.f_item_value[i]

                  console.log('f_item_value => ' + JSON.stringify(f_item_value))
                  console.log('f_device_type => ' + JSON.stringify(f_device_type))
                  console.log('this.data[device][item] => ' + JSON.stringify(this.data[device][item]))
                  console.log('this.config[this.data[device][item].f_device_type] => ' + JSON.stringify(this.config[this.data[device][item].f_device_type]))

                  let options = this.config[this.data[device][item].f_device_type].items[items.f_item_name].options
                  for (let option in options) {
                    if (options[option].data == f_item_value) {
                      if (options[option].isdefect == 'true' || options[option].isdefect == true) {
                        this.deviceresult = '有隐患'
                        let level = options[option].level
                        switch (level) {
                          case '一级隐患':
                            levelOneInfos = `${levelOneInfos}${options[option].data}/`
                            break
                          case '一级隐患安检维修':
                            levelOneInfos = `${levelOneInfos}${options[option].data}/`
                            break
                          case '一级隐患安装组维修':
                            levelOneInfos = `${levelOneInfos}${options[option].data}/`
                            break
                          case '二级隐患':
                            levelTwoInfos = `${levelTwoInfos}${options[option].data}/`
                            break
                          case '三级隐患':
                            levelThreeInfos = `${levelThreeInfos}${options[option].data}/`
                            break
                          default:
                            levelOtherInfos = `${levelOtherInfos}${options[option].data}/`
                            break
                        }
                      }

                    }

                  }
                }
                if (levelOneInfos.endsWith('/')) {
                  levelOneArr.push(levelOneInfos.substring(0, levelOneInfos.length - 1))
                }
                if (levelTwoInfos.endsWith('/')) {
                  levelTwoArr.push(levelTwoInfos.substring(0, levelTwoInfos.length - 1))
                }
                if (levelThreeInfos.endsWith('/')) {
                  levelThreeArr.push(levelThreeInfos.substring(0, levelThreeInfos.length - 1))
                }
                if (levelOtherInfos.endsWith('/')) {
                  levelOtherArr.push(levelOtherInfos.substring(0, levelOtherInfos.length - 1))
                }
              }
              if (items.type === 'selector') {
                items.selected = []
              } else if (items.type === 'inputSelector') {
                items.selected = ''
              }
            }

            if (levelOneArr.length > 0) {
              levelOneDeviceInfos.push(levelOneArr.join(','))
            }
            if (levelTwoArr.length > 0) {
              levelTwoDeviceInfos.push(levelTwoArr.join(','))
            }
            if (levelThreeArr.length > 0) {
              levelThreeDeviceInfos.push(levelThreeArr.join(','))
            }
            if (levelOtherArr.length > 0) {
              levelOtherDeviceInfos.push(levelOtherArr.join(','))
            }
          }
        }
      }

      if (levelOneDeviceInfos.length > 0) {
        levelOne.deviceInfos = levelOneDeviceInfos.join(',')
        this.deviceCollects.push(levelOne)
      }
      if (levelTwoDeviceInfos.length > 0) {
        levelTwo.deviceInfos = levelTwoDeviceInfos.join(',')
        this.deviceCollects.push(levelTwo)
      }
      if (levelThreeDeviceInfos.length > 0) {
        levelThree.deviceInfos = levelThreeDeviceInfos.join(',')
        this.deviceCollects.push(levelThree)
      }
      if (levelOtherDeviceInfos.length > 0) {
        levelOther.deviceInfos = levelOtherDeviceInfos.join(',')
        this.deviceCollects.push(levelOther)
      }
      console.log('levelOne => ' + JSON.stringify(levelOne))
      console.log('levelTwo => ' + JSON.stringify(levelTwo))
      console.log('levelThree => ' + JSON.stringify(levelThree))
      console.log('levelOther => ' + JSON.stringify(levelOther))
      if (this.deviceCollects.length > 0) {
        this.hasDevice = true
      }
    },

    // 本地logic同步异步调用
    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
      })
    },

    // 数据校验
    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 '到访不遇必须拍照'
    },
    verifyUser() {
      let prefix = '用户基本信息：'
      if (Util.required(this.data.f_user_name)) {
        return prefix + '用户名必须输入'
      }
      /*if (Util.required(this.data.f_area)) {
        return prefix + '区/县必须输入'
      }
      if (Util.required(this.data.f_street)) {
        return prefix + '街道必须输入'
      }
      if (Util.required(this.data.f_residential_area)) {
        return prefix + '小区名称必须输入'
      }*/
      /*if (Util.required(this.data.f_building)) {
        return prefix + '楼号必须输入'
      }
      if (Util.required(this.data.f_unit)) {
        return prefix + '单元必须输入'
      }
      if (Util.required(this.data.f_floor)) {
        return prefix + '楼层必须输入'
      }
      if (Util.required(this.data.f_room)) {
        return prefix + '门牌号必须输入'
      }*/
      if (Util.required(this.data.f_address)) {
        return prefix + '详细地址必须输入'
      }
      /* if (Util.required(this.data.f_people_num)) {
         return prefix + '常住人口必须输入'
       }
       if (Util.required(this.data.f_idnumber) && this.f_no_checkplan == '预约过户单') {
         return prefix + '证件号码必须输入'
       }*/
      if (Util.requiredJM(this.data.f_safeagreement_id) && this.data.f_is_safeagreement == '是') {
        return prefix + '安全用气协议编号必须输入,且必须是大写JM与8位数字拼接而成'
      }
      /*if (Util.requiredJM(this.data.f_contract_id) && this.data.f_is_safeagreement == '是') {
        return prefix + '供气合同编号必须输入,且必须是大写JM与8位数字拼接而成'
      }
      if (Util.required(this.data.f_rent)) {
        return '请选择租住情况'
      }
      if (Util.required(this.data.f_residential_properties)) {
        return '请选择小区性质'
      }*/
      if (Util.required(this.data.f_distinct)) {
        return '请选择所属区域'
      }
      /*if (Util.required(this.data.f_emphasis_user)) {
        return '请选择重点用户'
      }
      if (Util.required(this.data.f_heating_style)) {
        return '请选择供暖方式'
      }
      if (Util.required(this.data.f_user_equipmen)) {
        return '请选择用气设备'
      }
      if (this.data.f_emphasis_user == '临街商铺') {
        if (Util.required(this.data.f_use_type)) {
          return '请选择商铺用途'
        }
        if (Util.required(this.data.f_source_type)) {
          return '请选择气源接入'
        }
      }*/
      // 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) {
        console.log('===================>',this.data.f_mark)
        if (this.config[dev].checkmust == true || (this.data.f_mark && dev=='用气环境')) {
          let error = true
          let erroritem = true
          for (let device in this.data) {
            if (device.startsWith('device')) {
              //TODO 用户信息选择的用气设备为必填
              for (let item in this.data[device]) {
                if (this.data[device][item].f_device_type == dev && this.data[device][item].f_device_type == '燃气表') {
                  for (let f_item in this.data[device][item].f_items) {
                    let f_items = this.data[device][item].f_items[f_item]
                    if (f_items.f_item_name != '表具故障' && f_items.f_item_name != '电子屏用气量' && f_items.f_item_name != '表具隐患类型'
                      && f_items.f_item_name != '其他' && f_items.f_item_name != '表封号' && f_items.f_item_name != '新表底数' && f_items.f_item_name != '剩余气量参考'
                      && f_items.f_item_name != '总购气量' && f_items.f_item_name != '换表后累购' && f_items.f_item_name != '表封号修正原因' && f_items.f_item_name != '表编号修正原因'
                      && f_items.f_item_name != 'IC卡表类型'
                    ) {
                      if (!f_items.f_item_value || f_items.f_item_value.length == 0) {
                        return '请检查' + this.data[device][item].f_device_type + f_items.f_item_name
                      }
                    }
                  }
                }
                if (this.data[device].length != 0 && this.data[device][item].f_device_type == dev) {
                  error = false
                }
              }
            }
          }
          if (error) {
            return '请检查' + dev
          }
        }

        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) {
                  //检查安检下拉结果
                  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 + '选中必须拍照'
                    }
                  }
                }
              }
            }
          }
        }
      }

      // 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) {
              for (let f_item in this.data[device][item].f_items) {
                let f_items = this.data[device][item].f_items[f_item]
                if (this.data[device][item].f_device_type == '灶具') {
                  if (f_items.f_item_name == '是否安装') {
                    if (f_items.f_item_value == '是') {
                      this.hasZJ = true
                    }
                  }
                }
                if (this.data[device][item].f_device_type == '热水器') {
                  if (f_items.f_item_name == '是否安装') {
                    if (f_items.f_item_value == '是') {
                      this.hasRsq = true
                    }
                  }
                }
                if (this.data[device][item].f_device_type == '壁挂锅炉') {
                  if (f_items.f_item_name == '是否安装') {
                    if (f_items.f_item_value == '是') {
                      this.hasBgl = true
                    }
                  }
                }
              }
              // for (let i in this.data[device][item].f_items) {
              // for (let it in this.config[dev].items) {
              //TODO
              // if (this.config[dev].items[it].checkmust == true
              //   && this.data[device][item].f_items[i].f_item_value instanceof Array
              //   && this.data[device][item].f_items[i].f_item_value.length == 0
              //   && this.data[device][item].f_items[i].f_path == ''
              //   && it == this.data[device][item].f_items[i].f_item_name) {
              //   return dev + (this.data[device].indexOf(this.data[device][item]) + 1) + this.data[device][item].f_items[i].f_item_name + "未检查"
              // } else if (this.config[dev].items[it].checkmust == true
              //   && this.data[device][item].f_items[i].f_item_value == ''
              //   && this.data[device][item].f_items[i].f_path == ''
              //   && it == this.data[device][item].f_items[i].f_item_name) {
              //   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') {
              //   if (this.data[device][item].f_items[i].f_is_defect == true && this.data[device][item].f_items[i].f_path == Vue.nopic) {
              //     //todo
              //     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 = '用户反馈：'
      // console.log('this.data.f_all_imgs==>' + this.data.f_all_imgs.toString())
      console.log('this.data.f_all_imgs.length==>' + this.data.f_all_imgs.length)
      // if (Vue.android && (!this.data.f_all_imgs || this.data.f_all_imgs.length == 0) && this.data.f_entry_status == '入户')
      //   return prefix + '必须有安检总体照片'
      for (let i in this.data.f_all_imgs) {
        /*if (this.data.f_all_imgs[i].title == '表具正面' && this.data.f_all_imgs[i].f_overall_path.includes('nopic.png')) {
          return prefix + '请拍摄表具正面照片'
        }
        if ((this.hasBgl || this.hasRsq) && this.data.f_all_imgs[i].title == '热水器/壁挂锅炉' && this.data.f_all_imgs[i].f_overall_path.includes('nopic.png')) {
          return prefix + '请拍摄热水器/壁挂锅炉照片'
        }
        if (this.hasZJ && this.data.f_all_imgs[i].title == '灶具熄火保护' && this.data.f_all_imgs[i].f_overall_path.includes('nopic.png')) {
          return prefix + '请拍灶具熄火保护照片'
        }*/
      }
      if (Vue.android && this.data.f_defect_notified && this.data.f_notified_path == Vue.nopic) {
        return prefix + '下发安检通知书则必须给通知书拍照'
      }
      if (!this.data.f_notification_number || this.data.f_notification_number.length != 11) {
        if (this.data.f_entry_status == '入户' && this.f_no_checkplan != '点火通气单') {
          return prefix + '请检查安检告知书单号是否为11位'
        }
      }
      if ((this.f_no_checkplan == '预约开户单') && this.data.f_allow_open == '') {
        return '请选择是否同意开户'
        if (this.f_no_checkplan != '重点用户跟进单' && this.data.f_indoor_circumstance == '') {
          return prefix + '请填写户内情况'
        }
      }
    },
    verifyDefect() {
      console.log('检测是否选择this.f_user_defects========>' + JSON.stringify(this.f_user_defects))
      for (let i = 0; i < this.f_user_defects.length; i++) {
        console.log('this.data.f_user_defects[i]========>' + JSON.stringify(this.f_user_defects[i]))
        if (this.f_user_defects[i].f_is_eliminate == '') {
          return '请确认隐患' + this.f_user_defects[i].f_defect_type + ':' + this.f_user_defects[i].f_defect_name + '是否处理'
        } else {
          if (!this.f_user_defects[i].f_defect_img_path || this.f_user_defects[i].f_defect_img_path.indexOf(Vue.nopic) !== -1) {
            return '请确认隐患' + this.f_user_defects[i].f_defect_type + ':' + this.f_user_defects[i].f_defect_name + '是否已经拍照'
          }
        }
      }
    },
    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.verifyDefect()
      if (hasError) {
        return hasError
      }
      hasError = this.verifyFeedback()
      if (hasError) {
        return hasError
      }
    },
    // 生成uuid
    S4() {
      return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
    }
    // getWebMeterParam(){
    //   let year = Util.toStandardTimeString().substr(2,2)
    //   let month = Util.toStandardTimeString().substr(5,2)
    //   let parseMonth = parseInt(Util.toStandardTimeString().substr(5,2))
    //   let day = Util.toStandardTimeString().substr(8,2)
    //   let parseDay = parseInt(Util.toStandardTimeString().substr(8,2))
    //   let param={
    //     month:month,
    //     parseDay:parseDay,
    //     parseMonth:parseMonth,
    //     year:year,
    //     f_perform_date:Util.toStandardTimeString(),
    //     day:day
    //   }
    //   return param
    // },
  },
  ready() {
    let self = this
    // 给当前计划类型赋值【工商无计划安检、点火通气单、等】
    this.f_no_checkplan = this.item.f_no_checkplan
    // 如果是点火通气单则先获取模板数据
    if (this.f_no_checkplan === '点火通气单') {
      let response = this.$androidUtil.bzLogic('getTemplateInfo', {
        f_plan_id: this.item.f_plan_id
      })
      console.log('获取模板信息结果===》' + JSON.stringify(response))
      if (response.result.code === 200) {
        console.log('获取模板信息成功' + JSON.stringify(response.result))
        self.templateInfo = response.result.data
      } else {
        self.$showMessage('点火通气单，获取模板信息失败！！！')
      }
      self.initAll()
    } else {
      self.initAll()
    }
  },
  watch: {
    //   'isUpload'(val){
    //     console.log('isUpload发生变化===>'+val)
    //   }
  },
  events: {
    'result'(val) {
      this.deviceresult = val
    },
    'devicesCollect'(val) {
      console.log('set的devicesCollect')
      this.devicesCollect()
    },
    'deviceCollects'(val) {
      this.deviceCollects = val
    },
    'hasDevice'(val) {
      this.hasDevice = val
    },
    'picture'(val) {
      for (let row of val) {
        let a = 1
        for (let item of this.picture) {
          if (row.name === item.name) {
            item.f_path = row.f_path
            a = 0
          }
        }
        if (a === 1) {

          if (!row.f_path) {
            continue
          }
          this.picture.push(row)
        }

      }
    },
    'updateUserInfo'(val) {
      console.log('更新用户信息')
      Object.assign(this.data, this.data, this.userInfo)
    }
  },
  destroyed() {
    console.log('退出当前页Set')
    this.disableTimer()
  }
}
</script>
