<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <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-input clearable v-model="select.memberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'会员姓名'">
              <el-input clearable v-model="select.memberName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="'业绩时间'">
              <el-date-picker
                v-model="creationTime"
                @change="changeTime"
                value-format="yyyy-MM-dd"
                type="daterange"
                :range-separator="'至'"
                :start-placeholder="'开始日期'"
                :end-placeholder="'结束日期'"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="4" style="margin-left: 10px">
            <el-button type="primary" @click="getDataList">
              {{ '搜索' }}</el-button
            >
            <el-button @click="reset"> {{ '重置' }}</el-button>
          </el-col>
        </el-row>
        <el-row> </el-row>
      </el-form>
      <div class="maintop">
        <div class="mainbtn">
          <el-button
            size="small"
            @click="handleExport"
            v-hasButtons="['personalAllocationExport']"
            class="thebtn2"
          >
            {{ '导出' }}</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          :data="tableData"
          ref="mainTable"
          height="710px"
          :header-cell-style="{ background: '#EEEEEE' }"
          :row-class-name="tableRowClassName"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="60"> </el-table-column>
          <el-table-column
            align="center"
            prop="memberCode"
            :label="'会员编号'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="memberName"
            :label="'会员姓名'"
          >
          </el-table-column>

          <!-- <el-table-column
            align="center"
            prop="pkRegisterGradeVal"
            :label="'注册等级'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="pkAwardsVal"
            :label="'真实奖衔'"
          >
          </el-table-column> -->
          <el-table-column
            align="center"
            prop="vertexName"
            :label="'隶属体系'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="teamName"
            :label="'隶属团队'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="firstPurchaseAll"
            :label="'首购金额'"
          >
          <template slot-scope="scope">
              {{ scope.row.firstPurchaseAll | numberToCurrency }}
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="repurchaseAllAmount"
            :label="'复购金额'"
          >
            <template slot-scope="scope">
              {{ scope.row.repurchaseAllAmount | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="mainBonus"
            :label="'首购拨出金额'"
          >
            <template slot-scope="scope">
              {{ scope.row.mainBonus | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="mainBonusRate"
            :label="`${'首购拨出比例'}(%)`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="repurBonus"
            :label="'复购拨出金额'"
          >
            <template slot-scope="scope">
              {{ scope.row.repurBonus | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="repurBonusRate"
            :label="`${'复购拨出比例'}(%)`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="totalBonus"
            :label="'总拨出金额'"
          >
            <template slot-scope="scope">
              {{ scope.row.totalBonus | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="totalBonusRate"
            :label="`${'总拨出比例'}(%)`"
          >
          </el-table-column>
        </el-table>
      </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/topBarRole";
import * as api from "@/api/settle.js";
export default {
  name: "Bzpz",
  components: {
    topBar,
  },

  data() {
    return {
      creationTime: [],
      select: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total: 0,
      tableData: [],
      moren: "/settlementCenter/personalAllocation",
      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,
        },
      ],
    };
  },
  mounted() {
    // 获取列表
    this.getDataList();
  },
  methods: {
    reset() {
      this.select = {};
      this.creationTime = [];
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
      };
      this.getDataList();
    },

    changeTime(val) {
      this.select.startDate = val ? val[0] : "";
      this.select.endDate = val ? val[1] : "";
    },
    getDataList() {
      api
        .getPersonStatList(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          if (res.code == 200) {
            this.tableData = [res.data];
            if (res.data) {
              this.total = 1;
            }

            this.getTotal();
          }
        });
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        this.download(
          "/member/manage/bonus-statis/export-singlePersonList",
          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);
    display: flex;
    flex-direction: column;
    .maintop {
      display: flex;
      // padding: 0 10px;
      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;
      }
    }
    .maintable {
      flex: 1;
    }
  }
  .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;
    }
  }
}
::v-deep .el-date-editor--daterange,
.el-cascader {
  width: 100%;
}
::v-deep .el-input__suffix {
  top: -3px;
}
</style>
  