<template>
  <div id='app' class="flex">
    <criteria-paged :model="model" :pager='true' v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div novalidate class="form-inline auto " partial >
          <p class="bg-info text-center" style="padding: 8px;">不用气用户查询</p>
          <div class="flex-row auto" style="justify-content: space-between">
            <div class="form-group" >
              <label for="startDate">用户姓名:</label>
              <div class="form-group">
                <input  type="text" class="form-control" v-model="model.f_username" placeholder='用户姓名'
                        condition="u.f_username = '{}'" v-next-el='yhxm'
                        :size="model.f_username ? model.f_username.length  : 2">
              </div>
              <label for="startDate">小区:</label>
              <div class="form-group">
                <input  type="text" class="form-control" v-model="model.f_districtname" placeholder='小区'
                        condition="f_districtname = '{}'"
                        :size="model.f_districtname ? model.f_districtname.length  : 2">
              </div>
              <label for="startDate">地址:</label>
              <div class="form-group">
                <input  type="text" class="form-control" v-model="model.f_address" placeholder='地址'
                        condition="f_address = '{}'"
                        :size="model.f_address ? model.f_address.length  : 2">
              </div>

            <div class="form-group">
              <label for="endDate">用户类型:</label>
              <v-select id="f_user_type"
                        v-model="model.f_usertype"
                        placeholder='用户类型'
                        :value.sync="model.f_user_type"
                        :options='$parent.$parent.usertypes'
                        condition="f_gasproperties = '{}'"
                        close-on-select >
              </v-select>
              <label for="startDate">通讯区间:</label>
              <datepicker id="startDate" placeholder="通讯开始日期"
                          v-model="model.startDate"
                          :value.sync="model.startDate"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd 00:00:00'"
                          condition= "h.lastinputdate >= '{}'"
                          :show-reset-button="reset">
              </datepicker>
              <label for="endDate">~</label>
              <datepicker id="endDate" placeholder="通讯结束日期"
                          v-model="model.endDate"
                          :value.sync="model.endDate"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd 23:59:59'"
                          condition= "h.lastinputdate <= '{}'"
                          :show-reset-button="reset">
              </datepicker>
              <label for="startDate">不用气天数:</label>
              <div class="form-group">
                <input  type="text" class="form-control" v-model="model.tianshu" placeholder='不用气天数'
                        condition="tianshu = '{}'"
                        :size="model.tianshu ? model.tianshu.length  : 2">
              </div>
              <div class="form-group">
                <v-select :value.sync="model.yytdepa" v-model='model.yytdepa'
                          :options='$parent.$parent.f_outlets' placeholder='营业网点'
                          close-on-select
                          condition="u.f_filiale = '{}'"></v-select>
              </div>
              <button class="btn btn-success" @click="search()">查询</button>
            </div>
            <span></span>
            <div class="form-group">
              <export-excel :data="{orderitem: 'f_userid desc', condition: '1=1'}"
                            :field="{f_username: '用户名称', f_districtname: '小区', f_address: '地址', f_zhye: '账户结余', f_gasproperties: '用户类型', tianshu: '不用气天数',
                            f_meternumber: '表号', f_userid: '档案编码', lastinputdate: '通讯时间' }"
                            sqlurl="rs/sql/getnogas"></export-excel>
            </div>
          </div>
        </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th  style="text-align:center">序号</th>
            <th  style="text-align:center">用户名称</th>
            <th  style="text-align:center">小区</th>
            <th  style="text-align:center">地址</th>
            <th  style="text-align:center">账户结余</th>
            <th  style="text-align:center">用户类型</th>
            <th  style="text-align:center">不用气天数</th>
            <th  style="text-align:center">表号</th>
            <th  style="text-align:center">档案编码</th>
            <th  style="text-align:center">通讯时间</th>
          </tr>
        </template>
        <template partial='body'>
          <td style="text-align:center">{{$index+1}}</td>
          <td style="text-align:center">{{row.f_username}}</td>
          <td style="text-align:center">{{row.f_districtname}}</td>
          <td style="text-align:center">{{row.f_address}}</td>
          <td style="text-align:center">{{row.f_zhye}}</td>
          <td style="text-align:center">{{row.f_gasproperties}}</td>
          <td style="text-align:center">{{row.tianshu}}</td>
          <td style="text-align:center">{{row.f_meternumber}}</td>
          <td style="text-align:center">{{row.f_userid}}></td>
          <td style="text-align:center">{{row.lastinputdate}}</td>
        </template>
      </data-grid>
    </criteria-paged>
    <modal :show.sync="show" v-ref:modal small backdrop="false">
      <header slot="modal-header" class="modal-header">
        <h4 class="modal-title">输入文件名称</h4>
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="form-group">
          <input  type="text" class="form-control" v-model="filename" placeholder='保存的文件名'>
        </div>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button v-show="show" type="button" class="btn btn-default" @click='close'>取消</button>
        <button v-show="show" type="button" class="btn btn-success" @click='confirm(filename)'>确认</button>
      </footer>
    </modal>

  </div>
</template>

<script>
  import { DataModel, HttpResetClass } from 'vue-client'
  import * as Util from '../../Util'
  import AppData from '../../stores/AppData'
  import co from 'co'
  import { PagedList } from 'vue-client'

  export default {
    title: '不用气用户查询',
    props: ['data'],
    data () {
      return {
        model: new PagedList('rs/sql/getnogas', 20),
        reportStr: null,
        show: false,
        outlets: [],
        operator: [],
        filename: '',
        echarts: true
      }
    },
    ready () {
      this.search()
    },
    methods: {
      search () {
        this.$refs.paged.$refs.cri.search()
        this.condition = this.$refs.paged.$refs.cri.condition
      },
      // 将报表保存成文件
      confirmReport () {
        this.show = true
        this.filename = this.data.f_report_name + Util.toStandardDateString()
      }
    },
  computed: {
    usertypes() {
      return this.$getParams('用户类型', [{label: '全部', value: ''}])
    },
  }
  }
</script>
