<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" @queryByParams="queryByParams" />
        <pblm-table
          ref="XjdwOverTable"
          :pblmTableSetting="xjdwDoubleCheckTableSetting"
          @pageChange="handlePageChange"
          @sizeChange="handleSizeChange"
          @selectionChange="handleSelectionChange" />
      </a-card>
    </a-layout-content>
  </a-layout>
</template>

<script>
import moment from 'moment';
import { formatDateTime2 } from '../../utils/gw_date';
import { requestPblmListByQueryParams_over } from './Common/rectify_api';
import { formatDeadLineDate } from './Common/rectify_date';
import pblmQueryTerms from './Components/pblmQueryTerms_over.vue';
import pblmTable from './Components/pblmTable_over.vue';
export default {
  name: 'XjdwOver',
  props: [],
  components: {
    pblmQueryTerms,
    pblmTable,
  },
  data() {
    return {
      moment,
      loading: false,
      queryParams: {},
      xjdwDoubleCheckTableSetting: {
        adType: false,
        data: [], // 主数据源
        pagination: {
          pageSize: 10,
          pageNum: 1,
          pblmCount: 0,
        }, // 翻页相关配置项
        height: 500,
        currentPblmId: '', // 当前选中的问题的ID
        selectedPblms: {}, // 多选模式下选中的所有问题集合
        multiSelect: true, // 是否出现行复选框
        enablePblmRectifyInfo: false, // 操作栏是否有整改信息输入按钮
      },
      showActivityCommentDialog: false,
      isAg: 1, // 流程流转方向 0-正常向后 1=正常向前 2=列入调度清单
      actName: '', // 流程流转方向名称
    };
  },
  created() {
    this.getDoubleCheckPblm();
  },
  mounted() {
    this.$nextTick(function () {
      this.xjdwDoubleCheckTableSetting.height =
        document.getElementsByClassName('ant-tabs')[0].offsetHeight - 260;
    });
  },
  computed: {
    formatDateTime() {
      return formatDateTime2;
    },
    formatDeadLineDate() {
      return formatDeadLineDate;
    },
  },
  methods: {
    // 按指定条件获取待下发问题列表数据
    queryByParams(val) {
      this.queryParams = val.queryParams;
      this.$refs.XjdwOverTable.clearSelection(); // 清空问题列表子组件中原有的选中的行
      this.getDoubleCheckPblm();
    },
    // 获取待下发问题列表数据
    getDoubleCheckPblm() {
      this.loading = true;
      this.queryParams.pageSize =
        this.xjdwDoubleCheckTableSetting.pagination.pageSize;
      this.queryParams.pageNum =
        this.xjdwDoubleCheckTableSetting.pagination.pageNum;
      requestPblmListByQueryParams_over(this.queryParams).then((res) => {
        this.loading = false;
        if (res.data !== null) {
          res.data.list.forEach((item, index) => {
            item.reviewTm = formatDateTime2(item.reviewTm);
          });
          this.xjdwDoubleCheckTableSetting.data = res.data.list;
          this.xjdwDoubleCheckTableSetting.pagination.pblmCount =
            res.data.total;
        } else {
          this.xjdwDoubleCheckTableSetting.data = [];
          this.xjdwDoubleCheckTableSetting.pagination.pblmCount = 0;
        }
      });
    },
    // 直接页数跳转
    handlePageChange(val) {
      this.xjdwDoubleCheckTableSetting.pagination.pageNum = val.pageNum;
      this.getDoubleCheckPblm();
    },
    // 调整每页显示记录数
    handleSizeChange(val) {
      this.xjdwDoubleCheckTableSetting.pagination.pageSize = val.pageSize;
      this.getDoubleCheckPblm();
    },
    // 选中行时获取所有已选中行
    handleSelectionChange(val) {
      this.xjdwDoubleCheckTableSetting.selectedPblms = val.selectedPblms;
    },
  },
};
</script>

<style lang='less' scoped>

</style>
