<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.orderCode" 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.userTelegramId" 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.userName" 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.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.type" 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.orderCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="消息id">
            <el-input v-model="form.messageId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="聊天id">
            <el-input v-model="form.chatId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="用户电报号">
            <el-input v-model="form.userTelegramId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="用户名称">
            <el-input v-model="form.userName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="赔率">
            <el-input v-model="form.odds" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="发包金额">
            <el-input v-model="form.chipTotal" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="未抢完金额">
            <el-input v-model="form.chipRemain" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="总盈利">
            <el-input v-model="form.profit" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="雷号">
            <el-input v-model="form.bombNumber" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="领取次数">
            <el-input v-model="form.nowReceiveCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="状态">
            <el-input v-model="form.status" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="类型">
            <el-input v-model="form.type" 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>
        <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="id" label="id" />
        <el-table-column prop="orderCode" label="订单号" />
        <el-table-column prop="messageId" label="消息id" />
        <el-table-column prop="chatId" label="聊天id" />
        <el-table-column prop="userTelegramId" label="用户电报号" />
        <el-table-column prop="userName" label="用户名称" />
        <el-table-column prop="odds" label="赔率" />
        <el-table-column prop="chipTotal" label="发包金额" />
        <el-table-column prop="chipRemain" label="未抢完金额" />
        <el-table-column prop="profit" label="总盈利" />
        <el-table-column prop="bombNumber" label="雷号" />
        <el-table-column prop="nowReceiveCount" label="领取次数" />
        <el-table-column prop="status" label="状态">
          <template slot-scope="scope">
            {{ dict.label.order_status[scope.row.status] }}
          </template>
        </el-table-column>
        <el-table-column prop="type" label="类型">
          <template slot-scope="scope">
            {{ dict.label.order_type[scope.row.type] }}
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="updateTime" label="更新时间" />
        <!-- <el-table-column v-if="checkPer(['admin','botSendOrder:edit','botSendOrder:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="crud.toQuery">查看详情</el-button>
          </template>
          
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudBotSendOrder from '@/api/botSendOrder'
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, orderCode: null, messageId: null, chatId: null, userTelegramId: null, userName: null, odds: null, chipTotal: null, chipRemain: null, profit: null, bombNumber: null, nowReceiveCount: null, status: null, type: null, btcPrice: null, gongZhengNum: null, createTime: null, updateTime: null }
export default {
  name: 'BotSendOrder',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['order_status', 'order_type'],
  cruds() {
    return CRUD({ title: 'OrderController', url: 'api/botSendOrder', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBotSendOrder }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'botSendOrder:add'],
        edit: ['admin', 'botSendOrder:edit'],
        del: ['admin', 'botSendOrder:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'orderCode', display_name: '订单号' },
        { key: 'userTelegramId', display_name: '用户电报号' },
        { key: 'userName', display_name: '用户名称' },
        { key: 'status', display_name: '状态' },
        { key: 'type', display_name: '类型' }
      ]
    }
  },

  created() {
    this.crud.optShow = {
      add:false,
      edit: false,
      reset: true,
      download: true
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    queryOrderDetail(id){
        
    }
  }
}
</script>

<style scoped>

</style>
