企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
>index html ``` <div class="panel panel-default panel-intro"> <div class="panel-heading"> <div class="panel-lead"><em>活动管理</em></div> <ul class="nav nav-tabs"> {volist name='activity_list' id='v'} <li {if $key==0} class="active" {/if} ><a href="#jump_{$v.ID}" data-toggle="tab">{$v.ActivityType}</a></li> {/volist} </ul> </div> <div class="panel-body"> <div id="myTabContent" class="tab-content"> {volist name='activity_list' id='v'} <div class="tab-pane fade {if $key==0} active in {/if}" id="jump_{$v.ID}"> <div id="toolbar_{$v.ID}" class="toolbar"> <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('activity/activity_manager/del')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> <a href="javascript:;" class="btn btn-info btn-edit btn-disabled disabled {:$auth->check('activity/activity_manager/del')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('activity/activity_manager/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> </div> <table id="table_{$v.ID}" class="table table-striped table-bordered table-hover" data-operate-edit="{:$auth->check('activity/activity_manager/edit')}" data-operate-del="{:$auth->check('activity/activity_manager/del')}" width="100%"> </table> </div> {/volist} </div> </div> </div> ``` > controller ``` <?php namespace app\admin\controller\activity; use app\admin\model\rynativeweb\table\Act_ActivityType; use app\admin\model\rynativeweb\table\Act_FirstPayActivity; use app\admin\model\rynativeweb\table\Act_LuckyPlayActivity; use app\admin\model\rynativeweb\table\Act_PayActivityInfo; use app\admin\model\rynativeweb\table\Act_RescueActivity; use app\admin\model\rynativeweb\table\Act_ShareActivity; use app\admin\model\rynativeweb\table\Act_ShowImgActivity; use app\admin\model\rynativeweb\table\Act_SignInActivity; use app\admin\model\rynativeweb\table\Act_SpreadUpActivity; use app\common\controller\Backend; use Exception; use PDOException; use think\Db; use think\exception\ValidateException; /** * Class ActivityManager * @package app\admin\controller\activity * 活动管理 */ class ActivityManager extends Backend { protected $noNeedRight = ['activity']; protected $multiFields=['Enabled']; public function _initialize() { parent::_initialize(); // TODO: Change the autogenerated stub } /** * 查看 */ public function index() { //活动类型 $activity_list = Act_ActivityType::GetActivityType(); $this->assign('activity_list', $activity_list); return $this->view->fetch(); } //数据列表 public function activity() { //设置过滤方法 $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(); $filter = $this->request->get("filter", ''); $tempFilter = json_decode($filter, true) ?? []; //活动类型 $ActivityType = $tempFilter['ActivityType']; $table=$this->getTable($ActivityType); $list = $table ->where($where) ->order($sort, $order) ->paginate($limit); $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } } /** * 添加 */ public function add() { $type=$this->request->param('type',1); $table=$this->getTable($type); if ($this->request->isPost()) { $params = $this->request->post("row/a"); if ($params) { $params = $this->preExcludeFields($params); if ($this->dataLimit && $this->dataLimitFieldAutoFill) { $params[$this->dataLimitField] = $this->auth->id; } $result = false; Db::startTrans(); try { $result = $table->allowField(true)->save($params); Db::commit(); } catch (ValidateException $e) { Db::rollback(); $this->error($e->getMessage()); } catch (PDOException $e) { Db::rollback(); $this->error($e->getMessage()); } catch (Exception $e) { Db::rollback(); $this->error($e->getMessage()); } if ($result !== false) { $this->success(); } else { $this->error(__('No rows were inserted')); } } $this->error(__('Parameter %s can not be empty', '')); } $this->view->assign("type", $type); return $this->view->fetch(); } /** * 编辑 */ public function edit($ids = null) { $type=$this->request->param('type',1); $table=$this->getTable($type); $row = $table->get($ids); if (!$row) { $this->error(__('No Results were found')); } $adminIds = $this->getDataLimitAdminIds(); if (is_array($adminIds)) { if (!in_array($row[$this->dataLimitField], $adminIds)) { $this->error(__('You have no permission')); } } if ($this->request->isPost()) { $params = $this->request->post("row/a"); if ($params) { $params = $this->preExcludeFields($params); $result = false; Db::startTrans(); try { $result = $row->allowField(true)->save($params); Db::commit(); } catch (ValidateException $e) { Db::rollback(); $this->error($e->getMessage()); } catch (PDOException $e) { Db::rollback(); $this->error($e->getMessage()); } catch (Exception $e) { Db::rollback(); $this->error($e->getMessage()); } if ($result !== false) { $this->success(); } else { $this->error(__('No rows were updated')); } } $this->error(__('Parameter %s can not be empty', '')); } $this->view->assign("row", $row); $this->view->assign("type", $type); return $this->view->fetch(); } /** * 删除 */ public function del($ids = "") { if (!$this->request->isPost()) { $this->error(__("Invalid parameters")); } $ids = $ids ? $ids : $this->request->post("ids"); if ($ids) { $type=$this->request->param('type',1); $table=$this->getTable($type); $pk = $table->getPk(); $adminIds = $this->getDataLimitAdminIds(); if (is_array($adminIds)) { $table->where($this->dataLimitField, 'in', $adminIds); } $list = $table->where($pk, 'in', $ids)->select(); $count = 0; Db::startTrans(); try { foreach ($list as $k => $v) { $count += $v->delete(); } Db::commit(); } catch (PDOException $e) { Db::rollback(); $this->error($e->getMessage()); } catch (Exception $e) { Db::rollback(); $this->error($e->getMessage()); } if ($count) { $this->success(); } else { $this->error(__('No rows were deleted')); } } $this->error(__('Parameter %s can not be empty', 'ids')); } /** * 批量更新 */ public function multi($ids = "") { if (!$this->request->isPost()) { $this->error(__("Invalid parameters")); } $ids = $ids ? $ids : $this->request->post("ids"); if ($ids) { $type=$this->request->param('type',1); $table=$this->getTable($type); if ($this->request->has('params')) { parse_str($this->request->post("params"), $values); $values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields))); if ($values) { $adminIds = $this->getDataLimitAdminIds(); if (is_array($adminIds)) { $table->where($this->dataLimitField, 'in', $adminIds); } $count = 0; Db::startTrans(); try { $list = $table->where($table->getPk(), 'in', $ids)->select(); foreach ($list as $index => $item) { $count += $item->allowField(true)->isUpdate(true)->save($values); } Db::commit(); } catch (\think\exception\PDOException $e) { Db::rollback(); $this->error($e->getMessage()); } catch (Exception $e) { Db::rollback(); $this->error($e->getMessage()); } if ($count) { $this->success(); } else { $this->error(__('No rows were updated')); } } else { $this->error(__('You have no permission')); } } } $this->error(__('Parameter %s can not be empty', 'ids')); } protected function getTable($type){ switch ($type) { case 1: $table = new Act_PayActivityInfo(); //充值返现 break; case 2: $table = new Act_LuckyPlayActivity();//幸运玩家 break; case 3: $table = new Act_RescueActivity();//天天救援 break; case 4: $table = new Act_ShareActivity(); //邀请有奖 break; case 5: $table = new Act_FirstPayActivity();//首存送礼 break; case 6: $table = new Act_SignInActivity(); //签到送礼 break; case 7: $table = new Act_SpreadUpActivity(); //代理升级送礼 break; default: $table = new Act_ShowImgActivity(); //推广妙招 注册送金币 } return $table; } } ``` > js ``` ~~~ define(['jquery', 'bootstrap', 'backend', 'table', 'form','color'], function ($, undefined, Backend, Table, Form,Color) { var arr={ jump_1: function () { // 充值返现 var table1 = $("#table_1"); table1.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=1', add_url: 'activity/activity_manager/add?type=1', edit_url: 'activity/activity_manager/edit?type=1', multi_url: 'activity/activity_manager/multi?type=1', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_1', pk: 'ID', sortName: 'ID', sortOrder: 'desc', singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'StarTime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'EndTime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'Enabled', title: __('状态'), table: table1, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 1; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table1); }, jump_2: function () { // 幸运玩家 var table2 = $("#table_2"); table2.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=2', add_url: 'activity/activity_manager/add?type=2', edit_url: 'activity/activity_manager/edit?type=2', multi_url: 'activity/activity_manager/multi?type=2', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_2', pk: 'ID', sortName: 'ID', sortOrder: 'desc', //pagination:false, singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'ShareAmount', title: __('赠送金额'), formatter: Color.api.red}, {field: 'StarTime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'EndTime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'Enabled', title: __('状态'), table: table2, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 2; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table2); }, jump_3: function () { // 天天救援 var table3 = $("#table_3"); table3.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=3', add_url: 'activity/activity_manager/add?type=3', edit_url: 'activity/activity_manager/edit?type=3', multi_url: 'activity/activity_manager/multi?type=3', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_3', pk: 'ID', sortName: 'ID', sortOrder: 'desc', //pagination:false, singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'ShareAmount', title: __('赠送金额'), formatter: Color.api.red}, {field: 'ApplyStarTime', title: __('申请开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'ApplyEndTime', title: __('申请失效时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'ShareType', title: __('赠送方式'), searchList: {"1":__('金额'),"0":__('比例')}, formatter: function (value) { return value=='1'?'金额':'比例'; }}, {field: 'ShareRatio', title: __('赠送比例'), formatter: function (value) { return '<strong style="color: orange;">'+value+' %</strong>'; }}, {field: 'ApplyScore', title: __('输分额度'), formatter: Color.api.blue}, {field: 'StarTime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'EndTime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'Enabled', title: __('状态'), table: table3, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table3, events: Table.api.events.operate, buttons:[ { name: 'aply', text: __('申请记录'), classname: 'btn btn-xs btn-warning btn-dialog', extend: 'data-area=\'["80%","85%"]\' ', title: __('查看申请记录'), url: 'activity/activity_apply/index' }, ],formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 3; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table3); }, jump_4: function () { // 邀请有奖 var table4 = $("#table_4"); table4.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=4', add_url: 'activity/activity_manager/add?type=4', edit_url: 'activity/activity_manager/edit?type=4', multi_url: 'activity/activity_manager/multi?type=4', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_4', pk: 'ID', sortName: 'ID', sortOrder: 'desc', //pagination:false, singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'ShareAmount', title: __('赠送金额'), formatter: Color.api.red}, {field: 'StarTime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'EndTime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'Enabled', title: __('状态'), table: table4, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table4, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 4; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table4); }, jump_5: function () { // 首存送礼 var table5 = $("#table_5"); table5.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=5', add_url: 'activity/activity_manager/add?type=5', edit_url: 'activity/activity_manager/edit?type=5', multi_url: 'activity/activity_manager/multi?type=5', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_5', pk: 'ID', sortName: 'ID', sortOrder: 'desc', //pagination:false, singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'GiveRatio', title: __('赠送比例'), formatter: function (value) { return '<strong style="color: orange;">'+value+' %</strong>'; }}, {field: 'StarTime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'EndTime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'Enabled', title: __('状态'), table: table5, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table5, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 5; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table5); }, jump_6: function () { // 签到送礼 var table6 = $("#table_6"); table6.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=6', add_url: 'activity/activity_manager/add?type=6', edit_url: 'activity/activity_manager/edit?type=6', multi_url: 'activity/activity_manager/multi?type=6', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_6', pk: 'ID', sortName: 'ID', sortOrder: 'desc', //pagination:false, singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'ShareAmount', title: __('赠送金额'), formatter: Color.api.red}, {field: 'StarTime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'EndTime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'Enabled', title: __('状态'), table: table6, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table6, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 6; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table6); }, jump_7: function () { // 代理升级送礼 var table7 = $("#table_7"); table7.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=7', add_url: 'activity/activity_manager/add?type=7', edit_url: 'activity/activity_manager/edit?type=7', multi_url: 'activity/activity_manager/multi?type=7', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_7', pk: 'ID', sortName: 'ID', sortOrder: 'desc', //pagination:false, singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'CommBase', title: __('返佣等级')}, {field: 'ShareAmount', title: __('赠送金额'), formatter: Color.api.red}, {field: 'StarTime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'EndTime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'Enabled', title: __('状态'), table: table7, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table7, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 7; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table7); }, jump_8: function () { // 图片广告 var table8 = $("#table_8"); table8.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=8', add_url: 'activity/activity_manager/add?type=8', edit_url: 'activity/activity_manager/edit?type=8', multi_url: 'activity/activity_manager/multi?type=8', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_8', pk: 'ID', sortName: 'ID', sortOrder: 'desc', //pagination:false, singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'Enabled', title: __('状态'), table: table8, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table8, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 8; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table8); }, jump_9: function () { // 图片广告 var table9 = $("#table_9"); table9.bootstrapTable({ extend: { del_url: 'activity/activity_manager/del?type=9', add_url: 'activity/activity_manager/add?type=9', edit_url: 'activity/activity_manager/edit?type=9', multi_url: 'activity/activity_manager/multi?type=9', table: '', }, url: $.fn.bootstrapTable.defaults.extend.index_url, toolbar: '#toolbar_9', pk: 'ID', sortName: 'ID', sortOrder: 'desc', singleSelect: true, //启用单选 columns: [ [ {checkbox: true}, {field: 'ID', title: '标识'}, {field: 'ActivityName', title: __('活动名称'), formatter: Table.api.formatter.search}, {field: 'ActivityTitle', title: __('活动标题')}, {field: 'Enabled', title: __('状态'), table: table9, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, {field: 'ActivityImgPath', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'operate', title: __('Operate'), table: table9, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], queryParams: function (params) { //这里可以追加搜索条件 var filter = JSON.parse(params.filter); var op = JSON.parse(params.op); filter.ActivityType = 9; op.ActivityType = "="; params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); return params; }, }); Table.api.bindevent(table9); }, } var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'activity/activity_manager/activity' } }); //绑定事件 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { var panel = $($(this).attr("href")); if (panel.size() > 0) { Controller.table[panel.attr("id")].call(this); $(this).on('click', function (e) { $($(this).attr("href")).find(".btn-refresh").trigger("click"); }); } //移除绑定的事件 $(this).unbind('shown.bs.tab'); }); //必须默认触发shown.bs.tab事件 $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab"); }, table: arr, add: function () { Form.api.bindevent($("form[role=form]")); }, edit: function () { Form.api.bindevent($("form[role=form]")); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); }, } }; return Controller; }); ``` > color js 在 assets/js 下面 ``` define(['jquery'], function ($) { var Color = { config:{ reg:function (value) { var re = /^.[0-9]*/; if (!re.test(value)) { return value; } return parseFloat(value); } }, api: { red:function (value, row, index) { return '<strong style="color: red">'+Color.config.reg(value)+'</strong>'; }, blue:function (value, row, index) { return '<strong style="color: blue">'+Color.config.reg(value)+'</strong>'; }, green:function (value, row, index) { return '<strong style="color: green">'+Color.config.reg(value)+'</strong>'; }, grey:function (value, row, index) { return '<strong style="color: grey">'+Color.config.reg(value)+'</strong>'; }, orange:function (value, row, index) { return '<strong style="color: orange">'+Color.config.reg(value)+'</strong>'; }, orchid:function (value, row, index) { return '<strong style="color: orchid">'+Color.config.reg(value)+'</strong>'; }, orangered:function (value, row, index) { return '<strong style="color: orangered">'+Color.config.reg(value)+'</strong>'; }, } }; //将Fast渲染至全局 window.Color = Color; return Color; }); ```