<template>
  <div class="JCDetails" style="padding: 50px;">
    <!-- <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="width: 50%;"></div>
      <div class="selec">
        <el-select v-model="value" filterable multiple collapse-tags clearable placeholder="请选择">
          <el-option v-for="(item, index) in options" :key="index" :label="item.text" :value="item.value">
          </el-option>
        </el-select>
      </div>
      <div class="timeselec">
        <el-date-picker v-model="value1" type="daterange" range-separator="至" start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </div>
      <button style="width: 100px;height: 40px;background-color: aqua;" @click="chaxun2(value, value1)">查询</button>
    </div>
    <div> <el-table show-summary :summary-method="getSummaries" :header-cell-style="{
      background: 'rgba(30, 111, 200,0.8)',
      color: 'white',
      border: '1px rgb(70, 91, 117) solid',
    }" :data="tableData" style="width: 100%">
        <el-table-column prop="name" label="店名" width="150">
        </el-table-column>
        <el-table-column header-align="center" label="平安保险">
          <el-table-column prop="paxbds" label="新保单数">
          </el-table-column>
          <el-table-column prop="paxbje" label="新保金额">
          </el-table-column>
          <el-table-column prop="pazbds" label="续保单数">
          </el-table-column>
          <el-table-column prop="pazbje" label="续保金额">
          </el-table-column>
          <el-table-column prop="pazje" width="100" label="总承包金额">
          </el-table-column>

        </el-table-column>
        <el-table-column header-align="center" label="人寿保险">
          <el-table-column prop="rsxbds" label="新保单数">
          </el-table-column>
          <el-table-column prop="rsxbje" label="新保金额">
          </el-table-column>
          <el-table-column prop="rszbds" label="续保单数">
          </el-table-column>
          <el-table-column prop="rszbje" label="续保金额">
          </el-table-column>
          <el-table-column prop="rszje" label="总承包金额">
          </el-table-column>

        </el-table-column>
        <el-table-column header-align="center" label="人保保险">
          <el-table-column prop="rbxbds" label="新保单数">
          </el-table-column>
          <el-table-column prop="rbxbje" label="新保金额">
          </el-table-column>
          <el-table-column prop="rbzbds" label="续保单数">
          </el-table-column>
          <el-table-column prop="rbzbje" label="续保金额">
          </el-table-column>
          <el-table-column prop="rbzje" label="总承包金额">
          </el-table-column>

        </el-table-column>
        <el-table-column header-align="center" label="太平洋保险">
          <el-table-column prop="tpyxbds" label="新保单数">
          </el-table-column>
          <el-table-column prop="tpyxbje" label="新保金额">
          </el-table-column>
          <el-table-column prop="tpyzbds" label="续保单数">
          </el-table-column>
          <el-table-column prop="tpyzbje" label="续保金额">
          </el-table-column>
          <el-table-column prop="tpyzje" label="总承包金额">
          </el-table-column>

        </el-table-column>
        <el-table-column header-align="center" label="其他保险">
          <el-table-column prop="qtxbds" label="新保单数">
          </el-table-column>
          <el-table-column prop="qtxbje" label="新保金额">
          </el-table-column>
          <el-table-column prop="qtzbds" label="续保单数">
          </el-table-column>
          <el-table-column prop="qtzbje" label="续保金额">
          </el-table-column>
          <el-table-column prop="qtzje" label="总承包金额">
          </el-table-column>
        </el-table-column>


      </el-table></div>
  </div>
</template>
<script>
import { column } from "./tuozhuai";
import { bxcbhbtabledataInfo } from "../../../servuces/prove";
import { nowdaterange } from "../../../servuces/getnowtime";
export default {
  data () {
    return {
      tableData: [],
      tableDatahj: [],
      options: [],
      value: '',
      value1: '',
      activeName: 'second'
    }
  },
  created () {
    const data = sessionStorage.getItem('data')
    console.log(data);
    if (data) {
      this.options = JSON.parse(data)
    }
  },
  mounted () {
    this.bxcbhbtabledataapi()
    column(this.tableData)
  },
  methods: {
    getSummaries () {
      const keyindex = {
        'company': 0,
        'paxbds': 1,
        'paxbje': 2,
        'pazbds': 3,
        'pazbje': 4,
        'pazje': 5,
        'rsxbds': 6,
        'rsxbje': 7,
        'rszbds': 8,
        'rszbje': 9,
        'rszje': 10,
        'rbxbds': 11,
        'rbxbje': 12,
        'rbzbds': 13,
        'rbzbje': 14,
        'rbzje': 15,
        'tpyxbds': 16,
        'tpyxbje': 17,
        'tpyzbds': 18,
        'tpyzbje': 19,
        'tpyzje': 20,
        'qtxbds': 21,
        'qtxbje': 22,
        'qtzbds': 23,
        'qtzbje': 24,
        'qtzje': 25,

      }
      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
    },
    chaxun2 (value, value1) {
      const strvalue = value.join(',')
      if (value1) {
        const strvaluezh = value1.map(item => {
          const date = new Date(item)
          // 获取年份和月份
          const year = date.getFullYear();
          const month = date.getMonth() + 1; // 月份从0开始，需要加1
          const day = date.getDate()
          // 将年份和月份拼接成所需形式的字符串
          return `${year}-${month}-${day}`;
        });
        bxcbhbtabledataInfo({ "company_ids": strvalue, "date_begin": strvaluezh[0], 'date_end': strvaluezh[1] }).then(res => {
          // console.log('查询分期业务', res);
          this.tableData = res.data
          this.tableDatahj = res.footer
          console.log(res);
        }
        )
      } else {
        bxcbhbtabledataInfo({ "company_ids": strvalue, "date_begin": '', 'date_end': '' }).then(res => {
          // console.log('查询分期业务', res);
          this.tableData = res.data
          this.tableDatahj = res.footer
          // console.log(res);
        }
        )
      }
    },
    //接口数据
    bxcbhbtabledataapi () {
      this.value1 = nowdaterange
      bxcbhbtabledataInfo({ "company_ids": strvalue, "date_begin": nowdaterange[0], 'date_end': nowdaterange[1] }).then(res => {
        console.log('保险承保table数据', res);
        this.tableData = res.data
        this.tableDatahj = res.footer
      })
    },
  }
}
</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-wrapper {
  margin: 0;
}

::v-deep .el-table__footer {
  // margin: 0;
  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 #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>



