<!--
 * @Descripttion:
 * @version:
 * @Author: kBank
 * @Date: 2022-10-24 15:45:01
-->
<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :top-list="topList"
      :moren="moren"
    />
    <div class="main">
      <el-form
        ref="select"
        :model="select"
        style="padding:0 10px 0 0"
        label-width="80px"
      >
        <el-row>
          <!-- <el-col :span="4">
            <el-form-item :label="'币种展示'">
              <el-select clearable
                         :placeholder="'请选择'"
                         v-model="select.websiteType">
                <el-option v-for="item in acList"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->

          <el-col :span="8">
            <el-form-item :label="'业绩时间'">
              <el-date-picker
                v-model="creationTime"
                value-format="yyyy-MM-dd"
                type="daterange"
                :range-separator="'至'"
                :start-placeholder="'开始日期'"
                :end-placeholder="'结束日期'"
                @change="changeTime"
                @clear="clearTime"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'隶属体系'">
              <el-cascader
                v-model="select.pkBdVertexStred"
                :options="verList"
                :props="props"
                collapse-tags
                clearable
                @change="getPkBdVertexStr"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- <el-row>
          <el-col>
            <el-form-item :label="'隶属体系'">
              <el-checkbox-group v-model="select.pkVertexList" @change="getTeamList">
                <el-checkbox v-for="item in verList"
                             :key="item.pkId"
                             :value="item.pkId"
                             :label="item.pkId">{{ item.vertexName }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row> -->
        <!-- <el-row>
          <el-col>
            <el-form-item :label="'隶属团队'" style="margin-top: -10px">
              <el-checkbox-group v-model="select.pkMemberTeamList" @change="getTeam">
                <el-checkbox v-for="item in memberList"
                             :key="item.pkId"
                             :value="item.pkId"
                             :label="item.pkId">{{ item.teamName }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row> -->
        <el-row style="margin-left:20px">
          <el-col :span="4">
            <el-button
              type="primary"
              @click="getDataList"
            > {{ '搜索' }}</el-button>
            <el-button
              type="primary"
              @click="reset"
            > {{ '重置' }}</el-button>
          </el-col>
        </el-row>
      </el-form>
      <div class="maintop">
        <div class="mainbtn">
          <el-button
            v-hasButtons="['performanceChartExport']"
            size="small"
            class="thebtn2"
            @click="handleExport"
          > {{ '导出' }}</el-button>
        </div>

      </div>
      <div class="maintable">
        <div
          v-for="item in tableData"
          :key="item.pkId"
          class="maintable_i"
        >
          <div class="maintable_l">
            <div class="maintable_lt">
              <div class="maintable_ltt bg">
                <div>{{ '注册专区' }}(￥)</div>
                <div>{{ '升级专区' }}(￥)</div>
                <div>{{ '云代注册' }}(￥)</div>
                <div>{{ '云代升级' }}(￥)</div>
                <div>{{ '首购金额' }}(￥)</div>

                <div>{{ '直推收益' }}(￥)</div>
                <div>{{ '拓展收益' }}(￥)</div>
                <div>{{ '辅导收益' }}(￥)</div>
                <div>{{ '分红收益' }}(￥)</div>
                <div>{{ '服务补贴' }}(￥)</div>
                <div>{{ '云代直推' }}(￥)</div>
                <div>{{ '云代首购' }}(￥)</div>
                <div>{{ '云代复购' }}(￥)</div>
                <div>{{ '首购拨出比例' }}(%)</div>
              </div>
              <div class="maintable_ltt">
                <div>{{ item.mainRegAmount }}</div>
                <div>{{ item.mainUpAmount }}</div>
                <div>{{ item.agentRegAmount }}</div>
                <div>{{ item.agentUpAmount }}</div>
                <div>{{ item.firstPurchaseAll }}</div>
                <div class="t4">
                  <div class="t4t">
                    <div>{{ item.introduceBonus }}</div>
                    <div>{{ item.orgBonus }}</div>
                    <div>{{ item.leaderBonus }}</div>
                    <div>{{ item.shareBonus }}</div>
                    <div>{{ item.serviceBonus }}</div>
                    <div>{{ item.agentIntroduceBonus }}</div>
                    <div>{{ item.agentFirstAmount }}</div>
                    <div>{{ item.agentRepurAmount }}</div>
                    <div>{{ item.mainBonus }}</div>
                  </div>
                  <div class="xian1" />
                  <div class="t4t">
                    <div>{{ item.introduceBonusRate }}</div>
                    <div>{{ item.orgBonusRate }}</div>
                    <div>{{ item.leaderBonusRate }}</div>
                    <div>{{ item.shareBonusRate }}</div>
                    <div>{{ item.serviceBonusRate }}</div>
                    <div>{{ item.agentIntroduceBonus }}</div>
                    <div>{{ item.agentFirstAmountRate }}</div>
                    <div>{{ item.agentRepurAmountRate }}</div>
                    <div>{{ item.mainBonusRate }}</div>
                  </div>
                </div>
              </div>
            </div>
            <div class="maintable_lt">
              <div class="maintable_ltt1 bg">
                <div>{{ '复购专区' }}(￥)</div>
                <div>{{ '海粉专区' }}(￥)</div>
                <div>{{ '云代复购' }}(￥)</div>
                <div class="t1">{{ '复购金额' }}(￥)</div>
                <div class="t2">{{ '复购级差收益' }}(￥)</div>
                <div class="t3">{{ '复购拓展收益' }}(￥)</div>
                <div>{{ '复购拨出比例' }}(%)</div>
              </div>
              <div class="maintable_ltt1">
                <div>{{ item.mainRepurAmount }}</div>
                <div>{{ item.hifansRegAmount }}</div>
                <div>{{ item.agentRepurAmount }}</div>
                <div class="t1">{{ item.repurchaseAllAmount }}</div>
                <div class="t5">
                  <div class="t5t">
                    <div class="t2">{{ item.repurRangeBonus }}</div>
                    <div class="t3">{{ item.repurOrgBonus }}</div>
                    <div>{{ item.repurBonus }}</div>
                  </div>
                  <div class="xian1" />
                  <div class="t5t">
                    <div class="t2">{{ item.repurRangeBonusRate }}</div>
                    <div class="t3">{{ item.repurOrgBonusRate }}</div>
                    <div>{{ item.repurBonusRate }}</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="maintable_r">
            <div class="maintable_rt bg">
              <div>{{ '总拨出金额' }}(￥)</div>
              <div>{{ '总拨出比例' }}(%)</div>
              <div>{{ '业绩时间' }}</div>
            </div>
            <div class="maintable_rt1">
              <div>{{ item.totalBonus }}</div>
              <div>{{ item.totalBonusRate }}</div>
              <div>{{ item.creationTime }}</div>
            </div>
          </div>
        </div>
      </div>
      <el-divider>
        <div class="hj">合计</div>
      </el-divider>
      <!-- 合计 -->
      <div class="maintable1">
        <div class="maintable_i">
          <div class="maintable_l">
            <div class="maintable_lt">
              <div class="maintable_ltt bg">
                <div>{{ '注册专区' }}(￥)</div>
                <div>{{ '升级专区' }}(￥)</div>
                <div>{{ '云代注册' }}(￥)</div>
                <div>{{ '云代升级' }}(￥)</div>
                <div>{{ '首购金额' }}(￥)</div>

                <div>{{ '直推收益' }}(￥)</div>
                <div>{{ '拓展收益' }}(￥)</div>
                <div>{{ '辅导收益' }}(￥)</div>
                <div>{{ '分红收益' }}(￥)</div>
                <div>{{ '服务补贴' }}(￥)</div>
                <div>{{ '云代直推' }}(￥)</div>
                <div>{{ '云代首购' }}(￥)</div>
                <div>{{ '云代复购' }}(￥)</div>
                <div>{{ '首购拨出比例' }}(%)</div>
              </div>
              <div class="maintable_ltt">
                <div>{{ tableObj.mainRegAmountSum }}</div>
                <div>{{ tableObj.mainUpAmountSum }}</div>
                <div>{{ tableObj.agentRegAmountSum }}</div>
                <div>{{ tableObj.agentUpAmountSum }}</div>
                <div>{{ tableObj.firstPurchaseAllSum }}</div>
                <div class="t4">
                  <div class="t4t">
                    <div>{{ tableObj.introduceBonusSum }}</div>
                    <div>{{ tableObj.orgBonusSum }}</div>
                    <div>{{ tableObj.leaderBonusSum }}</div>
                    <div>{{ tableObj.shareBonusSum }}</div>
                    <div>{{ tableObj.serviceBonusSum }}</div>
                    <div>{{ tableObj.agentIntroduceBonusSum }}</div>
                    <div>{{ tableObj.agentFirstAmountSum }}</div>
                    <div>{{ tableObj.agentRepurAmountSum }}</div>
                    <div>{{ tableObj.mainBonusSum }}</div>
                  </div>
                  <div class="xian1" />
                  <div class="t4t">
                    <div>{{ tableObj.introduceBonusRateSum }}</div>
                    <div>{{ tableObj.orgBonusRateSum }}</div>
                    <div>{{ tableObj.leaderBonusRateSum }}</div>
                    <div>{{ tableObj.shareBonusRateSum }}</div>
                    <div>{{ tableObj.serviceBonusRateSum }}</div>
                    <div>{{ tableObj.agentIntroduceBonusSum }}</div>
                    <div>{{ tableObj.agentFirstAmountRateSum }}</div>
                    <div>{{ tableObj.agentRepurAmountRateSum }}</div>
                    <div>{{ tableObj.mainBonusRateSum }}</div>
                  </div>
                </div>
              </div>
            </div>
            <div class="maintable_lt">
              <div class="maintable_ltt1 bg">
                <div>{{ '复购专区' }}(￥)</div>
                <div>{{ '海粉专区' }}(￥)</div>
                <div>{{ '云代复购' }}(￥)</div>
                <div class="t1">{{ '复购金额' }}(￥)</div>
                <div class="t2">{{ '复购级差收益' }}(￥)</div>
                <div class="t3">{{ '复购拓展收益' }}(￥)</div>
                <div>{{ '复购拨出比例' }}(%)</div>
              </div>
              <div class="maintable_ltt1">
                <div>{{ tableObj.mainRepurAmountSum }}</div>
                <div>{{ tableObj.hifansRegAmountSum }}</div>
                <div>{{ tableObj.agentRepurAmountSum }}</div>
                <div class="t1">{{ tableObj.repurchaseAllAmountSum }}</div>
                <div class="t5">
                  <div class="t5t">
                    <div class="t2">{{ tableObj.repurRangeBonusSum }}</div>
                    <div class="t3">{{ tableObj.repurOrgBonusSum }}</div>
                    <div>{{ tableObj.repurBonusSum }}</div>
                  </div>
                  <div class="xian1" />
                  <div class="t5t">
                    <div class="t2">{{ tableObj.repurRangeBonusRateSum }}</div>
                    <div class="t3">{{ tableObj.repurOrgBonusRateSum }}</div>
                    <div>{{ tableObj.repurBonusRateSum }}</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="maintable_r">
            <div class="maintable_rt bg">
              <div>{{ '总拨出金额' }}(￥)</div>
              <div>{{ '总拨出比例' }}(%)</div>
              <!-- <div>{{ '创建时间' }}</div> -->
            </div>
            <div class="maintable_rt1">
              <div>{{ tableObj.totalBonusSum }}</div>
              <div>{{ tableObj.totalBonusRateSum }}</div>
              <!-- <div>{{ tableObj.creationTimeSum }}</div> -->
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import topBar from '@/components/topBarRole'
import * as api from '@/api/settle.js'
import { classifyUpdate, classifySave } from '@/api/product'
import { getRouters } from '@/api/settle.js'
import { isOther } from '@/utils/numberToCurrency'

// import { getTeamList } from '@/api/affiliatedteam';
export default {
  name: 'Bzpz',
  components: {
    topBar
  },
  filters: {
    isAgree(val) {
      if (!val) {
        return '允许'
      } else {
        return '禁止'
      }
    }
  },
  data() {
    return {
      creationTime: [],
      creationTime1: [],
      select: {
        pkVertexList: [],
        pkMemberTeamList: []
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50
      },
      addOrEdit: '',
      total: 0,
      dialogVisible: false,
      tableData: [],
      moren: '/settlementCenter/performanceChart',
      topList: [
        {
          name: '拨比图型',
          path: '/settlementCenter/performanceRatio',
          url: 'performanceRatio',
          changed: false
        },
        {
          name: '拨比图表',
          path: '/settlementCenter/performanceChart',
          url: 'performanceChart',
          changed: false
        },
        {
          name: '拨比列表',
          path: '/settlementCenter/performanceList',
          url: 'performanceList',
          changed: false
        }
        // {
        //   name: '个人伞下拨比查询',
        //   path: "/settlementCenter/personalAllocation",
        //   url: "PersonalAllocation",
        //   changed: false,
        // },
      ],
      form: {},
      verList: [],
      memberList: [],
      acList: [],
      tableObj: {},
      props: {
        multiple: true,
        expandTrigger: 'hover',
        value: 'pkId',
        label: 'vertexName',
        children: 'childList'
      }
    }
  },
  mounted() {
    // 获取下拉
    this.getData()
    // 获取列表
    this.getDataList()
    this.getUserRoute()
    // this.getTeamList()
  },
  methods: {
    clearTime() {
      this.select.startDate = []
      this.select.endDate = []
    },
    getPkBdVertexStr(e) {
      const arr = e.map((item) => item[1])
      const pkBdVertexStr = arr.join(',')
      this.$set(this.select, 'pkBdVertexStr', pkBdVertexStr)
    },
    isOther,
    getUserRoute() {
      getRouters().then((res) => {
        res.data.forEach((item) => {
          this.topList.forEach((items) => {
            if (item.routeName == items.url) {
              items.changed = true
            }
          })
        })
      })
    },
    reset() {
      this.select = {
        pkVertexList: [],
        pkMemberTeamList: []
      }
      this.creationTime = []
      // 获取列表
      this.getDataList()
    },
    getMenu(e, id) {
      if (e && id == 0) {
        this.menuList.forEach((item) => {
          this.$set(item, 'checked', true)
        })
      } else if (!e && id == 0) {
        this.menuList.forEach((item) => {
          this.$set(item, 'checked', false)
        })
      }
    },
    getData() {
      api.currencyType().then((res) => {
        this.acList = res.data
      })
      api.vertexChild().then((res) => {
        this.verList = res.data
      })
    },
    getTeamList() {
      const pkBdVertexStr = this.select.pkVertexList.join(',')
      this.$set(this.select, 'pkBdVertexStr', pkBdVertexStr)
      // api.listNoPage({
      //   pkBdVertexList:this.select.pkVertexList
      // }).then((res) => {
      //   this.memberList = res.rows
      // })
    },
    getTeam() {
      const pkTeamCodeStr = this.select.pkMemberTeamList.join(',')
      this.$set(this.select, 'pkTeamCodeStr', pkTeamCodeStr)
    },
    changeTime(val) {
      this.select.startDate = val ? val[0] : ''
      this.select.endDate = val ? val[1] : ''
    },
    getDataList() {
      api
        .bonusListChart(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          if (res.code == 200) {
            this.tableData = res.rows
            this.total = res.total
            api.bonusListChartSum(Object.assign({}, this.queryParams, this.select)).then(response => {
              if (res.code == 200) {
                this.tableObj = response.data || {}
              }
            })
          }
        })
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then((_) => {
        this.download(
          '/member/manage/bonus-statis/exportChart',
          Object.assign({}, this.queryParams, this.select),
          `拨比图表-${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%;
}
.uploadIcon ::v-deep .el-upload--picture-card {
  display: none !important; /* 上传按钮隐藏 */
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    .maintop {
      display: flex;
      padding: 10px 20px;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          background: #3181e5;
          color: #ffffff;
        }
        .thebtn2 {
          background: #ffad41;
          color: #ffffff;
        }
      }
      .maintitle {
        font-size: 10px;
        font-family: MicrosoftYaHei;
        color: #999999;
      }
    }
  }
  .tem {
    display: flex;
    align-items: center;
    justify-content: center;
    img {
      width: 28px;
      height: 20px;
      margin-right: 3px;
    }
  }
  .isRed {
    color: #ed1d25;
  }
  .isGreen {
    color: #1ab62b;
  }
  .bgImg {
    width: 48px;
    height: 48px;
  }
}
.openClose {
  text-align: right;
  margin-right: 10px;
  color: #3181e5;
}
.kuang {
  padding: 5px 20px;
  background: rgba(255, 255, 255, 0);
  border-radius: 4px;
  border: 1px solid #cccccc;
}
.heji {
  margin-top: 10px;
  .dis {
    display: flex;
    justify-content: right;
    padding: 5px 10px;
    font-size: 14px;
    color: #333333;
    :nth-child(1) {
      font-size: 14px;
      font-weight: bold;
      color: #333333;
      margin-right: 20px;
    }
  }
}
.maintable {

  overflow-x: auto;
  height: 380px;
  .maintable_i {
    display: flex;
    // align-items: center;
  }
  .bg {
    background: #eeeeee;
    box-shadow: 0px 2px 20px 0px rgba(204, 204, 204, 0.3);
  }
  .maintable_ltt {
    display: flex;
    align-items: center;
    padding: 10px 0;
    div {
      width: 120px;
      text-align: center;
    }
    .t4 {
      width: 1080px;
      text-align: center;
      .xian1 {
        height: 1px;
        background: #cccccc;
        width: 100%;
        margin: 10px 0;
      }
      .t4t {
        display: flex;
        width: 100%;
        div {
          width: 120px;
          text-align: center;
        }
      }
    }
  }
  .maintable_ltt1 {
    display: flex;
    align-items: center;
    padding: 10px 0;
    div {
      width: 120px;
      text-align: center;
    }
    .t1 {
      width: 360px;
    }
    .t2 {
      width: 240px;
    }
    .t3 {
      width: 600px;
    }
    .t5 {
      width: 960px;
      text-align: center;
      .xian1 {
        height: 1px;
        background: #cccccc;
        width: 100%;
        margin: 10px 0;
      }
      .t5t {
        display: flex;
        width: 100%;
      }
    }
  }
  .maintable_rt {
    display: flex;
    padding: 10px 0;
    div {
      width: 120px;
      text-align: center;
    }
  }
  .maintable_r{
    display: flex;
    flex-direction: column;
  }
  .maintable_rt1 {
    display: flex;
    // padding: 50px 0;
    flex: 1;
    display: flex;
    align-items: center;
    div {
      width: 120px;
      text-align: center;
    }
  }
}
.maintable1 {
  overflow-x: auto;
  height: 240px;
  .maintable_i {
    display: flex;
    // align-items: center;
  }
  .bg {
    background: #eeeeee;
    box-shadow: 0px 2px 20px 0px rgba(204, 204, 204, 0.3);
  }
  .maintable_ltt {
    display: flex;
    align-items: center;
    padding: 10px 0;
    div {
      width: 120px;
      text-align: center;
    }
    .t4 {
      width: 1080px;
      text-align: center;
      .xian1 {
        height: 1px;
        background: #cccccc;
        width: 100%;
        margin: 10px 0;
      }
      .t4t {
        display: flex;
        width: 100%;
        div {
          width: 120px;
          text-align: center;
        }
      }
    }
  }
  .maintable_ltt1 {
    display: flex;
    align-items: center;
    padding: 10px 0;
    div {
      width: 120px;
      text-align: center;
    }
    .t1 {
      width: 360px;
    }
    .t2 {
      width: 240px;
    }
    .t3 {
      width: 600px;
    }
    .t5 {
      width: 960px;
      text-align: center;
      .xian1 {
        height: 1px;
        background: #cccccc;
        width: 100%;
        margin: 10px 0;
      }
      .t5t {
        display: flex;
        width: 100%;
      }
    }
  }
  .maintable_rt {
    display: flex;
    padding: 10px 0;
    div {
      width: 120px;
      text-align: center;
    }
  }
  .maintable_r{
    display: flex;
    flex-direction: column;
  }
  .maintable_rt1 {
    display: flex;
    // padding: 50px 0;
    flex: 1;
    display: flex;
    align-items: center;
    div {
      width: 120px;
      text-align: center;
    }
  }
}
.hj{
  font-size: 25px;
}
::v-deep .el-date-editor--daterange,
.el-cascader {
  width: 100%;
}
::v-deep .el-input__suffix {
  top: -3px;
}
</style>

