<template>
  <div class="goods-list">
    <toptitle name="新品专区" style="position: relative"></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" v-if="false">
          <span class="label" style="width: 60px">专区：</span>
          <el-select class="input" style="width:120px;" clearable v-model="params.type" placeholder="请选择专区">
            <el-option
              v-for="item in preList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
        <div class="search-item">
          <span class="label">添加时间：</span>
          <el-date-picker
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            style="width: 300px"
            v-model="addTime"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </div>
        <!--<div class="search-item">-->
        <!--<span class="label" style="width: 100px">预计退出时间：</span>-->
        <!--<el-date-picker-->
        <!--format="yyyy-MM-dd"-->
        <!--value-format="yyyy-MM-dd"-->
        <!--style="width: 300px"-->
        <!--v-model="outTime"-->
        <!--type="daterange"-->
        <!--range-separator="-"-->
        <!--start-placeholder="开始日期"-->
        <!--end-placeholder="结束日期">-->
        <!--</el-date-picker>-->
        <!--</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"></el-table-column>
        <el-table-column prop="skuImg" label="商品图" align="center">
          <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>
            <!--<div class="lefttime">-->
              <!--<img style="height: 18px" v-if="scope.row.zoneIcon" :src="scope.row.zoneIcon" alt="">-->
            <!--</div>-->
          </template>
        </el-table-column>
        <el-table-column label="时间" align="center">
          <template slot-scope="scope">
            <div class="lefttime">添加时间：{{scope.row.addDate}}</div>
            <!--<div class="lefttime">预计退出时间：{{scope.row.quitDate}}</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: "xinPin",
    components: {
      pagination,
      toptitle,
    },
    data() {
      return {
        addTime: "",
        outTime: "",
        preList: [
          {
            value: 99,
            label: "全部",
          }, {
            value: 11,
            label: "铂金",
          }, {
            value: 10,
            label: "淘淘淘",
          },
        ],
        loading: false,
        dataList: [],
        total: 0,
        params: {
          pageSize: 20,
          pageNum: 1,
          search: "",
          type: 99,
        },
      };
    },
    mounted() {
      this.getData();
    },
    methods: {
      onSearch() {
        this.params.pageNum = 1;
        this.getData();
      },
      onReset() {
        this.params = {
          pageSize: 20,
          pageNum: 1,
          search: "",
          type: 99,
        };
        this.addTime = "";
        this.outTime = "";
        this.getData();
      },
      getData() {
        this.loading = true;
        if (this.addTime) {
          this.params.beginAddDate = this.addTime[0];
          this.params.endAddDate = this.addTime[1];
        }
        // if(this.outTime){
        //   this.params.beginQuitDate=this.outTime[0]
        //   this.params.endQuitDate=this.outTime[1]
        // }
        this.$axios.post("/products/newZoneSkuList", 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>


  .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: 70px;
          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>
