Kaynağa Gözat

选手排序

lizhen_gitee 1 gün önce
ebeveyn
işleme
5364b035ff

+ 2 - 1
application/admin/lang/zh-cn/voteplayer.php

@@ -16,5 +16,6 @@ return [
     'Set status to 1'=> '设为上架',
     'Score'          => '得分数',
     'Thumb_image'    => '视频封面图',
-    'Vodid'          => '云点播id'
+    'Vodid'          => '云点播id',
+    'Weigh'          => '排序'
 ];

+ 8 - 0
application/admin/model/Voteplayer.php

@@ -29,6 +29,14 @@ class Voteplayer extends Model
     ];
     
 
+    protected static function init()
+    {
+        self::afterInsert(function ($row) {
+            $pk = $row->getPk();
+            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+        });
+    }
+
     
     public function getStatusList()
     {

+ 6 - 0
application/admin/view/voteplayer/add.html

@@ -88,6 +88,12 @@
             <input id="c-vodid" class="form-control" name="row[vodid]" type="text" value="">
         </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="0">
+        </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">

+ 6 - 0
application/admin/view/voteplayer/edit.html

@@ -88,6 +88,12 @@
             <input id="c-vodid" class="form-control" name="row[vodid]" type="text" value="{$row.vodid|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 layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 1 - 1
application/api/controller/Subject.php

@@ -47,7 +47,7 @@ class Subject extends Api
 
         //选手列表
         $lists = Db::name('vote_player')
-            ->where($map)->orderRaw('RAND()')->select();
+            ->where($map)->order('weigh asc,id asc')->select();
         $lists = list_domain_image($lists,['thumb_image']);
 
 

+ 3 - 1
public/assets/js/backend/voteplayer.js

@@ -21,7 +21,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             table.bootstrapTable({
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
                 pk: 'id',
-                sortName: 'id',
+                sortName: 'weigh,id',
+                sortOrder: 'asc,asc',
                 fixedColumns: true,
                 fixedRightNumber: 1,
                 columns: [
@@ -39,6 +40,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 //                        {field: 'score', title: __('Score')},
                         {field: 'thumb_image', title: __('Thumb_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                         {field: 'vodid', title: __('Vodid'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'weigh', title: __('Weigh'), operate: false},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]