<template>
  <el-row>
    <el-col :span="24">
      <el-table
        class="left"
        :cell-style="{ color: '#fff' }"
        :header-cell-style="{ color: '#fff' }"
        :data="tableData"
        height="700px"
        border
      >
        <!-- <el-table-column
          prop="id"
          label="类型"
          align="center"
          width="140"
        ></el-table-column> -->
        <el-table-column prop="url" label="地址">
          <template slot-scope="{ row }">
            <div :style="{ color: 'row.url' ? 'red' : 'red' }">
              {{ row.url }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="130">
          <template slot-scope="{ row }">
            <el-button
              class=".tag-read"
              size="mini"
              type="success"
              @click="fuzhibtn(row)"
              >复制</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        style="margin-top: 20px"
        background
        layout="prev, pager, next"
        :page-size="page.size"
        :total="page.total"
        :current-page="page.current"
        @size-change="Sizechange"
        @current-change="Currentchange"
      >
      </el-pagination>
    </el-col>
  </el-row>
</template>

<script>
import { getLayer } from "../../../api/Datadetails";
export default {
    props: {
        row: {
          type: Object,
          default() {
            return {};
          },
        },
      },
  data() {
    return {
      page: {
        total: 10, //总数量
        size: 10, //每页数量
        current: 1, //当前页
      },
      tableData: [],
    };
  },
  methods: {
    onLoad() {
      // console.log(this.row);
      if(!this.row.tableRef){
        return;
      }
      getLayer({
        spaceType: this.row.spaceType,
        tableName: this.row.tableRef
      }).then((res) => {
        // console.log(res);
        if (res.data.code == 200) {
          this.tableData = res.data.data.data;
        }
      });
    },
    fuzhibtn(row) {
      // console.log(row);
      var input = document.createElement("input"); // 创建input对象
      input.value = row.url; // 设置复制内容
      document.body.appendChild(input); // 添加临时实例
      input.select(); // 选择实例内容
      document.execCommand("Copy"); // 执行复制
      document.body.removeChild(input); // 删除临时实例
      this.$message.success("复制成功！");
    },
    Sizechange() {
    },
    Currentchange(val) {
      // console.log(val);
      // console.log("页码改变了");
    },
  },
};
</script>

<style>
</style>