<template>
  <div class="JCDetails" style="padding:0 50px;">
    <h1>销售三级毛利</h1>
    <div class="topbox" style="display: flex;justify-content: space-between;">
      <div style="flex: 1;"></div>
      <div class="selec ershi">
        <el-select v-model="value" filterable multiple collapse-tags clearable placeholder="请选择">
          <el-option v-for="item in options" :key="item.value" :label="item.text" :value="item.value">
          </el-option>
        </el-select>
      </div>
      <div class="timeselec ershi">
        <el-date-picker v-model="value2" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <button class="ershi" style="width: 100px;height: 40px;background-color: aqua;"
        @click="chaxun2(value, value2)">查询</button>
    </div>
    <div> <el-table ref="table" :height="taheight" :header-cell-style="{
      background: 'rgba(30, 111, 200,0.8)',
      color: 'white',
      border: '1px rgb(70, 91, 117) solid',
    }" :row-key="(row, index) => index" :data="tableData" style="width: 100%">
        <el-table-column prop="company" label="品牌">
        </el-table-column>
        <el-table-column prop="dymb" sortable label="当月目标">
        </el-table-column>
        <el-table-column prop="drxl" sortable label="当日销量">
        </el-table-column>
        <el-table-column prop="drtj" sortable label="当日台均">
        </el-table-column>
        <el-table-column prop="ylxl" sortable label="月累销量">
        </el-table-column>
        <el-table-column prop="yltj" sortable label="月累台均">
        </el-table-column>
        <el-table-column prop="syzytjml" sortable width="160" label="上月整月台均毛利">
        </el-table-column>
        <el-table-column prop="hb" sortable label="环比">
        </el-table-column>
        <el-table-column prop="tb" sortable label="同比">
        </el-table-column>
        <el-table-column prop="yltj1" sortable label="月累台均一级毛利(进销存)">
        </el-table-column>
        <el-table-column prop="yltj2" sortable label="月累台均二级毛利(返利政策)">
        </el-table-column>
        <el-table-column prop="yltj3" sortable label="月累台均三级毛利(衍生业务)">
        </el-table-column>
      </el-table></div>
  </div>
</template>
<script>
import { column } from "./tuozhuai";
import { monthlytabledataInfo } from "../../../servuces/prove";
import { nowdate } from "../../../servuces/getnowtime";
export default {
  data () {
    return {
      taheight: window.innerHeight - (window.innerHeight * 0.15),
      tableData: [],
      options: [],
      value: '',
      value2: '',
      activeName: 'second'
    }
  },
  created () {
    const data = sessionStorage.getItem('data')
    console.log(data);
    if (data) {
      this.options = JSON.parse(data)
    }
  },
  mounted () {
    column(this)
    this.monthlytabledataapi()
  },
  methods: {
    chaxun2 (value, value2) {
      const strvalue = value.join(',')
      const date = new Date(value2)
      // 获取年份和月份
      const year = date.getFullYear();
      const month = date.getMonth() + 1; // 月份从0开始，需要加1
      const day = date.getDate()
      // 将年份和月份拼接成所需形式的字符串
      const strvalue1 = `${year}-${month}-${day}`;
      monthlytabledataInfo({ "company_ids": strvalue, "search_date": strvalue1 }).then(res => {
        // console.log('查询分期业务', res);
        this.tableData = res.data
        // this.tableDatahj = res.footer
      }
      )
      console.log(strvalue, strvalue1);
    },
    monthlytabledataapi () {
      this.value2 = nowdate
      monthlytabledataInfo({ "company_ids": '', "search_date": nowdate }).then(res => {
        // console.log('三级毛利', res);
        this.tableData = res.data
      })
    }
  }
}
</script>
<style>
/* .el-table tr {
  background-color: none;
  color: white;
} */
.el-table .warning-row {
  background-color: rgba(15, 78, 146, 0.827);

}

.el-table .success-row {
  background-color: rgb(15, 78, 146, 0.5);
}

.has-gutter tr th:last-child {
  background-color: rgba(30, 111, 200, 0.8);
}

.el-table tr {
  background-color: rgb(15, 78, 146, 0.5);
}
</style>
<style scoped lang="scss">
.JCDetails {
  .selec {
    margin: 0 0 20px 0;
  }
}

::v-deep .el-table {
  background-color: transparent;
  border-color: rgb(70, 91, 117);
}

::v-deep .el-table td,
.building-top .el-table th.is-leaf {
  border-color: rgb(70, 91, 117);
  color: white;
}

::v-deep .el-table td:hover {
  color: rgb(5, 51, 159);
}

::v-deep .has-gutter th {
  border-color: rgb(70, 91, 117);
}

::v-deep .el-table--enable-row-hover .el-table__body tr:hover>td {
  background-color: rgb(58, 147, 189);
}

::v-deep #tab-first,
::v-deep #tab-second,
::v-deep #tab-third,
::v-deep #tab-fourth {
  color: #fff; //设置修改默认蚊子颜色，背景颜色，等
}

::v-deep .el-tabs__item.is-active {
  color: rgb(37, 99, 214) !important;
}
</style>



