<template>
  <div style="height: 70%;">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' v-ref:criteria @condition-changed="search">
        <div novalidate class="form-inline" partial>
          <p class="bg-info text-center" style="padding: 8px;">报表历史纪录</p>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_files_name"
  					condition="f_files_name like '%{}%'" placeholder='报表名'>
          </div>
          <div class="form-group">
            <v-select :value.sync="model.f_files_type" v-model='model.f_files_type'
                :options='$parent.$parent.types' placeholder='报表类型'
                close-on-select
                condition="f_files_type = '{}'" ></v-select>
          </div>
          <div class="form-group">
            <v-select :value.sync="model.f_operator" v-model='model.f_operator'
                :options='$parent.$parent.operatores' placeholder='保存操作人'
                close-on-select
                condition="f_operator = '{}'" ></v-select>
          </div>
          <button class="btn btn-success width-100" @click="search()">查询</button>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid id="test" >
        <template partial='head'>
          <tr>
            <th>表名</th>
            <th>保存人</th>
            <th>保存时间</th>
            <th>操作</th>
          </tr>
        </template>
        <template partial='body' >
          <td>{{row.f_files_name}}</td>
          <td>{{row.f_operator}}</td>
          <td>{{row.f_operate_date}}</td>
          <td><button type="button" class="btn btn-link" @click.stop="$parent.$parent.$parent.delete(row)">删除</button></td>
        </template>
      </data-grid>
     </criteria-paged>
  </div>
</template>

<script>
import { PagedList } from 'vue-client'
import AppData from '../../stores/AppData'

export default {
  title: '历史报表数据',
  data () {
    return {
      model: new PagedList('rs/sql/manageSingleTable_OrderBy', 50, {items: '"*"', tablename: '"t_report_record"', orderitem: '"f_operate_date desc"'})
    }
  },
  ready () {
    this.model.search('1=1')
  },
  methods: {
    search () {
      this.$refs.paged.$refs.criteria.search()
    },
    delete (row) {
      this.$resetdelete('rs/entity/t_report_record', row, ).then(() => {
        this.$dispatch('delect-report', '删除计划', row )
        this.search()
      })
    }
  },
  computed: {
    operatores () {
      return [{label: '全部', value: ''}, ...AppData.getParam('操作员')]
    },
    types () {
      return [{label: '全部', value: ''}, ...AppData.getParam('报表类型')]
    }
  },
}
</script>
