<template>
  <div class="table">
    <table>
      <thead>
        <tr>
          <td colspan="4">基础信息</td>
          <td>媒体平台</td>
          <td colspan="4">媒体账号信息</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>No.</td>
          <td>DLR Code</td>
          <td>所属区域</td>
          <td>经销商店名</td>
          <td>所属平台</td>
          <td>账号</td>
          <td>是否认证</td>
          <td>粉丝数</td>
          <td>操作</td>
        </tr>
        <tr
          v-for="(obj, index) in tableData"
          :key="index"
          :class="{ table_gray: index % 2 === 0 }"
        >
          <td>{{ index + 1 }}</td>
          <td>{{ obj.dlrCode }}</td>
          <td>{{ obj.localArea }}</td>
          <td>{{ obj.dlrName }}</td>
          <td>{{ obj.platformName }}</td>
          <td>{{ obj.accountCode }}</td>
          <td>{{ obj.authorizationName }}</td>
          <td>{{ obj.fansCount}}</td>
          <td class="operation">
            <span @click="edit(index)">编辑</span>
          </td>
        </tr>
      </tbody>
    </table>
    <EditModal
      @edit_data="editData"
      @hide_modal="closeModal"
      :modalFlag="deleteModalFlag"
      :dataObj="modalData"
    ></EditModal>
  </div>
</template>

<script>
import EditModal from "./EditModal";
export default {
  props: {
    // 表数据
    tableData: {
      type: Array,
      default: () => {
        return [];
      },
    },
    //  表格一页共有多少数据
    pageSize: {
      type: Number,
      default: 20,
    },
  },
  components: {
    EditModal,
  },
  data() {
    return {
      deleteModalFlag: false,
      index: 0,
      editFlag: [],
      modalData: {},
    };
  },
  methods: {
    edit: function (i) {
      this.index = i;
      this.deleteModalFlag = true;
      this.modalData = this.tableData[i];
    },
    // 模态框确认
    editData: function (isAttesta, fansNum, accountCode) {
      this.deleteModalFlag = false;
      this.$emit("edit_data", this.index, isAttesta, fansNum, accountCode);
    },
    // 模态框取消
    closeModal: function () {
      this.deleteModalFlag = false;
    },
    mounted() {
    },
  },
};
</script>

<style scoped lang="less">
.table {
  background-color: #fff;
  width: 100%;
  margin-top: 10px;
  text-align: center;
  table {
    width: 100%;
    border-collapse: collapse;
    border: none;
    thead {
      td {
        background: #8d9092;
        height: 36px;
        color: #fff;
        border: 1px solid #ccc;
      }
    }
    tbody {
      td {
        height: 36px;
        border: 1px solid #ccc;
      }
      .operation {
        span {
          color: #00f;
          margin: 0 20px;
          &:hover {
            cursor: pointer;
          }
        }
      }
    }
  }
}
.table_gray {
  background: #f5f5f5;
}
</style>
