<template>
  <a-layout>
    <a-layout-content style="padding: 0;">
      <a-card class="box-card" style="flex: 1; overflow-y: auto; padding: 0 !important;">
        <pblm-query-terms ref="queryTerms" :showRectifyStatus="false" :showZgXianOrgId="false" :isAppeal="true" @queryByParams="queryByParams" />
        <a-row type="flex" justify="space-between" style="border-top:1px solid #0014ff2e;">
          <a-col :span="24" class="el-row-operation">
            <a-button :disabled="loading" size="small" type="primary" style="color:rgba(255,255,255,1);float:left;margin-right:10px;">退回修改</a-button>
            <a-button :disabled="loading" size="small" type="primary" style="color:rgba(255,255,255,1);float:left;margin-right:10px;">同意上报</a-button>
          </a-col>
        </a-row>
        <pblm-table
          ref="sdccPblmTable"
          :pblmTableSetting="tableSetting"
          @pageChange="handlePageChange"
          @sizeChange="handleSizeChange"
          @selectionChange="handleSelectionChange" />
      </a-card>
    </a-layout-content>
  </a-layout>
</template>

<script>
import moment from 'moment';
import { requestOverdueAppealList } from './Common/rectify_api';
import pblmQueryTerms from './Components/pblmQueryTerms';
import pblmTable from './Components/pblmTable';
export default {
  data() {
    return {
      moment,
      queryParams: {
        hasVedio: '',
        adCode: '',
        pblmStat: '',
        inspPblmCate: '',
        ifCasePblm: '',
        nm: '',
        rsName: '',
        adFullName: '',
        startTime: '',
        endTime: '',
        objType: '', // 为空才能不区分督查类别
        inspPblmName: '',
        dataStat: '2', // 整改阶段必须为2
        persId: localStorage.getItem('userid'),
        villType: '0',
        pageSize: 20,
        pageNum: 1,
        pblmTotal: 0,
        pTypeCode: '', // 督查类别
        pYear: '', // 年度
        zgXianOrgId: null, // 接收单位
        zgWh: '', // 整改文号
        schdYear: moment(new Date().getFullYear().toString()).format('YYYY'),
        recordWorkflowStat: '',
      },
      loading: false,
      tableSetting: {
        adType: false,
        data: [], // 主数据源
        pagination: {
          pageSize: 20,
          pageNum: 1,
          pblmCount: 0,
        }, // 翻页相关配置项
        height: 500,
        currentPblmId: '', // 当前选中的问题的ID
        selectedPblms: {}, // 多选模式下选中的所有问题集合
        multiSelect: true, // 是否出现行复选框
        enablePblmRectifyInfo: false, // 操作栏是否有整改信息输入按钮
      },
    };
  },
  components: {
    pblmQueryTerms,
    pblmTable,
  },
  created() {
    this.searchData();
  },
  mounted() {
    // 浏览器自适应
    this.tableSetting.height = window.innerHeight - 150;
    window.addEventListener('resize', () => {
      return (() => {
        this.tableSetting.height = window.innerHeight - 150;
      })();
    });
  },
  methods: {
    queryByParams(val) {
      console.log(val);
      this.queryParams = val.queryParams;
      // this.$refs.xjdwPblmTable.clearSelection() // 清空问题列表子组件中原有的选中的行
      this.searchData();
    },
    searchData() {
      this.loading = true;
      this.queryParams.pageSize = this.tableSetting.pagination.pageSize;
      this.queryParams.pageNum = this.tableSetting.pagination.pageNum;
      this.queryParams.recordWorkflowStat = '';
      requestOverdueAppealList(this.queryParams).then((res) => {
        this.loading = false;
        if (res.data !== null) {
          this.tableSetting.data = res.data.list;
          this.tableSetting.pagination.pblmCount = res.data.total;
        } else {
          this.tableSetting.data = [];
          this.tableSetting.pagination.pblmCount = 0;
        }
      });
    },
    // 直接页数跳转
    handlePageChange(val) {
      this.tableSetting.pagination.pageNum = val.pageNum;
      this.searchData();
    },
    // 调整每页显示记录数
    handleSizeChange(val) {
      this.tableSetting.pagination.pageSize = val.pageSize;
      this.searchData();
    },
    // 选中行时获取所有已选中行
    handleSelectionChange(val) {
      this.tableSetting.selectedPblms = val.selectedPblms;
    },
  },
};
</script>

<style lang='less' scoped>

</style>
