<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">交易哈希</label>
        <el-input v-model="query.txHash" 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.fromAddress" 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.toAddress" 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.status" filterable placeholder="请选择" class="filter-item" @keyup.enter.native="crud.toQuery">
              <el-option
                v-for="item in dict.flow_chain_status"
                :key="item.id"
                :label="item.label"
                :value="item.value" />
            </el-select>
        <!-- <el-input v-model="query.status" 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="状态编辑" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="id"  v-if="false">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="PETK数量">
            <el-input v-model="form.amountPetk" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="链上状态">
            <template>
              <el-select v-model="form.status"  placeholder="请选择">
              <el-option
                v-for="item in chianstatus"
                :key="item.value"
                :label="item.label"
                :value="item.value" />
            </el-select>
            </template>
            
          </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="id" label="id" v-if="false"/>
        <el-table-column prop="userId" label="操作用户主键" v-if="false" />
        <el-table-column prop="userAccountId" label="操作用户账户主键" v-if="false"/>
        <el-table-column prop="outFee" label="提币手续费" />
        <el-table-column prop="amountUsdt" label="USDT数量" />
        <el-table-column prop="amountPetk" label="PETK数量" />
        <el-table-column prop="pricePetk" label="当前价格" />
        <el-table-column prop="txHash" label="交易哈希" />
        <el-table-column prop="fromAddress" label="转出地址" />
        <el-table-column prop="toAddress" label="到账地址" />
        <el-table-column prop="status" label="链上状态">
          <template slot-scope="scope">
            {{ dict.label.flow_chain_status[scope.row.status] }}
          </template>
        </el-table-column>
        <el-table-column prop="sendStatus" label="发送状态">
          <template slot-scope="scope">
            {{ dict.label.flow_send_status[scope.row.sendStatus] }}
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="updateTime" label="更新时间" />
        
        <el-table-column v-if="checkPer(['admin','viewWalletFlow:edit',,'viewWalletFlow:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
            :disabled-dle="scope.row.id ===scope.row.id"
            :disabled-edit="(scope.row.status==='success')||(scope.row.status==='notpass')"
            
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudViewWalletFlow from '@/api/viewWalletFlow'
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, userAccountId: null, outFee: null, amountUsdt: null, amountPetk: null, pricePetk: null, txHash: null, fromAddress: null, toAddress: null, status: null, sendStatus: null, createTime: null, updateTime: null, address: null }
export default {
  name: 'ViewWalletFlow',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['flow_chain_status', 'flow_send_status'],
  cruds() {
    return CRUD({ title: 'walletflow', url: 'api/viewWalletFlow', idField: 'id', sort: 'id,desc', crudMethod: { ...crudViewWalletFlow }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'viewWalletFlow:add'],
        edit: ['admin', 'viewWalletFlow:edit']
        
      },
      value: '',
      chianstatus:[{label:"请选择",value:"waitPass"},{label:"通过",value:"waitsend"},{label:"拒绝",value:"notpass"}],
      rules: {
      },
      queryTypeOptions: [
        { key: 'txHash', display_name: '交易哈希' },
        { key: 'fromAddress', display_name: '转出地址' },
        { key: 'toAddress', display_name: '到账地址' },
        { key: 'status', display_name: '链上状态' },
        { key: 'address', display_name: '钱包地址' }
      ]
    }
  },
  created() {
    this.crud.optShow = {
      edit: true,
      reset: true,
      // download: true
    }
  },
  created() {
    this.crud.optShow = {
      // edit: true,
      reset: true,
      // download: true
    }
  },
  
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
