<template>
  <div class="active pagePadding">
    <ex-table
      v-loading="loading"
      :table="table"
      :data="tableData"
      :columns="columns"
      :page="pageInfo"
      :size="size"
      @page-curr-change="handlePageChange"
      @page-size-change="handleSizeChange"
      @screen-reset="
        pageInfo.curr = 1;
        parmValue.page = 1;
        searchList();
      "
      @screen-submit="
        pageInfo.curr = 1;
        parmValue.page = 1;
        searchList();
      "
    >
      <!-- <template #status="{ scope }">
        <el-tag
          :size="tablebtnSize"
          :type="scope.row.status + '' == '1' ? '' : 'warning'"
          v-text="
            (statusOptions.find((item) => item.id == scope.row.status + '') || {})
              .label || '--'
          "
        ></el-tag>
      </template> -->
      <template #atime="{ scope }"> {{ scope.row.start }}~{{ scope.row.end }} </template>
      <template #operation="{ scope }">
        <el-tooltip
          v-if="powers.some((i) => i == '007')"
          effect="dark"
          content="详情"
          placement="top"
        >
          <i
            class="el-icon-view tb-icon"
            @click="getRouter('othgoodsOfflineDetail', scope.row.actCode)"
          ></i>
        </el-tooltip>
      </template>
    </ex-table>
  </div>
</template>
<script>
import asyncRequest from "@/apis/service/youzan/luckDrawGood";
import mixinPage from "@/mixins/elPaginationHandle";
import { mapGetters } from "vuex";
import resToken from "@/mixins/resToken";
import { goodColumns } from "../columns";

export default {
  name: "active",
  props: ["id", "newTime"],
  mixins: [mixinPage, resToken],
  computed: {
    //组件SIZE设置
    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  },
  data() {
    return {
      select: "1",
      sinput: "",
      loading: false,
      parmValue: {
        act_name: "",
        actCode: "",
        status: "",
        start: "",
        end: "",
        page: 1, // 页码
        size: 15, // 每页显示条数
        company_id: "",
        contactor: "",
        company_name: "", //活动公司
      },
      // 状态
      statusOptions: [
        { id: "0", label: "待上传" },
        { id: "1", label: "已完成" },
      ],
      // 表格 - 数据
      tableData: [],
      // 表格 - 参数
      table: {
        stripe: true,
        border: true,
        _defaultHeader_: [],
      },
      // 表格 - 分页
      pageInfo: {
        size: 15,
        curr: 1,
        total: 0,
      },
      // 表格 - 列参数
      columns: goodColumns,
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    // 刷新表格
    async searchList() {
      this.loading = true;
      this.parmValue.actCode = this.id;
      const { code, data } = await asyncRequest.list(this.parmValue);
      if (code === 0) {
        const { list, count } = data;
        this.tableData = list;
        this.pageInfo.total = Number(count);
      } else if (code >= 100 && code <= 104) {
        await this.logout();
      } else {
        this.tableData = [];
        this.pageInfo.total = 0;
      }
      this.loading = false;
    },
  },
};
</script>

<style lang="scss" scoped></style>
