lizhen_gitee 1 rok temu
rodzic
commit
f9f805c992

+ 1 - 0
application/admin/lang/zh-cn/classes.php

@@ -4,5 +4,6 @@ return [
     'Id'                => 'ID',
     'School_id'         => '学校ID',
     'Classname'         => '班级名',
+    'Weigh'             => '排序',
     'School.schoolname' => '学校名'
 ];

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

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

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

@@ -12,6 +12,12 @@
             <input id="c-classname" data-rule="required" class="form-control" name="row[classname]" 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="1">
+        </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/classes/edit.html

@@ -12,6 +12,12 @@
             <input id="c-classname" data-rule="required" class="form-control" name="row[classname]" type="text" value="{$row.classname|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">

+ 3 - 2
public/assets/js/backend/classes.js

@@ -21,13 +21,14 @@ 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: 'classname', title: __('Classname'), operate: 'LIKE'},
                         {field: 'school_id', title: __('School_id')},
+                        {field: 'classname', title: __('Classname'), operate: 'LIKE'},
+                        {field: 'weigh', title: __('Weigh'), operate: false},
                         {field: 'school.schoolname', title: __('School.schoolname'), operate: 'LIKE'},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]