<template>
  <div id="unit" class="flex-row" class="foot_tabset">
    <div class="basic-main">
      <div class="flex">
        <criteria-paged :model="model" v-ref:paged >
          <criteria partial='criteria' v-ref:criteria  @condition-changed='$parent.search'>
            <div  novalidate class="form-horizontal select-overspread container-fluid auto" partial>
              <div class="row" width="100%">
                <div class="col-sm-2" >
                  <label class="font_normal_body">表&nbsp;钢&nbsp;号&nbsp;</label>
                  <input type="text" class="input_search" style="width:60%"
                         placeholder='表钢号'
                         v-model="model.f_meternumber"
                         condition="ui.f_meternumber like '%{}%'"
                  >
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">组织机构</label>
                  <right-tree :userid.sync='$parent.$parent.obj.userid' :source.sync='$parent.$parent.obj.source'  @re-res="$parent.$parent.getRes"></right-tree>
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">客户编号</label>
                  <input type="text" class="input_search" style="width:60%"
                         v-model="model.f_userinfo_code"
                         placeholder='客户编号'
                         condition="u.f_userinfo_code like '%{}%'">
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">客户名称</label>
                  <input type="text" class="input_search" style="width:60%" v-model="model.f_user_name"
                         placeholder='用户姓名'
                         condition="mr.f_user_name like '%{}%'">
                </div>

                <div class="span" style="float:right;">
                  <button class="button_search button_spacing" @click="search()" v-el:cba>查询</button>
                  <button class="button_clear button_spacing" @click="$parent.$parent.clearmsg">清空</button>
                  <label class="font_normal_body" v-if="!$parent.$parent.excelTable">超过十万条限制导出</label>
                  <export-excel v-if="$parent.$parent.excelTable"
                                :data="{condition: $parent.$parent.condition}"
                                :field="$parent.$parent.getfield"
                                sqlurl="rs/logic/saleExport" sql-name="iot_getNewAllWebHandPlan" template-name='NewWebMeterHandPlan'
                                :choose-col="true"></export-excel>
                  <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
                </div>
              </div>
              <div class="row" v-show="$parent.$parent.criteriaShow">

                <div class="col-sm-2">
                  <label class="font_normal_body">用气地址</label>
                  <input type="text" class="input_search" style="width:60%" v-model="model.f_address"
                         placeholder='用气地址'
                         condition="a.f_address like '%{}%'"
                  >
                </div>




                <div class="col-sm-2" >
                  <label class="font_normal_body">用户类型</label>
                  <v-select placeholder='用户类型' close-on-select
                            v-model="model.f_user_type"
                            value-single="true"
                            :value.sync="model.f_user_type"
                            :options="$parent.$parent.Gasusertype"
                            condition="ui.f_user_type {}"
                  >
                  </v-select>
                </div>
                <div class="col-sm-2" >
                  <label class="font_normal_body">用气性质</label>
                  <v-select placeholder='用气性质' close-on-select
                            value-single="true"
                            v-model="model.f_gasproperties"
                            :value.sync="model.f_gasproperties"
                            :options="$parent.$parent.Gasproperties"
                            condition="ui.f_gasproperties {}">
                  </v-select>
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">上报类型</label>
                  <v-select placeholder='上报类型' close-on-select multiple
                            v-model="model.f_upload_type"
                            :value.sync="model.f_upload_type"
                            :options="$parent.$parent.Getuploadtype"
                            condition="mr.f_upload_type in {}"
                  >
                  </v-select>
                </div>
                <div class="col-sm-2" >
                  <label class="font_normal_body" >上报时间</label>
                  <datepicker style="width:60%" placeholder="起始时间"
                              :value.sync="model.startDate"
                              v-model="model.startDate"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              condition="mr.f_hand_date >= '{}'"
                  ></datepicker>
                </div>
                <div class="col-sm-2" >
                  <label class="font_normal_body" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <datepicker style="width:60%" placeholder="结束时间"
                              :value.sync="model.endDate"
                              v-model="model.endDate"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              condition="mr.f_hand_date <= '{}'"
                  ></datepicker>
                </div>
                <div class="col-sm-2" >
                  <label class="font_normal_body" >安装时间</label>
                  <datepicker style="width:60%" placeholder="起始时间"
                              :value.sync="model.startDate1"
                              v-model="model.startDate1"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              condition="ui.f_gas_date >= '{}'"
                  ></datepicker>
                </div>
                <div class="col-sm-2" >
                  <label class="font_normal_body" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <datepicker style="width:60%" placeholder="结束时间"
                              :value.sync="model.endDate1"
                              v-model="model.endDate1"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              condition="ui.f_gas_date <= '{}'"
                  ></datepicker>
                </div>
                <!--<div class="col-sm-2">
                  <label class="font_normal_body">气表品牌</label>
                  <v-select
                          placeholder='气表品牌'
                          :value.sync="model.f_meter_brand"
                          v-model="model.f_meter_brand"
                          :options='$parent.$parent.WarningType'
                          @change="$parent.$parent.getMeterType"
                          close-on-select
                          condition="f_meter_brand='{}'">
                  </v-select>
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">气表型号</label>
                  <v-select v-if="$parent.$parent.styles"
                            placeholder='气表型号'
                            :value.sync="model.f_meter_style"
                            v-model="model.f_meter_style"
                            :options='$parent.$parent.Warningstyle'
                            close-on-select
                            condition="f_meter_style='{}'">
                  </v-select>
                  <v-select v-if="!$parent.$parent.styles"
                            placeholder='气表型号'
                            :value.sync="model.f_meter_style"
                            v-model="model.f_meter_style"
                            :options='$parent.$parent.Warningstyles'
                            close-on-select
                            condition="f_meter_style='{}'">
                  </v-select>
                </div>-->
                <div class="col-sm-2">
                  <label class="font_normal_body">用&nbsp;气&nbsp;量&nbsp;</label>
                  <input  type="text" class="input_search" style="width:60%" v-model="model.start_gas" placeholder='最小气量'
                          condition="mr.f_tablebase-mr.f_last_tablebase >= '{}'" >
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <input type="text" class="input_search" style="width:60%" v-model="model.end_gas" placeholder='最大气量'
                         condition="mr.f_tablebase-mr.f_last_tablebase <= '{}'">
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">剩余金额</label>
                  <input type="text" class="input_search" style="width:60%"
                         v-model="model.start_f_balance"
                         placeholder='最小金额'
                         condition="h.f_balance >= '{}'">
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <input type="text" class="input_search" style="width:60%"
                         v-model="model.end_f_balance"
                         placeholder='最大金额'
                         condition="h.f_balance <= '{}'"
                  >
                </div>
                <!--                <div class="col-sm-2" >-->
                <!--                  <label class="font_normal_body" >操作时间</label>-->
                <!--                  <datepicker style="width:60%" placeholder="起始时间"-->
                <!--                            :value.sync="model.startDate2"-->
                <!--                            v-model="model.startDate2"-->
                <!--                            :format="'yyyy-MM-dd HH:mm:ss'"-->
                <!--                            condition="p.f_parameter_date >= '{}'"-->
                <!--                  ></datepicker>-->
                <!--                </div>-->
                <!--                <div class="col-sm-2" >-->
                <!--                  <label class="font_normal_body" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>-->
                <!--                  <datepicker style="width:60%" placeholder="结束时间"-->
                <!--                            :value.sync="model.endDate2"-->
                <!--                            v-model="model.endDate2"-->
                <!--                            :format="'yyyy-MM-dd HH:mm:ss'"-->
                <!--                            condition="p.f_parameter_date <= '{}'"-->
                <!--                  ></datepicker>-->
                <!--                </div>-->
                <!--<div class="col-sm-2" >
                  <label class="font_normal_body">标记状态</label>
                  <v-select placeholder='标记状态' close-on-select
                            v-model="model.f_parameter_state"
                            :value.sync="model.f_parameter_state"
                            :options="$parent.$parent.getSignStatus"
                            condition="p.f_parameter_state {}">
                  </v-select>
                </div>-->
                <div class="col-sm-2">
                  <label class="font_normal_body">阀门状态</label>
                  <v-select placeholder='阀门状态'  close-on-select
                            v-model="model.f_valvestate"
                            :value.sync="model.f_valvestate"
                            condition="mr.f_valvestate like '%{}%'"
                            :options="$parent.$parent.Valvestates">
                  </v-select>
                </div>




              </div>
            </div>
          </criteria>
          <data-grid id="webmeterhandplan" :model="model" partial='list' class="list_area table_sy" v-ref:grid>
            <template partial='head'>
              <tr>
                <th style="text-align:center" v-show="!$parent.$parent.$parent.isdeal"><nobr>操作</nobr></th>
                <th style="text-align:center"><nobr>组织机构</nobr></th>
                <th style="text-align:center"><nobr>用户号</nobr></th>
                <th style="text-align:center"><nobr>用户类型</nobr></th>
                <th style="text-align:center"><nobr>用气性质</nobr></th>
                <th style="text-align:center"><nobr>用户姓名</nobr></th>
                <th style="text-align:center"><nobr>用气地址</nobr></th>
                <th style="text-align:center"><nobr>安装时间</nobr></th>
                <th style="text-align:center"><nobr>表钢号</nobr></th>
                <th style="text-align:center"><nobr>气表品牌</nobr></th>
                <th style="text-align:center"><nobr>气表型号</nobr></th>
                <th style="text-align:center"><nobr>期初余额</nobr></th>
                <th style="text-align:center"><nobr>上次抄表底数</nobr></th>
                <th style="text-align:center"><nobr>本次抄表底数</nobr></th>
                <th style="text-align:center"><nobr>本次用气量(m³)</nobr></th>
                <th style="text-align:center"><nobr>气价(元/m³)</nobr></th>
                <th style="text-align:center"><nobr>本次用气金额(元)</nobr></th>
                <th style="text-align:center"><nobr>剩余金额</nobr></th>
                <th style="text-align:center"><nobr>上报类型</nobr></th>
                <th style="text-align:center"><nobr>系统接收时间</nobr></th>
                <th style="text-align:center"><nobr>信号强度</nobr></th>
                <th style="text-align:center"><nobr>电压</nobr></th>
                <th style="text-align:center"><nobr>阀门状态</nobr></th>
                <th style="text-align:center"><nobr>软件版本号</nobr></th>
                <th style="text-align:center"><nobr>本次上报日期</nobr></th>
                <th style="text-align:center"><nobr>上次上报日期</nobr></th>
                <th style="text-align:center"><nobr>上次表状态</nobr></th>
                <th style="text-align:center"><nobr>本次表状态</nobr></th>
                <!--<th style="text-align:center"><nobr>标记状态</nobr></th>-->
                <!-- <th style="text-align:center"><nobr>标记时间</nobr></th>-->
              </tr>
            </template>
            <template partial='body' partial='list' v-ref:grid>
              <tr>
                <td style="text-align:center"   v-show="!$parent.$parent.$parent.isdeal"><button-link type="button" class="btn btn-link" @click="$parent.$parent.$parent.handchange(row)">处理</button-link></td>
                <td style="text-align:center"><nobr>{{row.f_filiale}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_userinfo_code}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_user_type}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_gasproperties}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_user_name}}</nobr></td>
                <td ><nobr>{{row.f_address}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_gas_date}}</nobr></td>
                <td style="text-align:center" v-show="$parent.$parent.$parent.isdeal"><nobr><span @click="$parent.$parent.$parent.dealmsg(row)"><a>{{row.f_meternumber}}</a></span></nobr></td>
                <td style="text-align:center" v-show="!$parent.$parent.$parent.isdeal"><nobr><nobr><span @click="$parent.$parent.$parent.dealmsg(row)"><a>{{row.f_meternumber}}</a></span></nobr></nobr></td>
                <td style="text-align:center"><nobr>{{row.f_meter_brand}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_meter_style}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_curbalance}}</nobr></td>
                <td style="text-align:center">{{row.f_last_tablebase}}</td>
                <td style="text-align:center">{{row.f_tablebase}}</td>
                <td style="text-align:center">{{row.f_oughtamount}}</td>
                <td style="text-align:center"><nobr>{{row.f_price}}</nobr></td>
                <td style="text-align:center">{{row.f_oughtfee}}</td>
                <td style="text-align:center"><nobr>{{row.f_balance_amount}}</nobr></td>
                <td style="text-align:center;width: 170px;"><nobr>{{row.f_upload_type}}</nobr></td>

                <td style="text-align:center"><nobr>{{row.f_insert_date}}</nobr></td>
                <td style="text-align:center" >
                  <img :title='row.f_signal' v-if="row.f_signal>-80"
                       src="../../../static/WebMetericon/1.png"
                       height="12" width="24"/>
                  <img :title='row.f_signal' v-if="row.f_signal>-100&&row.f_signal<=-80"
                       src="../../../static/WebMetericon/2.png"
                       height="12" width="24"/>
                  <img :title='row.f_signal' v-if="row.f_signal>-120&&row.f_signal<=-100"
                       src="../../../static/WebMetericon/3.png"
                       height="12" width="24"/>
                  <img :title='row.f_signal' v-if="row.f_signal<=-120"
                       src="../../../static/WebMetericon/4.png"
                       height="12" width="24"/>
                </td>
                <td style="text-align:center" >
                  <img :title='row.f_batterylevel' v-if="row.f_batterylevel>=6.00"
                       src="../../../static/WebMetericon/01.png"
                       height="12" width="24"/>
                  <img :title='row.f_batterylevel' v-if="row.f_batterylevel>=5.00&&row.f_batterylevel<6.00"
                       src="../../../static/WebMetericon/02.png"
                       height="12" width="24"/>
                  <img :title='row.f_batterylevel' v-if="row.f_batterylevel>=4.00&&row.f_batterylevel<5.00"
                       src="../../../static/WebMetericon/03.png"
                       height="12" width="24"/>
                  <img :title='row.f_batterylevel' v-if="row.f_batterylevel<4.00"
                       src="../../../static/WebMetericon/04.png"
                       height="12" width="24"/>
                </td>
                <td style="text-align:center;width: 51px">{{row.f_valvestate==0?'开阀':'关阀'}}</td>
                <td style="text-align:center"><nobr>{{row.f_software_version}}</nobr></td>
                <td style="text-align:center;width: 170px;"><nobr>{{row.f_hand_date}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_last_hand_date}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_last_meter_state_msg}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_table_msg}}</nobr></td>
                <!--<td style="text-align:center"><nobr>{{row.f_parameter_state}}</nobr></td>
                <td style="text-align:center"><nobr>{{row.f_parameter_date}}</nobr></td>-->
              </tr>
            </template>
            <template partial='foot'></template>
          </data-grid>
        </criteria-paged>
      </div>
      <!--异常抄表录入-->
      <modal :show.sync="handshow" v-ref:modal backdrop="false">
        <header slot="modal-header" class="modal-header">
          <button type="button" class="close" @click="handchange()"><span>&times;</span></button>
          <h4 class="modal-title">表号{{handExce.exceobj.f_meternumber}}</h4>
        </header>
        <article slot="modal-body" class="modal-body">
          <div class="col-sm-12">
            <label class="font_normal_body">上报异常类型</label>
            <textarea name="name" rows="2" style="width: 100%"
                      class="ver-textarea" class="input_search" style="width:60%"
                      placeholder='上报异常类型'
                      v-model='handExce.f_error_type'></textarea>
          </div>
          <div class="col-sm-12  form-fix-width">
            <label class="font_normal_body">异常描述</label>
            <textarea name="name" rows="2" style="width: 100%"
                      placeholder='上报异常类型'
                      class="ver-textarea" class="input_search" style="width:60%"
                      v-model='handExce.f_error_msg'></textarea>
          </div>
        </article>
        <footer slot="modal-footer" class="modal-footer">
          <button v-show="handshow" type="button" class="btn btn-default" @click='handchange()'>取消</button>
          <button v-show="handshow" type="button" class="btn btn-success" @click='saveException'>确认</button>
        </footer>
      </modal>
    </div>
</template>

<script>
  import {PagedList} from 'vue-client'
  import getLodop from '../../plugins/LodopFuncs'
  import * as Util from '../../Util'
  import vue from 'vue'
  import co from 'co'
  import {HttpResetClass} from 'vue-client'

  let readyGen = async function (self) {
    self.getfield = self.config.excelHeaders
  }

  export default {
    title: '数据采集',
    data() {
      return {
        model: new PagedList('rs/sql/iot_getNewAllWebHandPlan', 50),
        row: null,
        criteriaShow:false,
        // 搜索显示开关
        searchshow: false,
        // 抄表录入开关
        handshow: false,
        Gasusertype: [],
        Gasproperties: [],
        isdeal:true,
        getSignStatus: [
          {label: '全部', value: ''},
          {label: '已标记', value: 'is not null'},
          {label: '未标记', value: 'is null'}
        ],
        condition:'',
        excelTable:true,
        getfield: {},
        config: {
          excelHeaders: {
            'f_filiale': '组织机构',
            'f_userinfo_code': '用户号',
            'f_user_type': '用户类型',
            'f_gasproperties': '用气性质',
            'f_user_name': '用户姓名',
            'f_address': '用气地址',
            'f_gas_date': '安装时间',
            'f_meternumber': '表钢号',
            'f_meter_brand': '气表品牌',
            'f_meter_style': '气表型号',
            'f_curbalance': '期初余额',
            'f_last_tablebase': '上次抄表底数',
            'f_tablebase': '本次抄表底数',
            'f_oughtamount': '本次用气量(m³)',
            'f_price': '气价(元/m³)',
            'f_oughtfee': '本次用气金额(元)',
            'f_balance_amount': '剩余金额',
            'f_upload_type': '上报类型',
            'f_insert_date': '系统接收时间',
            'f_signal': '信号强度',
            'f_batterylevel': '电压',
            'f_valvestate': '阀门状态',
            'f_software_version': '软件版本号',
            'f_hand_date': '本次上报日期',
            'f_last_hand_date': '上次上报日期',
            'f_last_meter_state_msg': '上次表状态',
            'f_table_msg': '本次表状态'
            /*'f_parameter_state': '标记状态',
            'f_parameter_date': '标记时间'*/
          }
        },
        WarningType: [
          {label: '全部', value: ''}
        ],
        Warningstyle: [
          {label: '全部', value: ''}
        ],
        Warningstyles: [
          {label: '全部', value: ''}
        ],
        styles: false,
        obj: {
          userid:this.$login.f.id,
          source: `tool.getFullTree(this.getRights().where(row.getType() == $organization$))`,
          res: this.$login.f.f_fengongsi,
          resids: this.$login.f.f_orgids,
        },
        handExce: {
          //异常对象
          exceobj:{},
          //异常类型
          f_error_type:"",
          //异常描述
          f_error_msg:'',
        },
        show: false,
      }
    },
    props: ['searchobj','isdeal'],
    ready() {
      this.$refs.paged.$refs.criteria.model.startDate = Util.toStandardDateString() + ' 00:00:00'
      this.$refs.paged.$refs.criteria.model.endDate = Util.toStandardDateString() + ' 23:59:59'
      //初始化气表品牌下拉框
      // this.getMeterTypeAndBrand('f_meter_brand', '1=1')
      //初始化用户类型，用气性质，下拉框
      this.getTypes()
      readyGen(this)
    },
    methods: {
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      // 跳转处理页面
      dealmsg(val) {
        val.model=this.model.model
        this.$emit('deal-msg', val)
      },
      // 查询开关
      seachchange() {
        this.searchshow = !this.searchshow
      },
      // 异常开关
      handchange(val) {
        if(val){
          console.log("开启弹窗")
          this.handExce.exceobj=val
        }else{
          console.log("返回置空")
          this.handExce={}
        }
        this.handshow= !this.handshow
      },
      // 保存输入
      saveException() {
        // 准备数据
        var Exejson={

        }
        // 抄表记录id
        Exejson.data_id=this.handExce.exceobj.id
        // 异常表档案ID
        Exejson.f_userfiles_id=this.handExce.exceobj.f_userfiles_id
        // 异常户档案ID
        Exejson.f_userinfo_id=this.handExce.exceobj.f_userinfo_id
        // 异常表号
        Exejson.f_meternumber=this.handExce.exceobj.f_meternumber
        // 分公司
        Exejson.f_filiale=this.handExce.exceobj.f_filiale
        // 分公司编号
        Exejson.f_filialeids=this.handExce.exceobj.f_filialeids
        // 营业网点
        Exejson.f_outlets=this.handExce.exceobj.f_outlets
        // 组织机构
        Exejson.f_orgstr=this.handExce.exceobj.f_orgstr
        // 异常类型
        Exejson.f_error_type=this.handExce.f_error_type
        // 异常说明
        Exejson.f_error_msg=this.handExce.f_error_msg
        console.log("提交异常数据")
        console.log(Exejson)
        let param = {
          tablename: 't_exception',
          basedata: Exejson
        }
        try {
          this.$resetpost('rs/logic/iot_saveTable', param, {resolveMsg: null, rejectMsg: null}).then((req) => {
            console.log(val)
            this.handExce={}
            console.log("提交成功")
          }).then(()=>{
            this.$showMessage("异常保存成功！")
          })
        } catch (e) {
          this.handExce={}
          console.log("提交失败")
          this.$showMessage("异常保存失败！")
        }
        this.handshow= false
      },
      DealSignal(val){
        console.log(val.model.f_signal)
        if(val.model&&val.model.f_signal) {
          if (val.model.f_signal == '信号正常') {
            val.condition = val.condition + " and " + "f_signal>-100 "
          }
          if (val.model.f_signal == '信号异常') {
            val.condition = val.condition + " and " + "f_signal<-100 "
          }
        }
        return val
      },
      SaveAsFile(str) {
        this.$showMessage('您是否需要导出本页数据？', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            let style = '<style>' +
              'td {border-width: 1px;padding: 2px;border-style: solid; border-color:black; border-collapse:collapse;} .tdright{text-align: right;}  .tdcenter{text-align: center;}</style>';
            let strHtml = style + document.getElementById(str).innerHTML;
            console.log(strHtml);
            let LODOP = getLodop();
            LODOP.PRINT_INIT('');
            LODOP.ADD_PRINT_TABLE(5, 5, '99%', '100%', strHtml);
            LODOP.SAVE_TO_FILE('抄表查看.xls')
          }
        })
      },
      clearmsg () {
        this.$refs.paged.$refs.criteria.model = {
          f_upload_type:[]
        }
      },
      search (args) {
        // 处理信号
        args=this.DealSignal(args)
        args.condition =  `${args.condition} and ui.f_filialeids like '${this.obj.resids}%'`
        this.condition=args.condition
        this.model.search(args.condition, args.model)
      },
      getRes(obj) {
        this.obj.res = obj.res
        this.obj.resids = obj.resids
      },
      getMeterType() {
        this.Warningstyle = [{label: '全部', value: ''}]
        this.styles = false
        let f_meter_brand = this.$refs.paged.$refs.cri.model.f_meter_brand
        this.getMeterTypeAndBrand('f_meter_style', `f_meter_brand='${f_meter_brand}'`)
      },
      getMeterTypeAndBrand(groupname, condition) {
        condition = `${condition} and ui.f_filialeids like '${this.obj.resids}%'`
        let self = this
        let load = new HttpResetClass()
        load.load('POST', 'rs/sql/iot_getMeterStyleAndBrand', {
          data: {
            condition: condition,
            groupname: groupname
          }
        }, {warnMsg: null, resolveMsg: null}).then((res) => {
          let dr = {label: '', value: ''}
          let i = 0
          for (i = 0; i < res.data.length; i++) {
            dr = {label: '', value: ''}
            if (groupname == 'f_meter_brand') {
              dr.label = res.data[i].f_meter_brand
              dr.value = res.data[i].f_meter_brand
              //气表品牌
              self.WarningType[i + 1] = dr
            } else if (groupname == 'f_meter_style') {
              dr.label = res.data[i].f_meter_style
              dr.value = res.data[i].f_meter_style
              //气表类型
              self.Warningstyle[i + 1] = dr
            }
          }
          if (self.Warningstyle.length > 1) {
            self.showMeterStyle()
          }
        })

      },
      showMeterStyle() {
        this.styles = true
      },
      getTypes() {
        let f_user_type = []
        let f_gasproperties = []
        let load = new HttpResetClass()
        let self = this
        load.load('POST', 'rs/sql/iot_getTypes', {data: {}},{warnMsg:null,resolveMsg:null}).then((res) => {
          let i = 0
          for (i = 0; i < res.data.length; i++) {
            f_user_type[i] = res.data[i].f_user_type==null?'n':res.data[i].f_user_type
            f_gasproperties[i] = res.data[i].f_gasproperties==null?'n':res.data[i].f_gasproperties
          }
          self.Gasusertype=self.uniq(f_user_type)
          self.Gasproperties=self.uniq(f_gasproperties)
        })
      },
      uniq(array) {
        array.sort();
        let arraytype=[{label: '全部', value: ''}]
        let dr = {label: '', value: ''}
        if (array[0] == 'n') {
          dr={label: '空值', value: 'is null'}
        } else {
          dr={label: array[0], value: "='"+array[0]+"'"}
        }
        arraytype.push(dr)
        let temp=[array[0]];
        console.log(array[0] + "array[0]")
        for (var i = 1; i < array.length; i++) {
          if (array[i] !== temp[temp.length - 1]) {
            if (array[i] == 'n') {
              dr={label: '空值', value: 'is null'}
            } else {
              dr={label: array[i], value: "='"+array[i]+"'"}
            }
            arraytype.push(dr);
            temp.push(array[i]);
          }
        }
        return arraytype;
      }
    },

    watch: {
      // 监听查询对象
      'searchobj' (val) {
        if (this.searchobj != null) {
          this.$refs.paged.$refs.criteria.model.f_meternumber = this.searchobj.f_meternumber
          this.$refs.paged.$refs.criteria.search()
        }
      },
      'model.state'(val) {
        if (val === '正确') {
          if (this.model.count <= 100000) {
            this.excelTable = true
          } else {
            this.excelTable = false
          }
        }
      }
    },
    computed: {
      /* // 上报异常类型
       Excestates () {
         return [{label: '全部', value: ''}, ...this.$appdata.getParam('上报异常类型')]
       },*/
      Getuploadtype() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('上报类型')]
      },
      /* //标记状态
       parameterState () {
         return [{label: '全部', value: ''}, ...this.$appdata.getParam('标记状态')]
       },*/
      /*//标记名称
      parameterName () {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('标记名称')]
      },*/
      // 阀门状态
      Valvestates () {
        return [{label: '全部', value: '%%'}, {label: '关阀', value: '1'}, {label: '开阀', value: '0'}]
      }
      /* // 故障状态
       FaultStates () {
         return [{label: '全部', value: ''}, ...this.$appdata.getParam('故障状态')]
       },*/
      /* SignalStates () {
         return [
           {label: '全部', value: '全部'},
           {label: '信号正常', value: '信号正常'},
           {label: '信号异常', value: '信号异常'},
         ]
       }*/
    }
  }
</script>
<style>
  .datapanel {
    color: #333;
    background-color: white;
    box-shadow: darkgrey 0.5px 0.5px 0.5px 0.5px ;
    padding: 10px 30px 10px 30px;
    border-radius:15px;
  }
</style>
