<template>
  <div class="JCDetails" style="padding:0 50px;">

    <h1>售后收入明细</h1>
    <!-- <div class="topbox">
      <div class="selec">
        <el-select v-model="value" clearable placeholder="请选择">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </div>
      <div class="timeselec">

      </div>
    </div> -->
    <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="value1" type="month" placeholder="选择日期">
        </el-date-picker>
      </div>
      <button class="ershi" style="width: 100px;height: 40px;background-color: aqua;"
        @click="chaxun(value, value1)">查询</button>
    </div>
    <div> <el-table ref="table" show-summary :height="taheight" :summary-method="getSummaries" :header-cell-style="{
      background: 'rgba(30, 111, 200,0.8)',
      color: 'white',
      textAlign: 'center',
      border: '1px rgb(70, 91, 117) solid',
    }" :data="tableData" style="width: 100%">
        <el-table-column prop="name" fixed label="店面" width="100">
        </el-table-column>
        <el-table-column label="产值">
          <el-table-column prop="mbcz" sortable label="目标">
          </el-table-column>
          <el-table-column prop="sjcz" sortable width="110" label="实际达成">
          </el-table-column>
          <el-table-column prop="czwcl" sortable label="完成率">
          </el-table-column>
          <el-table-column prop="cztb" sortable label="同比">
          </el-table-column>
          <el-table-column prop="czhb" sortable label="环比">
          </el-table-column>

        </el-table-column>
        <el-table-column label="产值分类">
          <el-table-column prop="jdmb" sortable width="110" label="机电目标">
          </el-table-column>
          <el-table-column prop="jdsj" sortable width="110" label="实际达成">
          </el-table-column>
          <el-table-column prop="spmb" sortable width="110" label="索赔目标">
          </el-table-column>
          <el-table-column prop="spsj" sortable width="110" label="实际达成">
          </el-table-column>
          <el-table-column prop="bpmb" sortable width="110" label="钣喷目标">
          </el-table-column>
          <el-table-column prop="bpsj" sortable width="110" label="实际达成">
          </el-table-column>
        </el-table-column>
        <el-table-column label="毛利率">
          <el-table-column prop="jdmlv" sortable width="120" label="机电毛利率">
          </el-table-column>
          <el-table-column prop="spmlv" sortable width="120" label="索赔毛利率">
          </el-table-column>
          <el-table-column prop="bpmlv" sortable width="120" label="钣喷毛利率">
          </el-table-column>
          <el-table-column prop="zhmlv" sortable width="120" label="综合毛利率">
          </el-table-column>
          <el-table-column prop="mlvhb" sortable label="环比">
          </el-table-column>
          <el-table-column prop="mlvtb" sortable label="同比">
          </el-table-column>
        </el-table-column>
        <el-table-column label="客单价">
          <el-table-column prop="jxkdj" sortable width="120" label="机修客单价">
          </el-table-column>
          <el-table-column prop="bpkdj" sortable width="120" label="钣喷客单价">
          </el-table-column>
        </el-table-column>


      </el-table></div>


  </div>
</template>
<script>
import { column } from "./tuozhuai";
import { rccztabledataInfo } from "../../../servuces/prove";
import { nowmonthy } from "../../../servuces/getnowtime";
export default {
  data () {
    return {
      tableData: [],
      taheight: window.innerHeight - (window.innerHeight * 0.15),
      tableDatahj: [],
      options: [],
      value: '',
      value1: '',
      activeName: 'second'
    }
  },
  //获取公司
  created () {
    const data = sessionStorage.getItem('data')
    // console.log(data);
    if (data) {
      this.options = JSON.parse(data)
    }
  },
  mounted () {
    column(this)
    this.rccztabledataapi()
  },
  updated () {

    this.$nextTick(() => {
      this.$refs.table.doLayout()
    })
  },
  methods: {
    chaxun (value, value1) {
      const strvalue = value.join(',')
      const date = new Date(value1)
      // 获取年份和月份
      const year = date.getFullYear();
      const month = date.getMonth() + 1; // 月份从0开始，需要加1

      // 将年份和月份拼接成所需形式的字符串
      const strvalue1 = `${year}-${month}`;
      rccztabledataInfo({ "company_ids": strvalue, "search_month": strvalue1 }).then(res => {
        console.log('入场产值', res);
        this.tableData = res.data
        this.tableDatahj = res.footer
      }
      )
      // console.log(strvalue, strvalue1);
    },
    getSummaries () {
      const keyindex = {
        'company': 0,
        'mbcz': 1,
        'sjcz': 2,
        'czwcl': 3,
        'cztb': 4,
        'czhb': 5,
        'jdmb': 6,
        'jdsj': 7,
        'spmb': 8,
        'spsj': 9,
        'bpmb': 10,
        'bpsj': 11,
        'jdmlv': 12,
        'spmlv': 13,
        'bpmlv': 14,
        'zhmlv': 15,
        'mlvhb': 16,
        'mlvtb': 17,
        'jxkdj': 18,
        'bpkdj': 19,
      }
      const item_value = []
      for (let key in this.tableDatahj) {
        let index = keyindex[key]
        item_value[index] = this.tableDatahj[key] + ''
      }
      // console.log(item_value);
      item_value[0] = '合计'
      return item_value
    },
    rccztabledataapi () {
      this.value1 = nowmonthy
      rccztabledataInfo({ "company_ids": '', "search_month": nowmonthy }).then(res => {
        this.tableData = res.data
        this.tableDatahj = res.footer
        console.log('入场产值', res);
      })
    }
  }
}
</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__footer {
  border: none;

  tr {
    border: none;

    td {
      color: white;
      background-color: rgba(30, 111, 200, 0.8);
    }

    td:hover {
      color: white;
    }
  }

}



::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 .el-table__body tr.hover-row>td.el-table__cell {
  background-color: rgb(58, 147, 189) !important;
}

::v-deep .gutter {
  background-color: rgba(30, 111, 200, 0.8) !important;
  border: 0 !important;
}

::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>
