<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="$t('MN_T_1')">
              <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">
                {{ $t("MN_T_2") }}</el-button
              >
              <el-button class="my_reset" @click="reChongzhi">
                {{ $t("MN_T_3") }}</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="$t('w_0452') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account2"
            v-if="showData.account2"
            :label="$t('w_0448') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account3"
            v-if="showData.account3"
            :label="$t('w_0453') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account4"
            :label="$t('w_0450') + `(${isLocalSymbol()})`"
            v-if="showData.account4"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="account5"
            :label="$t('w_0454') + `(${isLocalSymbol()})`"
            v-if="showData.account5"
          >
          </el-table-column>
          <el-table-column
            v-if="showData.account6"
            align="center"
            prop="account6"
            :label="$t('w_0455') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account7"
            v-if="showData.account7"
            :label="$t('w_0456') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            v-if="showData.account8"
            align="center"
            prop="account8"
            :label="$t('MN_F_T_1197') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            v-if="showData.account9"
            prop="account9"
            :label="$t('w_0477') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account10"
            v-if="showData.account10"
            :label="$t('w_0478') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account11"
            v-if="showData.account11"
            :label="$t('w_0479') + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="account12"
            v-if="showData.account12"
            :label="$t('w_0480') + `(${isLocalSymbol()})`"
          >
          </el-table-column> -->
          <el-table-column
            align="center"
            prop="account1"
            v-if="showData.account1"
            min-width="100px"
            :label="$t('w_0452') + `(${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="$t('w_0448') + `(${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="$t('w_0453') + `(${isLocalSymbol()})`"
          >
            <template slot-scope="scope">
              {{ scope.row.account3 | numberToCurrency }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="account4"
            :label="$t('w_0450') + `(${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="$t('w_0454') + `(${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="$t('w_0455') + `(${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="$t('w_0456') + `(${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="$t('MN_F_T_1197') + `(${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="$t('w_0477') + `(${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="$t('w_0478') + `(${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="$t('w_0479') + `(${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="$t('w_0480') + `(${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="$t('w_0452') + `(${isLocals()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount2"
            v-if="showData.settleAccount2"
            :label="$t('w_0448') + `(${isLocals()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount3"
            v-if="showData.settleAccount3"
            :label="$t('w_0453') + `(${isLocals()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount4"
            :label="$t('w_0450') + `(${isLocals()})`"
            v-if="showData.settleAccount4"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="settleAccount5"
            :label="$t('w_0454') + `(${isLocals()})`"
            v-if="showData.settleAccount5"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount6"
            :label="$t('w_0455') + `(${isLocals()})`"
            v-if="showData.settleAccount6"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount7"
            :label="$t('w_0456') + `(${isLocals()})`"
            v-if="showData.settleAccount7"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount8"
            :label="$t('MN_F_T_1197') + `(${isLocals()})`"
            v-if="showData.settleAccount8"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount9"
            :label="$t('w_0477') + `(${isLocals()})`"
            v-if="showData.settleAccount9"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount10"
            :label="$t('w_0478') + `(${isLocals()})`"
            v-if="showData.settleAccount10"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount11"
            :label="$t('w_0479') + `(${isLocals()})`"
            v-if="showData.settleAccount11"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="settleAccount12"
            :label="$t('w_0480') + `(${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: this.$t("MN_T_1"), 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>
      