<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 label="现督查对象名称：" >
            <a-input v-model:value="searchParam.nm1"/>
          </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"-->
<!--            :pageSize.sync="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: '',
        nm1: '',
      },
      dataList: [
        {
          index: 1,
          column1: '万宝灌区',
          column2: '吉安市',
          column3: '新干县',
          column4: '万宝灌区',
          column5: '吉安市',
          column6: '峡江县',
          column7: '2024-11-20',
        },
        {
          index: 2,
          column1: '沂江联圩',
          column2: '吉安市',
          column3: '新干县',
          column4: '沂江联圩',
          column5: '吉安市',
          column6: '峡江县',
          column7: '2024-11-20',
        },
        {
          index: 3,
          column1: '红星水库',
          column2: '吉安市',
          column3: '新干县',
          column4: '红星水库',
          column5: '吉安市',
          column6: '永丰县',
          column7: '2024-11-20',
        },
        {
          index: 4,
          column1: '滨湖水库',
          column2: '吉安市',
          column3: '新干县',
          column4: '滨湖水库',
          column5: '抚州市',
          column6: '乐安县',
          column7: '2024-11-20',
        },
        {
          index: 5,
          column1: '龙溪河左岸堤',
          column2: '吉安市',
          column3: '新干县',
          column4: '龙溪河左岸堤',
          column5: '宜春市',
          column6: '樟树市',
          column7: '2024-11-20',
        },
      ],
      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: 'column1',
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '100px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '原地市',
          dataIndex: 'column2',
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '100px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '原区县',
          dataIndex: 'column3',
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '100px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '现督查对象名称',
          dataIndex: 'column4',
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '100px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '现地市',
          dataIndex: 'column5',
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '120px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '现区县',
          dataIndex: 'column6',
          align: 'center',
          slots: { customRender: 'tooltipCell' },
          customCell: () => {
            return {
              style: {
                maxWidth: '100px',
                overflow: 'hidden',
                whiteSpace: 'nowrap',
                textOverflow: 'ellipsis',
              },
            };
          },
        },
        {
          title: '调整日期',
          dataIndex: 'column7',
          width: 150,
          align: 'center',
          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;
      this.tableData = [];
      this.dataList.forEach((item) => {
        if (
          (this.searchParam.nm !== '' &&
            item.column1.includes(this.searchParam.nm)) ||
          (this.searchParam.nm1 !== '' &&
            item.column4.includes(this.searchParam.nm1)) ||
          (this.searchParam.nm === '' && this.searchParam.nm1 === '')
        ) {
          this.tableData.push(item);
        }
      });
      // getPblmTab_3(this.searchParam).then((res) => {
      this.isLoading = false;
      //   this.tableData =
      //   this.total = res.data.total
      //   this.tableData.f
      // })
    },
    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>
