<!--
 * @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: 0px 10px 0px 0; background: #fff"
        label-width="auto"
      >
        <el-row :gutter="20">
          <!-- 一层 -->
          <el-col :span="4">
            <el-form-item :label="'结算期数'">
              <div style="display: flex">
                <div>
                  <el-input v-model="select.period" clearable />
                </div>
                <!--                <span style="margin: 0 10px">至</span>-->
                <!--                <div>-->
                <!--                  <el-input v-model="select.endPeriod" clearable />-->
                <!--                </div>-->
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'币种展示'">
              <el-select v-model="select.pkCurrency" clearable placeholder="">
                <el-option
                  v-for="item in acList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </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"
                format="yyyy-MM-dd"
                :range-separator="'至'"
                :start-placeholder="'开始日期'"
                :end-placeholder="'结束日期'"
                @change="changeTime"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'隶属体系'">
              <el-cascader
                :options="verList"
                v-model="select.pkBdVertexStred"
                @change="getPkBdVertexStr"
                :props="props"
                collapse-tags
                clearable
              ></el-cascader>
            </el-form-item>
          </el-col>
          <!-- <el-row>
          <el-col>
            <el-form-item :label="'隶属体系'" style="margin-top: -5px">
              <el-checkbox-group v-model="pkVertex">
                <el-checkbox
                  v-for="item in verList"
                  :key="item.value"
                  :value="item.pkId"
                  :label="item.vertexName"
                  @change="vertCheck($event,item)"
                />
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row> -->
          <!-- <el-row>
          <el-col>
            <el-form-item :label="'隶属团队'" style="margin-top: -15px">
              <el-checkbox-group v-model="pkMemberTeam">
                <el-checkbox
                  v-for="item in memberList"
                  :key="item.value"
                  :value="item.pkId"
                  :label="item.teamName"
                  @change="teamCheck($event,item)"
                />
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row> -->
          <el-col :span="4">
            <el-button type="primary" class="my_search" @click="getDataList">
              {{ '搜索' }}</el-button
            >
            <el-button
              style="margin-left: 20px"
              class="my_reset"
              @click="reset"
            >
              {{ '重置' }}</el-button
            >
          </el-col>
        </el-row>
      </el-form>
      <div class="maintop">
        <div class="mainbtn">
          <el-button
            size="small"
            class="thebtn2"
            @click="exports"
            v-has-buttons="['totalBonusExport']"
          >
            {{ '导出' }}</el-button
          >
        </div>
        <!-- <div>
          <el-dropdown :hide-on-click="false">
            <span class="el-dropdown-link kuang">
              {{'筛选字段'}}<i class="el-icon-arrow-down el-icon--right" />
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                v-for="item in menuList"
                :key="item.id"
              >
                <el-checkbox
                  v-model="item.checked"
                  @change="getMenu($event,item.id)"
                >{{ item.text }}</el-checkbox>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div> -->
      </div>
      <div class="maintable">
        <div>
          <el-table
            :data="tableData.censusSummaryList"
            v-loading="loading"
            height="610px"
            style="width: 100%"
            :header-cell-style="{ background: '#EEEEEE' }"
            :row-class-name="tableRowClassName"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55" />
            <el-table-column
              align="center"
              prop="period"
              width="130"
              :label="'结算期数'"
            />
            <el-table-column
              align="center"
              prop="retailRangeIncomeOri"
              width="130"
              :label="$t('极差收益') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="retailRangeIncome"
              width="130"
              :label="$t('极差收益') + '($)'"
            />
            <el-table-column
              align="center"
              prop="retailSameLevelIncomeOri"
              width="130"
              :label="$t('平级收益') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="retailSameLevelIncome"
              width="130"
              :label="$t('平级收益') + '($)'"
            />
            <el-table-column
              align="center"
              prop="retailAreaIncomeOri"
              width="130"
              :label="$t('区域收益') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="retailAreaIncome"
              width="130"
              :label="$t('区域收益') + '($)'"
            />
            <el-table-column
              align="center"
              prop="retailBenefitRangeIncomeOri"
              width="130"
              :label="$t('福利极差收益') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="retailBenefitRangeIncome"
              width="130"
              :label="$t('福利极差收益') + '($)'"
            />
            <!-- <el-table-column
              align="center"
              prop="retailBenefitAvgIncomeOri"
              width="130"
              :label="$t('福利平均收益') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="retailBenefitAvgIncome"
              width="130"
              :label="$t('福利平均收益') + '($)'"
            /> -->
            <el-table-column
              align="center"
              prop="retailBenefitIncomeOri"
              width="130"
              :label="$t('福利分红收益') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="retailBenefitIncome"
              width="130"
              :label="$t('福利分红收益') + '($)'"
            />
            <el-table-column
              align="center"
              prop="backPointsOri"
              width="130"
              :label="$t('重消收益') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="backPoints"
              width="130"
              :label="$t('重消收益') + '($)'"
            />
            <el-table-column
              align="center"
              prop="retailRealSubtotalOri"
              width="130"
              :label="$t('小计') + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="retailRealSubtotal"
              width="130"
              :label="$t('小计') + '($)'"
            />
            <!-- <el-table-column
              align="center"
              prop="directIncomeOri"
              width="130"
              :label="'直推收益' + `(${isLocalSymbol()})`"
              v-if="allTxt.directIncomeOri"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.directIncome"
              align="center"
              prop="directIncome"
              width="130"
              :label="'直推收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="expandIncomeOri"
              width="130"
              :label="'拓展收益' + `(${isLocalSymbol()})`"
              v-if="allTxt.expandIncomeOri"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.expandIncome"
              align="center"
              prop="expandIncome"
              width="130"
              :label="'拓展收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="coachIncomeOri"
              width="130"
              :label="'辅导收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
              v-if="allTxt.coachIncomeOri"
            />
            <el-table-column
              v-if="allTxt.coachIncome"
              align="center"
              prop="coachIncome"
              width="130"
              :label="'辅导收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="shareIncomeOri"
              width="130"
              v-if="allTxt.shareIncomeOri"
              :label="'分红收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.shareIncome"
              align="center"
              prop="shareIncome"
              width="130"
              :label="this.$t('N_I_134') + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="serviceIncomeOri"
              width="130"
              :label="'报单收益' + `(${isLocalSymbol()})`"
              v-if="allTxt.serviceIncomeOri"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.serviceIncome"
              align="center"
              prop="serviceIncome"
              width="130"
              :label="'报单收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="cloudDirectIncomeOri"
              width="130"
              :label="'云代直推收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
              v-if="allTxt.cloudDirectIncomeOri"
            />
            <el-table-column
              v-if="allTxt.cloudDirectIncome"
              align="center"
              prop="cloudDirectIncome"
              width="130"
              :label="'云代直推收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              v-if="allTxt.cloudPurIncomeOri"
              prop="cloudPurIncomeOri"
              width="130"
              :label="'云代首购收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.cloudPurIncome"
              align="center"
              prop="cloudPurIncome"
              width="130"
              :label="'云代首购收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="cloudRepurIncomeOri"
              width="130"
              :label="'云代复购收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
              v-if="allTxt.cloudRepurIncomeOri"
            />
            <el-table-column
              v-if="allTxt.cloudRepurIncome"
              align="center"
              prop="cloudRepurIncome"
              width="130"
              :label="'云代复购收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.repurPushIncomeOri"
              align="center"
              prop="repurPushIncomeOri"
              width="130"
              :label="'复购推荐收益'"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.repurPushIncome"
              align="center"
              prop="repurPushIncome"
              width="130"
              :label="'复购推荐收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.repurRangeIncomeOri"
              align="center"
              prop="repurRangeIncomeOri"
              width="130"
              :label="'复购级差收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.repurRangeIncome"
              align="center"
              prop="repurRangeIncome"
              width="130"
              :label="'复购级差收益' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="repurExpandIncomeOri"
              width="130"
              :label="'复购拓展收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
              v-if="allTxt.repurExpandIncomeOri"
            />
            <el-table-column
              align="center"
              prop="repurCouponOri"
              width="130"
              :label="'复购券' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
              v-if="allTxt.repurCouponOri"
            />
            <el-table-column
              v-if="allTxt.repurExpandIncome"
              align="center"
              prop="repurExpandIncome"
              width="130"
              :label="'复购拓展收益' + '($)'"
              :formatter="stateFormat"
            /> -->
            <el-table-column
              align="center"
              prop="repurCoupon"
              width="130"
              :label="'复购券' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="repurCouponShareOri"
              width="130"
              :label="'复购券均分'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="repurCouponShare"
              width="130"
              :label="'复购券均分' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="backPointsOri"
              width="130"
              :label="'商城重消' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="backPoints"
              width="130"
              :label="'商城重消' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="serviceSpendOri"
              width="130"
              :label="'平台服务费' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="serviceSpend"
              width="130"
              :label="'平台服务费' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="globalPointsOri"
              width="130"
              :label="$t('直推极差') + '(￥)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="globalPoints"
              width="130"
              :label="$t('直推极差') + '($)'"
              :formatter="stateFormat"
            />

            <el-table-column
              align="center"
              prop="carAwardPointsOri"
              width="130"
              :label="'车奖积分'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="carAwardPoints"
              width="130"
              :label="'车奖积分' + '($)'"
              :formatter="stateFormat"
            />
            <!-- <el-table-column
              align="center"
              prop="storeIncomeOri"
              width="130"
              :label="'店铺收益'"
              v-if="allTxt.storeIncomeOri"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="storeIncome"
              width="130"
              :label="'店铺收益' + '($)'"
              v-if="allTxt.storeIncome"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="hiFunIncome"
              width="130"
              :label="'嗨粉推荐收益' + `($)`"
              v-if="allTxt.hiFunIncome"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="hiFunIncomeOri"
              width="130"
              :label="'嗨粉推荐收益' + `(${isLocalSymbol()})`"
              v-if="allTxt.hiFunIncomeOri"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="makerDirectIncomeOri"
              width="160"
              :label="'创客空间直推收益' + `(${isLocalSymbol()})`"
              v-if="allTxt.makerRealSubtotalOri"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="makerDirectIncome"
              width="160"
              :label="'创客空间直推收益' + `($)`"
              v-if="allTxt.makerDirectIncome"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="makerShareIncomeOri"
              width="130"
              v-if="allTxt.makerShareIncomeOri"
              :label="'创客共享收益' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="makerShareIncome"
              width="130"
              v-if="allTxt.makerShareIncome"
              :label="'创客共享收益' + `($)`"
              :formatter="stateFormat"
            /> -->
            <el-table-column
              align="center"
              prop="purRealSubtotalOri"
              width="130"
              :label="'首购实发小计' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="purRealSubtotal"
              width="130"
              :label="'首购实发小计' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="cloudRealSubtotalOri"
              width="130"
              :label="'云代实发小计' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="cloudRealSubtotal"
              width="130"
              :label="'云代实发小计' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="repurRealSubtotalOri"
              width="130"
              :label="'复购实发小计' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="repurRealSubtotal"
              width="130"
              :label="'复购实发小计' + '($)'"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="repurCouponSubtotalOri"
              width="160"
              :label="'复购券实发小计' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="repurCouponSubtotal"
              width="160"
              :label="'复购券实发小计' + `($)`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="makerRealSubtotalOri"
              width="160"
              :label="'创客空间实发小计' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              align="center"
              prop="makerRealSubtotal"
              width="160"
              :label="'创客空间实发小计' + `($)`"
              :formatter="stateFormat"
            />
            <!-- <el-table-column
              align="center"
              prop="realIncomeTotalOri"
              width="130"
              v-if="allTxt.realIncomeTotalOri"
              :label="'实发收益总计' + `(${isLocalSymbol()})`"
              :formatter="stateFormat"
            />
            <el-table-column
              v-if="allTxt.realIncomeTotal"
              align="center"
              prop="realIncomeTotal"
              width="130"
              :label="'实发收益总计' + '($)'"
              :formatter="stateFormat"
            /> -->
            <!-- <el-table-column
              align="center"
              prop="settleDate"
              width="200"
              :label="'开始日期'"
              v-if="allTxt.settleDate"
            /> -->
            <el-table-column
              align="center"
              prop="settleDate"
              width="200"
              :label="'结算时间'"
            />
            <el-table-column
              align="center"
              prop="time"
              width="150"
              :label="'操作'"
            >
              <template slot-scope="scope">
                <el-button
                  style="color: #e70dec"
                  type="text"
                  size="small"
                  @click="bonusTap(scope.row)"
                >
                  {{ '奖金明细' }}
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!--        <div class="heji">-->
        <!--          <div-->
        <!--            v-for="item in menuList"-->
        <!--            v-if="item.checked&&item.id != 0&&item.id > 13"-->
        <!--            :key="item.id"-->
        <!--            class="dis"-->
        <!--          >-->
        <!--            <div>{{ item.text }}</div>-->
        <!--            <div>{{ tableData[item.prop] }}</div>-->
        <!--          </div>-->
        <!--        </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/settle.js";
import { classifyUpdate, classifySave } from "@/api/product";
import { queryBonusDetail, queryBonusTotal } from "@/api/bonus";
import { isLocalSymbol, stateFormat } from "@/utils/numberToCurrency";
import { getRoleMenu } from "@/api/notice";
export default {
  name: "Bzpz",
  components: {
    topBar,
  },
  filters: {
    isAgree(val) {
      if (!val) {
        return this.$t("ENU_POPUP_TYPE_1");
      } else {
        return this.$t("ENU_POPUP_TYPE_2");
      }
    },
  },
  data() {
    return {
      typeList: [
        {
          value: 0,
          label: this.$t("ENU_NOTICE_WEBSITE_TYPE_1"),
        },
        {
          value: 1,
          label: this.$t("ENU_NOTICE_WEBSITE_TYPE_2"),
        },
      ],
      digList: [
        {
          value: 0,
          label: this.$t("ENU_POPUP_TYPE_1"),
        },
        {
          value: 1,
          label: this.$t("ENU_POPUP_TYPE_2"),
        },
      ],
      menuList: [
        {
          id: 0,
          text: this.$t("MN_F_T_948"),
          checked: true,
        },
        {
          id: 21,
          text: this.$t("N_I_131") + "($)",
          checked: true,
          prop: "firstBuyAmountDollar",
        },
        {
          id: 22,
          text: this.$t("N_I_132") + "($)",
          checked: true,
          prop: "expandIncome",
        },
        {
          id: 23,
          text: this.$t("N_I_133") + "($)",
          checked: true,
          prop: "coachIncome",
        },
        {
          id: 24,
          text: this.$t("N_I_134") + "($)",
          checked: true,
          prop: "shareIncome",
        },
        {
          id: 25,
          text: this.$t("MN_F_T_887") + "($)",
          checked: true,
          prop: "serviceIncome",
        },
        {
          id: 26,
          text: this.$t("MN_F_T_889") + "($)",
          checked: true,
          prop: "cloudDirectIncome",
        },
        {
          id: 27,
          text: this.$t("MN_F_T_890") + "($)",
          checked: true,
          prop: "cloudPurIncome",
        },
        {
          id: 28,
          text: this.$t("MN_F_T_891") + "($)",
          checked: true,
          prop: "cloudRepurIncome",
        },
        {
          id: 39,
          text: this.$t("w_0155") + "($)",
          checked: true,
          prop: "repurRangeIncome",
        },
        {
          id: 30,
          text: this.$t("N_I_141") + "($)",
          checked: true,
          prop: "repurExpandIncome",
        },
        {
          id: 31,
          text: this.$t("ENU_ACCOUNT_8"),
          checked: true,
          prop: "repurCoupon",
          flag: 1,
        },
        {
          id: 32,
          text: this.$t("MN_F_T_893") + "($)",
          checked: true,
          prop: "backPoints",
        },
        {
          id: 35,
          text: this.$t("N_I_137") + "($)",
          checked: true,
          prop: "backPoints",
        },
        {
          id: 44,
          text: this.$t("MN_F_T_897") + "($)",
          checked: true,
          prop: "purRealSubtotal",
        },
        {
          id: 45,
          text: this.$t("MN_F_T_898") + "($)",
          checked: true,
          prop: "cloudRealSubtotal",
        },
        {
          id: 46,
          text: this.$t("MN_F_T_899") + "($)",
          checked: true,
          prop: "repurRealSubtotal",
        },
        {
          id: 47,
          text: this.$t("MN_F_T_902") + "($)",
          checked: true,
          prop: "realIncomeTotal",
        },
      ],
      creationTime: [],
      creationTime1: [],
      select: {
        // pkVertex: [],
        // pkMemberTeam: [],
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      addOrEdit: "",
      total: 0,
      dialogVisible: false,
      loading: false,
      tableData: {
        censusSummaryList: [],
      },
      moren: "/settlementCenter/totalBonus",
      topList: [
        {
          name: this.$t("MN_F_T_52"),
          path: "/settlementCenter/totalBonus",
        },
      ],
      form: {
        name: "",
      },
      rules: {
        name: [
          { required: true, message: this.$t("MN_F_T_302"), trigger: "blur" },
        ],
      },
      acList: [],
      verList: [],
      memberList: [],
      pkMemberTeam: [],
      pkVertex: [],
      pkTeamId: "", // 隶属团队id
      pkVertId: "", // 隶属体系id
      dataList: [
        {
          name: "period",
          key: "",
        },
        {
          name: "directIncomeOri",
          key: "",
        },
        {
          name: "directIncome",
          key: "",
        },
        {
          name: "expandIncomeOri",
          key: "",
        },
        {
          name: "expandIncome",
          key: "",
        },
        {
          name: "coachIncomeOri",
          key: "",
        },
        {
          name: "coachIncome",
          key: "",
        },
        {
          name: "shareIncomeOri",
          key: "",
        },
        {
          name: "shareIncome",
          key: "",
        },
        {
          name: "serviceIncomeOri",
          key: "",
        },
        // 10
        {
          name: "serviceIncome",
          key: "",
        },
        {
          name: "cloudDirectIncomeOri",
          key: "",
        },
        {
          name: "cloudDirectIncome",
          key: "",
        },
        {
          name: "cloudPurIncomeOri",
          key: "",
        },
        {
          name: "cloudPurIncome",
          key: "",
        },
        {
          name: "cloudRepurIncomeOri",
          key: "",
        },
        {
          name: "cloudRepurIncome",
          key: "",
        },
        {
          name: "repurRangeIncomeOri",
          key: "",
        },
        {
          name: "repurRangeIncome",
          key: "",
        },
        {
          name: "repurExpandIncomeOri",
          key: "",
        },
        //20
        {
          name: "repurExpandIncome",
          key: "",
        },
        {
          name: "repurCoupon",
          key: "",
        },
        {
          name: "repurCouponShareOri",
          key: "",
        },
        {
          name: "backPointsOri",
          key: "",
        },
        {
          name: "backPoints",
          key: "",
        },
        {
          name: "serviceSpendOri",
          key: "",
        },
        {
          name: "serviceSpend",
          key: "",
        },
        {
          name: "globalPoints",
          key: "",
        },
        {
          name: "carAwardPoints",
          key: "",
        },
        {
          name: "storeIncome",
          key: "",
        },
        //30
        {
          name: "hiFunIncomeOri",
          key: "",
        },
        {
          name: "makerDirectIncomeOri",
          key: "",
        },
        {
          name: "makerShareIncomeOri",
          key: "",
        },
        {
          name: "purRealSubtotalOri",
          key: "",
        },
        {
          name: "purRealSubtotal",
          key: "",
        },
        {
          name: "cloudRealSubtotalOri",
          key: "",
        },
        {
          name: "cloudRealSubtotal",
          key: "",
        },
        {
          name: "repurRealSubtotalOri",
          key: "",
        },
        {
          name: "repurRealSubtotal",
          key: "",
        },
        {
          name: "repurCouponSubtotalOri",
          key: "",
        },
        //40
        {
          name: "makerRealSubtotalOri",
          key: "",
        },
        {
          name: "realIncomeTotalOri",
          key: "",
        },
        {
          name: "realIncomeTotal",
          key: "",
        },
        {
          name: "settleDate",
          key: "",
        },
        {
          name: "hiFunIncome",
          key: "",
        },
      ],
      flag: false,
      allTxt: {},
      props: {
        multiple: true,
        expandTrigger: "hover",
        value: "pkId",
        label: "vertexName",
        children: "childList",
      },
    };
  },
  mounted() {
    // 获取下拉
    this.getData();
    // 获取列表

    this.getUserRole();
    var s1 = this.getStartTime();
    var s2 = this.getEndTime();
    this.select.startDate = s1;
    this.select.endDate = s2;
    this.creationTime = [s1, s2];

    setTimeout(() => {
      this.getDataList();
    }, 10);
  },
  methods: {
    getPkBdVertexStr(e) {
      let arr = e.map((item) => item[1]);
      let pkBdVertexStr = arr.join(",");
      this.$set(this.select, "pkBdVertexStr", pkBdVertexStr);
    },
    getStartTime() {
      let date = new Date();
      // console.error(date.getDate()==1?date.getMonth():date.getMonth() + 1)
      let year = date.getFullYear(); // 得到当前年份
      let month = date.getDate() === 1 ? date.getMonth() : date.getMonth() + 1; // 得到当前月份（0-11月份，+1是当前月份）
      date.setDate(1); // 将当前时间的日期设置成第一天
      month = month >= 10 ? month : "0" + month; // 补零
      let day = date.getDate(); // 得到当前天数，实际是本月第一天，因为前面setDate(1) 设置过了
      day = day >= 10 ? day : "0" + day; // 补零
      return year + "-" + month + "-" + day;
    },
    getEndTime() {
      var date = new Date();
      var year = date.getFullYear(); // 年
      let month = date.getDate() === 1 ? date.getMonth() : date.getMonth() + 1; // 得到当前月份（0-11月份，+1是当前月份）
      var day = date.getDate() > 1 ? date.getDate() - 1 : date.getDate(); // 日
      let day1 = date.getDate();
      var hour = date.getHours(); // 时
      var minutes = date.getMinutes(); // 分
      var seconds = date.getSeconds(); //秒
      // 给一位数的数据前面加 “0”
      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (day >= 0 && day <= 9) {
        day = "0" + day;
      }
      if (hour >= 0 && hour <= 9) {
        hour = "0" + hour;
      }
      if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
      }
      if (seconds >= 0 && seconds <= 9) {
        seconds = "0" + seconds;
      }
      if (day1 == 1) {
        var date2 = new Date();
        var year2 = date2.getFullYear();
        var month2 = date2.getMonth();
        // let dates =this.getMonthDay(year2,month2,0)
        var dates = new Date(year2, month2, 0).getDate();
        day = dates;
      }
      return year + "-" + month + "-" + day;
    },
    isLocalSymbol,
    // getUserRole() {
    //   getRoleMenu('totalBonus').then((res) => {
    //     this.dataList.forEach((item) => {
    //       res.data.forEach((items) => {
    //         if (item.name == items) {
    //           item.key = items
    //         }
    //       })
    //     })
    //     this.flag = true
    //   })
    // },
    getUserRole() {
      getRoleMenu("totalBonus").then((res) => {
        let obj = {};
        res.data.forEach((item) => {
          obj[item] = 1;
        });
        this.allTxt = obj;
        this.$nextTick(() => {
          this.$refs.table.doLayout();
        });
      });
    },
    stateFormat,
    vertCheck(index, item) {
      if (this.pkVertex.length > 1) {
        this.pkVertex.splice(0, 1);
        this.pkVertId = item.pkId;
      } else if (this.pkVertex.length == 1) {
        this.pkVertId = item.pkId;
      } else {
        this.pkVertId = "";
      }
    },
    teamCheck(index, item) {
      if (this.pkMemberTeam.length > 1) {
        this.pkMemberTeam.splice(0, 1);
        this.pkTeamId = item.pkId;
      } else if (this.pkMemberTeam.length == 1) {
        this.pkTeamId = item.pkId;
      } else {
        this.pkTeamId = "";
      }
    },
    bonusTap(item) {
      this.$router.push({
        path: "/settlementCenter/bonusDetail",
      });
    },
    reset() {
      this.select = {
        // pkVertex: [],
        // pkMemberTeam: [],
      };
      this.creationTime = [];
      this.pkVertex = [];
      this.pkMemberTeam = [];

      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.accountList().then((res) => {
        this.acList = res.data;
      });
      api.vertexChild().then((res) => {
        this.verList = res.data;
      });
      api.memberTeam().then((res) => {
        this.memberList = res.rows;
      });
    },
    changeTime(val) {
      if (val) {
        this.select.startDate = val[0];
        this.select.endDate = val[1];
      }
    },
    changeTime1(val) {
      this.select.startEffectDate = val[0];
      this.select.endEffectDate = val[1];
    },
    // 点击修改
    toFixed(id) {
      this.addOrEdit = false;
      this.dialogVisible = true;
      this.$router.push({
        path: "noticeList/details",
        query: {
          pkId: id,
        },
      });
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = this.$t("MN_F_T_951") + "(￥)";
          return;
        }
        if (index === 1) {
          sums[index] = "";
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        if (!values.every((value) => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          // sums[index] += ' 元'
        } else {
          sums[index] = "";
        }
      });

      return sums;
    },
    // 删除
    handleDelete(id) {
      this.$confirm(this.$t("MN_F_T_303"), this.$t("w_0034"), {
        confirmButtonText: this.$t("w_0035"),
        cancelButtonText: this.$t("ENU_P_TYPE0"),
        type: "warning",
      }).then(() => {
        api.classifyDel(id).then((res) => {
          this.getDataList();
        });
      });
    },
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let url = "";
          if (this.addOrEdit == true) {
            url = classifySave;
          } else {
            url = classifyUpdate;
          }
          url(this.form).then((res) => {
            if (res.code == 200) {
              this.$message({
                message: res.msg,
                type: "success",
              });
              this.dialogVisible = false;
              // 充值数据
              this.$refs[formName].resetFields();
              // 获取列表
              this.getDataList();
            }
          });
        } else {
          return false;
        }
      });
    },
    handleClose() {
      this.dialogVisible = false;
      this.$refs["form"].clearValidate();
      this.$refs["form"].resetFields();
    },
    openDig() {
      this.$router.push({
        path: "noticeList/details",
      });
    },
    getDataList() {
      this.loading = true;
      if (this.select.period) {
        this.select.period = parseInt(this.select.period);
      }
      if (this.creationTime == "" || this.creationTime == null) {
        this.select.startDate = "";
        this.select.endDate = "";
      }
      queryBonusTotal(
        Object.assign(
          {},
          { pkVertex: this.pkVertId, pkTeamCode: this.pkTeamId },
          this.select
        ),
        `?pageNum=${this.queryParams.pageNum}&pageSize=${this.queryParams.pageSize}`
      ).then((res) => {
        this.loading = false;
        this.tableData.censusSummaryList = res.rows;
        this.total = res.total;
      });
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    exports() {
      this.$confirm(this.$t("MN_F_T_407"), this.$t("MN_F_T_304"), {
        confirmButtonText: this.$t("w_0035"),
        cancelButtonText: this.$t("ENU_P_TYPE0"),
        type: "warning",
      }).then((_) => {
        this.download(
          "/bonus/manage/bonus/export-bonus-total",
          Object.assign({}, this.queryParams, this.select),
          `${this.$t("MN_F_T_52")}-${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__body-wrapper {
  // height: 740px!important;
}
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-button {
  padding: 8px 20px;
}
::v-deep .el-date-editor .el-range__close-icon {
  margin-top: -10px;
}
::v-deep .el-date-editor .el-range-separator {
  margin-top: -10px;
}
::v-deep .el-date-editor .el-range__icon {
  margin-top: -10px;
}
::v-deep .el-input__inner {
  //height:28px;
  //line-height: 28px;
}
::v-deep .el-form-item__label {
  color: #333;
  font-weight: inherit;
}
::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: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    .maintop {
      display: flex;
      //padding: 10px 0px;
      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;
}
::v-deep .el-cascader {
  width: 100%;
}
.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;
    }
  }
}
// el-table__body-wrapper is-scrolling-left
/* 设置滚动条宽度和高度 */
</style>
<!-- <style>
.itemTrading .el-table {
  overflow: auto;
}
.itemTrading .el-table__body-wrapper,
.itemTrading .el-table__header-wrapper,
.itemTrading .el-table__footer-wrapper {
  overflow: visible;
}
.itemTrading .el-table::after {
  position: relative !important;
}

.body-theme-grenn .el-table--scrollable-x .el-table__body-wrapper {
  overflow: visible;
}
</style> -->
