<template>
<div>
  <criteria-paged :model="model" v-ref:cp>
    <criteria partial='criteria'  @condition-changed='search' v-ref:criteria>
      <div novalidate partial>
        <div class="row form-inline auto select-overspread">
          <div class="form-group">
            <input type="text"  id="f_title" class="form-control" v-model="model.f_title" v-on:keyup.enter="search"
                    placeholder="标题" condition="f_title like '%{}%'" >
          </div>
          <div class="form-group">
            <datepicker id="f_start"
                        :value.sync="model.f_start"
                        placeholder="开始时间"
                        :disabled-days-of-Week="[]"
                        :format="'yyyy-MM-dd'"
                        v-model="model.f_start"  condition="f_time >= '{}'"> </datepicker>
          </div>
          <div class="form-group">
            <datepicker id="f_end"
                        :value.sync="model.f_end"
                        placeholder="结束时间"
                        :disabled-days-of-Week="[]"
                        :format="'yyyy-MM-dd'"
                        v-model="model.f_end"  condition=" f_time <= '{} 23:59:59'"> </datepicker>
          </div>
          <div class="form-group">
            <v-select :value.sync="$parent.$parent.model.f_division" :options='$parent.$parent.f_divisions' placeholder='请选择子公司'
                      close-on-select clear-button></v-select>
          </div>
          <div class="form-group">
            <button type="button" class="btn btn-success width-80" @click="search()">查询</button>
          </div>
        </div>
      </div>
    </criteria>
    <data-grid :model="model" partial='list' v-ref:grid>
      <template partial='head'>
        <tr>
          <th>标    题</th>
          <th>下发时间</th>
          <th>分公司</th>
        </tr>
      </template>
      <template partial='body'>
        <td>{{row.f_title}}</td>
        <td>{{row.f_time}}</td>
        <td>{{row.f_subcompany}}</td>
      </template>
    </data-grid>
  </criteria-paged>
</div>
</template>

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

export default {
  title: '公告查询',
  data () {
    let model = new PagedList('api/af-safecheck/sql/公告查询', 20, {f_subcompany: 'this.f_division[0]'})
    model.f_division = [this.$login.f.f_fengongsi]
    return {
      model: model,
      f_divisions: this.$login.f.f_fengongsi != '' ? [{label: this.$login.f.f_fengongsi, value: this.$login.f.f_fengongsi}]: this.$appdata.getParam('安检系统用子公司')
    }
  },
  computed: {
    selected () {
      return this.$refs.cp.$refs.grid.selected
    }
  }
}
</script>
