<template>
  <div class="mainCss">
    <div class="pageRight_none">
      <div class="content">
        <a-form layout="inline" style="padding-left: 10px;">
          <a-form-item label="督查对象名称：" >
            <a-input v-model:value="searchParam.nm"/>
          </a-form-item>
          <a-form-item>
            <a-button type="primary" @click="search" style="margin-left: 10px">查询</a-button>
          </a-form-item>
        </a-form>
        <a-table
            :columns="columns"
            :data-source="tableData"
            :pagination="false"
            rowKey="index"
            :loading="isLoading"
            :style="{ height: tableHeight + 'px' }"
            :scroll="{ x: '100%', y: tableHeight - 100 }"
            bordered>
            <template #bodyCell="{ column, text }">
                <template v-if="column.slots?.customRender === 'tooltipCell'">
                    <a-tooltip placement="topLeft" :title="text">
                        <span>{{ text }}</span>
                    </a-tooltip>
                </template>
                <template v-else>
                    {{ text }}
                </template>
            </template>
        </a-table>
        <a-pagination
            show-size-changer
            v-model="pageNum"
            v-model:pageSize="pageSize"
            :total="total"
            :page-size-options="['5', '10', '20', '30', '40']"
            :show-total="total => `共${total}条`"
            @showSizeChange="handleSizeChange"
            @change="handleCurrentChange"/>
      </div>
    </div>
  </div>
</template>

<script>
import { getPblmTab_3 } from '@/api/slzj/slzj';
import { hostUrl } from '../../utils/global_variable.js';
import { dateFormat, formatD } from '../../utils/gw_date';

export default {
  components: {},
  data() {
    return {
      searchParam: {
        nm: '',
      },
      tableData: [],
      pageNum: 1,
      pageSize: 10,
      total: 0,
      isLoading: false,
      tableHeight: window.innerHeight - 260,
      columns: [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          align: 'center',
          fixed: 'left',
        },
        {
          title: '督查对象名称',
          dataIndex: 'nm',
          width: 100,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '100px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '资金督查问题类别',
          dataIndex: 'inspPblmNameA',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '资金督查检查项目',
          dataIndex: 'checkPointBzA',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '资金督查问题描述',
          dataIndex: 'pblmDescBzA',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '资金督查详细描述',
          dataIndex: 'inspPblmDescA',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '局领导审核日期',
          dataIndex: 'moddateA',
          align: 'center',
          width: 150,
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '综合督查问题类别',
          dataIndex: 'inspPblmName',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '综合督查检查项目',
          dataIndex: 'checkPointBz',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '综合督查问题描述',
          dataIndex: 'pblmDescBz',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '综合督查详细描述',
          dataIndex: 'inspPblmDesc',
          width: 150,
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '业务处室审核日期',
          dataIndex: 'moddate',
          align: 'center',
          width: 150,
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '150px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
      ],
    };
  },
  computed: {
    userId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '';
    },
    hostUrl() {
      return hostUrl;
    },
    formatD() {
      return formatD;
    },
  },
  created() {},
  mounted() {
    this.search();
  },
  methods: {
    search() {
      this.getList();
    },
    handleSizeChange(size, val) {
      this.pageSize = val;
      this.search();
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getList();
    },
    getList() {
      this.searchParam.pageNum = this.pageNum;
      this.searchParam.pageSize = this.pageSize;
      this.isLoading = true;
      getPblmTab_3(this.searchParam).then((res) => {
        this.isLoading = false;
        this.tableData = res.data.list;
        this.total = res.data.total;
        this.tableData.forEach((element, index) => {
          element['index'] = this.pageSize * (this.pageNum - 1) + index + 1;
          element['moddateA'] = dateFormat(element['moddateA'], 'yyyy-MM-dd');
          element['moddate'] = dateFormat(element['moddate'], 'yyyy-MM-dd');
        });
      });
    },
    timestampToTime(val) {
      return dateFormat(val, 'yyyy-MM-dd');
    },
  },
};
</script>

<style lang='less' scoped>
:deep(.ant-table-pagination) {
  float: left;
}

:deep(.ant-layout-sider),
:deep(.ant-layout-content) {
  background: #fff;
}

:deep(.ant-table-thead > tr > th),
:deep(.ant-table-tbody > tr > td) {
  padding: 0;
  height: 60px;
  line-height: 60px;
}

:deep(.ant-table-scroll) {
  position: relative;
  z-index: 1;
}

:deep(.ant-table-fixed-left),
:deep(.ant-table-fixed-right) {
  z-index: 2;
}

.pageRight_none {
  width: calc(100% - 20px);
  margin-left: 10px;
}

.content {
  width: 100%;
}

:deep(.success-delete) {
  background: #ffa3a8 !important;
}

.mainCss {
  width: 100%;
  height: calc(100% - 20px);
  display: flex;
}

.pageLeft_none {
  display: none;
}

.pageRight {
  width: calc(100% - 330px);
  margin-left: 10px;
}

.custom_dialog .scroll300 {
  max-height: 60vh !important;
}
</style>
