From 2886c4162ba8fde23b00bcecdfcee8aa28919e11 Mon Sep 17 00:00:00 2001 From: xiadc <251308692@qq.com> Date: Wed, 30 Apr 2025 16:15:04 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E8=B5=9B=E4=BA=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/zy/Game.php | 74 +++++++ application/admin/lang/zh-cn/zy/game.php | 77 ++++++++ application/admin/model/zy/Game.php | 62 ++++++ application/admin/validate/zy/Game.php | 27 +++ application/admin/view/zy/game/add.html | 213 +++++++++++++++++++++ application/admin/view/zy/game/edit.html | 223 ++++++++++++++++++++++ application/admin/view/zy/game/index.html | 29 +++ public/assets/js/backend/zy/game.js | 76 ++++++++ 8 files changed, 781 insertions(+) create mode 100644 application/admin/controller/zy/Game.php create mode 100644 application/admin/lang/zh-cn/zy/game.php create mode 100644 application/admin/model/zy/Game.php create mode 100644 application/admin/validate/zy/Game.php create mode 100644 application/admin/view/zy/game/add.html create mode 100644 application/admin/view/zy/game/edit.html create mode 100644 application/admin/view/zy/game/index.html create mode 100644 public/assets/js/backend/zy/game.js diff --git a/application/admin/controller/zy/Game.php b/application/admin/controller/zy/Game.php new file mode 100644 index 0000000..37d5e56 --- /dev/null +++ b/application/admin/controller/zy/Game.php @@ -0,0 +1,74 @@ +model = new \app\admin\model\zy\Game; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['activity','stadium','club','user']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + $row->getRelation('activity')->visible(['name']); + $row->getRelation('stadium')->visible(['name']); + $row->getRelation('club')->visible(['name']); + $row->getRelation('user')->visible(['username']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/admin/lang/zh-cn/zy/game.php b/application/admin/lang/zh-cn/zy/game.php new file mode 100644 index 0000000..3078f59 --- /dev/null +++ b/application/admin/lang/zh-cn/zy/game.php @@ -0,0 +1,77 @@ + '主活动比赛', + 'Act_id' => '球局活动', + 'Gym_id' => '球馆', + 'Club_id' => '俱乐部', + 'Name' => '赛事名称', + 'Team_type' => '队伍类型', + 'Rule_type' => '规则类型', + 'Date' => '比赛日期', + 'Week' => '星期几', + 'Start_time' => '开始时间', + 'End_time' => '结束时间', + 'Public_time' => '发布时间', + 'Join_start_time' => '报名开始时间', + 'Join_end_time' => '报名截止时间', + 'Quit_time' => '免费退坑时间', + 'Game_time' => '比赛时长(时)', + 'Address' => '地点', + 'Field' => '场地号', + 'Position' => '经纬度', + 'Cost' => '报名费用', + 'Limit_num' => '报名限制人数', + 'Join_num' => '报名人数', + 'Attention' => '关注人数', + 'Status' => '状态', + 'Describe' => '比赛介绍', + 'Img' => '图片', + 'Game_rule' => '比赛规则', + 'Is_public' => '是否公开', + 'Bring_num' => '可带人数', + 'Is_bring' => '可否带人', + 'Referee' => '裁判', + 'Create_time' => '创建时间', + 'Update_time' => '修改时间', + 'Activity.name' => '名称', + 'Stadium.name' => '球馆名称', + 'Club.name' => '俱乐部名称', + 'User.username' => '用户名', + + + "Is_public0" => "否", + "Is_public1" => "是", + + "Is_bring0" => "否", + "Is_bring1" => "是", + + "Team_type1" => "双打", + "Team_type2" => "单打", + "Team_type3" => "团队", + + "Rule_type1" => "八人转", + "Rule_type2" => "超八转", + "Rule_type3" => "混双转", + "Rule_type4" => "固搭转", + "Rule_type5" => "固定擂", + "Rule_type6" => "活动擂", + + "Type0" => "一次性", + "Type1" => "周期性", + + "Status0" => "未开始", + "Status1" => "报名中", + "Status2" => "进行中", + "Status3" => "已结束", + + "Week0" => "周日", + "Week1" => "周一", + "Week2" => "周二", + "Week3" => "周三", + "Week4" => "周四", + "Week5" => "周五", + "Week6" => "周六", + + +]; diff --git a/application/admin/model/zy/Game.php b/application/admin/model/zy/Game.php new file mode 100644 index 0000000..40e150c --- /dev/null +++ b/application/admin/model/zy/Game.php @@ -0,0 +1,62 @@ +belongsTo('Activity', 'act_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function stadium() + { + return $this->belongsTo('Stadium', 'gym_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function club() + { + return $this->belongsTo('Club', 'club_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function user() + { + return $this->belongsTo('app\admin\model\User', 'referee', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/admin/validate/zy/Game.php b/application/admin/validate/zy/Game.php new file mode 100644 index 0000000..7a41ba6 --- /dev/null +++ b/application/admin/validate/zy/Game.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/zy/game/add.html b/application/admin/view/zy/game/add.html new file mode 100644 index 0000000..3803ef2 --- /dev/null +++ b/application/admin/view/zy/game/add.html @@ -0,0 +1,213 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {:build_radios('row[team_type]', ['1'=>__('Team_type1'), '2'=>__('Team_type2'), '3'=>__('Team_type3')],1)} +
+
+
+ +
+ {:build_radios('row[rule_type]', ['1'=>__('Rule_type1'), '2'=>__('Rule_type2'), '3'=>__('Rule_type3'), '4'=>__('Rule_type4'), '5'=>__('Rule_type5'), '6'=>__('Rule_type6')],1)} +
+
+
+ +
+ {:build_radios('row[week]', ['0'=>__('Week0'), '1'=>__('Week1'), '2'=>__('Week2'), '3'=>__('Week3'), '4'=>__('Week4'), '5'=>__('Week5'), '6'=>__('Week6')],0)} +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ {:__('Key')} + {:__('Value')} +
+
{:__('Append')}
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+ +
+
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + {:build_radios('row[is_public]', ['1'=>__('Is_public1'), '0'=>__('Is_public0')],1)} +
    +
    +
    + +
    + {:build_radios('row[is_bring]', ['0'=>__('Is_bring0'), '1'=>__('Is_bring1')],1)} +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + {:build_radios('row[status]', ['0'=>__('Status0'), '1'=>__('Status1'), '2'=>__('Status2'), '3'=>__('Status3')],0)} +
    +
    + + +
    diff --git a/application/admin/view/zy/game/edit.html b/application/admin/view/zy/game/edit.html new file mode 100644 index 0000000..7dbefdb --- /dev/null +++ b/application/admin/view/zy/game/edit.html @@ -0,0 +1,223 @@ +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + {:build_radios('row[team_type]', ['1'=>__('Team_type1'), '2'=>__('Team_type2'), + '3'=>__('Team_type3')],$row['team_type'])} +
    +
    +
    + +
    + {:build_radios('row[rule_type]', ['1'=>__('Rule_type1'), '2'=>__('Rule_type2'), '3'=>__('Rule_type3'), + '4'=>__('Rule_type4'), '5'=>__('Rule_type5'), '6'=>__('Rule_type6')],$row['rule_type'])} +
    +
    +
    + +
    + {:build_radios('row[week]', ['0'=>__('Week0'), '1'=>__('Week1'), '2'=>__('Week2'), '3'=>__('Week3'), + '4'=>__('Week4'), '5'=>__('Week5'), '6'=>__('Week6')],$row['week'])} +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + {:__('Key')} + {:__('Value')} +
    +
    {:__('Append')}
    + +
    + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    + + +
    + +
    +
      +
      +
      +
      + +
      + +
      +
      +
      + +
      + {:build_radios('row[is_public]', ['1'=>__('Is_public1'), '0'=>__('Is_public0')],$row['is_public'])} +
      +
      +
      + +
      + {:build_radios('row[is_bring]', ['0'=>__('Is_bring0'), '1'=>__('Is_bring1')],$row['is_bring'])} +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + {:build_radios('row[status]', ['0'=>__('Status0'), '1'=>__('Status1'), '2'=>__('Status2'), + '3'=>__('Status3')],$row['status'])} +
      +
      + + +
      diff --git a/application/admin/view/zy/game/index.html b/application/admin/view/zy/game/index.html new file mode 100644 index 0000000..18f3617 --- /dev/null +++ b/application/admin/view/zy/game/index.html @@ -0,0 +1,29 @@ +
      + {:build_heading()} + +
      +
      +
      + +
      + +
      +
      +
      diff --git a/public/assets/js/backend/zy/game.js b/public/assets/js/backend/zy/game.js new file mode 100644 index 0000000..8115094 --- /dev/null +++ b/public/assets/js/backend/zy/game.js @@ -0,0 +1,76 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'zy/game/index' + location.search, + add_url: 'zy/game/add', + edit_url: 'zy/game/edit', + del_url: 'zy/game/del', + multi_url: 'zy/game/multi', + import_url: 'zy/game/import', + table: 'zy_game', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + fixedColumns: true, + fixedRightNumber: 1, + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'pid', title: __('Pid')}, + {field: 'activity.name', title: __('Activity.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'stadium.name', title: __('Stadium.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'club.name', title: __('Club.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + { field: 'is_public', title: __('Is_public'), formatter: Table.api.formatter.label, searchList: { 0: __('Is_public0'), 1: __('Is_public1') } }, + { field: 'team_type', title: __('Team_type'), formatter: Table.api.formatter.label, searchList: { 3: __('Team_type3'), 1: __('Team_type1'), 2: __('Team_type2') } }, + { field: 'rule_type', title: __('Rule_type'), formatter: Table.api.formatter.label, searchList: { 1: __('Rule_type1'), 2: __('Rule_type2'), 3: __('Rule_type3'), 4: __('Rule_type4'), 5: __('Rule_type5'), 6: __('Rule_type6') } }, + { field: 'week', title: __('Week'), formatter: Table.api.formatter.label, searchList: { 0: __('Week0'), 1: __('Week1'), 2: __('Week2'), 3: __('Week3'), 4: __('Week4'), 5: __('Week5'), 6: __('Week6') } }, + {field: 'date', title: __('Date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'start_time', title: __('Start_time')}, + {field: 'end_time', title: __('End_time')}, + {field: 'game_time', title: __('Game_time'), operate:'BETWEEN'}, + {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'field', title: __('Field'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'limit_num', title: __('Limit_num')}, + {field: 'join_num', title: __('Join_num')}, + {field: 'attention', title: __('Attention')}, + { field: 'is_bring', title: __('Is_bring'), formatter: Table.api.formatter.label, searchList: { 0: __('Is_bring0'), 1: __('Is_bring1') } }, + {field: 'bring_num', title: __('Bring_num')}, + { field: 'status', title: __('Status'), formatter: Table.api.formatter.label, searchList: { 0: __('Status0'), 1: __('Status1') } }, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +});