<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(true)">
        <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="变动PV">
          <template slot-scope="scope">
            <span>{{scope.row.CHANGE_PV}}</span>
          </template>
        </el-table-column>
        <el-table-column label="变动月数">
          <template slot-scope="scope">
            <span>{{scope.row.CHANGE_MONTH}}</span>
          </template>
        </el-table-column>
        <el-table-column label="状态">
          <template slot-scope="scope">
            {{allData.auditStatus[scope.row.AUDIT_STATUS]}}
          </template>
        </el-table-column>
        <el-table-column label="申请管理员">
          <template slot-scope="scope">
            {{scope.row.CA_ADMIN_NAME}}
          </template>
        </el-table-column>
        <el-table-column label="申请时间">
          <template slot-scope="scope">
            {{tool.formatDate(scope.row.CREATED_AT)}}
          </template>
        </el-table-column>
        <el-table-column label="审核管理员">
          <template slot-scope="scope">
            {{scope.row.AA_ADMIN_NAME}}
          </template>
        </el-table-column>
        <el-table-column label="审核时间">
          <template slot-scope="scope">
            {{tool.formatDate(scope.row.AUDITED_AT)}}
          </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="">
                操作该数据<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="edit" @click.native="handleAudit(scope.row)">审核</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <div class="white-box-footer">
        <el-button type="primary" size="small" @click="handleAdd">申请变动复销</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 LeoFilter from '@/components/Filter'
import baseInfo from '@/utils/baseInfo'
import Pagination from '@/components/Pagination'

export default {
  name: 'user_re-consume-audit-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)
    },
    handleAdd () {
      this.$router.push({path: `/user/re-consume-audit-add`})
    },
    handleAudit (row) {
      this.$confirm('确定要审核通过该移网操作？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        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-audit-list', page, pageSize, this.filterData, function (response) {
        vueObj.allData = response
        vueObj.tableData = response.list
      })
    },
  }
}

</script>

<style scoped>

</style>