<template>
  <div>
    <detailDatatable
      :newTime="newTime"
      v-if="newTime !== ''"
      :sitem="sitem"
      :columns="columns"
      :border="true"
    >
      <template slot="status">
        <el-tag
          :size="'mini'"
          :type="sitem.status == '0' ? 'warning' : ''"
          v-text="
            (statusOptions.find((item) => item.value == sitem.status) || {}).label || '--'
          "
        ></el-tag>
      </template>
      <template slot="file_url">
        <el-link :underline="false" :href="sitem.file_url" target="_blank">{{
          sitem.file_name
        }}</el-link>
      </template>
    </detailDatatable>
  </div>
</template>

<script>
import { columns, statusOptions } from "./columns";
// import { cg_order_type_options } from "@/assets/js/statusList";

//————————————————
import mixinPage from "@/mixins/elPaginationHandle";
import resToken from "@/mixins/resToken";
import asyncRequest from "@/apis/service/sellOut/stockApply";
import { mapGetters } from "vuex";
import detailDatatable from "../detail-data-table";

export default {
  mixins: [mixinPage, resToken],
  components: {
    detailDatatable,
  },
  computed: {
    ...mapGetters(["tablebtnSize", "searchSize", "size", "private_field"]),
    powers() {
      const tran =
        this.$store.getters.btnList.find(
          (item) => item.menu_route == "standingBookDetail"
        ) || {};
      const { action } = tran ?? {};
      return action ?? [];
    },
  },
  props: ["queryId"],
  data() {
    return {
      // cg_order_type_options,
      statusOptions,
      // cost_detailArr: [],

      //——————————————————————
      columns,
      newTime: "",
      status: "",
      sitem: null,
      loading: false,
    };
  },
  mounted() {
    this.initData();
  },
  methods: {
    getNewTime() {
      this.newTime = new Date().valueOf();
    },
    async initData() {
      this.loading = true;
      const res = await asyncRequest.detail({
        id: this.queryId,
      });
      const { code, data, message } = res;
      if (code === 0) {
        const { status } = data;
        this.sitem = data;
        this.status = status;
        this.getNewTime();
      } else if (res && res.code >= 100 && res.code <= 104) {
        await this.logout();
      } else {
        this.$message.warning(message);
      }
      this.loading = false;
    },
  },
};
</script>

<style></style>
