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

                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </ul>
    </div>

  </div>
</template>

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

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

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

          // 参数全部设置成空，在ready时，等model处理好了，再添加
          {
            header: '客户信息',complete:'safecheck-userinfo',class: 'repair-info-class', props: null
          },
          {
            header: '拍照签名',complete:'paper-feedback', class: 'outlay-class', props: null
          }
        ],
        faultshow:{
          number : 8
        }     // 控制 故障汇总 在 菜单里显示与否,
      }
    },
    computed: {
      actionEnabled: {
        get() {
          return this.role == 'inspect'
        }
      }
    },
    methods: {
      ToRepair(){
        this.isToRepair=true
        this.data.f_repaired='未派维修单'
        this.uploadCheckPaper()
      },
      timeSet(val){
        if (!val){
          return
        }
        let time =new Date(val).getTime()
        let time2=new Date().getTime()
        if (time2>time) {
          return true
        }
      },
      imgback(val,isheader){
        if(val && this.routeShow && isheader){
          return require('../../assets/xiangxia1.png')
        }else{
          return require('../../assets/xiangyou1.png')
        }
      },
      changediv(val){
        console.log(val)
        return val
      },
      // 选择tab
      tabSelect (item,number) {
        this.header = item.header
        console.log('item',item)
        console.log('number',number)
        console.log('this.routeShow',this.routeShow)
        console.log('this.number',this.number)
        // 处理关闭/显示 内容
        if(this.number == number && !this.routeShow ){
          this.routeShow = true
        }else if(this.number == number && this.routeShow){
          this.routeShow = false
        }else if(this.number != item.complete){
          this.routeShow = true
        }
        this.number = number
        this.componentName = item.complete
        console.log('跳转前this.routeShow',this.routeShow)
        if(item.complete == 'safecheck-devices'){
          console.log('this.data', this.data)
          if(item.header != '燃气表' && this.data['device'+item.number].length == 0){
            this.data['device' + item.number].push({})
          }
          console.log('length', this.data['device' + item.number])
          console.log('this.data[\'device\' + item.number] ===> ' + JSON.stringify(this.data['device' + item.number]))
          let idx=this.data['device' + item.number].length - 1
          let itemprops = {
            config:this.config,
            device:this.devices[item.number-1],
            idx:idx,
            role:'inspect'
          }
          console.log('tabSelect函数中赋值')
          console.log(JSON.stringify(itemprops))
          console.log('itemprops.device ===> ' + JSON.stringify(itemprops.device))
          console.log('item.complete',item.complete)
          if(this.routeShow){
            this.$goto(item.complete, itemprops, 'repair')
            console.log('跳转完成')
          }
        }else{
          console.log('页面跳转==》',this.tabs[number])
          if(this.routeShow){
            this.$goto(item.complete, {userinfo:this.data}, 'repair')
          }
        }
        this.shupingshow = true
      },
      // 给组件添加参数
      getImgPath() {
        for (var i = 0; i < this.model.serviceacitivity[0].imgs.length; i++) {
          this.ids += this.model.serviceacitivity[0].imgs[i].imgid + ','
        }
        this.ids = this.ids.substring(0, this.ids.length - 1)
        if(this.ids){
          this.getImgGen();
        }
      },
      getImgGen(){
        let http = new HttpResetClass()
        http.load('POST','api/af-safecheck/sql/safe_singleTable_OrderBy', {data: {
            items: '*',
            tablename: 't_files',
            condition: `id in (${this.ids})`,
            orderitem: 'id'
          }}, {resolveMsg: null, rejectMsg: null}).then((res) => {
          for (let i = 0; i < res.data.length; i++) {
            for (let j = 0; j < this.model.serviceacitivity[0].imgs.length; j++) {
              console.log(res.data[i].id.toString())
              console.log(this.model.serviceacitivity[0].imgs[j].imgid)
              if (res.data[i].id.toString() === this.model.serviceacitivity[0].imgs[j].imgid) {
                this.model.serviceacitivity[0].imgs[j] = Object.assign({}, res.data[i], this.model.serviceacitivity[0].imgs[j])
              }
            }

          }
        })
      },

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

        if(this.data.f_entry_status != '入户')
          return null
        hasError = this.verifyUser()
        if(hasError)
          return hasError
        hasError = this.verifyDevices()
        if(hasError)
          return hasError
        hasError = this.verifyFeedback()
        if(hasError)
          return hasError
      },
      verifyState() {
        if(Vue.android && this.data.f_entry_status == '未使用天然气' && this.data.f_nongasuser_path == Vue.nopic)
          return '未使用天然气则必须拍照'
        if(Vue.android && this.data.f_entry_status == '到访不遇' && this.data.f_noanswer_path == Vue.nopic)
          return  '到访不遇必须拍照'
      },
      verifyUser() {
        let prefix = '用户基本信息：'
        if(Util.required(this.data.f_user_name))
          return prefix + '用户名必须输入'
        if(Util.required(this.data.f_user_phone))
          return prefix + '用户电话必须输入'
        // if(Util.required(this.data.f_residential_area))
        //   return prefix + '小区名称必须输入'
        if(Util.required(this.data.f_address))
          return prefix + '地址必须输入'
      },
      verifyDevices() {
        for (let dev in this.config) {
          if (this.config[dev].checkmust == true) {
            let error = true
            for(let device in this.data) {
              if (device.startsWith("device")) {
                for (let item in this.data[device]) {
                  if (this.data[device].length != 0 && this.data[device][item].f_device_type == dev) {
                    error = false
                  }
                }
              }
            }
            if (error) {
              return "请检查" + dev
            }
          }
        }

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


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

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

                        console.log('f_is_defect=====>' + f_is_defect)
                        console.log('f_item_value=====>' + f_item_value)
                        console.log('f_defect_level=====>' + f_defect_level)

                        if (f_is_defect) {
                          if (checkResults.result !== '有隐患') {
                            checkResults.result = '有隐患'
                          }
                          if (!this.checkResult.hasOwnProperty(f_item_name)) {
                            console.log(`The ${f_item_name} initialized`)
                            this.checkResult[f_item_name] = []
                          }

                          console.log(`The ${f_item_name} was pushed ${f_item_value}`)
                          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_is_eliminate: null,
                          f_create_time: Util.toStandardTimeString()
                        }
                        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) !== '{}') {
                            console.log('放了')
                            items.f_item_lists.push(items_list)
                          }
                        } else {
                          console.log('items_list=========>' + JSON.stringify(items_list))
                          if (JSON.stringify(items_list) !== '{}') {
                            console.log('也放了')
                            items.f_item_lists.push(items_list)
                          }
                        }
                      }
                    }
                  }
                } else {
                  let configItems = this.config[codata[device][item].f_device_type].items[items.f_item_name]
                  console.log('configItems===>' + JSON.stringify(configItems))
                  f_is_defect = configItems.isdefect
                  f_defect_level = configItems.level
                  f_item_value = items.f_item_value
                  console.log('else f_is_defect=====>' + f_is_defect)
                  console.log('else f_defect_level=====>' + f_defect_level)
                  console.log('items.f_item_value==>' + items.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_create_time: Util.toStandardTimeString()
                  }
                  if (f_is_defect && f_item_value) {
                    items.f_is_defect = true
                    if (checkResults.result !== '有隐患') {
                      checkResults.result = '有隐患'
                    }
                    if (!this.checkResult.hasOwnProperty(items.f_item_name)) {
                      console.log(`The ${items.f_item_name} initialized`)
                      this.checkResult[items.f_item_name] = []
                    }

                    console.log(`The ${items.f_item_name} was pushed ${f_item_value}`)
                    this.checkResult[items.f_item_name].push(f_item_value)

                  }
                  console.log('items_list=========>' + JSON.stringify(items_list))
                  console.log('items.f_item_lists' + JSON.stringify(items.f_item_lists))
                  if (!items.f_item_lists) {
                    console.log('f_item_lists未定义')
                    items.f_item_lists = []
                    if (JSON.stringify(items_list) != '{}') {
                      console.log('else放了')
                      items.f_item_lists.push(items_list)
                    }
                  } else {
                    // items.f_item_lists[0].f_item_value = f_item_value
                    if (JSON.stringify(items_list) != '{}') {
                      console.log('else也放了')
                      console.log('放之后items_list=========>' + JSON.stringify(items_list))
                      console.log('放之后items.f_item_lists' + JSON.stringify(items.f_item_lists))
                      console.log('type=>items.f_item_lists' + typeof items.f_item_lists)
                      items.f_item_lists.push(items_list)
                    }
                  }
                }
                if (hasOther !== '' && otherValue !== null) {
                  console.log(`The other value was pushed.`)
                  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])
            }
          }
        }
        if (this.checkResult) {
          for (let key in this.checkResult) {
            // 上次安检结果数据组织
            console.log('key=>' + key)
            console.log('value=>' + this.checkResult[key])
            let temp = {}
            temp[key] = this.checkResult[key].join(',')
            checkResults.data.push(temp)
            // this.newcheckResult[key] = this.checkResult[key]
            // checkResults.data.push(this.newcheckResult)
            console.log('checkResults.data==>' + JSON.stringify(checkResults))
            // this.newcheckResult = {}
          }
          this.checkResult = {}
        }
        codata.f_is_meterreadding = '未抄表'
        console.log(`typeof-checkResults-->${typeof checkResults}`)
        console.log('checkResults ==> ' + JSON.stringify(checkResults))
        codata.f_defect_content = JSON.stringify(checkResults)
        this.data.f_defect_content = JSON.stringify(checkResults)
        console.log('f_defect_content' + codata.f_defect_content)
        return codata
      },
      uploadCheckPaper(){
        console.log('进入上传')
        let errString = this.errorVerify()
        if (errString) {
          console.log(errString)
          console.log('Vue.android',Vue.android)
          console.log('this.isUpload',this.isUpload)
          if (Vue.android){
            // if(this.isUpload){
            //   this.isUpload = false
            // }
            this.$showMessage(errString)
          }
          return
        } else {
          this.$set('data.f_offsite_time', Util.toStandardTimeString())
          this.$set('data.f_upload_time', Util.toStandardTimeString())
          this.$set('data.f_upload_date', Util.toStandardTimeString())
          console.log('赋值后',this.data)
          this.data.f_complete = '已完成'
          this.disableTimer()
        }
        console.log('uploadCheckPaper-->isUpload'+this.isUpload)
        this.onlySave = false
        let res =  this.save()
        // if(res) {
        //   try {
        //     let codata = this.getAllDefect()
        //     //获取微信推送内容
        //     let WxResult = this.getWeixin(codata)
        //     let haslivedispose = this.$androidUtil.bzLogic('getLiveDispose', {
        //       f_check_item_id: this.data.f_check_item_id
        //     })
        //     //如果是转维修上传，则不做校验，上传完成后自动转维修
        //     console.log('this.isToRepair=======》'+this.isToRepair)
        //     console.log('this.livedispose=======》'+this.livedispose)
        //     if(!this.isToRepair){
        //       if(haslivedispose.data.length > 0 && (this.livedispose == 'true' || this.livedispose == true)){
        //         console.log('是否已转维修')
        //         console.log(this.isSafeCheckToRepair)
        //         if(!this.isSafeCheckToRepair){
        //           this.$showMessage('有未处理的隐患，请前往拍照上传中将安检转为维修单！')
        //           return
        //         }
        //       }
        //     }
        //     console.log(`codata类型-->${typeof codata}`)
        //     for (let key in codata){
        //       if(key.startsWith("device")){
        //         codata[key] = []
        //       }
        //     }
        //     console.log(`codata内容-->${JSON.stringify(codata)}`)
        //
        //     console.log('遮挡上传')
        //     let isStart = true
        //     let res
        //     for (let i in this.f_devices){
        //       res = HostApp.organizeJSON({isStart:isStart,isDevice:true,device:this.f_devices[i]})
        //       if(res.code == 200){
        //         isStart = false
        //       }else{
        //         this.$showMessage("保存失败!")
        //       }
        //     }
        //     let result = HostApp.organizeJSON({
        //       isStart:false,
        //       isJSON:true,
        //       jsonstr:{
        //         f_check_item_id: this.data.f_check_item_id,
        //         f_checker_id: this.data.f_checker_id,
        //         row: codata
        //       }
        //     })
        //     if(result.code == 200){
        //       HostApp.__this__ = this
        //       this.runSyncLogic('上传安检信息','javascript:HostApp.__this__.uploadCallBack()',1)
        //     }
        //
        //
        //     // let response = this.$androidUtil.bzLogic('上传安检信息', {
        //     //   f_check_item_id: this.data.f_check_item_id,
        //     //   f_checker_id: this.data.f_checker_id,
        //     //   row: codata
        //     // })
        //     // if (response.code == 200) {
        //     //   console.log('=============response.data==================')
        //     //   console.log(JSON.stringify(response.data))
        //     //   let f_paper_id
        //     //   if(response.data != '' && response.data != null){
        //     //     f_paper_id = JSON.parse(response.data).id
        //     //   }
        //     //   this.$set('data.f_paper_id', f_paper_id)
        //     //   console.log('=============f_paper_id==================')
        //     //   console.log(JSON.stringify(f_paper_id))
        //     //   console.log(this.data.f_paper_id)
        //     //   console.log("===data"+JSON.stringify(this.data))
        //     //   for (let device in this.data){
        //     //     console.log("上传设备信息device=======>"+device)
        //     //     console.log("上传设备信息device=======>"+JSON.stringify(this.data[device]))
        //     //     if(device.startsWith("device")){
        //     //       for(let devices of this.data[device]) {
        //     //         devices.f_paper_id = f_paper_id
        //     //         let ret = this.$androidUtil.bzLogic('UpCheckPaperDevices', {
        //     //           row: devices
        //     //         })
        //     //         console.log(`上传设备信息结果res======${JSON.stringify(ret.data)}`)
        //     //         if(ret.code == 200){
        //     //           console.log(`设备信息id======${ret.data.f_device_id}`)
        //     //           devices.f_device_id = JSON.parse(ret.data.f_device_id).id
        //     //         }
        //     //         console.log('上传设备信息device======')
        //     //         console.log(JSON.stringify(devices))
        //     //         if (ret.code != 200) {
        //     //           //TODO 失败后处理
        //     //           // this.isUpload = false
        //     //           this.$showMessage("上传失败!")
        //     //           return false
        //     //         }
        //     //       }
        //     //     }
        //     //   }
        //     //   // for (let device of this.f_devices) {
        //     //   //   device.f_paper_id = f_paper_id
        //     //   //   console.log('上传设备信息device======')
        //     //   //   console.log(JSON.stringify(device))
        //     //   //   let ret = this.$androidUtil.bzLogic('UpCheckPaperDevices', {
        //     //   //     row: device
        //     //   //   })
        //     //   //   console.log(`上传设备信息结果res======${ret}`)
        //     //   //   if (ret.code != 200) {
        //     //   //     //TODO 失败后处理
        //     //   //     HostApp.alert("上传失败!")
        //     //   //     return false
        //     //   //   }
        //     //   // }
        //     //   let result = this.$androidUtil.bzLogic('FinishUpload',
        //     //     {
        //     //       f_check_item_id: this.data.f_check_item_id,
        //     //       f_userinfo_id: codata.f_userinfoid,
        //     //       f_last_check_result: codata.f_defect_content
        //     //     })
        //     //   if(result.code == 200){
        //     //     // this.$showAlert('上传成功!', 'success', 2000)
        //     //     this.$showMessage('上传成功!')
        //     //     this.isStrat=false
        //     //     if(url != "" ){
        //     //       this.$resetpost(`${url}`,{data:WxResult})
        //     //     }
        //     //     return true
        //     //   }else{
        //     //     // this.isUpload = false
        //     //     this.$showMessage("上传失败!")
        //     //     return false
        //     //   }
        //     // }else{
        //     //   // this.isUpload = false
        //     //   this.$showMessage("上传失败!")
        //     //   return false
        //     // }
        //   }catch (e) {
        //     console.log('上传失败==='+JSON.stringify(e))
        //     // this.isUpload = false
        //     this.$showMessage("上传失败!")
        //   }
        // }
      },
      save(type) {
        console.log('进入保存')
        if(type == 'temp'){
          this.data.f_complete = '未完成'
          this.disableTimer()
        }else {
          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.data.f_complete = '已完成'
            this.$set('data.f_offsite_time', Util.toStandardTimeString())
            this.disableTimer()
          }
        }
        // try {
        let codata = this.getAllDefect()
        if(this.isToRepair && JSON.parse(this.data.f_defect_content).result != '有隐患'){
          this.$showMessage("未发现隐患，请点击上传")
          return
        }
        console.log(`codata类型-->${typeof codata}`)
        console.log(`codata内容-->${JSON.stringify(codata)}`)
        for (let key in codata) {
          if (key.startsWith("device")) {
            console.log('this.data.' + key + JSON.stringify(codata[key]))
            codata[key] = []
          }
        }
        console.log(`codata内容-->${JSON.stringify(codata)}`)
        console.log(`codata内容-->${JSON.stringify(codata.f_user_defects)}`)
        console.log('安卓环境？=》' + Vue.android)
        if (Vue.android) {
          console.log('Vue.android is true')
          let value = this.$androidUtil.path({
            alias: 'getUserinfomation',
            data: {condition: "f_userinfoid = '" + this.item.f_userinfoid + "' and f_no_checkplan = '无计划安检'"}
          })
          console.log('getUserinfomation value ==> ' + JSON.stringify(value))
          if (this.item.f_no_checkplan == '无计划安检'  && this.item.f_no_checkplan != '打回') {
            // let result = this.$androidUtil.bzLogic('SafeSaveNoPaper', {
            //   f_check_item_id: this.data.f_check_item_id,
            //   f_checker_id: this.data.f_checker_id,
            //   f_upload_state:'未传',
            //   row: codata
            // })
            console.log('无计划安检保存')
            let isStart = true
            // let res
            // for (let i in this.f_devices) {
            //   res = HostApp.organizeJSON({isStart: isStart, isDevice: true, device: this.f_devices[i]})
            //   if (res.code == 200) {
            //     isStart = false
            //   } else {
            //     this.$showMessage("保存失败!")
            //   }
            // }
            // let result = HostApp.organizeJSON({
            //   isStart: false,
            //   isJSON: true,
            //   jsonstr: {
            //     f_check_item_id: this.data.f_check_item_id,
            //     f_checker_id: this.data.f_checker_id,
            //     f_upload_state: '未传',
            //     row: codata
            //   }
            // })
            codata.f_devices = this.f_devices
            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
            }
            console.log('codata ===> ' + JSON.stringify(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('非无计划安检保存')
            let isStart = true
            let res
            console.log('this.f_devices' + JSON.stringify(this.f_devices))
            // for (let i in this.f_devices) {
            //   console.log('this.f_devices[i] ====>' + JSON.stringify(this.f_devices[i]))
            //   for (let j = 0; j < this.f_devices[i].f_items.length; j++) {
            //     console.log(`this.f_devices[i].f_items[${j}] ===> ` + JSON.stringify(this.f_devices[i].f_items[j]))
            //   }
            //   res = HostApp.organizeJSON({isStart: isStart, isDevice: true, device: this.f_devices[i]})
            //   console.log('f_devices organizeJSON ==> ' + JSON.stringify(res))
            //   if (res.code == 200) {
            //     isStart = false
            //   } else {
            //     this.$showMessage("保存失败!")
            //   }
            // }
            console.log('this.data ==> ' + JSON.stringify(this.data))
            console.log('f_check_item_id ==> ' + JSON.stringify(this.data.f_check_item_id))
            console.log('f_checker_id ==> ' + JSON.stringify(this.data.f_checker_id))
            // let result = HostApp.organizeJSON({
            //   isStart: false,
            //   isJSON: true,
            //   jsonstr: {
            //     f_check_item_id: this.data.f_check_item_id,
            //     f_checker_id: this.data.f_checker_id,
            //     row: codata
            //   }
            // })
            codata.f_devices = this.f_devices
            let param = {
              f_check_item_id: this.data.f_check_item_id,
              f_checker_id: this.data.f_checker_id,
              row: codata
            }
            console.log('codata ===> ' + JSON.stringify(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 {
          console.log("保存的值", codata)
          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) => {
                  console.log(`查询paper结果res======${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
                      console.log('设备信息device======', device)
                      this.$androidUtil.bzLogic('saveDevice', {
                        row: device
                      }).then((ret) => {
                        console.log(`保存设备信息结果res======`, 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) => {
              console.log('asdddddddddddddddddddddddddddddd')
              if (res.data.code == 200) {
                //保存devices
                this.$androidUtil.bzLogic('getPaperInfo', {
                  f_check_item_id: this.data.f_check_item_id
                }).then((res) => {
                  console.log(`查询paper结果res======${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
                      console.log(`设备信息device======${device}`)
                      this.$androidUtil.bzLogic('saveDevice', {
                        row: device
                      }).then((ret) => {
                        console.log(`保存设备信息结果res======${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("保存失败!")
        // }
      },
      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
        })
      },
      saveCallBack(jo){
        console.log(JSON.stringify(jo))
        if(jo.state == 'ok'){
          let res = JSON.parse(jo.result)
          console.log('保存结果===》'+JSON.stringify(res))
          if(res.code == 200){
            console.log('onlySave=====>'+this.onlySave)
            if(!this.onlySave){
              let codata = this.getAllDefect()
              //获取微信推送内容
              // let WxResult = this.getWeixin(codata)
              let haslivedispose = this.$androidUtil.bzLogic('getLiveDispose', {
                f_check_item_id: this.data.f_check_item_id
              })
              //如果是转维修上传，则不做校验，上传完成后自动转维修
              console.log('this.isToRepair=======》'+this.isToRepair)
              console.log('this.livedispose=======》'+this.livedispose)
              if(!this.isToRepair){
                if(haslivedispose.data.length > 0 && (this.livedispose == 'true' || this.livedispose == true)){
                  console.log('是否已转维修')
                  console.log(this.isSafeCheckToRepair)
                  if(!this.isSafeCheckToRepair){

                  }
                }
              }
              console.log(`codata类型-->${typeof codata}`)
              for (let key in codata){
                if(key.startsWith("device")){
                  codata[key] = []
                }
              }
              console.log(`codata内容-->${JSON.stringify(codata)}`)

              console.log('遮挡上传')
              // let isStart = true
              // let res
              // for (let i in this.f_devices){
              //   res = HostApp.organizeJSON({isStart:isStart,isDevice:true,device:this.f_devices[i]})
              //   if(res.code == 200){
              //     isStart = false
              //   }else{
              //     this.$showMessage("上传失败!")
              //     return
              //   }
              // }
              // let result = HostApp.organizeJSON({
              //   isStart:false,
              //   isJSON:true,
              //   jsonstr:{
              //     f_check_item_id: this.data.f_check_item_id,
              //     f_checker_id: this.data.f_checker_id,
              //     row: codata
              //   }
              // })
              codata.f_devices = this.f_devices
              let param = {
                f_check_item_id: this.data.f_check_item_id,
                f_checker_id: this.data.f_checker_id,
                row: codata
              }
              console.log('codata ===> ' + JSON.stringify(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': 'rc_upCheckPaper',
                // 回调执行方法名，key必须为callback
                'callback': 'javascript:HostApp.__this__.uploadCallBack()',
                // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
                // 执行回调方法传入key为backresult
                // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
                'backresult': 1
              })
            }else{
              this.$showMessage('保存成功！')
              if(this.clickBack){
                this.isStrat = false
                this.$dispatch('confirm')
                //this.$back()
              }
            }
          }else{
            this.$showMessage('保存失败！')
            return
          }
        }else{
          this.$showMessage('移动网络异常,请稍后再试,保存失败！')
          return
        }
      },
      uploadCallBack(jo){
        //获取微信推送路径
        let url = ""
        if(Vue.config.safecheck != undefined) {
          if (Vue.config.safecheck.ApproveConfig != undefined) {
            if (Vue.config.safecheck.ApproveConfig.weixinurl != undefined) {
              url = Vue.config.safecheck.ApproveConfig.weixinurl
            }
          }
        }
        console.log(JSON.stringify(jo))
        console.log('jo ===> ' + 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){
            //上传抄表信息
            if(this.item.f_user_type=='民用' && this.item.f_safecheck_type=='年度普检'){
              //let codata = this.getAllDefect()
              let res3= this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/sql/safe_singleTable_OrderBy`,{
                data:{
                  items:" f_userfiles_id",
                  tablename:"t_userfiles",
                  condition:"f_userinfo_id="+this.item.f_userinfoid,
                  orderitem:"f_userfiles_id"
                }
              }).then(res3 => {
                console.log("res---"+JSON.stringify(res3))
                let f_tablebase1=''
                this.f_devices.forEach(row=>{
                  if(row.f_device_type=='燃气表'){
                    row.f_items.forEach(item =>{
                      if(item.f_item_name=='本期表读数'){
                        f_tablebase1=item.f_item_lists[0].f_item_value
                      }
                    })
                  }
                })

                console.log("抄表底数！"+f_tablebase1+"------userfilesid"+res3.data[0].f_userfiles_id +'------'+this.data.f_checker_name+this.data.f_checker_id+this.data.f_checker_name)
                this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/logic/handCommonEnter`, {data:{
                    f_userfiles_id:res3.data[0].f_userfiles_id,
                    f_operator:this.data.f_checker_name,
                    f_operatorid:this.data.f_checker_id,
                    f_inputtor:this.data.f_checker_name,
                    f_tablebase:f_tablebase1,
                    isAudit:false,f_meter_source:''
                  }
                }).then(res4 =>{
                  console.log("抄表上传成功！"+JSON.stringify(res4))
                  if(res4.data.status==200){
                    console.log("开始修改状态！！！！"+this.item.id)
                    let param={
                      itemid:res.id
                    }
                    this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/logic/rc_UpPaperHandMeterState`, {data:param})
                  }
                })

              })
            }
            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){
              console.log('开始转维修！1'+JSON.stringify(this.userinfo))
              console.log('开始转维修！2'+JSON.stringify(this.item))
              console.log('开始转维修！3'+JSON.stringify(this.data))
              let defect=JSON.parse(this.data.f_defect_content)
              console.log("defect----------"+JSON.stringify(defect))
              console.log("defect----------"+JSON.stringify(defect.data))
              let repairContent=''
              defect.data.forEach(de =>{
                let arr=Object.keys(de)
                console.log("defect----------"+JSON.stringify(arr))
                arr.forEach(key=>{
                  repairContent += key+':'+de[key]+' '
                })
              })
              console.log("defect----------"+repairContent)
              let repair={
                "sn": res.id,
                "caseType": "客户问题",
                "callerPhone": "",
                "caseTime":  Util.toStandardTimeString(),
                "orderSource": "安检转维修",
                "orderSourceUserID": "",
                "customerNo": this.item.f_userinfo_code,
                "customerName": this.item.f_user_name,
                "customerAddress": this.item.f_address,
                "customerDistrictCode": "",
                "customerDistrict": "",
                "callerName": this.item.checker,
                "callerSex": "",
                "phone": this.item.f_user_phone,
                "repairAddress": this.item.f_address,
                "repairContent": repairContent,
                "company": Vue.user.orgs,
                "orderType": "报修",
                "faultCategory": "安检隐患",
                "processingLevel": "普通",
                "remarks": "" }
              console.log('开始转维修！4'+JSON.stringify(repair))
              new HttpResetClass().load('POST','http://39.101.182.117:8909/api/cc/workorder.ashx?sign=5F27F9CA-2793-40CE-9834-0F033F71EDD2&method=postpreorder',repair,{resolveMsg: null, rejectMsg: null}).then(res =>{
                console.log('调维修接口返回的结果！'+JSON.stringify(res))
                if(res.data.success){
                  console.log('调维修接口成功！'+JSON.stringify(res))
                  let param={
                    itemid:res.id,
                    gid:res.data.gid
                  }
                  new HttpResetClass().load('POST',`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/logic/rc_UpPaperRepairState`,{data:param},{resolveMsg: null, rejectMsg: null})
                  this.$showMessage('转维修成功!')
                }else{
                  this.$showMessage('转维修失败!')
                }
                this.$dispatch('confirm')
              })
              //this.todo()
            }else{
              this.$showMessage('上传成功!')
              console.log('上传结束back')
              this.$dispatch('confirm')
              // this.$back()
            }
          }else if(res.code == 309){
            this.$showMessage('该安检单已作废!')
            console.log('该安检单已作废')
            this.$dispatch('confirm')
          }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))
          if(res.code == 200){
            console.log('安检转维修成功')
            if(res.data.code == 200){
              this.$showMessage('上传并转维修成功！')
            }else{
              this.$showMessage('上传并转维修成功，回写安检单失败！')
            }
            this.$dispatch('confirm')
            // this.$back()
          }else{
            this.$showMessage('上传失败！')
            this.onlySave = true
          }
        }else{
          this.$showMessage('移动网络异常,请稍后再试,上传失败！')
          this.onlySave = true
        }
      },
      todo(){
        let gen = getRepairParam(this)
        co(gen)
      },
      undo(){
        this.showCheckToRepair = !this.showCheckToRepair
        this.model.serviceacitivity[0].f_reciever = ''
        this.model.serviceacitivity[0].f_meetunit = ''
        this.model.f_repairtype = ''
        this.meading = '转站点'
      },
      disableTimer() {
        if(this.timer) {
          window.clearTimeout(this.timer)
          this.timer = null
        }
      },
      loaded(paper) {
        if(!paper.hasOwnProperty('id')) {
          this.$showMessage("该安检单在手机上已经不存在，可能是卸载过程序。可以进入重新安检，或返回安检计划。")
          this.init()
        } else {
          Util.booleanFilter(paper)
          HostApp.__this__.$set('data', paper)
          HostApp.__this__.$goto('safecheck-userinfo', {}, 'paper-router')
          // 如果打回重检则重新计时
          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
      },
      S4() {
        return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
      },
      extend(initalObj, finalObj) {
        var obj = finalObj || {};
        for (var i in initalObj) {
          var prop = initalObj[i];

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

          if (typeof prop === 'object') {
            if (obj[i]) {
              this.extend(obj[i], prop)
            } else {
              obj[i] = prop;
            }
          }
        }
        return obj;
      },
      async isoverDate(){
        console.log('123456')
        let res= await this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/sql/androidGetuserinfo`, {data:{
            condition:"f_plan_item_id='"+this.item.id+"'"
          }
        })

        this.isneedDate=res.data.length>0?res.data[0]["f_subscribe_date"]:''
      },
      putDevices() {
        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) {
          if (Vue.config.safecheck.ApproveConfig != undefined) {
            if (Vue.config.safecheck.ApproveConfig.approve != undefined) {
              this.$set('data.approve', Vue.config.safecheck.ApproveConfig.approve)
            }
            if (Vue.config.safecheck.ApproveConfig.writeback != undefined) {
              this.$set('data.writeback', Vue.config.safecheck.ApproveConfig.writeback)
            }
            if (Vue.config.safecheck.ApproveConfig.livedispose != undefined) {
              this.livedispose = Vue.config.safecheck.ApproveConfig.livedispose
            }
          }
          console.log(Vue.config)
          console.log('Vue.config.safecheck.DevicesConfig=>' + JSON.stringify(Vue.config.safecheck.DevicesConfig))
          console.log('赋值前的config=>' + JSON.stringify(this.config))
          console.log("当前用户类型"+this.item.f_user_type)
          if(this.item.f_user_type == '民用'){
            // 民用户

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

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

          if(this.config[i].quantity &&  this.config[i].quantity >0){
            let items = []
            for (let it in this.config[i].items) {
              //赋值下拉选项
              if (this.config[i].items[it].type == 'selector') {
                for (let op in this.config[i].items[it].options) {
                  if (this.config[i].items[it].options[op].isdefault == true) {
                    items.push({
                      f_defect_level: this.config[i].items[it].options[op].level,
                      f_is_defect: this.config[i].items[it].options[op].isdefect,
                      f_item_name: it,
                      f_item_value: this.config[i].items[it].options[op].data,
                      f_path: "",
                      type: "selector"
                    })
                  }
                }
              }
            }
            for(let q =0;q<this.config[i].quantity;q++) {
              this.data['device' + n].push(
                {f_device_type: i, f_items:items}
              )
            }
          }
          // this.data['device' + n].push(
          //   {f_device_type: i, f_items: items}
          // )
          n = n + 1
        }
        console.log('tbs合并数组')
        this.faultshow.number = this.tabs.length
      },
      init () {
        console.log("123456789")
        // this.data.f_noplan_item_id =  this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()+""+this.S4()
        this.data.ename = Vue.user.ename
        this.data.f_outlets = Vue.user.f_parentname
        this.data.f_meetunit = Vue.user.orgpathnames
        this.data.orgpathstr = Vue.user.orgpathstr
        this.data.f_check_item_id = this.item.id
        this.data.f_check_plan_id = this.f_plan_id
        this.data.f_checker_id = Vue.user.id
        this.data.f_checker_name = Vue.user.name
        this.data.f_check_type = this.item.f_user_type
        this.data.f_safecheck_type = this.item.f_safecheck_type
        //this.data.f_exceed_reason = ''//存放送气超期原因
        console.log('设置参数2')
        this.data.f_subcompany = this.item.f_subcompany
        this.data.f_approved = this.item.f_approved
        this.data.f_repair_approved = this.item.f_repair_approved
        this.data.f_no_checkplan = this.item.f_no_checkplan
        this.data.f_approved = this.item.f_approved
        this.data.f_filialeid = this.item.f_filialeid
        this.data.f_orgstr = this.item.f_orgstr
        this.data.version = this.item.version
        this.$set('data.f_meters', this.item.f_plan_meters)
        this.$set('data.f_userinfo_code', this.item.f_userinfo_code)
        // 安检状态
        this.$set('data.f_entry_status', '入户')
        this.$set('data.f_usegas', '已使用')
        this.$set('data.f_state',this.item.f_state)
        console.log('设置参数3')
        // 用户信息
        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_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_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)
        console.log('设置参数4')
        this.$set('data.f_floor', this.item.f_floor)
        this.$set('data.f_residential_area' , this.item.f_residential_area)
        this.$set('data.f_idnumber', this.item.f_idnumber)
        this.$set('data.f_comments', this.item.f_comments)
        this.$set('data.f_userproperties', this.item.f_userproperties)
        // this.$set('data.f_user_inhome_time', this.item.f_user_inhome_time)
        // this.$set('data.f_user_check_time', this.item.f_user_check_time)
        // this.$set('data.f_user_spare_phone', this.item.f_user_spare_phone)
        // this.$set('data.f_user_family_remarks', this.item.f_user_family_remarks)
        // this.$set('data.f_user_equipment_remarks', this.item.f_user_equipment_remarks)
        // 处置方式
        console.log('设置参数5')
        this.$set('data.f_no_gas_device', false)
        this.$set('data.f_close_valve', false)
        this.$set('data.f_unload_battery', false)
        console.log('设置参数6')
        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("item.f_plan_meters",this.item.f_plan_meters)
        if(this.item.f_plan_meters) {
          for (let de in this.devices) {
            this.$set('data.device' + this.devices[de].n, [])
            for (let i = 0; i < this.item.f_plan_meters.length; i++) {
              if (this.item.f_plan_meters[i].f_meter_type) {
                console.log('this.item.f_plan_meters[i] ===> ' + JSON.stringify(this.item.f_plan_meters[i]))
                if (this.devices[de].device == "燃气表" && this.item.f_plan_meters[i].f_meter_type.indexOf('机表') > 0) {
                  console.log("111111111:"+this.devices[de].device)
                  this.data['device' + this.devices[de].n].push({
                    f_device_type: "燃气表",
                    f_items: [
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "基表编号",
                        f_item_value: this.item.f_plan_meters[i].f_meter_no,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "气表型号",
                        f_item_value: this.item.f_plan_meters[i].f_diaphgram_size,
                        f_path: "",
                        type: "string"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "气表品牌",
                        f_item_value: this.item.f_plan_meters[i].f_aliasname,
                        f_path: "",
                        type: "string"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "进气方向",
                        f_item_value: this.item.f_plan_meters[i].f_flow_direction,
                        f_path: "",
                        type: "selector"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "上期表读数",
                        f_item_value: this.item.f_plan_meters[i].f_prior_reading,
                        f_path: "",
                        type: "number"
                      }
                    ]
                  })
                } else if (this.devices[de].device == "燃气表") {
                  // delete this.config['燃气表']['items']['表底数']
                  this.data['device' + this.devices[de].n].push({
                    f_device_type: "燃气表",
                    f_items: [
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "基表编号",
                        f_item_value: this.item.f_plan_meters[i].f_meter_no,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "气表型号",
                        f_item_value: this.item.f_plan_meters[i].f_diaphgram_size,
                        f_path: "",
                        type: "string"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "气表品牌",
                        f_item_value: this.item.f_plan_meters[i].f_aliasname,
                        f_path: "",
                        type: "string"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "进气方向",
                        f_item_value: this.item.f_plan_meters[i].f_flow_direction,
                        f_path: "",
                        type: "selector"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "上期表读数",
                        f_item_value: this.item.f_plan_meters[i].f_prior_reading,
                        f_path: "",
                        type: "number"
                      }
                    ]
                  })
                }
                if (this.devices[de].device == "燃气表" && this.item.f_plan_meters[i].f_collection_type) {
                  this.data['device' + this.devices[de].n].forEach(device => {
                    console.log('device ===> ' + JSON.stringify(device))
                    console.log('this.item.f_plan_meters[i].f_collection_type ===> ' + JSON.stringify(this.item.f_plan_meters[i].f_collection_type))
                    /*
                      "累购气量":{"index":8,"type":"number","readonly":true},
                      "累购金额":{"index":8,"type":"number","readonly":true},
                      "字轮读数":{"index":9,"type":"number","checkmust": true},
                      "已用金额":{"index":9,"type":"number","checkmust": true},
                      "剩余气量":{"index":10,"type":"number","checkmust": true},
                      "剩余金额":{"index":10,"type":"number","checkmust": true},
                      "气量异常差值":{"index":11,"type":"number","readonly": true},
                      "金额异常差值":{"index":11,"type":"number","readonly": true}
                    */
                    if (this.item.f_plan_meters[i].f_collection_type == '按金额') {
                      if (!this.data.f_collection_type) {
                        this.data.f_collection_type = this.item.f_plan_meters[i].f_collection_type
                        delete this.config['燃气表']['items']['累购气量']
                        delete this.config['燃气表']['items']['已用气量']
                        delete this.config['燃气表']['items']['剩余气量']
                        delete this.config['燃气表']['items']['气量异常差值']
                        device.f_items.push(
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "初始表底",
                            isshow: false,
                            f_item_value: '',
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "累购金额",
                            f_item_value: this.item.f_plan_meters[i].f_total_fee,
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "已用金额",
                            f_item_value: null,
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "剩余金额",
                            f_item_value: null,
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "金额异常差值",
                            f_item_value: null,
                            f_path: "",
                            type: "number"
                          }
                        )
                        console.log('this.config[\'燃气表\'][\'items\']  ===> ' + JSON.stringify(this.config['燃气表']['items']))
                      }
                    } else if (this.item.f_plan_meters[i].f_collection_type == '按气量') {
                      if (!this.data.f_collection_type) {
                        this.data.f_collection_type = this.item.f_plan_meters[i].f_collection_type
                        delete this.config['燃气表']['items']['累购金额']
                        delete this.config['燃气表']['items']['已用金额']
                        delete this.config['燃气表']['items']['剩余金额']
                        delete this.config['燃气表']['items']['金额异常差值']
                        device.f_items.push(
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "初始表底",
                            isshow: true,
                            f_item_value: this.item.f_plan_meters[i].f_initial_base,
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "累购气量",
                            f_item_value: this.item.f_plan_meters[i].f_total_gas,
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "已用气量",
                            f_item_value: this.item.f_plan_meters[i].f_meter_base,
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "剩余气量",
                            f_item_value: this.item.f_plan_meters[i].f_total_gas-this.item.f_plan_meters[i].f_meter_base,
                            f_path: "",
                            type: "number"
                          },
                          {
                            f_defect_level: null,
                            f_device_id: "",
                            f_is_defect: "",
                            f_item_name: "气量异常差值",
                            f_item_value: null,
                            f_path: "",
                            type: "number"
                          }
                        )
                        console.log('this.config[\'燃气表\'][\'items\']  ---> ' + JSON.stringify(this.config['燃气表']['items']))
                      }
                    }
                  })
                }else{
                  if (!this.data.f_collection_type) {
                    this.data.f_collection_type = this.item.f_plan_meters[i].f_collection_type
                    delete this.config['燃气表']['items']['累购金额']
                    delete this.config['燃气表']['items']['已用金额']
                    delete this.config['燃气表']['items']['剩余金额']
                    delete this.config['燃气表']['items']['金额异常差值']
                    device.f_items.push(
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "初始表底",
                        isshow: true,
                        f_item_value: this.item.f_plan_meters[i].f_initial_base,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "累购气量",
                        f_item_value: this.item.f_plan_meters[i].f_total_gas,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "已用气量",
                        f_item_value: this.item.f_plan_meters[i].f_meter_base,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "剩余气量",
                        f_item_value: this.item.f_plan_meters[i].f_total_gas-this.item.f_plan_meters[i].f_meter_base,
                        f_path: "",
                        type: "number"
                      },
                      {
                        f_defect_level: null,
                        f_device_id: "",
                        f_is_defect: "",
                        f_item_name: "气量异常差值",
                        f_item_value: null,
                        f_path: "",
                        type: "number"
                      }
                    )
                    console.log('this.config[\'燃气表\'][\'items\']  ---> ' + JSON.stringify(this.config['燃气表']['items']))
                  }
                }
              }
            }
          }
        }
        var pardate = {
          _this:this,
          tittle:'安检详情',
          safe:true
        }
        // this.$dispatch('gotoson',pardate)
        console.log('页面跳转')
        this.$goto('safecheck-userinfo', {userinfo:this.data}, 'repair')
      }
    },
    watch: {
      'row' () {
        console.log('row changed')
        this.copy()
      }
    },
    async ready () {
      await this.isoverDate()
      console.log('8888888')
      this.putDevices()
      //如果已检，则提取安检单
      if (this.item.f_state != '未检') {
        if (this.role == 'inspect' || this.role == 'androidview') {
          HostApp.__callback__ = this.loaded
          HostApp.__this__ = this
          let that = this
          let value = {}
          console.log('this.item.f_no_checkplan',this.item.f_no_checkplan)
          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/path/getUserinfomation`, {data: {condition: `id = '${this.item.f_paper_id}'`}})
          }
          Util.replaceFalse(value)
          console.log("value:" + JSON.stringify(value))
          if (value.data.length != 0) {
            that.$set('data', value.data[0])
            console.log("this.data.f_collection_type:" + JSON.stringify(this.data.f_collection_type))
            if (this.data.f_collection_type == '按气量') {
              delete this.config['燃气表']['items']['累购金额']
              delete this.config['燃气表']['items']['已用金额']
              delete this.config['燃气表']['items']['剩余金额']
              delete this.config['燃气表']['items']['金额异常差值']
            } else if (this.data.f_collection_type == '按金额') {
              delete this.config['燃气表']['items']['累购气量']
              delete this.config['燃气表']['items']['已用气量']
              delete this.config['燃气表']['items']['剩余气量']
              delete this.config['燃气表']['items']['气量异常差值']
            }
            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' || that.config[item.f_device_type].items[de].type == 'checkbox') {
                        item.f_items[i].f_item_value = []
                      } else {
                        item.f_items[i].f_item_value = ''
                      }
                    }
                  }
                  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') {
                Util.androidRatifyPics(that.data, this.$androidUtil.getProxyUrl())
                Util.androidRatifyPics(that.picture, this.$androidUtil.getProxyUrl())
                Util.booleanFilter(that.data)
              }
              console.log('回写数据完成后'+JSON.stringify(that.data))
            }
          } else {
            console.log("该安检单可能已不在本地!")
            this.init()
          }
          console.log('页面跳转')
          var pardate = {
            _this:this,
            tittle:'安检详情',
            safe:true
          }
          // this.$dispatch('gotoson',pardate)getImgPath
          this.$goto('safecheck-userinfo', {userinfo:this.data}, 'repair')
        } else {
          let that = this
          let id
          if (this.role == 'view') {
            id = this.item.id
          }
          this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/path/getUserinfomation`, {data:{condition:`id = '${id}'`}}).then((respanse)=> {
              if (respanse.data.length != 0) {
                that.data = Object.assign(that.data,respanse.data[0])
                if(respanse.data[0].f_devices) {
                  for (let da in that.devices) {
                    that.$set('data.device' + that.devices[da].n, [])
                  }
                  respanse.data[0].f_devices.forEach((item) => {
                    for (let de in that.devices) {
                      if (that.devices[de].device == item.f_device_type) {
                        that.data['device' + that.devices[de].n].push({
                          f_device_type: item.f_device_type,
                          f_items: item.f_items
                        })
                      }
                    }
                  })
                }
                Util.replaceFalse(that.data)
                Util.booleanFilter(that.data)
                if(this.role == 'view'){
                  Util.ratifyPics(that.data)
                }else{
                  Util.androidRatifyPics(that.data,this.$androidUtil.getProxyUrl())
                }
                console.log("that.data:", that.data)
              } else {
                alert("该安检单可能已不在本地!")
                this.init()
              }
              var pardate = {
                _this:this,
                tittle:'安检详情',
                safe:true
              }
              // this.$dispatch('gotoson',pardate)
              this.$goto('safecheck-userinfo', {userinfo:this.data}, 'paper-router')
            }
          ).catch(
            (respanse) => {
              alert('查找安检单失败')
            })
        }
      }else{
        this.init()
      }
      // tbs合并数组
      // if( this.model.serviceacitivity[0].servicerepair.length > 0){
      //   for(let i = 0;i < this.model.serviceacitivity[0].servicerepair.length;i++ ){
      //
      //   }
      // }
    },
    components: {
      // 'door-service': DoorService,
      // 'repair-info': RepairInfo,
      // 'repair-user-info': RepairUserInfo,
      // 'outlay': Outlay,
      // 'fault-all': FaultAll,
      // 'repair-details':RepairDetails
      // 'pipeline': Pipeline,
      // 'device-service': DeviceService,
      // 'trouble-removal': TroubleRemoval,
      // 'cooking-utensils': CookingUtensils,
      // 'repair-matter-info': RepairMatterInfo,
      // 'first-gas-check': FirstGasCheck,
      // 'tel-change-matter': TelChangeMatter/
    },
    events: {
      'tijiao': function () {
        // 事件回调内的 `this` 自动绑定到注册它的实例上
        this.confirm()
      }
    }
  }
</script>
<style lang="less">
  @import "../../../src/bootstrap/less/variables.less";

  .tab-befor-img (@url) {
    content: '';
    background-image: url("@{url}");
    background-size: 20px;
    display: inline-block;
    margin-right: 8px;
    margin-top: 0.3em;
    height: 1.3em;
    width: 1.3em;
    vertical-align: -35%;
  }

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

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

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

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

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

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

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

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

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

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