<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_metertype"
                        v-model="model.f_usertype"
                        placeholder='用户类型'
                        :value.sync="model.f_user_type"
                        :options='$parent.$parent.usertypes'
                        condition="f_gasproperties = '{}'"
                        close-on-select >
              </v-select>
              <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: '档案编码', f_eventdate: '创建时间' }"
                            sqlurl="rs/sql/interference"></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_meternumber}}</td>
          <td style="text-align:center">{{row.f_gasproperties}}</td>
          <td style="text-align:center">{{row.f_phone}}</td>
          <td style="text-align:center">{{row.f_zhye}}</td>
          <td style="text-align:center">{{row.f_userid}}</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_eventdate}}</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/interference', 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: ''}])
    },
    metertypes() {
      return this.$getParams('表具类型', [{label: '全部', value: ''}])
    },
  }
  }
</script>
