<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="thetopbox">
      <el-form label-width="100px">
        <el-row>
          <el-col :span="4">
            <el-form-item label="查询类型">
              <el-select v-model="queryParams.type">
                <el-option
                  v-for="item in typeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" v-if="queryParams.type == 1">
            <el-form-item label="顶点">
              <el-select v-model="queryParams.pkMember">
                <el-option
                  v-for="item in topMemberList"
                  :key="item.pkId"
                  :label="`${item.memberCode}(${item.memberName})`"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" v-if="queryParams.type == 2">
            <el-form-item label="体系">
              <el-select v-model="queryParams.pkVertex">
                <el-option
                  v-for="item in vertexList"
                  :key="item.value"
                  :label="item.vertexName"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" v-if="queryParams.type == 3">
            <el-form-item :label="'会员编号'">
              <el-input clearable v-model="queryParams.memberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <div class="searchbox">
              <el-button class="my_search" @click="getSearch">
                {{ '搜索' }}</el-button
              >
              <el-button class="my_reset" @click="reChongzhi">
                {{ '重置' }}</el-button
              >
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main">
     
      <div class="maintable">
        <el-table
          :data="tableData"
          :header-cell-style="{ background: '#EEEEEE' }"
          @selection-change="handleSelectionChange"
          height="720px"
          style="width: 100%"
        >
          <el-table-column type="selection" width="55"> </el-table-column>

          <el-table-column
            min-width="100px"
            align="center"
            prop="code"
            v-if="queryParams.type"
            :label="getLabel(queryParams.type)"
          >
          </el-table-column>
          <el-table-column
            min-width="100px"
            v-if="queryParams.type"
            align="center"
            prop="name"
            :label="getLabel2(queryParams.type)"
          >
          </el-table-column>
          <!-- <el-table-column
            align="center"
            prop="account1"
            v-if="showData.account1"
            min-width="100px"
            :label="'消费账户余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account2"
            v-if="showData.account2"
            :label="'现金账户余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account3"
            v-if="showData.account3"
            :label="'政策账户余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account4"
            :label="'奖金账户余额' + `(${isLocalSymbol()})`"
            v-if="showData.account4"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="account5"
            :label="'重消账户余额' + `(${isLocalSymbol()})`"
            v-if="showData.account5"
          >
          </el-table-column>
          <el-table-column
            v-if="showData.account6"
            align="center"
            prop="account6"
            :label="'积分账户余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account7"
            v-if="showData.account7"
            :label="'鼓励账户余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            v-if="showData.account8"
            align="center"
            prop="account8"
            :label="'复购券余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            v-if="showData.account9"
            prop="account9"
            :label="'全球积分余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account10"
            v-if="showData.account10"
            :label="'车奖积分余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account11"
            v-if="showData.account11"
            :label="'直播代金券余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account12"
            v-if="showData.account12"
            :label="'乐学代金券余额' + `(${isLocalSymbol()})`"
          >
          </el-table-column> -->
          <el-table-column
            align="center"
            prop="account1"
            v-if="showData.account1"
            min-width="100px"
            :label="'消费账户余额' + `(${isLocalSymbol()})`"
          >
            <template slot-scope="scope">
              {{ scope.row.account1 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account2"
            v-if="showData.account2"
            :label="'现金账户余额' + `(${isLocalSymbol()})`"
          >
            <template slot-scope="scope">
              {{ scope.row.account2 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account3"
            v-if="showData.account3"
            :label="'政策账户余额' + `(${isLocalSymbol()})`"
          >
            <template slot-scope="scope">
              {{ scope.row.account3 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account4"
            :label="'奖金账户余额' + `(${isLocalSymbol()})`"
            v-if="showData.account4"
          >
            <template slot-scope="scope">
              {{ scope.row.account4 | numberToCurrency }}
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="account5"
            :label="'重消账户余额' + `(${isLocalSymbol()})`"
            v-if="showData.account5"
          >
            <template slot-scope="scope">
              {{ scope.row.account5 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            v-if="showData.account6"
            align="center"
            prop="account6"
            :label="'积分账户余额' + `(${isLocalSymbol()})`"
          >
            <template slot-scope="scope">
              {{ scope.row.account6 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account7"
            v-if="showData.account7"
            :label="'鼓励账户余额' + `(${isLocalSymbol()})`"
          >
            <template slot-scope="scope">
              {{ scope.row.account7 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            v-if="showData.account8"
            align="center"
            prop="account8"
            :label="'复购券余额' + `(${isLocalSymbol()})`"
          >
            <template slot-scope="scope">
              {{ scope.row.account8 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            v-if="showData.account9"
            prop="account9"
            :label="'全球积分余额' + `(${isLocalSymbol()})`"
            ><template slot-scope="scope">
              {{ scope.row.account9 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account10"
            v-if="showData.account10"
            :label="'车奖积分余额' + `(${isLocalSymbol()})`"
            ><template slot-scope="scope">
              {{ scope.row.account10 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account11"
            v-if="showData.account11"
            :label="'直播代金券余额' + `(${isLocalSymbol()})`"
            ><template slot-scope="scope">
              {{ scope.row.account11 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account12"
            v-if="showData.account12"
            :label="'乐学代金券余额' + `(${isLocalSymbol()})`"
            ><template slot-scope="scope">
              {{ scope.row.account12 | numberToCurrency }}
            </template>
          </el-table-column>
          <!-- <el-table-column
            align="center"
            prop="settleAccount1"
            v-if="showData.settleAccount1"
            :label="'消费账户余额' + `(${isLocals()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount2"
            v-if="showData.settleAccount2"
            :label="'现金账户余额' + `(${isLocals()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount3"
            v-if="showData.settleAccount3"
            :label="'政策账户余额' + `(${isLocals()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount4"
            :label="'奖金账户余额' + `(${isLocals()})`"
            v-if="showData.settleAccount4"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="settleAccount5"
            :label="'重消账户余额' + `(${isLocals()})`"
            v-if="showData.settleAccount5"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount6"
            :label="'积分账户余额' + `(${isLocals()})`"
            v-if="showData.settleAccount6"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount7"
            :label="'鼓励账户余额' + `(${isLocals()})`"
            v-if="showData.settleAccount7"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount8"
            :label="'复购券余额' + `(${isLocals()})`"
            v-if="showData.settleAccount8"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount9"
            :label="'全球积分余额' + `(${isLocals()})`"
            v-if="showData.settleAccount9"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount10"
            :label="'车奖积分余额' + `(${isLocals()})`"
            v-if="showData.settleAccount10"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount11"
            :label="'直播代金券余额' + `(${isLocals()})`"
            v-if="showData.settleAccount11"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount12"
            :label="'乐学代金券余额' + `(${isLocals()})`"
            v-if="showData.settleAccount12"
          >
          </el-table-column> -->
        </el-table>
      </div>
    </div>
    <!-- <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getSearch"
    /> -->
  </div>
</template>
      
<script>
import topBar from "@/components/topBar";
import { isLocals, isLocalSymbol } from "@/utils/numberToCurrency";
import * as fin from "@/api/financial.js";
import { mapGetters } from "vuex";
export default {
  name: "BalanceSummaryTotal",
  components: {
    topBar,
  },
  data() {
    return {
      moren: "balanceSummaryTotal",
      topList: [
        {
          name: "余额汇总统计",
          path: "balanceSummaryTotal",
        },
      ],
      tableData: [],
      queryParams: {
        // pageNum: 1,
        // pageSize: 50,
        type:"1"
      },
      total: 0,
      multipleSelection: [],
      showData: {},
      typeList: [
        {
          label: "顶点",
          value: "1",
        },
        { label: "体系", value: "2" },
        { label: '会员编号', value: "3" },
      ],
     topMemberList:[],
      vertexList:[]
    };
  },
  computed: {
    ...mapGetters(["getUser"]),

    getLabel() {
      return function (type) {
        if (type == "1") {
          return "系统编号";
        } else if (type == "2") {
          return "体系编号";
        } else if (type == "3") {
          return "会员编号";
        } 
      };
    },
    getLabel2() {
      return function (type) {
        if (type == "1") {
          return "顶点名称";
        } else if (type == "2") {
          return "体系名称";
        } else if (type == "3") {
          return "会员名称";
        } 
      };
    },
  },
  created() {
    this.getOthers();
    // this.getSearch();
  },
  methods: {
    isLocals,
    isLocalSymbol,

    getOthers() {
      fin.getBalanceSummaryField().then((res) => {
        const obj = {};
        res.data.forEach((ele) => {
          obj[ele] = true;
        });
        this.showData = obj;
      });
      fin.getTopMemberList().then(res=>{
        this.topMemberList =  res.data
      })
      fin.getvertexValue().then(res=>{
        this.vertexList = res.data
      })
    },
   

    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.queryParams.createTimes = val.map((item) => item.createTime);
    },
    reChongzhi() {
      this.queryParams = {
        // pageNum: 1,
        // pageSize: 50,
        type: "1",
      };
      // this.getSearch();
    },
    getSearch() {
      fin.getBalanceSummaryTotalList(this.queryParams).then((res) => {
        this.tableData = [res.data];
        // this.total = res.total;
      });
    },
  },
};
</script>
      
  <style lang="scss" scoped>
::v-deep .el-table--scrollable-x .el-table__body-wrapper {
  height: 600px !important;
}
.tem {
  display: flex;
  align-items: center;
  justify-content: center;
  img {
    width: 28px;
    height: 20px;
    margin-right: 3px;
  }
}
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}
.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    padding: 15px 20px 15px 0;
    background: #ffffff;
    border-radius: 8px;
    .searchbox {
      display: flex;
      align-items: center;
      margin-left: 40px;
    }
    .searchtitle {
      margin-right: 10px;
    }
    .searchbtn {
      background: #08143f;
      color: #ffffff;
    }
  }
  .main {
    background: #f9f9f9;

    .maintop {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  }
}
</style>
      