<template>
  <div class="select-overspread repair-bg auto" style="padding-bottom:5px;">
    <!--<div class="bq-parent" v-if="shutype == 'heng'">-->
    <!--<blockquote class="blockquote">-->
    <!--<p><span>{{repairitem.header}}</span><a   @click="mute()" style="float:right"  href="#" class="repair-mute-class"><img src="../../assets/novoice.png" width="25px;" alt=""><span style="margin-left:10px;color: #304A66">关闭声音</span></a></p>-->
    <!--</blockquote>-->
    <!--</div>-->
    <div class="panel panel-default auto repair-info-content">
      <div class="panel-body" style="padding: 0">
        <!-- 安检项内容 -->
        <div  class="auto repair-info-content compatible" style="padding: 0">
          <div class="row auto" style="padding: 0">
            <div v-show="false" class="{{shuclass}}" v-if=" device.device != '燃气表'">
              <button type="button" name="button" class="btn btn-primary" @click='adddetails()' :disabled="issee">增加</button>
            </div>
            <!--<div class="{{shuclass}}" v-if="device.device != '燃气表' && candelete">-->
            <!--<button type="button" name="button" class="btn btn-primary" @click='deletedetails()' :disabled="issee">删除</button>-->
            <!--</div>-->
            <div class="shuclass1"  v-show="row.isshow" v-for="row in f_items"  style="padding: 4px; border:1px solid #D4D4D4;border-bottom: 0" >
              <label v-if="row.type != 'radio' && row.type != 'text' &&  row.type != 'checkbox'" v-show="row.isshow" class="fivelabel" :class="{'defectfront' :row.f_is_defect != ''}">{{row.f_item_name}}<br/>{{row.remark}}</label>
              <label v-if="row.type == 'radio'" v-show="row.isshow" class="radiolabel"  :class="{'defectfront' :row.f_is_defect != ''}">{{row.f_item_name}}<br/>{{row.remark}}</label>
              <label v-if="row.type == 'text'" v-show="row.isshow" class="textlabel1"  :class="{'defectfront' :row.f_is_defect != ''}">{{row.f_item_name}}<br/>{{row.remark}}</label>
              <label v-if="row.type == 'checkbox'" v-show="row.isshow" class="textlabel"  :class="{'defectfront' :row.f_is_defect != ''}">{{row.f_item_name}}<br/>{{row.remark}}</label>
              <!--<span v-if="show" style="font-weight:bold">{{row.f_content}}</span>-->
              <!--<datepicker placeholder="请选择时间"-->
              <!--:value.sync="row.f_content"-->
              <!--v-model="row.f_content"-->
              <!--:format="'yyyy-MM-dd'"-->
              <!--v-if="!show && row.type == 'date'"-->
              <!--:readonly="true"-->
              <!--&gt;</datepicker>-->
              <div style="float: left;width:60%" v-if="row.type == 'picture'" class="form-group" >
                <button style="float: left;" v-show="!row.f_path" type="button" name="button" class="btn btn-primary" @click="takePic($index, row.f_item_name,1)">拍照</button>
                <div class="auto" v-show="row.f_path" style="float: left;">
                  <div class="panel">
                    <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 160px;height: 160px;position: relative">
                      <div class="row" style="height: 160px;width:160px;overflow: scroll;top: 1px">
                        <div class="col-sm-4" v-show="row.f_path">
                          <img-self  :src="row.f_path" :alt="row.f_item_name"  width="140" height="140"></img-self>
                        </div>
                        <!--                        <div class="col-sm-4" v-show="!row.f_path" @click="takePic($index, row.f_item_name,1)">-->
                        <!--                          <img src="../../assets/tackpic.png" :alt="点击拍摄照片"  width="140" height="140"></img>-->
                        <!--                        </div>-->
                        <img v-show="row.f_path" src="../../../../assets/remove.png" :class="style__"   @click="delfile($index, row.f_path)" v-if="role!='androidview'" style="width: 40px;height: 40px;position: absolute;left:110px;top:110px"></img>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <div style="float: left;width:60%" class="form-group" v-if="row.type == 'string'" v-show="row.isshow">
                <input type="text" class="form-control" maxlength="100" v-model="row.f_item_value" :readonly="role == 'androidview' || row.readonly">
              </div>
              <div style="float: left;width:60%" class="form-group col-sm-12" v-if="row.type == 'date'" v-show="row.isshow">
                <datepicker id="f_making_date" :placeholder= row.f_item_name
                            :value.sync="row.f_item_value"
                            v-if="row.type == 'date'"
                            v-show="row.isshow"
                            :disabled-days-of-Week="[]"
                            :format="'yyyy-MM'"
                            :show-reset-button="reset" readonly="readonly">
                </datepicker>
              </div>
              <div style="float: left;width:60%" class="form-group" v-if="row.type == 'stringp'" v-show="row.isshow">

                <input type="text" class="form-control" maxlength="100" v-model="row.f_item_value" :readonly="role == 'androidview' || row.readonly">
                <div class="auto" v-if="row.f_item_value" >
                  <div class="panel">
                    <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 160px;height: 160px;position: relative">
                      <div class="row" style="height: 160px;width:160px;overflow: scroll;top: 1px">
                        <div class="col-sm-4" v-show="row.f_path">
                          <img-self  :src="row.f_path" :alt="row.f_item_name"  width="140" height="140"></img-self>
                        </div>
                        <div class="col-sm-4" v-show="!row.f_path" @click="takePic($index, row.f_item_name)">
                          <img src="../../../../assets/tackpic.png" :alt="点击拍摄照片"  width="140" height="140"></img>
                        </div>
                        <img v-show="row.f_path" src="../../../../assets/remove.png" :class="style__"   @click="delfile($index, row.f_path,1)" v-if="role!='androidview'" style="width: 40px;height: 40px;position: absolute;left:110px;top:110px"></img>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <div style="float: left;width:60%" class="form-group" v-if="!show && row.type == 'number'" v-show="row.isshow">
                <input type="text" class="form-control" maxlength="100" v-model="row.f_item_value"   @change="row.f_item_value=replaceStr(row.f_item_value)" :readonly="row.readonly">
              </div>
              <!--<input type="text" class="form-control" v-model="row.f_content" v-if="!show && row.type == 'string' && row.f_project != '表号'" :disabled="(!(ischecked == '有')) || issee" :readonly="issee">-->
              <!--<input type="text" class="form-control" v-model="meternum" v-if="!show && row.type == 'string' && row.f_project == '表号' " :disabled="(!(ischecked == '有')) || issee" :readonly="issee" >-->
              <!--<button type="button" name="button" class="btn btn-primary" @click="scan" v-if="!show && row.f_project == '表号' ">扫码</button>-->
              <input-select    v-if="row.type == 'inputSelector'"
                               v-show="row.isshow"
                               :value.sync="row.selected"
                               v-model="row.selected"
                               :readonly="false"
                               :options="row.options"
                               @change="changse"
                               @click="transelation($index)"></input-select>
              <v-select  style="float: left"  :value.sync="row.selected"
                         v-model="row.selected"
                         v-if="row.type == 'selector'"
                         v-show="row.isshow"
                         placeholder='请选择'
                         :options="row.options"
                         :disabled="role == 'androidview' || row.readonly"
                         @change="changse"
                         @click="transelation($index)"
                         :multiple="row.multiple"
                         :close-on-select="!row.multiple" clear-button></v-select>
              <div style="float: left;width: 30%" class="form-group" v-if="!show && row.type == 'radio'">
                <div  class="col-xs-6 col-sm-6 col-md-6" v-for="item in row.options">
                  <input type="radio" :name="row.f_item_name"  :value="item.value" :disabled="(!(ischecked == '有')) || issee" v-model="row.f_item_value" >
                  <span>{{item.label}}</span>
                </div>
              </div>
              <div v-if="!show && row.type == 'checkbox'" class="col-xs-12 col-sm-12 col-md-12" style="white-space: nowrap" >
                <div style="float: left" v-for="item in row.options">
                  <input type="checkbox" :name="row.f_item_name" :value="item.value" :disabled="(!(ischecked == '有')) || issee" v-model="row.f_item_value">
                  <span>{{item.label}}</span>
                </div>
              </div>
              <div style="clear: both">
                <label v-if="row.f_item_value.indexOf('其他') >-1" class="fivelabel">其他</label>
                <div style="float: left;width:60%" class="form-group" v-if="row.f_item_value.indexOf('其他') >-1">
                  <input type="text" class="form-control" maxlength="100" v-model="row.f_else" :readonly="role == 'androidview' || row.readonly">
                </div>
              </div>
              <div style="clear: both">
                <div class="form-group"  v-if="(row.type == 'selector' || row.type == 'radio' || row.type =='checkbox') && (row.f_path != '' || row.f_is_defect != '') && (livedispose == 'true' || livedispose == true) " >
                  <label class="fivelabel">处理方式</label>
                  <v-select   :value="row.f_processing"
                              :value-single="true"
                              :options="lives"
                              :disabled="role == 'androidview'"
                              @change="changlive"
                              @click="transelation($index)"
                              close-on-select clear-button></v-select>
                </div>
                <div class="form-group col-sm-12"  v-if="(row.type == 'selector' || row.type == 'radio' || row.type =='checkbox' || row.type =='string') && (row.f_path != '' || row.f_is_defect != '')" style="margin-top: 40px">
                  <div class="auto" style="display: inline-block;">
                    <div class="panel">
                      <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 160px;height: 160px;position: relative">
                        <div class="row" style="height: 160px;width:160px;overflow: scroll;top: 1px">
                          <div class="col-sm-4" v-show="row.f_path">
                            <img-self  :src="row.f_path" :alt="row.f_item_name"  width="140" height="140"></img-self>
                          </div>
                          <div class="col-sm-4" v-show="!row.f_path" @click="takePic($index, row.f_item_name,1)">
                            <img src="../../../../assets/tackpic.png" :alt="点击拍摄照片"  width="140" height="140"></img>
                          </div>
                          <img v-show="row.f_path" src="../../../../assets/remove.png" :class="style__"   @click="delfile($index, row.f_path,1)" v-if="role!='androidview'" style="width: 40px;height: 40px;position: absolute;left:110px;top:110px"></img>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div class="auto" style="display: inline-block;">
                    <div class="panel">
                      <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 160px;height: 160px;position: relative">
                        <div class="row" style="height: 160px;width:160px;overflow: scroll;top: 1px">
                          <div class="col-sm-4" v-show="row.f_second_path">
                            <img-self  :src="row.f_second_path" :alt="row.f_item_name"  width="140" height="140"></img-self>
                          </div>
                          <div class="col-sm-4" v-show="!row.f_second_path" @click="takePic($index, row.f_item_name,2)">
                            <img src="../../../../assets/tackpic.png" :alt="点击拍摄照片"  width="140" height="140"></img>
                          </div>
                          <img v-show="row.f_second_path" src="../../../../assets/remove.png" :class="style__"   @click="delfile($index, row.f_second_path,2)" v-if="role!='androidview'" style="width: 40px;height: 40px;position: absolute;left:110px;top:110px"></img>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>

                <div class="auto" v-if="(row.type == 'selector' || row.type == 'radio' || row.type =='checkbox') && row.tooltip != undefined  && row.tooltip != '' ">
                  <div class="panel">
                    <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 100%;height: auto">
                      {{row.tooltip}}
                    </div>
                  </div>
                </div>
              </div>

              <!--<v-select :value.sync="row.f_content" :options='getOptions(row.f_project)' placeholder='请选择' :disabled="(!(ischecked == '有')) || issee"  close-on-select  :value-single="true" v-if="!show && row.type == 'selector' && row.f_project != '气表品牌'"-->
              <!--&gt;</v-select>-->
              <!--<v-select :value.sync="row.f_content" :options='getOptions(row.f_project)' @change="getgasmodel" placeholder='请选择' :disabled="(!(ischecked == '有')) || issee"  close-on-select  :value-single="true" v-if="!show && row.type == 'selector' && row.f_project == '气表品牌'"-->
              <!--&gt;</v-select>-->
              <!--              <div class="auto" v-if="!show && row.type == 'checkbox' ">-->
              <!--                <input class="magic-checkbox" type="checkbox"  id="shebeicheckbox"-->
              <!--                       :checked="row.f_content == '有'"-->
              <!--                       @click="switchDetails(row.f_project, $event)" :disabled="issee"/>-->
              <!--                <label for="shebeicheckbox" style="width:150px;padding-bottom: 10px">{{row.f_project}}</label>-->
              <!--              </div>-->
              <!--<img-area  :model="Detail.imgs"  :sutitle="row.f_project" v-if="row.type == 'picture'" :disabled="issee"></img-area>-->
            </div>
          </div>
        </div>
        <div style="border-top: 1px solid #D4D4D4"></div>
      </div>
    </div>
  </div>
</template>
<script>
import Vue from 'vue'
import * as Util from '../../../Util'

  export default {
    title: '维修列表信息',
    data() {
      return {
        // telphoneValid: '/^((0\\d{2,3}-\\d{7,8})|(1[3584]\\d{9}))$/',
        // meterstyle:[],
        shuclass:'col-xs-12 col-sm-12 col-md-12 form-input-group mg8',
        shuclass1:'col-xs-12 col-sm-12 col-md-12 mg8',
        // labels:[],
        meternum:'',
        ischecked:'有',
        gasmodel:'',
        textstyle:'color: red',
        paper: this.$parent.$parent.data,
        f_items:[],
        page:{},
        selectindex:null,
        lives:[{label: '现场处理', value: '现场处理'},{label: '用户自行处理', value: '用户自行处理'},{label: '需转维修处理', value: '需转维修处理'}],
        f_live_dispose:'需转维修处理',
        // 初始表底
        //f_initial_base: {},
        // 气量异常差值  计算公式 =>  气量异常差值 = 累计购气量 - （已用气量 - 初始表底） - 剩余气量
        f_gas_aberrant_number: {},
        // 金额异常差值  计算公式 =>  金额异常差值 = 累计购金额 - 已用金额 - 剩余金额
        f_fee_aberrant_number: {},
        // 累购气量
        f_total_gas: {},
        // 累购金额
        f_total_fee: {},
        // 已用气量
        f_table_base: {},
        // 已用金额
        f_fee_base: {},
        // 剩余气量
        f_gas_balance: {},
        // 剩余金额
        f_fee_balance: {},

        //物联网表数据存储
        f_balance_amount:{},//物联网表剩余金额
        f_meter_base:{},//物联网表读数
        f_balance_amount1:{},//物联网表现场录入的表上剩余金额
        f_meter_base1:{},//物联网表现场录入的表字轮数
        f_meter_aberrant_number1: {},//物联网表 表数异常差值
        f_fee_aberrant_number1: {},//物联网 表金额异常差值

        // 气量异常差值允许误差
        gasDeviation: (
          function (_this) {
            let deviation = _this.$appdata.getSingleValue('气量异常差值允许误差')
            if (deviation && !isNaN(deviation)) {
              return deviation
            } else {
              return 0
            }
          }
        )(this),
        // 气量异常差值允许误差
        meterbase: (
          function (_this) {
            let deviation = _this.$appdata.getSingleValue('字轮异常差值允许误差')
            if (deviation && !isNaN(deviation)) {
              return deviation
            } else {
              return 0
            }
          }
        )(this),
        // 金额异常差值允许误差
        feeDeviation: (
          function (_this) {
            let deviation = _this.$appdata.getSingleValue('金额异常差值允许误差')
            if (deviation && !isNaN(deviation)) {
              return deviation
            } else {
              return 0
            }
          }
        )(this),
        showElse:false, //控制其他选项是否显示
      }
    },
    props: ['config','device','idx','operation','role'],
    // props: {
    //   // 维修对应的用户数据收集
    //   model: {
    //     type: Object
    //   },
    //   service:{
    //     type: Object
    //   },
    //   show: {
    //     type: Boolean,
    //     default: false
    //   },
    //   repairitem:{
    //     type: Object
    //   },
    //   shutype:'heng',
    //   tabs:{
    //     type: Object
    //   },
    //   repairdetails:{
    //     type: Object
    //   },
    //   faultshow:{
    //     type: Object
    //   },
    //   issee:''
    // },
    methods: {
      replaceStr(value){
        if(value){
          if(value.indexOf(".")==0 || ((value.split('.')).length-1)>1 || value.lastIndexOf(".")==(value.length-1)){
            return ''
          }
          return value.replace(/[^\d\.]/g,'')
        }
      },
      changse(val){
        if(val == undefined){
          return
        }
        if(this.selectindex != null) {
          if(this.f_items[this.selectindex].type == 'selector'){
            this.f_items[this.selectindex].f_item_value = val
          }else if(this.f_items[this.selectindex].type == 'inputSelector'){
            this.f_items[this.selectindex].f_item_value = val.target.value
          }
        }
      },
      changlive(val){
        if(val == undefined){
          return
        }
        if(this.selectindex != null) {
          if (val === '现场处理') {
            this.f_items[this.selectindex].f_processing = '现场处理' // 处理方式 【现场处理、用户自行处理、需转维修处理】
            this.f_items[this.selectindex].f_is_repaired = '不转维修' // 是否已经转维修处理过了 【已转维修、维修已处理、需转维修、不转维修，空字符串（目前空串都是异常差值）】
            this.f_items[this.selectindex].f_live_dispose = '是' //  是否现场处理 【是、否】
            this.f_items[this.selectindex].f_user_changes = '否'  //用户自行整改 【是、否】
          } else if (val ==='用户自行处理') {
            this.f_items[this.selectindex].f_processing = '用户自行处理' // 处理方式 【现场处理、用户自行处理、需转维修处理】
            this.f_items[this.selectindex].f_is_repaired = '不转维修' // 是否已经转维修处理过了  【已转维修、维修已处理、需转维修、不转维修，空字符串（目前空串都是异常差值）】
            this.f_items[this.selectindex].f_live_dispose = '否'  // 是否现场处理 【是、否】
            this.f_items[this.selectindex].f_user_changes = '是' // 用户自行整改 【是、否】
          } else if (val === '需转维修处理') {
            this.f_items[this.selectindex].f_processing = '需转维修处理' // 处理方式 【现场处理、用户自行处理、需转维修处理】
            this.f_items[this.selectindex].f_is_repaired = '需转维修'  // 是否已经转维修处理过了  【已转维修、维修已处理、需转维修、不转维修，空字符串（目前空串都是异常差值）】
            this.f_items[this.selectindex].f_live_dispose = '否' // 是否现场处理 【是、否】
            this.f_items[this.selectindex].f_user_changes = '否' // 用户自行整改 【是、否】
          }
          // 如果选项里面的所有内容中 用户自行整改有一个为 “是” 则勾选隐患整改单必须拍照
          for (let nindex in this.f_items) {
            if (this.f_items[nindex].f_user_changes=== '是') {
              this.$parent.$parent.data.f_defect_notified = true
              break
            } else {
              this.$parent.$parent.data.f_defect_notified = false;
            }
          }
          // this.f_items[this.selectindex].f_live_dispose = val
        }
      },
      switchDetails(detailsType, event){
        if (event.srcElement.checked) {
          for(var i = 0;i<this.Detail.details.length;i++){
            if(this.Detail.details[i].f_project == detailsType){
              this.Detail.details[i].f_content =  '有'
              this.ischecked = '有'
              return
            }
          }
        } else {
          this.Detail.imgs = []
          for(var i = 0;i<this.Detail.details.length;i++){
            if(this.Detail.details[i].f_project == detailsType){
              this.Detail.details[i].f_content =  '无'
              this.ischecked = '无'
            }else{
              this.Detail.details[i].f_content = ''
            }
          }
        }
      },
      getgasmodel(val){
        this.gasmodel = val
      },
      getradios(val,flag){
        let Reoptions = []
        for (let i = 0;i<this.repairdetails.length;i++) {
          var t = false
          if(this.repairdetails[i].f_type == this.repairitem.header ){
            for(var j =0;j<this.repairdetails[i].details.length;j++){
              if(this.repairdetails[i].details[j].f_project == val ){
                Reoptions = this.repairdetails[i].details[j].options
                t = true
                break
              }
            }
          }
          if(t){
            break
          }
        }
        for(let j = 0;j<Reoptions.length;j++){
          if(Reoptions[j].data == flag){
            for(var e = 0;e<this.Detail.details.length;e++){
              if(this.Detail.details[e].f_project == val){
                this.Detail.details[e].f_status = Reoptions[j].f_status
                return
              }
            }
            break
          }
        }
      },
      deletedetails(){
        this.$showMessage('该操作会删除所填信息，是否继续！', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            for(var i = 0;i<this.tabs.length;i++){
              if(this.tabs[i].number == this.repairitem.number){
                this.tabs.splice(i, 1)
                this.model.servicerepair.splice(this.repairitem.number, 1)
                for(let t = i;t < this.tabs.length;t++ ) {
                  this.tabs[t].number -= 1
                }
                return
              }
            }
          }
        })
      },
      takePic(prop, title,order) {
        if (this.role == 'androidview') {
          return
        }
        HostApp.__callback__ = this.cameraCallBack
        HostApp.__this__ = this
        console.log('this.f_items[prop]:' + prop)
        let fileName
        if(order==1 && (!this.f_items[prop].f_path || this.f_items[prop].f_path.includes("nopic.png"))) {
          fileName = Util.guid() + '-' + 'device'+this.device.n + '-' + this.idx + '-'+'f_items'+prop+ '.jpg'
        }else if(order==2 && (!this.f_items[prop].f_second_path || this.f_items[prop].f_path.includes("nopic.png"))) {
          fileName = Util.guid() + '-' + 'device'+this.device.n + '-' + this.idx + '-'+'f_items'+prop+ '.jpg'
        }else {
          fileName = Util.getFileName(this.f_items[prop].f_path)
        }
        HostApp._open_a_page({type: 'boomerang',
          page: 'com.aofeng.hybrid.android.peripheral.CameraActivity',
          param: {file: fileName, requestCode: 111, callback:'javascript:HostApp.__callback__("'+ prop +'", "%s",'+order+');', watermark: title + '\t时间：'+ Util.toStandardTimeString() + '\t' + Vue.user.name}
        })
      },
      cameraCallBack(prop, fileName,order) {
        console.log("传入参数---"+order)
        if(order==2){
          HostApp.__this__.$set( 'f_items['+prop+'].f_second_path', fileName + '?' + Math.random())
          console.log("path11111111111111111111111111:"+this.f_items[prop].f_second_path)
          console.log(HostApp.__this__.f_items[prop].f_second_path)
        }else{
          HostApp.__this__.$set( 'f_items['+prop+'].f_path', fileName + '?' + Math.random())
          console.log("path000000000000000000000000000:"+this.f_items[prop].f_path)
          console.log(HostApp.__this__.f_items[prop].f_path)
        }
        HostApp.__callback__ = null
        HostApp.__this__ = null
      },
      delfile(prop, fileName,order) {
        console.log('照片路径')
        console.log(JSON.stringify(fileName))
        if(fileName == Vue.nopic)
          return
        else {
          if(order==2){
            HostApp.delfile(fileName)
            this.f_items[prop].f_second_path = Vue.nopic
          }else{
            HostApp.delfile(fileName)
            this.f_items[prop].f_path = Vue.nopic
          }
        }
      },
      adddetails(){
        // 下标作为序号，取值用。 增加  序号得依次增加
        if(this.tabs.length > 0){
          for(let i = this.tabs.length-1;i > 0 ;i-- ){
            if(this.tabs[i].header == this.repairitem.header){
              if(this.model.servicerepair.length > 0){
                for(let j = this.model.servicerepair.length -1;j > -1;j-- ){
                  if(this.model.servicerepair[j].f_type == this.repairitem.header){
                    this.model.servicerepair.splice(j+1, 0, Object.assign({}, JSON.parse(JSON.stringify(this.tabs[i].details))))
                    this.tabs.splice(i+1, 0, {header: `${this.repairitem.header}`,details:this.tabs[i].details,complete:'repair-details',class:'repair-details-class',number:j+1,items:this.tabs[i].items})
                    for(let t = i+2;t < this.tabs.length;t++ ) {
                      this.tabs[t].number += 1
                    }
                    this.faultshow.number += this.faultshow.number + 1
                    return
                  }
                }
              }
            }
          }
        }
      },
      transelation(val){
        this.selectindex = val
      },
      towatch(){
        for(let n in this.f_items){

          if(this.f_items[n].type  == 'selector' || this.f_items[n].type  == 'inputSelector'){
            // 监听下拉框，如果有隐患，需要拍照
            this.$watch('f_items['+n+'].selected',function(val) {
                // 下拉框值
                console.log('val'+JSON.stringify(val))
                // 下拉框所属设备
                console.log('this.piece.f_device_type==》'+this.piece.f_device_type)
                // 下拉框所属项
                console.log('this.f_items[n].f_item_name==》'+this.f_items[n].f_item_name)
                let shImage = false
                if(val.indexOf('其他') == -1){
                  this.f_items[n].f_else = ''
                }
                // if(this.config[this.device.device].items[item].type == 'selector'){
                //   this.f_items[n].f_item_value = val
                // }else if(this.config[this.device.device].items[item].type == 'inputSelector'){
                //   this.f_items[n].f_item_value = val[0]
                // }
                // 在配置中查找该项
                for (let item in this.config[this.device.device].items) {
                  let type = this.config[this.device.device].items[item].type
                  let multiple = this.config[this.device.device].items[item].multiple
                  let options = this.config[this.device.device].items[item].options
                  if ((this.config[this.device.device].items[item].type == 'selector' || this.config[this.device.device].items[item].type == 'inputSelector') && item == this.f_items[n].f_item_name) {
                    for (let i in options) {
                      let value
                      if(this.config[this.device.device].items[item].type == 'selector' && this.config[this.device.device].items[item].multiple == false){
                        value = val[0]
                      }else if (this.config[this.device.device].items[item].type == 'inputSelector'){
                        value = val
                      }
                      console.log('options[i]'+JSON.stringify(options[i]))
                      // 如果未选择，清空图片、隐患信息等
                      if((type == 'selector' && val.length == 0) || (type == 'inputSelector' && val == '')){
                        this.f_items[n].f_path = ''
                        this.f_items[n].f_is_defect = ''
                        this.f_items[n].f_defect_level = ''
                        this.f_items[n].f_live_dispose = ''
                        this.f_items[n].tooltip = ''
                      }
                      if((type == 'selector' && multiple == false && options[i].data == val[0]) || (type == 'inputSelector' && options[i].data == val) || (type == 'selector' && multiple == true && val.indexOf(options[i].data) > -1)){
                        // 找到选中的项了
                        console.log('firstIf')
                        if(options[i].isdefect == true ){
                          shImage = true
                        }
                        if(options[i].isdefect == false || this.f_items[n].f_item_value == ''){
                          shImage = false
                        }
                        console.log('shImage'+shImage)
                        if(shImage){
                          this.f_items[n].f_is_defect =true
                          this.f_items[n].f_defect_level = options[i].level
                          this.f_items[n].f_path = Vue.nopic
                          this.f_items[n].f_live_dispose = '否' //是否现场处理 【是、否】
                          this.f_items[n].f_processing = '需转维修处理' //处理方式 【现场处理、用户自行处理、需转维修处理】
                          this.f_items[n].f_is_repaired = '需转维修' // 是否已经转维修处理过了 【已转维修、维修已处理、需转维修、不转维修，空字符串（目前空串都是异常差值）】
                          this.f_items[n].f_user_changes = '否' // 用户自行整改 【是、否】
                          this.f_items[n].tooltip= options[i].tooltip
                        }else{
                          this.f_items[n].f_path = ''
                          this.f_items[n].f_is_defect = ''
                          this.f_items[n].f_defect_level = ''
                          this.f_items[n].f_processing = ''
                          this.f_items[n].f_is_repaired = ''
                          this.f_items[n].f_user_changes = ''
                          this.f_items[n].f_live_dispose = ''
                          this.f_items[n].tooltip = ''
                        }
                      }
                    }
                  }
                }
              }
            )
            // this.$watch('other',function(val){
            //   console.log('other val===>'+val)
            //   if(this.selectindex != null) {
            //     let index = this.f_items[this.selectindex].f_item_value.indexOf('其他')
            //     if(index > -1){
            //       this.f_items[this.selectindex].f_item_value.splice(index,1,this.other)
            //     }
            //   }
            //
            // })
          }else if(this.f_items[n].type  == 'radio') {
            //如果radio有默认值 就判断级联项是否显示
            if (this.f_items[n].correlation) {
              if(this.f_items[n].f_item_value){
                for (let i = 0; i < this.f_items[n].options.length; i++){
                  if(this.f_items[n].f_item_value==this.f_items[n].options[i].value){
                    if (this.f_items[n].options[i].selcorrelation) {
                      for (let itm = 1; itm <= this.f_items[n].correlationnum; itm++){
                        console.log('111this.f_items[n+itm] ===> ' + JSON.stringify(this.f_items[n+itm]))
                        console.log('111n-------------itm ' + n+"-------"+itm)
                        let idex=parseInt(n)+parseInt(itm)
                        console.log("indx"+idex)
                        this.f_items[idex].isshow=false
                        this.f_items[idex].f_path=''
                        this.f_items[idex].f_item_value=''
                      }
                    }
                  }
                }
              }
            }
            // 监听单选框，如果有隐患，需要拍照
            this.$watch('f_items[' + n + '].f_item_value', function (val) {
              console.log('11this.f_items ===> ' + JSON.stringify(this.f_items))
              console.log('radio selected ===> ' + JSON.stringify(val))
              console.log('this.f_items[n] ===> ' + JSON.stringify(JSON.stringify(this.f_items[n])))
              let options = this.f_items[n].options
              console.log('this.f_items[n].options ===> ' + JSON.stringify(this.f_items[n].options))
              for (let i = 0; i < options.length; i++) {
                console.log('option ===> ' + JSON.stringify(options[i]))
                // 找到选中的项了
                if (options[i].value == val) {
                  //当项是否有级联显示开关
                  if (this.f_items[n].correlation) {
                    //当选中值是否有级联显示开关
                    if (options[i].selcorrelation) {
                      //如果有就关闭所有子项的显示 并且清空数据
                      for (let itm = 1; itm <= this.f_items[n].correlationnum; itm++){
                        console.log('1this.f_items[n+itm] ===> ' + JSON.stringify(this.f_items[n+itm]))
                        console.log('n-------------itm ' + n+"-------"+itm)
                        let idex=parseInt(n)+parseInt(itm)
                        console.log("indx"+idex)
                        this.f_items[idex].isshow=false
                        this.f_items[idex].f_path=''
                        this.f_items[idex].f_item_value=''
                      }
                    }else{
                      for (let itm = 1; itm <= this.f_items[n].correlationnum; itm++){
                        console.log('2this.f_items[n+itm] ===> ' + JSON.stringify(this.f_items[n+itm]))
                        console.log('n-------------itm ' + n+"-------"+itm)
                        let idex=parseInt(n)+parseInt(itm)
                        console.log("indx"+idex)
                        this.f_items[idex].isshow=true
                      }
                    }
                    console.log('this.f_items ===> ' + JSON.stringify(JSON.stringify(this.f_items)))
                  }
                  // 如果有隐患，拍图片
                  if (options[i].isdefect) {
                    this.f_items[n].f_is_defect = true
                    this.f_items[n].f_defect_level = options[i].level
                    this.f_items[n].f_path = Vue.nopic
                    this.f_items[n].f_live_dispose = '否' //是否现场处理 【是、否】
                    this.f_items[n].f_processing = '需转维修处理' //处理方式 【现场处理、用户自行处理、需转维修处理】
                    this.f_items[n].f_is_repaired = '需转维修' // 是否已经转维修处理过了 【已转维修、维修已处理、需转维修、不转维修，空字符串（目前空串都是异常差值）】
                    this.f_items[n].f_user_changes = '否' // 用户自行整改 【是、否】
                    this.f_items[n].tooltip = options[i].tooltip
                    console.log('this.f_items[n] ===> ' + JSON.stringify(this.f_items[n]))
                    return
                  }
                }
              }
              this.f_items[n].f_path = ''
              this.f_items[n].f_is_defect = ''
              this.f_items[n].f_defect_level = ''
              this.f_items[n].f_processing = ''
              this.f_items[n].f_is_repaired = ''
              this.f_items[n].f_user_changes = ''
              this.f_items[n].f_live_dispose = ''
              this.f_items[n].tooltip = ''
            })
          }else if(this.f_items[n].type  == 'checkbox') {
            // 监听单选框，如果有隐患，需要拍照
            this.$watch('f_items[' + n + '].f_item_value', function (val) {
              console.log('checkbox selected ===> ' + JSON.stringify(val))
              // 如果是手动赋值，不执行下面逻辑
              if (this.f_items[n].isReSet) {
                this.f_items[n].isReSet = false
                return
              }
              let options = this.f_items[n].options
              console.log('this.f_items[n].options ===> ' + JSON.stringify(this.f_items[n].options))
              // 取出选中项中有隐患的详细信息
              let selected = options.filter(item => { return val.indexOf(item.value) != -1 && item.isdefect })

              if(selected.length > 0){
                // 防止赋值无限调用
                this.f_items[n].isReSet = true
                let selectList = selected.map(item => {return item.value})
                // 如果选中的是非隐患项,取消选中isdefect为true的
                if (selectList.indexOf(val[val.length - 1]) == -1) {
                  this.f_items[n].f_item_value = val.filter(item => {return selectList.indexOf(item) == -1})
                  this.f_items[n].f_path = ''
                  this.f_items[n].f_is_defect = ''
                  this.f_items[n].f_defect_level = ''
                  this.f_items[n].f_processing = ''
                  this.f_items[n].f_is_repaired = ''
                  this.f_items[n].f_user_changes = ''
                  this.f_items[n].f_live_dispose = ''
                  this.f_items[n].tooltip = ''
                  return
                }
                // 如果选中的是隐患项,取消选中isdefect为false的
                this.f_items[n].f_item_value = selectList
                // 如果第一次选择隐患项，初始化
                if (!this.f_items[n].f_is_defect) {
                  this.f_items[n].f_is_defect = true
                  this.f_items[n].f_defect_level = selected[0].level
                  this.f_items[n].f_path = Vue.nopic
                  this.f_items[n].f_live_dispose = '否' //是否现场处理 【是、否】
                  this.f_items[n].f_processing = '需转维修处理' //处理方式 【现场处理、用户自行处理、需转维修处理】
                  this.f_items[n].f_is_repaired = '需转维修' // 是否已经转维修处理过了 【已转维修、维修已处理、需转维修、不转维修，空字符串（目前空串都是异常差值）】
                  this.f_items[n].f_user_changes = '否' // 用户自行整改 【是、否】
                  this.f_items[n].tooltip = selected[0].tooltip
                }
                console.log('this.f_items[n] ===> ' + JSON.stringify(this.f_items[n]))
                return
              }
              this.f_items[n].f_path = ''
              this.f_items[n].f_is_defect = ''
              this.f_items[n].f_defect_level = ''
              this.f_items[n].f_processing = ''
              this.f_items[n].f_is_repaired = ''
              this.f_items[n].f_user_changes = ''
              this.f_items[n].f_live_dispose = ''
              this.f_items[n].tooltip = ''
            })
          }
          if(this.f_items[n].f_item_name=='燃气灶购买年份' || this.f_items[n].f_item_name=='壁挂炉购买年份' || this.f_items[n].f_item_name=='热水器购买年份'){
            this.$watch('f_items[' + n + '].f_item_value',function(val){
              if(val){
                let d1=new Date(val)
                let idex=parseInt(n)+1
                this.f_items[idex].f_item_value =(d1.getFullYear()+8)+'-'+(d1.getMonth()+1)
              }
            })
          }
        }
        console.log('deviceitem.f_items=====>'+JSON.stringify(this.f_items))
      },
      getGasAberrantNumber() {
        console.log('检测到气量变化了 ===> ')

        // 先清空
        this.f_items[this.f_gas_aberrant_number.index].f_item_value = null
        this.f_items[this.f_gas_aberrant_number.index].f_is_defect = false

        // 只有两个值都填了才会计算
        if (!this.f_items[this.f_table_base.index].f_item_value || !this.f_items[this.f_gas_balance.index].f_item_value) {
          return
        }

        // 计算公式 =>  气量异常差值 = 累计购气量 - （已用气量 - 初始表底） - 剩余气量
        this.f_items[this.f_gas_aberrant_number.index].f_item_value = this.f_items[this.f_total_gas.index].f_item_value - this.f_items[this.f_gas_balance.index].f_item_value - this.f_items[this.f_table_base.index].f_item_value
        this.f_items[this.f_gas_aberrant_number.index].f_item_value = this.f_items[this.f_gas_aberrant_number.index].f_item_value.toFixed(3)
        // 如果数值有误，清空结果s
        if (isNaN(this.f_items[this.f_gas_aberrant_number.index].f_item_value)) {
          this.f_items[this.f_gas_aberrant_number.index].f_item_value = null
        }
        console.log('Math.abs(this.f_items[this.f_gas_aberrant_number.index].f_item_value) ===> ' + Math.abs(this.f_items[this.f_gas_aberrant_number.index].f_item_value))
        console.log('Number(this.gasDeviation) ===> ' + JSON.stringify(Number(this.gasDeviation)))
        // 计算差值是否在范围内
        if (Math.abs(this.f_items[this.f_gas_aberrant_number.index].f_item_value) > Number(this.gasDeviation)) {
          this.f_items[this.f_gas_aberrant_number.index].f_is_defect = true
        }

        console.log('this.f_items[this.f_gas_aberrant_number.index] ===> ' + JSON.stringify(this.f_items[this.f_gas_aberrant_number.index]))
      },
      getFeeAberrantNumber() {
        console.log('检测到金额变化了 ===> ')

        // 先清空
        this.f_items[this.f_fee_aberrant_number.index].f_item_value = null
        this.f_items[this.f_fee_aberrant_number.index].f_is_defect = false

        // 只有两个值都填了才会计算
        if (!this.f_items[this.f_fee_base.index].f_item_value || !this.f_items[this.f_fee_balance.index].f_item_value) {
          return
        }

        // 计算公式 =>  金额异常差值 = 累计购金额 - 已用金额 - 剩余金额
        this.f_items[this.f_fee_aberrant_number.index].f_item_value = this.f_items[this.f_total_fee.index].f_item_value - this.f_items[this.f_fee_balance.index].f_item_value - this.f_items[this.f_fee_base.index].f_item_value
        this.f_items[this.f_fee_aberrant_number.index].f_item_value = this.f_items[this.f_fee_aberrant_number.index].f_item_value.toFixed(3)
        if (isNaN(this.f_items[this.f_fee_aberrant_number.index].f_item_value)) {
          this.f_items[this.f_fee_aberrant_number.index].f_item_value = null
        }
        console.log('Math.abs(this.f_items[this.f_fee_aberrant_number.index].f_item_value) ===> ' + Math.abs(this.f_items[this.f_fee_aberrant_number.index].f_item_value))
        console.log('Number(this.feeDeviation) ===> ' + JSON.stringify(Number(this.feeDeviation)))
        // 计算差值是否在范围内
        if (Math.abs(this.f_items[this.f_fee_aberrant_number.index].f_item_value) > Number(this.feeDeviation)) {
          this.f_items[this.f_fee_aberrant_number.index].f_is_defect = true
        }

        console.log('this.f_items[this.f_fee_aberrant_number.index] ===> ' + JSON.stringify(this.f_items[this.f_fee_aberrant_number.index]))
      },
      //物联网表字轮数改变触发
      getmeteraberrantnumber() {
        console.log('检测到字轮数改变 ===> '+this.f_items[this.f_meter_base.index].f_item_value + this.f_items[this.f_meter_base1.index].f_item_value)

        // 先清空
        this.f_items[this.f_meter_aberrant_number1.index].f_item_value = null
        this.f_items[this.f_meter_aberrant_number1.index].f_is_defect = false
        console.log('检测到字轮数改变 ===>111111111111111 ')
        // 只有两个值都填了才会计算
        if (!this.f_items[this.f_meter_base.index].f_item_value || !this.f_items[this.f_meter_base1.index].f_item_value) {
          return
        }
        console.log("-----到了吗？"+this.f_items[this.f_meter_base.index].f_item_value+'----'+this.f_items[this.f_meter_base1.index].f_item_value)
        // 计算公式 =>   表数异常差值= - 字轮数 - 后台表读数
        this.f_items[this.f_meter_aberrant_number1.index].f_item_value = this.f_items[this.f_meter_base1.index].f_item_value - this.f_items[this.f_meter_base.index].f_item_value
        this.f_items[this.f_meter_aberrant_number1.index].f_item_value = this.f_items[this.f_meter_aberrant_number1.index].f_item_value.toFixed(3)
        if (isNaN(this.f_items[this.f_meter_aberrant_number1.index].f_item_value)) {
          this.f_items[this.f_meter_aberrant_number1.index].f_item_value = null
        }
        console.log('Math.abs(this.f_items[this.f_fee_aberrant_number.index].f_item_value) ===> ' + Math.abs(this.f_items[this.f_meter_aberrant_number1.index].f_item_value))
        // 计算差值是否在范围内
        console.log("字轮数异常范围"+Number(this.feeDeviation))
        if (Math.abs(this.f_items[this.f_meter_aberrant_number1.index].f_item_value) > Number(this.meterbase)){
          this.f_items[this.f_meter_aberrant_number1.index].f_is_defect = true
        }

        console.log('this.f_items[this.f_fee_aberrant_number.index] ===> ' + JSON.stringify(this.f_items[this.f_meter_aberrant_number1.index]))
      },
      //物联网表余额改变触发
      getfeeaberrantnumber1() {
        console.log('检测到表余额改变 ===> '+this.f_items[this.f_balance_amount1.index].f_item_value+this.f_items[this.f_balance_amount.index].f_item_value)
        // 先清空
        this.f_items[this.f_fee_aberrant_number1.index].f_item_value = null
        this.f_items[this.f_fee_aberrant_number1.index].f_is_defect = false

        // 只有两个值都填了才会计算
        if (!this.f_items[this.f_balance_amount1.index].f_item_value || !this.f_items[this.f_balance_amount.index].f_item_value) {
          return
        }
        console.log("-----到了吗？"+this.f_items[this.f_balance_amount1.index].f_item_value+'----'+this.f_items[this.f_balance_amount.index].f_item_value)
        // 计算公式 =>  表金额异常差值 =  已用金额 - 剩余金额
        this.f_items[this.f_fee_aberrant_number1.index].f_item_value = this.f_items[this.f_balance_amount.index].f_item_value - this.f_items[this.f_balance_amount1.index].f_item_value
        this.f_items[this.f_fee_aberrant_number1.index].f_item_value = this.f_items[this.f_fee_aberrant_number1.index].f_item_value.toFixed(3)
        if (isNaN(this.f_items[this.f_fee_aberrant_number1.index].f_item_value)) {
          this.f_items[this.f_fee_aberrant_number1.index].f_item_value = null
        }
        console.log('Math.abs(this.f_items[this.f_fee_aberrant_number.index].f_item_value) ===> ' + Math.abs(this.f_items[this.f_fee_aberrant_number1.index].f_item_value))
        // 计算差值是否在范围内
        if (Number(this.f_items[this.f_fee_aberrant_number1.index].f_item_value) < Number(0)) {
          this.f_items[this.f_fee_aberrant_number1.index].f_is_defect = true
        }

        console.log('this.f_items[this.f_fee_aberrant_number.index] ===> ' + JSON.stringify(this.f_items[this.f_fee_aberrant_number1.index]))
      },

      disSelect(index, itemValue) {
        console.log('this.f_items[index] ===> ' + JSON.stringify(this.f_items[index]))
        console.log('itemValue ===> ' + JSON.stringify(itemValue))
        if (this.f_items[index].f_item_value == itemValue) {
          this.$set(`f_items[${index}].f_item_value`, '')
        }
      }
    },

    ready() {
      console.log('deviec--role=>'+this.role)
      console.log('device=>',this.device)
      if(Vue.config.safecheck != undefined){
        if(Vue.config.safecheck.ApproveConfig != undefined){
          if(Vue.config.safecheck.ApproveConfig.livedispose != undefined) {
            this.livedispose = Vue.config.safecheck.ApproveConfig.livedispose
          }
        }
      }
      console.log('开始准备数据')
      console.log('this.paper ===> ' + JSON.stringify(this.paper))
      console.log('this.paper[\'device\'+this.device.n] ===> ' + JSON.stringify(this.paper['device'+this.device.n]))
      console.log('this.paper[\'device\'+this.device.n][this.idx] ===> ' + JSON.stringify(this.paper['device'+this.device.n][this.idx]))
      //创建页面所需数据
      this.$set('piece', this.paper['device'+this.device.n][this.idx])
      console.log('set之后的piece====》'+JSON.stringify(this.piece))
      console.log('this.config====》'+JSON.stringify(this.config))
      let n = 0
      for (let item in this.config[this.device.device].items) {
        let index = this.config[this.device.device].items[item].index-1
        this.config[this.device.device].items[item].isshow=this.config[this.device.device].items[item].isshow==undefined || this.config[this.device.device].items[item].isshow==null?true:this.config[this.device.device].items[item].isshow
        this.$set('page.options' + index, [])
        console.log('this.config[this.device.device].items='+JSON.stringify(this.config[this.device.device].items))
        console.log('item='+JSON.stringify(item))
        console.log('this.device.device='+JSON.stringify(this.device.device))
        // 先根据配置组接页面
        let f_item_value
        if(this.config[this.device.device].items[item].type == 'selector' || this.config[this.device.device].items[item].type == 'checkbox'){
          f_item_value = []
          // 判断选项的默认值
          for (let defitem in this.config[this.device.device].items[item].options) {
            let defopt = this.config[this.device.device].items[item].options[defitem]
            if (defopt.isdefault) {
              console.log('defopt', defopt)
              f_item_value[0] = defopt.data
            }
          }
          // if(this.config[this.device.device].items[item].data){
          //   f_item_value.push(this.config[this.device.device].items[item].data)
          // }
        }else if(this.config[this.device.device].items[item].type == 'radio'){
          //为radio添加默认值
          f_item_value=''
          console.log('进入单选-', JSON.stringify(this.config[this.device.device].items[item]))
          for (let defitem in this.config[this.device.device].items[item].options) {
            console.log('选项1111-', JSON.stringify(defitem))
            let defopt = this.config[this.device.device].items[item].options[defitem]
            if (defopt.isdefault) {
              console.log('defopt', JSON.stringify(defopt))
              f_item_value = defopt.data
            }
          }
        }else{
          f_item_value = this.config[this.device.device].items[item].f_item_value ? this.config[this.device.device].items[item].f_item_value : ''
        }
        console.log('f_item_value ====== > '+JSON.stringify(f_item_value))
        let it = {
          type: this.config[this.device.device].items[item].type,
          f_item_name: item,
          checkmust: this.config[this.device.device].items[item].checkmust,
          f_item_value: f_item_value,
          f_is_defect: '',
          multiple:this.config[this.device.device].items[item].multiple == true?this.config[this.device.device].items[item].multiple:false,
          isshow:this.config[this.device.device].items[item].isshow,
          readonly: this.config[this.device.device].items[item].readonly == true?true:false,
          remark: this.config[this.device.device].items[item].remark ? this.config[this.device.device].items[item].remark : '',
          f_path: '',
          f_second_path:'',
          tooltip:'',
          f_live_dispose:'',
          f_processing: '',
          f_user_changes:'',
          f_is_repaired:'',
          f_else:'',
          index:this.config[this.device.device].items[item].index,
          correlation:this.config[this.device.device].items[item].correlation?this.config[this.device.device].items[item].correlation:false,
          correlationnum:this.config[this.device.device].items[item].correlationnum?this.config[this.device.device].items[item].correlationnum:0
        }
        console.log('index ===> ' + JSON.stringify(index))
        console.log('it ===> ' + JSON.stringify(it))
        this.$set('f_items['+index+']',it)
        if (this.config[this.device.device].items[item].type == 'selector' ||this.config[this.device.device].items[item].type == 'inputSelector') {
          if(this.config[this.device.device].items[item].type == 'selector'){
            this.page['options' + index].push({
              label: "请选择",
              value: ''
            })
          }
          for (let i in this.config[this.device.device].items[item].options) {
            this.page['options' + index].push({
              label: this.config[this.device.device].items[item].options[i].data,
              value: this.config[this.device.device].items[item].options[i].data
            })
          }
          if(this.config[this.device.device].items[item].type == 'selector'){
            this.$set('f_items['+index+'].selected', f_item_value)
          }else if(this.config[this.device.device].items[item].type == 'inputSelector'){
            this.$set('f_items['+index+'].selected', f_item_value)
          }

          this.$set('f_items['+index+'].options',this.page['options' + index])

          console.log('lllllllllllllllllllthis.f_items===>'+JSON.stringify(this.f_items))
        } else if (this.config[this.device.device].items[item].type == 'radio' || this.config[this.device.device].items[item].type == 'checkbox') {
          for (let i in this.config[this.device.device].items[item].options) {
            this.page['options' + index].push({
              label: this.config[this.device.device].items[item].options[i].data,
              value: this.config[this.device.device].items[item].options[i].data,
              isdefect: this.config[this.device.device].items[item].options[i].isdefect,
              level: this.config[this.device.device].items[item].options[i].level,
              selcorrelation: this.config[this.device.device].items[item].options[i].selcorrelation
            })
          }
          this.$set('f_items[' + index + '].options', this.page['options' + index])
          this.$set('f_items[' + index + '].f_item_value', f_item_value)
          console.log('添加radio后的this.f_items===>'+JSON.stringify(this.f_items))
        }
        n = n + 1
      }

      if(!this.piece || JSON.stringify(this.piece) == '{}') {
        // 如果没有，则新建
        this.$set('piece.f_items',this.f_items)
        this.$set('piece.f_device_type',this.device.device)
      } else {
        // 已经存在，把之前的数据重新填入
        console.log("start---------------"+new Date())
        console.log('this.piece.f_items[p] 11111===> ' + JSON.stringify(this.piece.f_items))
        for (let f=0 ;f< this.f_items.length;f++){
          for(let p=0 ; p<this.piece.f_items.length;p++) {
            //console.log('this.f_items[f] 1111===> ' + JSON.stringify(this.f_items[f]))
            //console.log('this.piece.f_items[p] 11111===> ' + JSON.stringify(this.piece.f_items[p]))
            if (this.f_items[f].f_item_name == this.piece.f_items[p].f_item_name) {
              this.f_items[f] = Object.assign(this.f_items[f], this.piece.f_items[p])
              console.log('----> this.f_items[f] ===> ' + JSON.stringify(this.f_items[f]))
              if (this.f_items[f].type == 'selector' || this.f_items[f].type == 'inputSelector') {
                console.log('this.piece.f_items[p].f_item_value==>'+ JSON.stringify(this.piece.f_items[p].f_item_value))
                console.log('this.f_items[f].selected==>' + JSON.stringify(this.f_items[f].selected))
                this.f_items[f].selected = this.piece.f_items[p].f_item_value
                console.log('this.f_items[f].selected==>' + JSON.stringify(this.f_items[f].selected))
              }
              if (this.f_items[f].f_item_name == '累购气量') {
                console.log('累购气量: ' + JSON.stringify(f))
                this.f_total_gas.index = f
              } else if (this.f_items[f].f_item_name == '已用气量') {
                console.log('已用气量: ' + JSON.stringify(f))
                this.f_table_base.index = f
                this.$watch('f_items[' + f + '].f_item_value', function () {
                  this.getGasAberrantNumber()
                })
              } else if (this.f_items[f].f_item_name == '剩余气量') {
                console.log('剩余气量: ' + JSON.stringify(f))
                this.f_gas_balance.index = f
                this.$watch('f_items[' + f + '].f_item_value', function () {
                  this.getGasAberrantNumber()
                })
              } else if (this.f_items[f].f_item_name == '气量异常差值') {
                console.log('气量异常差值: ' + JSON.stringify(f))
                this.f_gas_aberrant_number.index = f
              } else if (this.f_items[f].f_item_name == '累购金额') {
                console.log('累购金额: ' + JSON.stringify(f))
                this.f_total_fee.index = f
              } else if (this.f_items[f].f_item_name == '已用金额') {
                console.log('已用金额: ' + JSON.stringify(f))
                this.f_fee_base.index = f
                this.$watch('f_items[' + f + '].f_item_value', function () {
                  this.getFeeAberrantNumber()
                })
              } else if (this.f_items[f].f_item_name == '剩余金额') {
                console.log('剩余金额: ' + JSON.stringify(f))
                this.f_fee_balance.index = f
                this.$watch('f_items[' + f + '].f_item_value', function () {
                  this.getFeeAberrantNumber()
                })
              } else if (this.f_items[f].f_item_name == '金额异常差值') {
                console.log('金额异常差值: ' + JSON.stringify(f))
                this.f_fee_aberrant_number.index = f
              }else if (this.f_items[f].f_item_name == '表读数') {
                console.log('表读数: ' + JSON.stringify(f))
                this.f_meter_base.index = f
              }else if (this.f_items[f].f_item_name == '表剩余金额') {
                console.log('表剩余金额: ' + JSON.stringify(f))
                this.f_balance_amount.index = f
              }else if (this.f_items[f].f_item_name == '字轮数') {
                console.log('字轮数: ' + JSON.stringify(f))
                this.f_meter_base1.index = f
                this.$watch('f_items[' + f + '].f_item_value', function () {
                  this.getmeteraberrantnumber()
                })
              }else if (this.f_items[f].f_item_name == '表余额') {
                console.log('表余额: ' + JSON.stringify(f))
                this.f_balance_amount1.index = f
                this.$watch('f_items[' + f + '].f_item_value', function () {
                  this.getfeeaberrantnumber1()
                })
              }else if (this.f_items[f].f_item_name == '表数异常差值') {
                console.log('表数异常差值: ' + JSON.stringify(f))
                this.f_meter_aberrant_number1.index = f
              }else if (this.f_items[f].f_item_name == '表金额异常差值') {
                console.log('表金额异常差值: ' + JSON.stringify(f))
                this.f_fee_aberrant_number1.index = f
              }
              break
            }
          }
          for (let em in this.config[this.device.device].items) {
            if (this.config[this.device.device].items[em].type == 'selector' && em == this.f_items[f].f_item_name) {
              this.f_items[f].options =[]
              for (let k in this.config[this.device.device].items[em].options) {
                this.f_items[f].options.push({
                  label: this.config[this.device.device].items[em].options[k].data,
                  value: this.config[this.device.device].items[em].options[k].data
                })
              }
              break
            }
          }
        }
        console.log('循环完f_items====》'+JSON.stringify(this.f_items))
        this.$set('piece.f_items',this.f_items)
        console.log("start2222---------------"+new Date())
      }
      this.towatch()
      console.log("start333333---------------"+new Date())
    },
    destroyed(){
      let nullCount = 0
      let metertitles
      //判断当前是否有选中项
      for (let row in this.f_items){
        if(this.f_items[row].selected  && this.f_items[row].selected != '' && this.f_items[row].selected instanceof Array){
          console.log('selected是数组')
          this.f_items[row].f_item_value = this.f_items[row].selected
        }else if(this.f_items[row].selected  && this.f_items[row].selected != ''){
          console.log('selected不是数组')
          this.f_items[row].f_item_value = this.f_items[row].selected
        }
        // if(this.f_items[row].f_item_value instanceof Array && this.f_items[row].f_item_value.length != 0 ){
        //   nullCount = nullCount+1
        // }else if(this.f_items[row].f_item_value != ''){
        //   nullCount = nullCount+1
        // }
      }
      let picture = []
      // for (let row in this.f_items){
      //   let a={}
      //   a.f_path = this.f_items[row].f_path
      //   a.name = this.f_items[row].f_item_name
      // }
      //   picture.push(a)
      this.$set(`paper['device${this.device.n}'][${this.idx}]`, this.piece)
      console.log('完成')
    },
    computed:{

    }
  }
</script>
<style lang="less" scoped>
  .class-erro {
    color: #a94442;
  }
  .defectfront{
    color: red;
  }
  .fivelabel{
    border: none;
    border-left: 5px solid #0075FF;
    float: left;
    width: 35%;
    margin-bottom: 3px;
    text-align: left;
    word-wrap: break-word;
    white-space: normal;
  }
  .radiolabel{
    border: none;
    border-left: 5px solid #0075FF;
    float: left;
    width: 65%;
    margin-bottom: 3px;
    text-align: left;
    word-wrap: break-word;
    white-space: normal;
  }

  .textlabel {
    border: none;
    border-left: 5px solid #0075FF;
    width: 100%;
    margin-bottom: 3px;
    text-align: left;
    word-wrap: break-word;
    white-space: normal;
  }
  .textlabel1 {
    border: none;
    border-left: 5px solid #2BA245;
    width: 100%;
    margin-bottom: 3px;
    text-align: left;
    word-wrap: break-word;
    white-space: normal;
  }
  .spanrodio{
    margin-right: 10px;
  }
  .div-photo{
    width: auto;
    height: auto;
    /* margin-top: 10px; */
    position: absolute;
    bottom: 10px;
    right: 10px;
  }
  .btn-photo{
    border: 0;
    border-radius: 7px;
    background-color: #7dc1f4;
    font: 15px PingFang-SC-Bold;
    height: 20%;
  }
</style>

