<template>
  <!-- 弹出窗 -->
    <el-dialog title="查看稽察对象" v-model:visible="dialogFormVisible" width="50%" @close="CloseDialog" :modal-append-to-body="true" :append-to-body="true">
        <el-container>
            <el-main style="border:1px solid #d5d5ff;margin-left:5px;padding:0;">
                <el-form style="padding:10px">
                    <div>
                        <el-table
                            border
                            v-loading="loading"
                            :data="currentShowList"
                            height="300px"
                            tooltip-effect="dark"
                            style="width: 100%">
                            <el-table-column align="center" prop="index" label="序号" min-width="40"></el-table-column>
                            <el-table-column align="center" show-overflow-tooltip prop="name" label="项目名称" min-width="100"></el-table-column>
                            <el-table-column align="center" show-overflow-tooltip prop="type" label="项目类型" min-width="100"></el-table-column>
                            <el-table-column align="center" show-overflow-tooltip prop="location" label="位置" min-width="150"></el-table-column>
                            <el-table-column align="center" show-overflow-tooltip prop="admOrg" label="所属流域机构" min-width="100"></el-table-column>
                        </el-table>
                    </div>
                </el-form>
            </el-main>
        </el-container>
    </el-dialog>
</template>
<script>
import request from '@/utils/gw_ajax_request.js';
export default {
  components: {},
  props: ['groupId'],
  computed: {
    userId: () =>
      localStorage.getItem('userid')
        ? localStorage.getItem('userid')
        : '1098101939614724096',
  },
  data() {
    return {
      pageIndex: 1,
      pageSize: 1,
      total: 0,
      currentShowList: [],
      dialogFormVisible: true,
    };
  },
  watch: {
    groupId() {
      this.getTableData_jc();
    },
  },
  mounted() {
    this.$nextTick(() => {
      this.getTableData_jc();
    });
  },
  computed: {
    userId: () =>
      localStorage.getItem('userid')
        ? localStorage.getItem('userid')
        : '1098101939614724096',
  },
  methods: {
    gateTypeFormatter(row, column) {
      return row.gateType == '1'
        ? '分(泄)洪闸'
        : row.gateType == '2'
          ? '节制闸'
          : row.gateType == '3'
            ? '排(退)水闸'
            : row.gateType == '4'
              ? '引(进)水闸'
              : row.gateType == '5'
                ? '挡潮闸'
                : row.gateType == '6'
                  ? '船闸'
                  : row.gateType == '9'
                    ? '其它'
                    : '';
    },
    getTableData_jc() {
      request
        .post(`/tac/insp/year/batch/obj/getObjList`, {
          groupId: this.groupId,
        })
        .then((res) => {
          if (res.success) {
            this.$nextTick(() => {
              this.loading = false;
              this.currentShowList = res.data;
              this.currentShowList.forEach((element, index) => {
                element['index'] =
                  this.pageSize * (this.pageIndex - 1) + index + 1;
              });
              this.total = res.data.total;
            });
          }
        });
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageIndex = val;
      this.refreshCurrentShow();
    },
    refreshCurrentShow: function () {
      this.getTableData_jc();
    },
    CloseDialog() {
      this.$emit('closeDialog');
    },
  },
};
</script>
<style>
</style>
