<template>
  <div style="margin-top:20px">
    <div class="table-content">
      <el-table
        v-loading="loading"
        :data="tableData"
        style="width: 100%"
        tooltip-effect="dark"
        :height="tableHeight">
        <el-table-column
          label="项目名称"
          prop="projectName" />
        <el-table-column
          label="分组"
          prop="groupName" />
        <el-table-column
          label="接口名称"
          prop="interfaceName" />
        <el-table-column
          label="绑定时间"
          prop="bindTime">
          <template slot-scope="scope">
            <div class="color-606266 line-18">
              {{ scope.row.bindTime | timeStampToYmd }}
            </div>
            <div class="color-606266 line-18">
              {{ scope.row.bindTime | timeStampToHms }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <dm-delete
              tips="确定要解除绑定吗?"
              @confirm="cancelBind(scope.row)">
              <el-button type="text">
                解除绑定
              </el-button>
            </dm-delete>
            <!-- <el-button type="text">日志</el-button> -->
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getRequest } from '@/api/api';
export default {
  components: {},
  props: {
    tableData: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {};
  },
  methods: {
    cancelBind(item) {
      let that = this;
      let params = {
        id: item.openPlatformInterfaceId
      };
      getRequest('/gateway-manage/platform/white/unbind', params)
        .then(res => {
          if (res.data.code == '0000') {
            this.$emit('getList');
          } else {
            this.$message.error(res.data.message);
          }
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  }
};
</script>
<style lang="less" scoped></style>
