<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="thetopbox">
      <el-form ref="form" :model="queryParams" label-width="100px">
        <el-row>
          <el-col :span="4">
            <el-form-item :label="'会员编号'" prop="teamCode">
              <el-input
                clearable
                v-model="queryParams.memberCode"
                :placeholder="'请输入'"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'会员姓名'" prop="teamCode">
              <el-input
                clearable
                v-model="queryParams.memberName"
                :placeholder="'请输入'"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="display: flex">
          <el-col style="display: flex">
            <el-form-item :label="'币种'" prop="pkAccounts">
              <el-checkbox-group v-model="queryParams.pkAccounts">
                <el-checkbox
                  class="check-s"
                  v-for="item in enumsAccountList"
                  :key="item.fieldValue"
                  :label="item.fieldValue"
                  @change="changeAccount"
                  >{{ item.accountName }}</el-checkbox
                >
              </el-checkbox-group></el-form-item
            >
            <el-col :span="4">
              <div class="searchbox" style="margin-left: 40px">
                <el-button class="my_search" @click="research()"> {{ '搜索' }}</el-button>
                <el-button class="my_reset" @click="reChongzhi"> {{ '重置' }}</el-button>
              </div>
            </el-col>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main">
      <div class="maintop">
        <div class="mainbtn">
          <el-button size="small"
                     v-has-buttons="['FreezeDetailExport']"
                     class="thebtn1" @click="exportFrozenList"> {{ '导出' }}</el-button>
        </div>
      </div>
      <div class="maintable">
        <el-table
          :data="tableData"
          v-loading="loading"
          height="680px"
          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>
          <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="" prop="" label="">
          </el-table-column>
          <div v-for="(item, index) in titelList" :key="index" class="thename1" >
            <el-table-column
              align="center"
              :prop="`account${item.value}`"
              :label="`${item.label}${'余额'}${isLocalSymbol()}`"
              :formatter="stateFormat"
              style="color:red!important"
              width="160"
            >
            </el-table-column>
            <el-table-column
              align="center"
              :prop="`availableAccount${item.value}`"
              :label="`${'可用'}${item.label}${isLocalSymbol()}`"
              :formatter="stateFormat"
              width="160"
            >
            </el-table-column>
            <el-table-column
              align="center"
              :prop="`lockAccount${item.value}`"
              :formatter="stateFormat"
              :label="`${'禁止消费'}(${isLocalSymbol()})`"
              width="160"
            >
            </el-table-column>
            <el-table-column
              align="center"
              :prop="`lockTransferAccount${item.value}`"
              :formatter="stateFormat"
               :label="`${'禁止转账'}(${isLocalSymbol()})`"
              width="160"
            >
            </el-table-column>

            <el-table-column
              align="center"
              :prop="`settleAccount${item.value}`"
              :label="`${item.label}${'余额'}(${isLocals()})`"
              :formatter="stateFormat"
              width="160"
            >
            </el-table-column>
            <el-table-column
              align="center"
              :formatter="stateFormat"
              :prop="`settleAvailableAccount${item.value}`"
              :label="`${'可用'}${item.label}(${isLocals()})`"
              width="160"
            >
            </el-table-column>
            <el-table-column
              align="center"
              :formatter="stateFormat"
              :prop="`settleLockAccount${item.value}`"
              :label="`${'禁止消费'}(${isLocals()})`"
              width="160"
            >
            </el-table-column>
            <el-table-column
              align="center"
              :formatter="stateFormat"
              :prop="`settleLockTransferAccount${item.value}`"
              :label="`${'禁止转账'}(${isLocals()})`"
              width="160"
            >
            </el-table-column>
          </div>
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="research"
    />
  </div>
</template>
<script>
import topBar from "@/components/topBar";
import { getFrozenList, getenumsAccount } from "@/api/financial";
import {isLocals, isLocalSymbol, stateFormat} from "@/utils/numberToCurrency";
export default {
  name: "Djmx",
  components: {
    topBar,
  },
  data() {
    return {
      moren: "djmx",
      topList: [
        {
          name: '冻结明细',
          path: "djmx",
        },
      ],
      multipleSelection: [],
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        memberCode: "", //会员编号
        memberName: "", //会员姓名
        pkAccounts: [], //币种选择
      },
      enumsAccountList: [], //币种
      tableData: [],
      loading:false,
      czsj: "", //充值时间
      shsj: "", //审核时间
      total: 0,
      titelList: [],
    };
  },
  created() {
    this.research();
    this.getenumsAccount();
  },
  methods: {
    isLocals,
    isLocalSymbol,
    stateFormat,
    changeAccount() {
      this.titelList = [];
      this.queryParams.pkAccounts.forEach((ele) => {
        this.enumsAccountList.forEach((item) => {
          if (ele == item.fieldValue) {
            this.titelList.push({ value: ele, label: item.accountName });
          }
        });
      });
      this.research();
    },
    getenumsAccount() {
      getenumsAccount().then((res) => {
        this.enumsAccountList = res.rows;
      });
    },
    research() {
      this.loading = true
      getFrozenList(this.queryParams).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
        this.loading = false
      });
    },
    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
        memberCode: "", //会员编号
        memberName: "", //会员姓名
        pkAccounts: [], //币种选择
      };
      this.titelList=[]
      this.research();
    },
    exportFrozenList(){
      this.download(
        "/member/manager/frozen/frozen-export",
        { ...this.queryParams },
        `${'冻结明细'}${new Date().getTime()}.xlsx`
      );
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },

    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return "warning-row";
      } else if (rowIndex % 2 == 0) {
        return "success-row";
      }
      return "";
    },
  },
};
</script>

<style lang="scss" scoped>
// ::v-deep .el-table--scrollable-y .el-table__body-wrapper{
//   height: 620px!important;
// }

::v-deep .check-s .el-checkbox__input .el-checkbox__inner{
  border-radius: 50%;
}
.thename1{
  background: red !important;
}
::v-deep .el-row {
  //margin-top: 20px;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}

::v-deep .el-table .success-row {
  background: #ffffff;
}
::v-deep .el-table thead {
  color: #000000;
}
.openClose {
  margin-top: 10px;
  margin-right: 10px;
  color: #666666;
  text-align: center;
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    background: #ffffff;
    border-radius: 8px;
    padding: 10px 0 0 0;
    .searchbox {
      display: flex;
      align-items: center;
      .searchtitle {
        margin-right: 10px;
      }
      .searchbtn {
        background: #08143f;
        color: #ffffff;
      }
    }
  }
  .main {
    //margin-top: 20px;
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);

    .maintop {
      display: flex;
      // padding: 10px 0;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          color: #ffffff;
          background: #ffad41;
          width: 68px;
          height: 32px;
        }
      }
    }
  }
}
</style>
