<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_meternumber" placeholder='表具号'
                        condition="f_meternumber = '{}'" v-next-el='yhxm'
                        :size="model.f_meternumber ? model.f_meternumber.length  : 2">
              </div>
            <div class="form-group">
              <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= "f_instruct_date >= '{}'"
                          :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= "f_instruct_date <= '{}'"
                          :show-reset-button="reset">
              </datepicker>
              <button class="btn btn-success" @click="search()">查询</button>
            </div>
            <span></span>
            <div class="form-group">

              <export-excel :data="{orderitem: 'lastinputdate desc', condition: '1=1'}"
                            :field="{f_meternumber: '表具号', f_type: '表具类型',f_instruct_type:'业务类型',f_instruct_date:'发送指令时间',f_instruct_state:'状态'}"
                            sqlurl="rs/sql/Communication"></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_meternumber}}</td>
          <td style="text-align:center">{{row.f_type}}</td>
          <td style="text-align:center">{{row.f_instruct_type}}</td>
          <td style="text-align:center"></td>
          <td style="text-align:center"></td>
          <td style="text-align:center"></td>
          <td style="text-align:center"></td>
          <td style="text-align:center">{{row.f_instruct_date}}</td>
          <td style="text-align:center">{{row.f_instruct_state}}</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/Communication', 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()
      }
    }

  }
</script>
