<template>
  <div class="box">
    <div v-if=" powers.some((i) => i == '007')">
      <el-tabs v-model="activeName" @tab-click="handleClick" v-loading="loading">
        <el-tab-pane label="商品下线详情" name="1">
          <show-data-table
            :newTime="newTime"
            v-if="newTime !== ''"
            :sitem="list"
            :columns="costArr"
          >
            <template slot="children_list">
              <el-table :data="list.children_list" size="mini" style="width: 100%">
                <el-table-column prop="skuCode" label="商品上线编号" min-width="140">
                </el-table-column>
                <el-table-column prop="platform_name" label="平台名称" min-width="140">
                </el-table-column>

                <el-table-column prop="purchease" label="采购人" min-width="90">
                </el-table-column>
                <el-table-column prop="creater" label="创建人" min-width="90">
                </el-table-column>
              </el-table>
            </template>
          </show-data-table>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div v-else>
      <no-auth></no-auth>
    </div>
  </div>
</template>

<script>
import mixinPage from "@/mixins/elPaginationHandle";
import resToken from "@/mixins/resToken";
import asyncRequest from "@/apis/service/goodStore/goodsOffline";
import { costArr } from "./columns";
import { mapGetters } from "vuex";
export default {
  name: "goodsOfflineDetail",
  mixins: [mixinPage, resToken],
  components: {},
  computed: {
    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
    powers() {
      const tran =
        this.$store.getters.btnList.find(
          (item) => item.menu_route == "goodsOfflineDetail"
        ) || {};
      const { action } = tran ?? {};
      return action ?? [];
    },
  },
  data() {
    return {
      //loading
      loading: false,
      //数据
      list: {},
      parmValue: {
        id: this.$route.query.id,
      },
      activeName: "1",
      newTime: "",
      costArr,
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    async searchList() {
      this.loading = true;

      const res = await asyncRequest.goodoffdetail(this.parmValue);
      if (res && res.code === 0 && res.data) {
        this.list = res.data;
        console.log(this.list);
      } else if (res && res.code >= 100 && res.code <= 104) {
        await this.logout();
      } else {
        this.$message.warning(res.message);
        this.list = [];
      }
      this.getNewTime();
      this.loading = false;
    },
    getNewTime() {
      this.newTime = new Date().valueOf();
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  padding: 20px 20px 0;
  box-sizing: border-box;
}
</style>
