<script setup>
import { ref, watch } from "vue";
import { raiInterface } from "@/api/api.js";

const props = defineProps({
  iscollectFansDlgShow: {
    type: Boolean,
    default: false,
  },
  collectFansDlgText: {
    type: String,
    default: "",
  },
  collectFansDlgItem: {
    type: Object,
    default: "",
  },
});

watch(
  () => props.iscollectFansDlgShow,
  (newVal) => {
    newVal && getTableList();
  }
);

const $emit = defineEmits();
// 关闭弹框
function handleClose() {
  $emit("update:iscollectFansDlgShow", false);
  $emit("update:collectFansDlgText", "");
  $emit("update:collectFansDlgItem", {});
}

const tableData = ref([]);

// 获取表格数据
async function getTableList() {
  const res =
    props.collectFansDlgText == "收藏详情"
      ? await raiInterface.getYanxuanSpecialCollect({
          SpecialId: props.collectFansDlgItem.Id,
        })
      : await raiInterface.getYanxuanSpecialFans({
          SpecialAuthorId: props.collectFansDlgItem.Id,
        });
  if (res.Ret === 200) {
   tableData.value = res.Data.List || [];
  }
}
</script>

<template>
  <div class="container">
    <!-- 选择图片的弹框 -->
    <el-dialog
      :title="props.collectFansDlgText"
      v-model="props.iscollectFansDlgShow"
      width="50%"
      :before-close="handleClose"
      draggable
      :close-on-click-modal="false"
      :modal-append-to-body="false"
      center
    >
      <div>
        <el-table :data="tableData" style="width: 100%; margin-bottom: 20px" border>
          <el-table-column prop="RealName" align="center" label="姓名"></el-table-column>
          <el-table-column prop="CompanyName" align="center" label="公司名称"></el-table-column>
          <el-table-column prop="SellerName" align="center" label="所属销售"></el-table-column>
          <el-table-column width="160" prop="CreateTime" align="center" :label="collectFansDlgText == '收藏详情' ? '收藏时间' : '关注时间'"></el-table-column>
        </el-table>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="handleClose">关闭</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
