Browse Source

奖池重建

lizhen_gitee 1 year ago
parent
commit
8913d29e0b

+ 5 - 4
application/admin/controller/egg/Jackpot.php

@@ -5,13 +5,13 @@ namespace app\admin\controller\egg;
 use app\common\controller\Backend;
 
 /**
- *
+ * 奖池管理
  *
  * @icon fa fa-circle-o
  */
 class Jackpot extends Backend
 {
-
+    
     /**
      * Jackpot模型对象
      * @var \app\admin\model\egg\Jackpot
@@ -22,7 +22,8 @@ class Jackpot extends Backend
     {
         parent::_initialize();
         $this->model = new \app\admin\model\egg\Jackpot;
-
+        $this->view->assign("statusList", $this->model->getStatusList());
+        $this->view->assign("typeList", $this->model->getTypeList());
     }
 
     public function import()
@@ -35,6 +36,6 @@ class Jackpot extends Backend
      * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
-
+    
 
 }

+ 12 - 5
application/admin/lang/zh-cn/egg/jackpot.php

@@ -1,9 +1,16 @@
 <?php
 
 return [
-    'Name'      => '奖池名称',
-    'Status'    => '状态',
-    'Status -1' => '已抽完奖池',
-    'Status 1'  => '当前奖池',
-    'Status 0'  => '未开放奖池',
+    'Name'       => '奖池名称',
+    'Status'     => '状态',
+    'Status -1'  => '已抽完奖池',
+    'Status 1'   => '当前奖池',
+    'Status 0'   => '未开放奖池',
+    'Tes'        => '更新字段',
+    'Updatetime' => '更新时间',
+    'Weigh'      => '排序',
+    'Type'       => '分类',
+    'Type 1'     => '普通',
+    'Type 2'     => '高级',
+    'Type 3'     => '大转盘'
 ];

+ 43 - 12
application/admin/model/egg/Jackpot.php

@@ -8,31 +8,62 @@ use think\Model;
 class Jackpot extends Model
 {
 
+    
 
-
-
+    
 
     // 表名
     protected $name = 'egg_jackpot';
-
+    
     // 自动写入时间戳字段
-    protected $autoWriteTimestamp = false;
+    protected $autoWriteTimestamp = 'int';
 
     // 定义时间戳字段名
     protected $createTime = false;
-    protected $updateTime = false;
+    protected $updateTime = 'updatetime';
     protected $deleteTime = false;
 
     // 追加属性
     protected $append = [
-
+        'status_text',
+        'type_text'
     ];
-
-
-
-
-
-
+    
+
+    protected static function init()
+    {
+        self::afterInsert(function ($row) {
+            $pk = $row->getPk();
+            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+        });
+    }
+
+    
+    public function getStatusList()
+    {
+        return ['-1' => __('Status -1'), '1' => __('Status 1'), '0' => __('Status 0')];
+    }
+
+    public function getTypeList()
+    {
+        return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+    public function getTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+        $list = $this->getTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
 
 
 

+ 36 - 0
application/admin/view/egg/jackpot/add.html

@@ -6,6 +6,42 @@
             <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="-1"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Tes')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-tes" class="form-control" name="row[tes]" type="number" value="1">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" class="form-control" name="row[weigh]" type="number">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 36 - 0
application/admin/view/egg/jackpot/edit.html

@@ -6,6 +6,42 @@
             <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Tes')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-tes" class="form-control" name="row[tes]" type="number" value="{$row.tes|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 11 - 1
application/admin/view/egg/jackpot/index.html

@@ -1,5 +1,15 @@
 <div class="panel panel-default panel-intro">
-    {:build_heading()}
+    
+    <div class="panel-heading">
+        {:build_heading(null,FALSE)}
+        <ul class="nav nav-tabs" data-field="status">
+            <li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
+            {foreach name="statusList" item="vo"}
+            <li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
+            {/foreach}
+        </ul>
+    </div>
+
 
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">

+ 5 - 1
public/assets/js/backend/egg/jackpot.js

@@ -21,13 +21,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             table.bootstrapTable({
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
                 pk: 'id',
-                sortName: 'id',
+                sortName: 'weigh',
                 columns: [
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
                         {field: 'name', title: __('Name'), operate: 'LIKE'},
                         {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
+                        {field: 'tes', title: __('Tes')},
+                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'weigh', title: __('Weigh'), operate: false},
+                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]