<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :top-list="topList"
      :moren="moren"
    />
    <div class="main">
      <div class="maintop">
        <div class="mainbtn">
          <el-button v-hasButtons="['ProductSaleStatisticsDetailExport']" size="small" class="thebtn1" @click="handleExport">
            {{ '导出' }}</el-button>
        </div>
      </div>
      <div class="maintable">
        <el-table
          v-loading="loading"
          :data="tableData"
          height="700px"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
        >
          <el-table-column
            align="center"
            prop="wmsCode"
            :label="'仓储编号'"
          />
          <el-table-column
            align="center"
            prop="specialAreaVal"
            label="所属专区"
            min-width="180px"
          />
          <el-table-column
            align="center"
            prop="isMakerGiftVal"
            label="商品类型"
          />
          <el-table-column
            align="center"
            prop="quantity"
            label="销量"
          />
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getSearch"
    />
  </div>
</template>

<script>
import topBar from '@/components/topBar'
import * as sta from '@/api/statistics'
export default {
  name: 'ProductSaleStatisticsDetail',
  components: {
    topBar
  },
  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      const realVal = parseFloat(value).toFixed(2)
      return realVal
    }
  },
  data() {
    return {
      moren: 'productSaleStatisticsDetail',
      topList: [
        {
          name: '产品销售统计',
          path: 'productSaleStatisticsDetail'
        }
      ],
      tableData: [],
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        pkProduct: '',
        orderType: ''
      },
      total: 0,
      pkProduct: '',
      multipleSelection: [],
      classifyAllList: [],
      awardsList: [],
      params: {}
    }
  },
  created() {
    this.pkProduct = this.$route.query.pkProduct
    this.queryParams.orderType = this.$route.query.orderType
    this.params = JSON.parse(this.$route.query.params)
    delete this.params.orderType
    this.getSearch()
  },
  methods: {
    // 导出
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then((_) => {
        this.download(
          '/report/manager/member-report/product-shipping-details-export',
          { ...this.queryParams, ...this.params },
          `${'产品销售统计'}${new Date().getTime()}.xlsx`
        )
      })
    },

    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
        pkProduct: ''
      }
      this.getSearch()
    },
    getSearch() {
      this.loading = true
      this.queryParams.pkProduct = this.pkProduct
      sta.getShippingSummaryDetail(Object.assign({}, this.queryParams, this.params)).then((res) => {
        this.loading = false
        if (res.code == 200) {
          this.tableData = res.rows
          this.total = res.total
        }
      })
    },
    getCzNum() {
      this.queryParams.pageNum = 1
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-image-viewer__close {
  right: 500px;
}
::v-deep .dizhi .el-cascader {
  width: 100%;
}
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}
.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    padding: 15px 20px 15px 0;
    background: #ffffff;
    border-radius: 8px;
    .searchbox {
      display: flex;
      align-items: center;
      margin-left: 40px;
    }
    .searchtitle {
      margin-right: 10px;
    }
    .searchbtn {
      background: #08143f;
      color: #ffffff;
    }
  }
  .main {
    //margin-top: 20px;
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);

    .maintop {
      display: flex;
      // padding: 10px 0;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          color: #ffffff;
          background: #ffad41;
          width: 68px;
          height: 32px;
        }
        .thebtn2 {
          color: #ffffff;
          background: #009b58;
          width: 68px;
          height: 32px;
        }
        .thebtn3 {
          color: #ffffff;
          background: #c8161d;
          width: 68px;
          height: 32px;
        }
      }
    }
  }
}
</style>
