<!--
 * @Descripttion: 
 * @version: 
 * @Author: 王三华
 * @Date: 2024-02-26 14:35:55
-->
<template>
  <div class="page">
    <div class="topbox">
      <div class="levelList_i"
           :class="moren == item.path ? 'act' : ''"
           v-for="(item, index) in topList"
           :key="index"
           @click.prevent="handleLink(item)">
        {{ item.name }}
      </div>
    </div>
    <div class="main">
      <div class="form_all">
      </div>
      <div class="main_a">
        <div class="mainbtn">
          <el-button size="small"
                     @click="handleExport"
                     v-hasButtons="['underProductTExport']"
                     class="exportBtn"> {{ '导出' }}</el-button>
        </div>
        <div class="maintable">
          <el-table :data="tableData"
          v-loading="loading"
                    style="width: 100%"
                    height="710px"
                    :header-cell-style="{ background: '#EEEEEE' }"
                    :row-class-name="tableRowClassName"
                    @selection-change="handleSelectionChange">
            <el-table-column type="selection"
                             width="55"> </el-table-column>
                             <el-table-column align="center"
                             prop="productCode"
                             :label="'产品编号'">
            </el-table-column>
            <el-table-column align="center"
                             prop="productName"
                             :label="'产品名称'">
            </el-table-column>
            <el-table-column align="center"
                             prop="price"
                             :label="'产品单价' + '(￥)'">
            </el-table-column>
            <el-table-column align="center"
                             prop="quantity"
                             :label="'数量'">
            </el-table-column>
            <el-table-column align="center"
                             prop="totalPrice"
                             :label="'产品总价'+ '(￥)'">
            </el-table-column>
            <el-table-column align="center"
                             prop="achievement"
                             :label="'产品业绩'+ '(￥)'">
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
    <pagination v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getDataList" />
  </div>
</template>

<script>
import topBar from '@/components/topBar'
import * as api from '@/api/statistics.js'
export default {
  name: 'Bzpz',
  components: {
    topBar,
  },
  data() {
    return {
      select: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total: 0,
      tableData: [],
      loading:false,
      moren: 'underDirectProductToTal',
      topList: [
        {
          name: '伞下直推产品明细',
          path: 'underDirectProductDetails',
        },
        {
          name: '伞下直推产品汇总',
          path: 'underDirectProductToTal',
        },
      ],
      allObj: {},
    }
  },
  mounted() {
    this.allObj = JSON.parse(this.$route.query.data)
    // 获取列表
    this.getDataList()
  },
  methods: {
    handleLink(item) {
      this.tabActive = item.path
      this.$router.push({
        path: item.path,
        query: {
          data: JSON.stringify(this.allObj)
        },
      })
    },
    // 获取列表
    getDataList() {
      this.loading = true
      api.umbrellaStat(
          Object.assign({},this.allObj,this.queryParams)
        )
        .then((res) => {
          this.tableData = res.rows
          this.total = res.total
          this.loading = false
        })
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then((_) => {
        this.download(
          'report/manager/member-awards/stat-product-excel',
          Object.assign({}, this.allObj),
          `伞下直推产品汇总${new Date().getTime()}.xlsx`
        )
      })
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return 'warning-row'
      } else if (rowIndex % 2 == 0) {
        return 'success-row'
      }
      return ''
    },
  },
}
</script>
<style scoped lang="scss">
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}

::v-deep .el-table .success-row {
  background: #ffffff;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-select {
  width: 100%;
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    // background: #ffffff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    .main_a {
      background: #fff;
      border-radius: 8px;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    }
    .mainbtn {
      padding: 0;
    }
    .maintable {
      flex: 1;
    }
  }
}
::v-deep .el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 100%;
}
.form_all {
  padding: 0 20px;
  margin-bottom: 10px;
  background: #fff;
}
.topbox {
  align-items: center;
  // height:74px;
  padding: 0px 0 0px 0;
  display: flex;
  //   background: skyblue;
  .levelList_i {
    padding: 4px 15px;
    margin-left: 10px;
    position: relative;
    cursor: pointer;
    min-width: 88px;
    // height: 28px;
    border-radius: 17px;
    border: 1px solid #cccccc;
    font-size: 12px;
    font-family: MicrosoftYaHei;
    text-align: center;
    // line-height: 28px;
  }
  .act {
    color: #ffffff;
    background: #c8161d;
  }
  .act1 {
    border-bottom: 3px solid #1890ff !important;
  }
}
</style>
