<template>
  <div style="background: #fff;height:642px;margin-top:10px;">
    <!--查询区域-->
    <div class="jeecg-basic-table-form-container">
      <a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row :gutter="24" style="margin-top: 10px;">
          <a-col :lg="8">
            <a-form-item label="标题">
              <j-input placeholder="请输入标题" v-model:value="queryParam.title"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-col :lg="6">
                <a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
                <a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
              </a-col>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
      <a-row>
        <a-col :span="24" v-for="(item,index) in dataSource" style="padding: 5px 10px;">
          <a-collapse expand-icon-position="right">
            <a-collapse-panel :key="index" >
              <template #header>
                <sapn style="font-size: 16px; font-weight: bold;">{{index+1}}.{{item.title}}</sapn>
                
              </template>
              <div v-html="item.content"></div>
              <!-- <setting-outlined /> -->
              <template #extra>
                <sapn>【{{item.createTime}}】</sapn>
                <sapn style="margin-left: 30px;">详情</sapn>
              </template>
            </a-collapse-panel>
          </a-collapse>
        </a-col>
        <a-col :span="24" v-show="dataSource.length>0" style="margin-top:10px;">
          <a-pagination v-model="current" :total="total" @change="handlePageChange" :pageSize="pageSize" style="text-align: right;"/>
        </a-col>
        <a-col :span="24" v-show="dataSource.length==0" style="margin-top:10px;">
          <a-empty/>
        </a-col>
      </a-row>
     
  </div>
</template>

<script lang="ts" name="zyGonggao-zyGonggao" setup>
  import { ref, reactive, unref, onMounted } from 'vue';
  import { downloadFile } from '/@/utils/common/renderUtils';
  import { defHttp } from '/@/utils/http/axios';
  import { useMessage } from "/@/hooks/web/useMessage";
  import { JInput } from '/@/components/Form';
  import { useRouter } from 'vue-router';
  import { Input, Popover, Pagination, Empty } from 'ant-design-vue';

  const { createConfirm } = useMessage();

  const APagination = Pagination;
  const { currentRoute } = useRouter();
  const { query } = unref(currentRoute);
  const { rwbh,xqxn } = query;//获取传递参数
  const queryParam = ref<any>({rwbh,  xqxn ,ggStatus:'1'});
  const current = ref<number>(0);
  const total = ref<number>(0);
  const pageNo = ref<number>(0);
  const pageSize = ref<number>(10);
  const dataSource = ref([]);
  //注册table数据
  const labelCol = reactive({
    xs: { span: 24 },
    sm: { span: 7 },
  });
  const wrapperCol = reactive({
    xs: { span: 24 },
    sm: { span: 16 },
  });


  /**
   * 查询
   */
  function searchQuery() {
    reload(1);
  }
  
  /**
   * 重置
   */
  function searchReset() {
    queryParam.value = {};
    queryParam.value.rwbh = rwbh;
    queryParam.value.xqxn = xqxn;
    queryParam.value.ggStatus='1';
    //刷新数据
    reload(1);
  }
  
  //翻页
  function handlePageChange(page: number) {
    reload(page);
  }
  //进入就加载
  onMounted(() => {
    reload(1);
  });

  function reload(arg){
    queryParam.pageNo = arg;
    console.log(`🚀 ~ reload ~ queryParam:`, queryParam)
    defHttp.get({ url: '/zyGonggao/zyGonggao/list', params: queryParam.value }).then((res) => {
      console.log(res);
      dataSource.value = res.records;
      total.value = res.total;
      pageNo.value = res.pages;
      current.value = res.current;
    });
  }



</script>

<style lang="less" scoped>
  .jeecg-basic-table-form-container {
    .table-page-search-submitButtons {
      display: block;
      margin-bottom: 24px;
      white-space: nowrap;
    }
    .query-group-cust{
      width: calc(50% - 15px);
      min-width: 100px !important;
    }
    .query-group-split-cust{
      width: 30px;
      display: inline-block;
      text-align: center
    }
  }
</style>
