<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label"> 锁定状态</label>
        <el-select v-model="query.lockStatus" filterable placeholder="请选择" class="filter-item" @keyup.enter.native="crud.toQuery" >
              <el-option
                v-for="item in dict.box_account_lock_status"
                :key="item.id"
                :label="item.label"
                :value="item.value" />
            </el-select>
        <!-- <el-input v-model="query.lockStatus" clearable placeholder=" 锁定状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> -->
        <label class="el-form-item-label">挖矿状态</label>
        <el-select v-model="query.minerStatus" filterable placeholder="请选择" class="filter-item" @keyup.enter.native="crud.toQuery" >
              <el-option
                v-for="item in dict.box_miner_status"
                :key="item.id"
                :label="item.label"
                :value="item.value" />
            </el-select>
        <!-- <el-input v-model="query.minerStatus" clearable placeholder="挖矿状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> -->
        <label class="el-form-item-label">用户钱包地址</label>
        <el-input v-model="query.address" clearable placeholder="用户钱包地址" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="下单人">
            <el-input v-model="form.userId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="购买数量">
            <el-input v-model="form.boxNumber" style="width: 370px;" />
          </el-form-item>
          <el-form-item label=" 预计收益(USDT)">
            <el-input v-model="form.payMinerTotal" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="累计收益">
            <el-input v-model="form.payMinerAlready" style="width: 370px;" />
          </el-form-item>
          <el-form-item label=" 出局进度(百分比)">
            <el-input v-model="form.payMinerAlreadyRate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label=" 锁定状态">
            <el-select v-model="form.lockStatus" filterable placeholder="请选择">
              <el-option
                v-for="item in dict.box_account_lock_status"
                :key="item.id"
                :label="item.label"
                :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="挖矿状态">
            <el-select v-model="form.minerStatus" filterable placeholder="请选择">
              <el-option
                v-for="item in dict.box_miner_status"
                :key="item.id"
                :label="item.label"
                :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label=" 累计静态总收益 每天更新 ">
            <el-input v-model="form.payMinerJingTotal" style="width: 370px;" />
          </el-form-item>
          <el-form-item label=" 累计动态总收益 一次性奖励 下级用户支付成功 立即返现 ">
            <el-input v-model="form.payMinerDongTotal" style="width: 370px;" />
          </el-form-item>
          <el-form-item label=" 累计管理总收益 每天更新 ">
            <el-input v-model="form.payMinerGuanTotal" style="width: 370px;" />
          </el-form-item>
          <el-form-item label=" 累计节点总收益 每天更新 ">
            <el-input v-model="form.payMinerJiedTotal" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="订单描述">
            <el-input v-model="form.remark" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="版本号">
            <el-input v-model="form.version" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.updateTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="用户钱包地址">
            <el-input v-model="form.address" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="address" label="用户钱包地址" />
        <el-table-column prop="boxNumber" label="购买数量" />
        <el-table-column prop="payMinerTotal" label=" 预计收益(USDT)" />
        <el-table-column prop="payMinerAlready" label="累计收益" />
        <el-table-column prop="payMinerAlreadyRate" label=" 出局进度(百分比)" />
        <el-table-column prop="lockStatus" label=" 锁定状态">
          <template slot-scope="scope">
            {{ dict.label.box_account_lock_status[scope.row.lockStatus] }}
          </template>
        </el-table-column>
        <el-table-column prop="minerStatus" label="挖矿状态">
          <template slot-scope="scope">
            {{ dict.label.box_miner_status[scope.row.minerStatus] }}
          </template>
        </el-table-column>
        <el-table-column prop="payMinerJingTotal" label=" 累计静态总收益" />
        <el-table-column prop="payMinerDongTotal" label=" 累计动态总收益" />
        <el-table-column prop="payMinerGuanTotal" label=" 累计管理总收益" />
        <el-table-column prop="payMinerJiedTotal" label=" 累计节点总收益" />
        <el-table-column prop="remark" label="订单描述" />
        <el-table-column prop="version" label="版本号" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="updateTime" label="更新时间" />

        <!-- <el-table-column v-if="checkPer(['admin','viewBoxAccount:edit','viewBoxAccount:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudViewBoxAccount from '@/api/viewBoxAccount'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, userId: null, boxNumber: null, payMinerTotal: null, payMinerAlready: null, payMinerAlreadyRate: null, lockStatus: null, minerStatus: null, payMinerJingTotal: null, payMinerDongTotal: null, payMinerGuanTotal: null, payMinerJiedTotal: null, remark: null, version: null, createTime: null, updateTime: null, address: null }
export default {
  name: 'ViewBoxAccount',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['box_account_lock_status', 'box_miner_status'],
  cruds() {
    return CRUD({ title: '盲盒账户', url: 'api/viewBoxAccount', idField: 'id', sort: 'id,desc', crudMethod: { ...crudViewBoxAccount }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'viewBoxAccount:add'],
        edit: ['admin', 'viewBoxAccount:edit'],
        del: ['admin', 'viewBoxAccount:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'lockStatus', display_name: ' 锁定状态' },
        { key: 'minerStatus', display_name: '挖矿状态' },
        { key: 'address', display_name: '用户钱包地址' }
      ]
    }
  },
  created() {
    this.crud.optShow = {
      // edit: true,
      reset: true,
      // download: true
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
