<template>
  <div class="flex bg-white p-10 datapanel">
    <div class="span">
      <criteria-paged :model="model" v-ref:paged>
        <criteria partial='criteria' v-ref:criteria @condition-changed='$parent.search'>
          <div v-show="$parent.$parent.isdeal" novalidate class="form-horizontal select-overspread container-fluid auto"
               partial>
            <div class="row" width="100%">
              <div class="col-sm-3 form-group form-input-group">
                <label class="button_search">表&nbsp;钢&nbsp;号&nbsp;</label>
                <input type="text" class="form-control"
                       placeholder='表钢号'
                       v-model="model.f_meternumber"
                       condition="ui.f_meternumber like '%{}%'"
                >
              </div>
              <div v-if="$parent.$parent.searchshow">

                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search">组织机构</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-3 form-group form-input-group">
                  <label class="button_search">&nbsp;用&nbsp;户&nbsp;号</label>
                  <input type="text" class="form-control"
                         v-model="model.f_userinfo_code"
                         placeholder='用户号'
                         condition="u.f_userinfo_code like '%{}%'">
                </div>
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search">用户姓名</label>
                  <input type="text" class="form-control" v-model="model.f_user_name"
                         placeholder='用户姓名'
                         condition="mr.f_user_name = '{}'">
                </div>
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search">用气地址</label>
                  <input type="text" class="form-control" v-model="model.f_address"
                         placeholder='用气地址'
                         condition="a.f_address like '%{}%'"
                  >
                </div>
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search">用户类型</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-3 form-group form-input-group">
                  <label class="button_search">用气性质</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-3 form-group form-input-group">
                  <label class="button_search">阀门状态</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 class="col-sm-3 form-group form-input-group">
                  <label class="button_search">上报类型</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-3 form-group form-input-group">
                  <label class="button_search" style="word-break:keep-all;">上报时间</label>
                  <datepicker 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-3 form-group form-input-group">
                  <label class="button_search" style="word-break:keep-all;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <datepicker 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-3 form-group form-input-group">
                  <label class="button_search" style="word-break:keep-all;">安装时间</label>
                  <datepicker 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-3 form-group form-input-group">
                  <label class="button_search" style="word-break:keep-all;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <datepicker 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-3 form-group form-input-group">-->
                <!--<label class="button_search">故障状态</label>-->
                <!--<v-select placeholder='故障状态'-->
                <!--v-model="model.faultstate"-->
                <!--multiple-->
                <!--:value.sync="model.faultstate"-->
                <!--:options="$parent.$parent.FaultStates">-->
                <!--</v-select>-->
                <!--</div>-->
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search">用&nbsp;气&nbsp;量&nbsp;</label>
                  <input type="text" class="form-control" v-model="model.start_gas" placeholder='最小气量'
                         condition="mr.f_tablebase-mr.f_last_tablebase >= '{}'" v-next-el='start_gas' v-el:start_gas>
                </div>
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search" style="word-break:keep-all;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <input type="text" class="form-control" v-model="model.end_gas" placeholder='最大气量'
                         condition="mr.f_tablebase-mr.f_last_tablebase <= '{}'" v-el:xq v-next-el='end_gas' v-el:end_gas
                  >
                </div>
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search">剩余金额</label>
                  <input type="text" class="form-control"
                         v-model="model.start_f_balance"
                         placeholder='最小金额'
                         condition="h.f_balance >= '{}'">
                </div>
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <input type="text" class="form-control"
                         v-model="model.end_f_balance"
                         placeholder='最大金额'
                         condition="h.f_balance <= '{}'"
                  >
                </div>
                <div class="col-sm-3 form-group form-input-group">
                  <label class="button_search" style="word-break:keep-all;">操作时间</label>
                  <datepicker 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-3 form-group form-input-group">
                  <label class="button_search" style="word-break:keep-all;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                  <datepicker 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-3 form-group form-input-group">
                  <label class="button_search">标记状态</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>

              <div class="col-sm-3 form-group">
                <label class="button_search"></label>
                <button class="btn btn-success width-100" @click="search()" v-el:cba>查询</button>
                <label class="button_search"></label>
                <button class="btn btn-default width-100" @click="$parent.$parent.clearmsg">清空</button>
                <label class="button_search" 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" progress="saleGetExportProgress" sql-name="flowWebHandPlan"
                              template-name='flowHandPlan'
                              :choose-col="true"></export-excel>
              </div>
              <div v-show="!$parent.$parent.searchshow" @click="$parent.$parent.seachchange"
                   style="position: relative;float: right;margin-right: 1%;">
                <img src="../../../static/webMeter/shousuo.png"><span>展开</span>
              </div>
              <div v-show="$parent.$parent.searchshow" @click="$parent.$parent.seachchange"
                   style="position: relative;float: right;margin-right: 1%;">
                <img src="../../../static/webMeter/shangsheng.png"><span>收缩</span>
              </div>
            </div>
          </div>
        </criteria>
        <data-grid id="webmeterhandplanFlowmeter" :model="model" partial='list' 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>24小时用气量</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>
              <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>23-0点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>0-1点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>1-2点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>2-3点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>3-4点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>4-5点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>5-6点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>6-7点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>7-8点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>8-9点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>9-10点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>10-11点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>11-12点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>12-13点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>13-14点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>14-15点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>15-16点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>16-17点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>17-18点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>18-19点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>19-20点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>20-21点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>21-22点</nobr>
              </th>
              <th style="text-align:center">
                <nobr>22-23点</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">
                <nobr>{{row.f_nsturalgas_data}}</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_snr}}</td>-->
              <td style="text-align:center;width: 51px">{{row.f_valvestate==0?'开阀':'关阀'}}</td>
              <td style="text-align:center;width: 51px">
                <img :title='故障' v-if="row.f_magneticinterference==1"
                     src="../../../static/WebMetericon/guzhang.png"
                     height="12" width="12"/>
                <img :title='正常' v-if="row.f_magneticinterference==0"
                     src="../../../static/WebMetericon/zhengchang.png"
                     height="12" width="17"/>
              </td>
              <td style="text-align:center;width: 51px">
                <img :title='关阀' v-if="row.f_cycleshutvalue==1"
                     src="../../../static/WebMetericon/guzhang.png"
                     height="12" width="12"/>
                <img :title='正常' v-if="row.f_cycleshutvalue==0"
                     src="../../../static/WebMetericon/zhengchang.png"
                     height="12" width="17"/>
              </td>
              <td style="text-align:center;width: 51px">
                <img :title='关阀' v-if="row.f_overcurrentprotection==1"
                     src="../../../static/WebMetericon/guzhang.png"
                     height="12" width="12"/>
                <img :title='正常' v-if="row.f_overcurrentprotection==0"
                     src="../../../static/WebMetericon/zhengchang.png"
                     height="12" width="17"/>
              </td>
              <td style="text-align:center;width: 51px">
                <img :title='走气' v-if="row.f_leakageflag==1"
                     src="../../../static/WebMetericon/guzhang.png"
                     height="12" width="12"/>
                <img :title='正常' v-if="row.f_leakageflag==0"
                     src="../../../static/WebMetericon/zhengchang.png"
                     height="12" width="17"/>
              </td>
              <td style="text-align:center;width: 51px">
                <img :title='拆表' v-if="row.f_splitalarm==='1'"
                     src="../../../static/WebMetericon/guzhang.png"
                     height="12" width="12"/>
                <img :title='正常' v-if="row.f_splitalarm==='0'"
                     src="../../../static/WebMetericon/zhengchang.png"
                     height="12" width="17"/>
              </td>
              <td style="text-align:center;width: 51px">
                <img :title='停止' v-if="row.f_xtipllstopflag==='1'"
                     src="../../../static/WebMetericon/guzhang.png"
                     height="12" width="12"/>
                <img :title='正常' v-if="row.f_xtipllstopflag==='0'"
                     src="../../../static/WebMetericon/zhengchang.png"
                     height="12" width="17"/>
              </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>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='00'">{{row.h1}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'00'">{{row.h1}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='01'">{{row.h2}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'01'">{{row.h2}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='02'">{{row.h3}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'02'">{{row.h3}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='03'">{{row.h4}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'03'">{{row.h4}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='04'">{{row.h5}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'04'">{{row.h5}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='05'">{{row.h6}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'05'">{{row.h6}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='06'">{{row.h7}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'06'">{{row.h7}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='07'">{{row.h8}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'07'">{{row.h8}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='08'">{{row.h9}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'08'">{{row.h9}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='09'">{{row.h10}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'09'">{{row.h10}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='10'">{{row.h11}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'10'">{{row.h11}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='11'">{{row.h12}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'11'">{{row.h12}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='12'">{{row.h13}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'12'">{{row.h13}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='13'">{{row.h14}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'13'">{{row.h14}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='14'">{{row.h15}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'14'">{{row.h15}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='15'">{{row.h16}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'15'">{{row.h16}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='16'">{{row.h17}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'16'">{{row.h17}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='17'">{{row.h18}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'17'">{{row.h18}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='18'">{{row.h19}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'18'">{{row.h19}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='19'">{{row.h20}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'19'">{{row.h20}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='20'">{{row.h21}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'20'">{{row.h21}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='21'">{{row.h22}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'21'">{{row.h22}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='22'">{{row.h23}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'22'">{{row.h23}}</nobr>
              </td>
              <td style="text-align:center">
                <nobr v-if="row.f_hour>='23'">{{row.h24}}</nobr>
                <nobr style="color: blue" v-if="row.f_hour<'23'">{{row.h24}}</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="button_search">上报异常类型</label>
          <textarea name="name" rows="2" style="width: 100%"
                    class="ver-textarea" class="form-control"
                    placeholder='上报异常类型'
                    v-model='handExce.f_error_type'></textarea>
        </div>
        <div class="col-sm-12 form-group form-fix-width">
          <label class="button_search">异常描述</label>
          <textarea name="name" rows="2" style="width: 100%"
                    placeholder='上报异常类型'
                    class="ver-textarea" class="form-control"
                    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_flowWebHandPlan', 50),
        row: null,
        // 搜索显示开关
        searchshow: false,
        // 抄表录入开关
        handshow: false,
        rowData: {},
        Gasusertype: [],
        Gasproperties: [],
        isdeal: true,
        getSignStatus: [
          {label: '全部', value: ''},
          {label: '已标记', value: 'is not null'},
          {label: '未标记', value: 'is null'}
        ],
        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': '本次用气量',
            'f_price': '气价',
            'f_oughtfee': '本次用气金额',
            'f_balance_amount': '剩余金额',
            'f_upload_type': '上报类型',
            'f_insert_date': '系统接收时间',
            'f_signal': '信号强度',
            'f_batterylevel': '电压',
            /* 'f_snr': '信噪比', */
            'f_valvestate': '阀门状态',
            'f_magneticinterference': '磁干扰',
            'f_cycleshutvalue': '周期关阀',
            'f_overcurrentprotection': '过流保护关阀',
            'f_leakageflag': '关阀走气',
            'f_splitalarm': '拆表报警',
            'f_xtipllstopflag': '外部晶振标志',
            'f_software_version': '软件版本号',
            'f_hand_date': '本次上报日期',
            'f_last_hand_date': '上次上报日期',
            'f_last_meter_state_msg': '上次表状态',
            'f_table_msg': '本次表状态',
            'f_parameter_state': '标记状态',
            'f_parameter_date': '标记时间',
            'h1': '23-0点',
            'h2': '0-1点',
            'h3': '1-2点',
            'h4': '2-3点',
            'h5': '3-4点',
            'h6': '4-5点',
            'h7': '5-6点',
            'h8': '6-7点',
            'h9': '7-8点',
            'h10': '8-9点',
            'h11': '9-10点',
            'h12': '10-11点',
            'h13': '11-12点',
            'h14': '12-13点',
            'h15': '13-14点',
            'h16': '14-15点',
            'h17': '15-16点',
            'h18': '16-17点',
            'h19': '17-18点',
            'h20': '18-19点',
            'h21': '19-20点',
            'h22': '20-21点',
            'h23': '21-22点',
            'h24': '22-23点'
          }
        },
        condition: '',
        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.$refs.paged.$refs.criteria.model.startDate1 = Util.toStandardDateString() + ' 00:00:00'
      // this.$refs.paged.$refs.criteria.model.endDate1 = Util.toStandardDateString() + ' 23:59:59'
      // 初始化用户类型，用气性质，下拉框
      this.getTypes()
      readyGen(this)
    },
    methods: {
      // 跳转处理页面
      dealmsg (val) {
        val.model = this.model.model
        this.$emit('deal-msg', val)
      },
      // 查询开关
      seachchange () {
        this.searchshow = !this.searchshow
      },
      // 隐藏图表
      ShowEcharts () {
        this.echarts = false
      },
      // 异常开关
      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_user_id = this.handExce.exceobj.f_user_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
      },
      DealFaults (val) {
        if (val.model && val.model.faultstate) {
          console.log(val.model.faultstate)
          val.model.faultstate.forEach((item) => {
            if (item == '磁干扰') {
              val.condition = val.condition + ' and ' + 'f_magneticInterference=1 '
            }
            if (item == '周期关阀') {
              val.condition = val.condition + ' and ' + 'f_cycleShutValue=1 '
            }
            if (item == '过流保护关阀') {
              val.condition = val.condition + ' and ' + 'f_overCurrentProtection=1 '
            }
            if (item == '关阀走气') {
              val.condition = val.condition + ' and ' + 'f_leakageFlag=1 '
            }
            if (item == '拆表报警') {
              val.condition = val.condition + ' and ' + 'f_SplitAlarm=1 '
            }
          })
        }
        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.DealFaults(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
      },
      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])
          }
        }
        /* console.log(arraytype[1].label + "label")
        console.log(arraytype[1].value + "value") */
        return arraytype
      }
    },

    watch: {
      '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('上报异常类型')]
      },
      /* Gasproperties () {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('用气性质')]
      }, */
      /* Getusertype () {
         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('故障状态')]
        // return [
        //   {label: '磁干扰', value: '磁干扰'},
        //   {label: '周期关阀', value: '周期关阀'},
        //   {label: '过流保护关阀', value: '过流保护关阀'},
        //   {label: '关阀走气', value: '关阀走气'},
        //   {label: '拆表报警', value: '拆表报警'},
        // ]
      },
      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;
  }
  .mystyle {
    float: right;
    padding-right: 10%;
  }
</style>
