<template>
  <div class="page-query" style="height: calc(100vh - 101px);">
    <div class="slot">
      <slot name="soltSearchBar"></slot>
    </div>
    <ToolBar
      v-if="is_tool_bar"
      :is_visbile_import="is_visbile_import"
      :is_visbile_export="is_visbile_export"
      ref="toolbar"
      :is_visbile_new="button_operation[0].is_visbile"
      @clickNew="clickNew"
      @clickRefresh="clickRefresh"
      @clickPrint="clickPrint"
      @clickDelete="clickDelete"
    ></ToolBar>
    <TableQuery
      ref="table_query"
      :table_name="table_name"
      :query_code ='query_code'
      :filter_data="filter_data"
    ></TableQuery>
  </div>
</template>

<script>
import system from '../../api/system.js';
export default {
  name: 'page-single',
  props: {
    table_name: {
      type: String,
      required: true
    },
    blank_spacing: String,
    // 工具栏是否可见
    is_tool_bar: {
      type: Boolean,
      default: true
    },
    query_code:{
      type:String,
      required:true,
    },
    // 是否是示示导入
    is_visbile_import:{
      type: Boolean,
      default: false
    },
    // 是否显示导出
    is_visbile_export:{
      type: Boolean,
      default: false
    },
    // 外面传入的过滤条件
    filter_data: {
      type: Object
    },
  },
  data() {
    return {
      button_operation: [
        {
          is_visbile: true
        }
      ]
    };
  },
  methods: {
    // 新建按钮
    clickNew() {
      let that = this;
      that.dialog_new = true;
    },
    searchClick(filter_data) {
      let that = this;
      that.page_index = 1;
      console.log('filter_data,', filter_data);
      that.$refs.table_query.setFilterData(filter_data,that.page_index);
      // 这个地方导出时要用到
      // console.log('conditions=====', that.$refs.grid.getFilterData());
    },
    // 得到真正查询时提交的数据
    getSearchCommitData(){
      let that = this;
      console.log('page-query===>getSearchCommitData')
      return that.$refs.table_query.getSearchCommitData();
    },
    // 刷新按钮
    clickRefresh() {
      let that = this;
      console.log('点击了确定按钮');
      that.reloadData(true);
    },
    clickPrint() {
      console.log('clickPrint');
      let that = this;
    },
    
    clickDelete() {
      let that = this;
    },
   
    // 重新加载数据
    reloadData(is_page_first) {
      let that = this;
      that.$refs.table_query.reloadData(is_page_first);
    }
  }
};
</script>

<style lang="scss" scoped>
.slot {
  padding: $spacing-normal;
  background: $theme-white-1;
}
</style>
