<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="true" :isView="true" @queryByParams="queryByParams" />
        <a-row type="flex" justify="space-between" style="border-top:1px solid #0014ff2e;">
        </a-row>
        <pblm-table
          ref="ywccPblmTable"
          :pblmTableSetting="ywccPblmViewTableSetting"
          @pageChange="handlePageChange"
          @sizeChange="handleSizeChange"
          @selectionChange="handleSelectionChange" />
      </a-card>
    </a-layout-content>
  </a-layout>
</template>

<script>
import { formatDateTime2 } from '../../utils/gw_date';
import { requestAllPblmsForProvince } from './Common/rectify_api';
import { formatDeadLineDate } from './Common/rectify_date';
import pblmQueryTerms from './Components/pblmQueryTerms';
import pblmTable from './Components/pblmTable';
export default {
  name: 'YwccPblmView',
  props: [],
  components: {
    pblmQueryTerms,
    pblmTable,
  },
  data() {
    return {
      loading: false,
      queryParams: {
        hasVedio: '',
        adCode: '',
        pblmStat: '',
        inspPblmCate: '',
        ifCasePblm: '',
        nm: '',
        rsName: '',
        adFullName: '',
        startTime: '',
        endTime: '',
        objType: '', // 为空才能不区分督查类别
        inspPblmName: '',
        dataStat: '2', // 整改阶段必须为2
        persId: localStorage.getItem('persId'),
        villType: '0',
        pageSize: 10,
        pageNum: 1,
        pblmTotal: 0,
        pTypeCode: '', // 督查类别
        pYear: '', // 年度
        zgXianOrgId: null, // 接收单位
        zgWh: '', // 整改文号
        workflowStat: '', // important 所有问题
      },
      ywccPblmViewTableSetting: {
        isEditVisible: false,
        data: [], // 主数据源
        pagination: {
          pageSize: 10,
          pageNum: 1,
          pblmCount: 0,
        }, // 翻页相关配置项
        height: 500,
        currentPblmId: '', // 当前选中的问题的ID
        selectedPblms: {}, // 多选模式下选中的所有问题集合
        multiSelect: false, // 是否出现行复选框
        enablePblmRectifyInfo: false, // 操作栏是否有整改信息输入按钮
        showWorkflowStat: true, // 是否显示整改状态
      },
    };
  },
  created() {},
  mounted() {
    this.$nextTick(function () {
      this.ywccPblmViewTableSetting.height =
        document.getElementsByClassName('ant-tabs')[0].offsetHeight - 220;
      this.$refs.queryTerms.queryByParams();
    });
  },
  computed: {
    formatDateTime() {
      return formatDateTime2;
    },
    formatDeadLineDate() {
      return formatDeadLineDate;
    },
  },
  methods: {
    // 按指定条件获取待下发问题列表数据
    queryByParams(val) {
      this.queryParams = val.queryParams;
      this.$refs.ywccPblmTable.clearSelection(); // 清空原有的选中行信息
      this.getAllPblms();
    },
    // 获取待下发问题列表数据
    getAllPblms() {
      this.loading = true;
      this.queryParams.pageSize =
        this.ywccPblmViewTableSetting.pagination.pageSize;
      this.queryParams.pageNum =
        this.ywccPblmViewTableSetting.pagination.pageNum;
      this.queryParams.dutyDeptRole = '1';
      requestAllPblmsForProvince(this.queryParams).then((res) => {
        this.loading = false;
        if (res.data !== null) {
          this.ywccPblmViewTableSetting.data = res.data.list;
          /* this.ywccPblmViewTableSetting.data.sort(function (x, y) {
            return x.zgDate - y.zgDate;
          }); */
          this.ywccPblmViewTableSetting.pagination.pblmCount = res.data.total;
        } else {
          this.ywccPblmViewTableSetting.data = [];
          this.ywccPblmViewTableSetting.pagination.pblmCount = 0;
        }
      });
    },
    // 直接页数跳转
    handlePageChange(val) {
      this.ywccPblmViewTableSetting.pagination.pageNum = val.pageNum;
      this.getAllPblms();
    },
    // 调整每页显示记录数
    handleSizeChange(val) {
      this.ywccPblmViewTableSetting.pagination.pageSize = val.pageSize;
      this.getAllPblms();
    },
    // 选中行时获取所有已选中行
    handleSelectionChange(val) {
      this.ywccPblmViewTableSetting.selectedPblms = val.selectedPblms;
    },
  },
};
</script>

<style lang='scss' scoped>

</style>
