<template>
  <div class="flex-row">
    <div class="basic-main">
      <criteria-paged :model="model" v-ref:paged @sort="sort">
        <criteria partial='criteria' class="search_area" @condition-changed='$parent.selfSearch' v-ref:criteria>
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row">
              <div class="form-group col-sm-2"  >
                <label class="font_normal_body">客户编号</label>
                <input type="text" class="input_search" v-model="model.f_userinfo_code"
                       style="width: 60%" placeholder="客户编号" condition="tcp.f_userinfo_code='{}'">
              </div>
              <div class="form-group col-sm-2"  >
                <label class="font_normal_body">客户名称</label>
                <input type="text" class="input_search" v-model="model.f_user_name"
                       style="width: 60%" placeholder="客户名称" condition="tcp.f_user_name like '%{}%'">
              </div>
              <div class="form-group col-sm-2"  >
                <label class="font_normal_body">客户电话</label>
                <input type="text" class="input_search" v-model="model.f_user_phone"
                       style="width: 60%" placeholder="客户电话" condition="tcp.f_user_phone like '%{}%'">
              </div>
              <div class="form-group col-sm-2"  >
                <label class="font_normal_body">客户表号</label>
                <input type="text" class="input_search" v-model="model.f_meternumber"
                       style="width: 60%" placeholder="客户表号" condition="tcp.f_meternumber like '%{}%'">
              </div>
              <div class="form-group col-sm-2"  >
                <label class="font_normal_body">小&emsp;&emsp;区</label>
                <input type="text" class="input_search" v-model="model.f_residential_area"
                       style="width: 60%" placeholder="小区" condition="tcp.f_residential_area like '%{}%'">
              </div>
              <div class="form-group col-sm-2"  >
                <label class="font_normal_body">详细地址</label>
                <input type="text" class="input_search" v-model="model.f_address"
                       style="width: 60%" placeholder="详细地址" condition="tcp.f_address like '%{}%'">
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body" >区&emsp;&emsp;域</label>
                <v-select :value.sync="model.f_user_region" :value-single="true" v-model="model.f_user_region"
                          :options='$parent.$parent.user_regions' placeholder='区域' class="select_list select" style="width: 60%"
                          @change="$parent.$parent.quyuChange"
                          condition="f_user_region = '{}'"
                          close-on-select>
                </v-select>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body" >营&ensp;业&ensp;厅</label>
                <v-select :value.sync="model.f_user_business_hall" :value-single="true" v-model="model.f_user_business_hall"
                          :options='$parent.$parent.bumens' placeholder='营业厅'
                          class="select_list select" style="width: 60%"
                          condition="f_user_business_hall = '{}'"
                          close-on-select>
                </v-select>
              </div>
              <div class="form-group col-sm-2" style="width: auto;margin-top:8px;float: right">
                <export-excel-safe :data="$parent.$parent.searchData"
                                   :field="$parent.$parent.excelHeaders"
                                   :choose-col="true"
                                   sqlurl="rs/logic/SafeExportExcel"
                                   sql-name="detailhistory"
                                   template-name='用户安检气量'></export-excel-safe>
                <button class="button_spacing button_search" @click="search()">查询</button>
                <button class="button_spacing button_search" @click="model = {}">清空</button>
              </div>
            </div>
          </div>
        </criteria>
        <data-grid class="list_area table_sy" style="overflow: hidden" :model="model" partial='list' v-ref:grid>
          <template partial='head'>
            <tr>
              <th>
                <nobr>序号</nobr>
              </th>
              <th>
                <nobr>分公司</nobr>
              </th>
              <th>
                <nobr>客户编号</nobr>
              </th>
              <th>
                <nobr>客户名称</nobr>
              </th>
              <th>
                <nobr>上月安检累计</nobr>
              </th>
              <th>
                <nobr>本月安检累计</nobr>
              </th>
              <th>
                <nobr>实际使用量</nobr>
              </th>
              <th>
                <nobr>剩余量</nobr>
              </th>
              <th>
                <nobr>剩余金额</nobr>
              </th>
              <th>
                <nobr>气量是否正常</nobr>
              </th>
            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center">{{(($parent.$parent.$parent.model.pageIndex-1) * $parent.$parent.$parent.model.pageSize)  + $index + 1}}</td>
            <td style="text-align: center">{{row.f_orgname}}</td>
            <td style="text-align: center">{{row.f_userinfo_code}}</td>
            <td style="text-align: center">{{row.f_user_name}}</td>
            <td style="text-align: center">{{row.shangcileigouqilaing}}</td>
            <td style="text-align: center">{{row.leigouqiliang}}</td>
            <td style="text-align: center">{{row.yiyongqilaing}}</td>
            <td style="text-align: center">{{ row.shengyuqiliang }}</td>
            <td style="text-align: center">{{ row.shengyujine }}</td>
            <td style="text-align: center"></td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'
  import Vue from 'vue'
  import co from 'co'
  import HttpResetClass from "vue-client/src/plugins/HttpResetClass";


export default {
  title: '用户气量历史记录',
  data() {
    let model = new PagedList('rs/sql/detailhistory', 20, {})
    return {
      model: model,
      searchData: {
        condition: "1=1",
      },
      user_regions: [{label: '请选择', value: ''}, ...this.$appdata.getParam('区域')],
      bumens: [{label: '请选择', value: ''}],
      excelHeaders: {
        'f_orgname':'分公司',
        'f_userinfo_code': '客户编号',
        'f_user_name': '客户姓名',
        'shangcileigouqilaing': '上月安检累计',
        'leigouqiliang': '本月安检累计',
        'yiyongqilaing': '实际使用量',
        'shengyuqiliang': '剩余量',
        'shengyujine': '剩余金额',
        ' ': '气量是否正常',
        }
      }
    },
    methods: {
      quyuChange(val) {
        if (val) {
          this.bumens = this.$appdata.getParam(val) ? [{
            label: '请选择',
            value: ''
          }, ...this.$appdata.getParam(val)] : [{ label: '请选择', value: '' }]
        }
      },
      search() {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch(args) {
        this.searchData.condition = args.condition
        this.model.search(args.condition, args.model, args.condValue)
      },

    },

    ready() {
    },
    watch: {
    }

  }
</script>
