<template>
  <div class="goods-list">
    <toptitle name="秒杀专区" style="position: relative">
      <div class="seckill_time">秒杀时间：{{Q_time.start}} - {{Q_time.end}}</div>
    </toptitle>
    <div class="search-wrap">
      <div class="search-box">
        <div class="search-item">
          <span class="label">商品信息：</span>
          <el-input class="input" @keyup.enter.native="onSearch" clearable v-model="params.search"
                    placeholder="请输入SPU ID/SPU型号/SKU型号"></el-input>
        </div>
        <div class="search-item">
          <el-button type="primary" @click="onSearch">搜索</el-button>
          <el-button @click="onReset">重置</el-button>
        </div>
      </div>
    </div>
    <div>
      <el-table
        v-loading="loading"
        ref="multipleTable"
        :data="dataList"
        tooltip-effect="dark"
        style="width: 100%"
        stripe
      >
        <!--<el-table-column type="index" width="70" label="序号" align="center">-->
          <!--<template slot-scope="scope">-->
            <!--<p>{{scope.$index+1}}</p>-->
          <!--</template>-->
        <!--</el-table-column>-->
        <el-table-column prop="skuImg" label="商品图" align="center" width="100">
          <template slot-scope="scope">
            <div class="">
              <img style="width:80px" :src="scope.row.mainImg" alt="">
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="spuId" label="商品信息" align="center">
          <template slot-scope="scope">
            <div class="lefttime">SPU ID：{{scope.row.spuId}}</div>
            <div class="lefttime">SPU 型号：{{scope.row.spuModel}}</div>
            <div class="lefttime">SKU 型号：{{scope.row.skuModel}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="templateTame" label="库存" align="center"width="150">
          <template slot-scope="scope">
            <div >库存数量：{{scope.row.stock}}</div>
            <div >占用库存：{{scope.row.virtualStock}}</div>
            <div  style="color: #0099ff">可用库存：{{scope.row.useableStock}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="model" label="日常价" align="center" width="150px">
          <template slot-scope="scope">
            <div class="lefttime">供货价：{{scope.row.supplyPrice}}888</div>
            <div class="lefttime">批发价：{{scope.row.purchasePrice}}</div>
            <div class="lefttime">优惠价：{{scope.row.salePrice}}</div>
            <div class="lefttime">零售价：{{scope.row.productPrice}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="etaoStatus" label="秒杀价" align="center">
          <template slot-scope="scope">
            <div class="lefttime">秒杀供货价：{{scope.row.secKillSupply}}</div>
            <div class="lefttime">秒杀批发价：{{scope.row.secKillPurchase}}</div>
          </template>
        </el-table-column>
        <el-table-column  label="折扣" align="center" >
          <template slot-scope="scope">
            <div>{{scope.row.discount}}折</div>
          </template>
        </el-table-column>
        <el-table-column label="时间" align="center" width="200px" >
          <template slot-scope="scope">
            <div class="lefttime">修改时间：{{scope.row.updateDate}}</div>
            <div class="lefttime">添加时间：{{scope.row.addDate}}</div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-box">
        <pagination
          @eventSizeChange="eventSizeChange"
          @eventCurrentChange="eventCurrentChange"
          :total="total"
          :pageSize="params.pageSize"
          :currentPage="params.pageNum"
          :pagerCount='5'
        ></pagination>
      </div>
    </div>
  </div>
</template>

<script>
  import { _getStorage } from "@/utils/utils";
  import pagination from "@/components/common/pagination";
  import toptitle from "@/components/common/topTitle";

  export default {
    name: "list",
    components: {
      pagination,
      toptitle,
    },
    data() {
      return {
        Q_time:{},
        loading: false,
        dataList: [],
        total: 0,
        params: {
          pageSize: 20,
          pageNum: 1,
          search: "",
        },
      };
    },
    mounted() {
      this.getData();
      this.getTime()
    },
    methods: {
      onSearch() {
        this.params.pageNum = 1;
        this.getData();
      },
      onReset() {
        this.params = {
          pageSize: 20,
          pageNum: 1,
          search: "",
        };
        this.getData();
      },
      getTime() {
        this.loading = true;
        this.$axios.get("/secKill/getTime").then(res => {
          let { code,data } = res.data;
          if (code == 200) {
           this.Q_time=data||{}
          }
          this.loading = false;
        });
      },
      getData() {
        this.loading = true;
        let { brandId } = _getStorage("info");
        this.params.brandId = brandId;
        this.$axios.get("/secKill/list", {params:this.params}).then(res => {
          let { data, code } = res.data;
          if (code == 200) {
            if (data && data.list && data.list.length > 0) {
              this.total = parseInt(data.total);
              this.dataList = data.list;
            } else {
              this.dataList = [];
              this.total = 0;
            }
          }
          this.loading = false;
        });
      },
      eventSizeChange(e) {
        this.params.pageSize = e;
        this.getData();
      },
      eventCurrentChange(e) {
        this.params.pageNum = e;
        this.getData();
      },
    },
  };
</script>

<style lang="scss" scoped>
  .seckill_time {
    position: absolute;
    left: 100px;
    color: #229afe;
    background: #f4f7fd;
    border-radius: 30px;
    padding: 10px;
    font-size: 14px;
  }

  .lefttime {
    text-align: left;
  }

  .goods-list {
    color: #333333;
    padding: 20px;
  }

  .search-wrap {
    .search-box {
      overflow: hidden;
      flex-wrap: wrap;
      display: flex;
      transition: max-height 0.15s ease-in-out;
      .search-item {
        margin-right: 15px;
        margin-bottom: 15px;
        .label {
          display: inline-block;
          width: 74px;
          text-align: right;
          font-size: 14px;
        }
        .input {
          width: 250px;
        }
      }
    }
    .search-btn-box {
      margin-bottom: 10px;

      display: flex;
      align-items: center;
      .icon-arrow {
        margin-left: 4px;
        transition: transform 0.25s ease-in-out;
      }
      .more {
        color: #ff6600;
        margin-left: 10px;
        cursor: pointer;
        line-height: 33px;
      }
    }
  }

  .edit {
    color: #0785dd;
    span {
      cursor: pointer;
      margin: 0 4px;
    }
  }

  .pagination-box {
    display: flex;
    align-items: center;
    justify-content: center;
    // justify-content: space-between;
  }

  .category {
    // min-height: 500px;
    padding-top: 50px;
    .f_c_theme {
      color: #f60;
    }
    .btn-box {
      text-align: center;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: 30px;
    }
  }

  /deep/ .el-cascader-menu__wrap {
    height: 368px;
  }
</style>
