<template>
  <div v-loading="loading">
    <div class="white-box">
      <leo-filter :filter="handleFilter" :userNameDisplay="true"></leo-filter>
      <el-table :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange" :height="tool.getTableHeight()">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column label="会员编号" prop="USER_NAME" width="150"></el-table-column>
        <el-table-column label="会员姓名" prop="REAL_NAME"></el-table-column>
        <el-table-column label="会员级别">
          <template slot-scope="scope">
            <span>{{baseInfo.decLevels[scope.row.DEC_LV].LEVEL_NAME}}</span>
          </template>
        </el-table-column>
        <el-table-column label="聘级">
          <template slot-scope="scope">
            <span>{{baseInfo.empLevels[scope.row.EMP_LV].LEVEL_NAME}}</span>
          </template>
        </el-table-column>
        <el-table-column label="复销未用BV">
          <template slot-scope="scope">
            <span>{{scope.row.UNUSED_PV}}</span>
          </template>
        </el-table-column>
        <el-table-column label="复销未用月数">
          <template slot-scope="scope">
            <span>{{scope.row.UNUSED_MONTH}}</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="180">
          <template slot-scope="scope">
            <el-dropdown size="small" trigger="click">
              <el-button type="primary" size="small" @click.stop="">
                Action<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="edit" @click.native="handleChangeBalance(scope.row)">调整余额</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <div class="white-box-footer">
        <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 LeoFilter from '@/components/Filter'
import baseInfo from '@/utils/baseInfo'
import Pagination from '@/components/Pagination'

export default {
  name: 'user_re-consume-list',
  components: {LeoFilter,Pagination},
  mounted () {
    this.getData()
  },
  data () {
    return {
      allData: null,
      tableData: null,
      loading: true,
      multipleSelection: [],
      currentPage: 1,
      totalPages: 1,
      totalCount: 1,
      pageSize: 20,
      tool: tool,
      filterData: null,
      baseInfo: baseInfo,
    }
  },
  methods: {
    handleSelectionChange (val) {
      this.multipleSelection = val
    },
    handleCurrentChange (page) {
      this.getData(page, this.pageSize)
    },
    handleSizeChange (pageSize) {
      this.getData(this.currentPage, pageSize)
    },
    handleChangeBalance (row) {
      this.$confirm('确定要审核通过该移网操作？', 'Hint', {
        confirmButtonText: 'confirm', // 确定
        cancelButtonText: 'cancel', // 取消
        type: 'warning'
      }).then(() => {
        return network.getData(`user/move-audit/${row.ID}`)
      }).then(response => {
        this.$message({
          message: response,
          type: 'success'
        })
        this.getData(this.currentPage, this.pageSize)
      }).catch(response => {

      })
    },
    handleFilter (model) {
      this.filterData = model
      this.getData(1, this.pageSize)
    },
    getData (page, pageSize) {
      let vueObj = this
      network.getPageData(this, 'user/re-consume-list', page, pageSize, this.filterData, function (response) {
        vueObj.allData = response
        vueObj.tableData = response.list
      })
    },
  }
}

</script>

<style scoped>

</style>
