<template>
  <div>
    <detailDatatable
      style="padding: -5px 0 10px 0"
      :newTime="newTime"
      v-if="newTime !== ''"
      :sitem="sitem"
      :columns="columns"
      :border="true"
    >
      <template slot="status">
        <el-tag
          :size="tablebtnSize"
          :type="(statusList.find((item) => item.id == sitem.status) || {}).type || ''"
          v-text="
            (statusList.find((item) => item.id == sitem.status) || {}).label || '--'
          "
        ></el-tag>
      </template>

      <template slot="is_addrs">
        <el-tag
          :size="'mini'"
          v-text="
            (options12.find((item) => item.id == sitem.is_addrs) || {}).name || '--'
          "
        ></el-tag>
      </template>
      <template slot="is_custom">
        <el-tag
          :size="'mini'"
          v-text="
            (options1.find((item) => item.id == sitem.is_custom) || {}).name || '--'
          "
        ></el-tag>
      </template>

      <template slot="good_num">
        <span>{{ sitem.good_num ? sitem.good_num : "0" }}{{ sitem.unit }}</span>
      </template>
      <template slot="rate_status">
        <el-tag
          :size="'mini'"
          v-text="
            (rate_status_options.find((item) => item.id == sitem.rate_status + '') || {})
              .label || '--'
          "
        ></el-tag>
      </template>

      <!-- 议价价格1/2/3权限 -->

      <template slot="sale_price">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '2')
          "
          >{{ sitem.sale_price }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="after_price">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '2')
          "
          >{{ sitem.after_price }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="cost_before_price">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '2')
          "
          >{{ sitem.cost_before_price }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="cost_after_price">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '2')
          "
          >{{ sitem.cost_after_price }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="before_rate">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '3')
          "
          >{{ sitem.before_rate }}%</span
        >
        <span v-else>******</span>
      </template>
      <template slot="after_rate">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '3')
          "
          >{{ sitem.after_rate }}%</span
        >
        <span v-else>******</span>
      </template>
      <template slot="cert_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.cert_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="pakge_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.pakge_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="cost_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.cost_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="mark_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.mark_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="demo_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.demo_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="open_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.open_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="delivery_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.delivery_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="nake_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.nake_fee }}元</span
        >
        <span v-else>******</span>
      </template>
      <template slot="total_fee">
        <span
          v-if="
            newTime !== '' &&
            private_field &&
            private_field.length > 0 &&
            private_field.some((item) => item == '1')
          "
          >{{ sitem.total_fee }}元</span
        >
        <span v-else>******</span>
      </template>
    </detailDatatable>
  </div>
</template>

<script>
import {
  columns,
  statusList,
  options1,
  options2,
  options3,
  options4,
  options5,
  options6,
  options7,
  options8,
  options9,
  options10,
  options11,
  options12,
  rate_status_options,
} from "./columns";

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

export default {
  mixins: [mixinPage, resToken],
  props: ["queryId"],
  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 ?? [];
    },
  },
  components: {
    detailDatatable,
  },
  data() {
    return {
      statusList,

      orderItem: {},
      moneyDirItem: {},
      moneyItem: {},
      BossItem: {},
      eaxmList: [],
      options1,
      options2,
      options3,
      options4,
      options5,
      options6,
      options7,
      options8,
      options9,
      options10,
      options11,
      options12,
      rate_status_options,

      //——————————————————————
      columns,
      status: "",
      newTime: "",
      sitem: null,
      loading: false,
    };
  },
  mounted() {
    this.initData();
  },
  methods: {
    getNewTime() {
      this.newTime = new Date().valueOf();
    },
    async initData() {
      this.loading = true;
      const { code, message, data } = await asyncRequest.detail({
        bargainNo: this.queryId,
      });

      this.eaxmList = [];
      this.loading = false;
      if (code === 0) {
        this.sitem = JSON.parse(JSON.stringify(data));

        const { status, exam_info } = this.sitem;
        this.orderItem = {};
        this.moneyDirItem = {};
        this.moneyItem = {};
        this.BossItem = {};
        if (exam_info && exam_info.length > 0) {
          exam_info.forEach((e) => {
            console.log(e.status);
            switch (e.info_status + "") {
              case "0":
                this.orderItem = JSON.parse(JSON.stringify(e));
                break;
              case "2":
                this.moneyDirItem = JSON.parse(JSON.stringify(e));
                break;
              case "4":
                this.moneyItem = JSON.parse(JSON.stringify(e));
                break;
              case "7":
                this.BossItem = JSON.parse(JSON.stringify(e));
                break;
              default:
                this.orderItem = JSON.parse(JSON.stringify(e));
            }
          });
          this.eaxmList = JSON.parse(JSON.stringify(exam_info));
        }

        this.status = status;

        this.getNewTime();
      } else if (code >= 100 && code <= 104) {
        await this.logout();
      } else {
        this.$message.warning(message);
      }
    },
  },
};
</script>

<style></style>
