<template>
  <div v-loading="loading">
    <div class="white-box">
      <div class="filter-box">
        <filter-user ref="filterUser" :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
      </div>
      <el-table :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange"
                :height="tool.getTableHeight(true)">
        <!--<el-table-column type="selection" width="55" v-if="tableHeaders"></el-table-column>-->
        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''">
          <template slot-scope="scope">
            <template v-if="scope.row[tableHeader.index].other.tag" >
              <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
            </template>
            <template v-else-if="scope.row[tableHeader.index].other.progress" >
              <el-progress type="circle" :percentage="Number.parseInt(percentList['MOVE_PERCENT'][scope.row.ID])"
                           :width="50"
                           :stroke-width="3"></el-progress>
            </template>
            <template v-else>
              <div v-html="scope.row[tableHeader.index].value"></div>
            </template>
          </template>
        </el-table-column>

      </el-table>
      <div class="white-box-footer">
        <el-button type="primary" size="small" @click="handleAdd" icon="el-icon-plus"
                   v-show="permission.hasPermission(`user/change-user-dec-level`)">Modify member level<!-- 修改会员级别 -->
        </el-button>

        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
      </div>

    </div>
  </div>
</template>

<script>
    import network from '@/utils/network'
    import tool from '@/utils/tool'
    import FilterUser from '@/components/FilterUser'
    import baseInfo from '@/utils/baseInfo'
    import permission from '@/utils/permission'
    import Pagination from '@/components/Pagination'
    import filterHelper from '@/utils/filterHelper'

    export default {
        name: 'leo-balance-audit-table',
        components: {FilterUser,Pagination},
        mounted() {
            network.getData('finance/change-balance-type').then(response => {
                this.type = response.type
                this.dealTypes = response.dealTypes
                this.getData()
            })
        },
        data() {
            return {
                tableHeaders: null,
                tableData: null,
                loading: true,
                multipleSelection: [],
                currentPage: 1,
                totalPages: 1,
                totalCount: 1,
                pageSize: 20,
                tool: tool,
                permission: permission,
                baseDecLevels: baseInfo.decLevels(),
                filterTypes: {},
                filterModel: {},
                filterStatus: '0',
                type: null,
                dealTypes: null,
                dialogEditLoading: false,
                dialogAuditLoading: false,
                dialogEditFormVisible: false,
                dialogAuditFormVisible: false,
                auditId: null,
                form: {
                    id: null,
                    baseInfo: {USER_NAME: null},
                    type: null,
                    dealType: null,
                    amount: 0,
                    createRemark: '',
                    remark: '',
                    auditStatus: null
                },
            }
        },
        methods: {
            handleMuli(command) {
                if (this.multipleSelection.length < 1) {
                    this.$message({
                        message: 'Please select the record to operate',//请选择要操作的记录
                        type: 'warning'
                    })
                    return;
                }
                if (command === 'pass') {
                    this.handleAudit(null, 'true')
                } else if (command === 'reject') {
                    this.handleAudit(null, 'reject')
                } else if (command === 'passMinus') {
                    this.handleAudit(null, 'true', true)
                }
            },
            handleAdd() {
                this.$router.push({path: `/user/change-user-dec-level`})
            },

            handleSelectionChange(val) {
                this.multipleSelection = val
            },
            handleCurrentChange(page) {
                this.getData(page, this.pageSize)
            },
            handleSizeChange(pageSize) {
                this.getData(this.currentPage, pageSize)
            },
            handleFilterUser(filterData) {
                filterHelper.handleFilterUser(this, filterData)
            },
            getData(page, pageSize) {
                let filterData = this.filterModel
                let vueObj=this
                filterData.filterStatus = this.filterStatus != -1 ? `=,${this.filterStatus}` : ''
                network.getPageData(this, 'user/dec-level-list', page, pageSize, filterData, function (response) {
                    vueObj.allData = response
                    vueObj.filterTypes = response.filterTypes
                })
            },
        }
    }
</script>

<style scoped>

</style>
