diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 3b96bde9..4f9233d9 100644 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -684,7 +684,7 @@ class Crud extends Command } //JS最后一列加上操作列 - $javascriptList[] = str_repeat(" ", 24) . "{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}"; + $javascriptList[] = str_repeat(" ", 24) . "{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}"; $addList = implode("\n", array_filter($addList)); $editList = implode("\n", array_filter($editList)); $javascriptList = implode(",\n", array_filter($javascriptList)); diff --git a/application/admin/command/Crud/stubs/index.stub b/application/admin/command/Crud/stubs/index.stub index d3eefa4f..dd11a92d 100644 --- a/application/admin/command/Crud/stubs/index.stub +++ b/application/admin/command/Crud/stubs/index.stub @@ -7,7 +7,7 @@
{:build_toolbar()} - - +
diff --git a/application/admin/common.php b/application/admin/common.php index 00c2f315..7c13b028 100644 --- a/application/admin/common.php +++ b/application/admin/common.php @@ -88,19 +88,27 @@ function build_category_select($name, $type, $selected = null, $attr = [], $head */ function build_toolbar($btns = NULL, $attr = []) { - $btns = $btns ? $btns : ['refresh', 'add', 'edit', 'delete']; + $auth = \app\admin\library\Auth::instance(); + $controller = strtolower(think\Request::instance()->controller()); + $btns = $btns ? $btns : ['refresh', 'add', 'edit', 'del']; $btns = is_array($btns) ? $btns : explode(',', $btns); + $index = array_search('delete', $btns); + if ($index !== FALSE) + { + $btns[$index] = 'del'; + } $btnAttr = [ 'refresh' => ['javascript:;', 'btn btn-primary btn-refresh', 'fa fa-refresh', ''], 'add' => ['javascript:;', 'btn btn-success btn-add', 'fa fa-plus', __('Add')], 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', 'fa fa-pencil', __('Edit')], - 'delete' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete')], + 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete')], ]; $btnAttr = array_merge($btnAttr, $attr); $html = []; foreach ($btns as $k => $v) { - if (!isset($btnAttr[$v])) + //如果未定义或没有权限 + if (!isset($btnAttr[$v]) || ($v !== 'refresh' && !$auth->check("{$controller}/{$v}"))) { continue; } @@ -135,87 +143,3 @@ function build_heading($title = NULL, $content = NULL) return ''; return '
' . $title . '' . $content . '
'; } - -/** - * 判断文件或文件夹是否可写 - * @param string - * @return bool - */ -function is_really_writable($file) -{ - if (DIRECTORY_SEPARATOR === '/') - { - return is_writable($file); - } - if (is_dir($file)) - { - $file = rtrim($file, '/') . '/' . md5(mt_rand()); - if (($fp = @fopen($file, 'ab')) === FALSE) - { - return FALSE; - } - fclose($fp); - @chmod($file, 0777); - @unlink($file); - return TRUE; - } - elseif (!is_file($file) OR ( $fp = @fopen($file, 'ab')) === FALSE) - { - return FALSE; - } - fclose($fp); - return TRUE; -} - -/** - * 删除文件夹 - * @param string $dirname - * @return boolean - */ -function rmdirs($dirname) -{ - if (!is_dir($dirname)) - return false; - $files = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($dirname, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST - ); - - foreach ($files as $fileinfo) - { - $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink'); - $todo($fileinfo->getRealPath()); - } - @rmdir($dirname); - return true; -} - -/** - * 复制文件夹 - * @param string $source 源文件夹 - * @param string $dest 目标文件夹 - */ -function copydirs($source, $dest) -{ - if (!is_dir($dest)) - { - mkdir($dest, 0755); - } - foreach ( - $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item - ) - { - if ($item->isDir()) - { - $sontDir = $dest . DS . $iterator->getSubPathName(); - if (!is_dir($sontDir)) - { - mkdir($sontDir); - } - } - else - { - copy($item, $dest . DS . $iterator->getSubPathName()); - } - } -} diff --git a/application/admin/controller/Addon.php b/application/admin/controller/Addon.php index 804e2e9d..803c7be5 100644 --- a/application/admin/controller/Addon.php +++ b/application/admin/controller/Addon.php @@ -46,7 +46,7 @@ class Addon extends Backend $name = $this->request->get("name"); if (!$name) { - $this->error(__('Parameter %s can not be empty', $id ? 'id' : 'name')); + $this->error(__('Parameter %s can not be empty', $ids ? 'id' : 'name')); } if (!is_dir(ADDON_PATH . $name)) { diff --git a/application/admin/controller/Category.php b/application/admin/controller/Category.php index 8336e3e5..0cc95d97 100644 --- a/application/admin/controller/Category.php +++ b/application/admin/controller/Category.php @@ -28,7 +28,7 @@ class Category extends Backend $tree = Tree::instance(); $tree->init($this->model->order('weigh desc,id desc')->select(), 'pid'); $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name'); - $categorydata = [0 => ['type'=>'all', 'name'=>__('None')]]; + $categorydata = [0 => ['type' => 'all', 'name' => __('None')]]; foreach ($this->categorylist as $k => $v) { $categorydata[$v['id']] = $v; @@ -45,11 +45,25 @@ class Category extends Backend { if ($this->request->isAjax()) { - + $search = $this->request->request("search"); //构造父类select列表选项数据 - $list = $this->categorylist; + $list = []; + if ($search) + { + foreach ($this->categorylist as $k => $v) + { + if (stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) + { + $list[] = $v; + } + } + } + else + { + $list = $this->categorylist; + } $total = count($list); - $result = array("total" => 1, "rows" => $list); + $result = array("total" => $total, "rows" => $list); return json($result); } diff --git a/application/admin/view/common/meta.html b/application/admin/view/common/meta.html index 6328462d..90ed129f 100644 --- a/application/admin/view/common/meta.html +++ b/application/admin/view/common/meta.html @@ -1,6 +1,6 @@ {$title|default=''} - + diff --git a/application/admin/view/general/profile/index.html b/application/admin/view/general/profile/index.html index 4a0d6a3c..d08071ab 100644 --- a/application/admin/view/general/profile/index.html +++ b/application/admin/view/general/profile/index.html @@ -43,7 +43,7 @@
{:__('Click to edit')}
- +

{$admin.username}

diff --git a/application/common.php b/application/common.php index 7189c997..3d117f49 100755 --- a/application/common.php +++ b/application/common.php @@ -94,3 +94,107 @@ if (!function_exists('cdnurl')) } } + + +if (!function_exists('is_really_writable')) +{ + + /** + * 判断文件或文件夹是否可写 + * @param string $file 文件或目录 + * @return bool + */ + function is_really_writable($file) + { + if (DIRECTORY_SEPARATOR === '/') + { + return is_writable($file); + } + if (is_dir($file)) + { + $file = rtrim($file, '/') . '/' . md5(mt_rand()); + if (($fp = @fopen($file, 'ab')) === FALSE) + { + return FALSE; + } + fclose($fp); + @chmod($file, 0777); + @unlink($file); + return TRUE; + } + elseif (!is_file($file) OR ( $fp = @fopen($file, 'ab')) === FALSE) + { + return FALSE; + } + fclose($fp); + return TRUE; + } + +} + +if (!function_exists('rmdirs')) +{ + + /** + * 删除文件夹 + * @param string $dirname 目录 + * @param bool $withself 是否删除自身 + * @return boolean + */ + function rmdirs($dirname, $withself = true) + { + if (!is_dir($dirname)) + return false; + $files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dirname, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST + ); + + foreach ($files as $fileinfo) + { + $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink'); + $todo($fileinfo->getRealPath()); + } + if ($withself) + { + @rmdir($dirname); + } + return true; + } + +} + +if (!function_exists('copydirs')) +{ + + /** + * 复制文件夹 + * @param string $source 源文件夹 + * @param string $dest 目标文件夹 + */ + function copydirs($source, $dest) + { + if (!is_dir($dest)) + { + mkdir($dest, 0755); + } + foreach ( + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item + ) + { + if ($item->isDir()) + { + $sontDir = $dest . DS . $iterator->getSubPathName(); + if (!is_dir($sontDir)) + { + mkdir($sontDir); + } + } + else + { + copy($item, $dest . DS . $iterator->getSubPathName()); + } + } + } + +} diff --git a/application/common/behavior/Common.php b/application/common/behavior/Common.php index bcb34512..01d9be8b 100644 --- a/application/common/behavior/Common.php +++ b/application/common/behavior/Common.php @@ -26,11 +26,16 @@ class Common { Config::set('upload.cdnurl', $cdnurl); } - // 如果是调试模式将version置为当前的时间戳可避免缓存 if (Config::get('app_debug')) { + // 如果是调试模式将version置为当前的时间戳可避免缓存 Config::set('site.version', time()); } + else + { + // 如果是开发模式修改异常页的模板 + Config::set('exception_tmpl', APP_PATH . 'common' . DS . 'view' . DS . 'tpl' . DS . 'think_exception.tpl'); + } } } diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 09c66120..52277ff5 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -165,6 +165,8 @@ class Backend extends Controller $this->assign('site', $site); //渲染配置信息 $this->assign('config', $config); + //渲染权限对象 + $this->assign('auth', $this->auth); //渲染管理员对象 $this->assign('admin', Session::get('admin')); } diff --git a/application/common/view/tpl/think_exception.tpl b/application/common/view/tpl/think_exception.tpl new file mode 100644 index 00000000..1a636729 --- /dev/null +++ b/application/common/view/tpl/think_exception.tpl @@ -0,0 +1,74 @@ + + + + + 发生错误 + + + + + + +
+
+ +
+
+ +
+
+
+ +

+ 你可以返回上一页重试,或直接向我们反馈错误报告 +

+ +
+
+ 返回主页 + 反馈错误 +
+
+ + \ No newline at end of file diff --git a/application/config.php b/application/config.php index 08cf414e..5b42069b 100755 --- a/application/config.php +++ b/application/config.php @@ -146,7 +146,7 @@ return [ // 异常页面的模板文件 'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl', // 错误显示信息,非调试模式有效 - 'error_message' => '页面错误!请稍后再试~', + 'error_message' => '你所浏览的页面暂时无法访问', // 显示错误信息 'show_error_msg' => false, // 异常处理handle类 留空使用 \think\exception\Handle diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 598385fb..c22a2086 100755 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -21,7 +21,7 @@ class Index extends Frontend public function news() { - $newslist = \app\common\model\Page::where('category_id', 1)->order('weigh', 'desc')->select(); + $newslist = []; return jsonp(['newslist' => $newslist, 'new' => count($newslist), 'url' => 'http://www.fastadmin.net?ref=news']); } diff --git a/extend/fast/Date.php b/extend/fast/Date.php index 8e84d044..9f094233 100644 --- a/extend/fast/Date.php +++ b/extend/fast/Date.php @@ -156,78 +156,6 @@ class Date return __("%d {$name}%s ago", $count, ($count > 1 ? 's' : '')); } - /** - * 判断Unix时间是否满足Cron指定的执行条件 - * - * @param string $cron Crontab格式 - * @param string $time 时间,默认为当前时间 - * @return boolean - */ - public static function cron($cron, $time = null) - { - $time = is_null($time) ? time() : $time; - $cron_parts = explode(' ', $cron); - if (count($cron_parts) != 5) - { - return false; - } - list($min, $hour, $day, $mon, $week) = explode(' ', $cron); - $to_check = array('min' => 'i', 'hour' => 'G', 'day' => 'j', 'mon' => 'n', 'week' => 'w'); - $ranges = array( - 'min' => '0-59', - 'hour' => '0-23', - 'day' => '1-31', - 'mon' => '1-12', - 'week' => '0-6', - ); - - foreach ($to_check as $part => $c) - { - $val = $$part; - $values = []; - if (strpos($val, '/') !== false) - { - //Get the range and step - list($range, $steps) = explode('/', $val); - //Now get the start and stop - if ($range == '*') - { - $range = $ranges[$part]; - } - list($start, $stop) = explode('-', $range); - for ($i = $start; $i <= $stop; $i = $i + $steps) - { - $values[] = $i; - } - } - else - { - $k = explode(',', $val); - foreach ($k as $v) - { - if (strpos($v, '-') !== false) - { - list($start, $stop) = explode('-', $v); - - for ($i = $start; $i <= $stop; $i++) - { - $values[] = $i; - } - } - else - { - $values[] = $v; - } - } - } - if (!in_array(date($c, $time), $values) and ( strval($val) != '*')) - { - return false; - } - } - return true; - } - /** * 获取一个基于时间偏移的Unix时间戳 * diff --git a/public/assets/js/backend/auth/admin.js b/public/assets/js/backend/auth/admin.js index 64e1183f..781b2bef 100755 --- a/public/assets/js/backend/auth/admin.js +++ b/public/assets/js/backend/auth/admin.js @@ -28,11 +28,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'email', title: __('Email')}, {field: 'status', title: __("Status"), formatter: Table.api.formatter.status}, {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime}, - {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) { + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { if(row.id == 1){ return ''; } - return Table.api.formatter.operate.call(this, value, row, index, table); + return Table.api.formatter.operate.call(this, value, row, index); }} ] ] diff --git a/public/assets/js/backend/auth/adminlog.js b/public/assets/js/backend/auth/adminlog.js index 055b0a30..467619bb 100644 --- a/public/assets/js/backend/auth/adminlog.js +++ b/public/assets/js/backend/auth/adminlog.js @@ -24,11 +24,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'id', title: 'ID', operate: false}, {field: 'username', title: __('Username'), formatter: Table.api.formatter.search}, {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符', style: 'width:200px'}, - {field: 'url', title: __('Url'), align: 'left', formatter: Controller.api.formatter.url}, - {field: 'ip', title: __('IP'), events: Controller.api.events.ip, formatter: Controller.api.formatter.ip}, - {field: 'browser', title: __('Browser'), operate: false, events: Controller.api.events.browser, formatter: Controller.api.formatter.browser}, + {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url}, + {field: 'ip', title: __('IP'), events: Table.api.events.ip, formatter: Table.api.formatter.search}, + {field: 'browser', title: __('Browser'), operate: false, formatter: Controller.api.formatter.browser}, {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD HH:mm:ss"'}, - {field: 'operate', title: __('Operate'), events: Controller.api.events.operate, formatter: Controller.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, + events: Table.api.events.operate, + buttons: [{ + name: 'detail', + text: 'Detail', + icon: 'fa fa-list', + classname: 'btn btn-info btn-xs btn-detail btn-dialog', + url: 'auth/adminlog/detail' + }], + formatter: Table.api.formatter.operate + } ] ] }); @@ -41,35 +51,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin Form.api.bindevent($("form[role=form]")); }, formatter: { - url: function (value, row, index) { - return '
'; - }, - ip: function (value, row, index) { - return ' ' + value + ''; - }, browser: function (value, row, index) { return '' + row.useragent.split(" ")[0] + ''; }, - operate: function (value, row, index) { - return '' + __('Detail') + ' ' - + Table.api.formatter.operate(value, row, index, $("#table")); - }, }, - events: { - ip: { - 'click .btn-ip': function (e, value, row, index) { - var options = $("#table").bootstrapTable('getOptions'); - //这里我们手动将数据填充到表单然后提交 - $("#commonSearchContent_" + options.idTable + " form [name='ip']").val(value); - $("#commonSearchContent_" + options.idTable + " form").trigger('submit'); - } - }, - operate: $.extend({ - 'click .btn-detail': function (e, value, row, index) { - Backend.api.open('auth/adminlog/detail/ids/' + row['id'], __('Detail')); - } - }, Table.api.events.operate) - } } }; return Controller; diff --git a/public/assets/js/backend/auth/group.js b/public/assets/js/backend/auth/group.js index 88912b2c..30f36f3a 100755 --- a/public/assets/js/backend/auth/group.js +++ b/public/assets/js/backend/auth/group.js @@ -41,11 +41,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ( {field: 'pid', title: __('Parent')}, {field: 'name', title: __('Name'), align: 'left'}, {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, - {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) { + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { if (row.id == 1) { return ''; } - return Table.api.formatter.operate.call(this, value, row, index, table); + return Table.api.formatter.operate.call(this, value, row, index); }} ] ], diff --git a/public/assets/js/backend/auth/rule.js b/public/assets/js/backend/auth/rule.js index 70fefef4..7f9dae53 100755 --- a/public/assets/js/backend/auth/rule.js +++ b/public/assets/js/backend/auth/rule.js @@ -32,7 +32,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, {field: 'ismenu', title: __('Ismenu'), align: 'center', formatter: Controller.api.formatter.menu}, {field: 'id', title: '', operate: false, formatter: Controller.api.formatter.subnode}, - {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], pagination: false, diff --git a/public/assets/js/backend/category.js b/public/assets/js/backend/category.js index 056e2c8e..ef870af5 100644 --- a/public/assets/js/backend/category.js +++ b/public/assets/js/backend/category.js @@ -22,6 +22,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin escape: false, pk: 'id', sortName: 'weigh', + pagination: false, + commonSearch: false, columns: [ [ {checkbox: true}, @@ -33,7 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'image', title: __('Image'), operate: false, formatter: Table.api.formatter.image}, {field: 'weigh', title: __('Weigh'), operate: false}, {field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status}, - {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); diff --git a/public/assets/js/backend/general/attachment.js b/public/assets/js/backend/general/attachment.js index 8e0dfd4d..626b28dd 100644 --- a/public/assets/js/backend/general/attachment.js +++ b/public/assets/js/backend/general/attachment.js @@ -33,7 +33,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin {field: 'filesize', title: __('Filesize')}, {field: 'mimetype', title: __('Mimetype')}, {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime}, - {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], }); diff --git a/public/assets/js/backend/general/config.js b/public/assets/js/backend/general/config.js index 4b4912d2..baa4492b 100644 --- a/public/assets/js/backend/general/config.js +++ b/public/assets/js/backend/general/config.js @@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'intro', title: __('Intro')}, {field: 'group', title: __('Group')}, {field: 'type', title: __('Type')}, - {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); diff --git a/public/assets/js/backend/general/profile.js b/public/assets/js/backend/general/profile.js index 6375e482..bc9875b4 100755 --- a/public/assets/js/backend/general/profile.js +++ b/public/assets/js/backend/general/profile.js @@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ( [ {field: 'id', title: 'ID'}, {field: 'title', title: __('Title')}, - {field: 'url', title: __('Url'), align: 'left', formatter: Controller.api.formatter.url}, + {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url}, {field: 'ip', title: __('ip')}, {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime}, ] @@ -37,24 +37,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ( // 为表格绑定事件 Table.api.bindevent(table);//当内容渲染完成后 + // 给上传按钮添加上传成功事件 + $("#plupload-avatar").data("upload-success", function (data) { + var url = Backend.api.cdnurl(data.url); + $(".profile-user-img").prop("src", url); + Toastr.success("上传成功!"); + }); + + // 给表单绑定事件 Form.api.bindevent($("#update-form"), function () { $("input[name='row[password]']").val(''); var url = Backend.api.cdnurl($("#c-avatar").val()); top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url); return true; }); - Upload.api.custom.changeavatar = function (response) { - var url = Backend.api.cdnurl(response.url); - $(".profile-user-img").prop("src", url); - }; }, - api: { - formatter: { - url: function (value, row, index) { - return '
'; - }, - }, - } }; return Controller; }); \ No newline at end of file diff --git a/public/assets/js/backend/index.js b/public/assets/js/backend/index.js index ec8b9383..cec1e3e1 100755 --- a/public/assets/js/backend/index.js +++ b/public/assets/js/backend/index.js @@ -376,7 +376,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi } //让错误提示框居中 - Backend.config.toastr.positionClass = "toast-top-center"; + Fast.config.toastr.positionClass = "toast-top-center"; //本地验证未通过时提示 $("#login-form").data("validator-options", { diff --git a/public/assets/js/fast.js b/public/assets/js/fast.js index 15ba4532..35f76e46 100644 --- a/public/assets/js/fast.js +++ b/public/assets/js/fast.js @@ -74,9 +74,9 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine Fast.events.onAjaxError(ret, error); } }, - error: function (err) { + error: function (xhr) { Layer.close(index); - var ret = {code: err.code, msg: err.message, data: null}; + var ret = {code: xhr.status, msg: xhr.statusText, data: null}; Fast.events.onAjaxError(ret, error); } }, options); @@ -161,7 +161,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine }, options ? options : {}); if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").size() > 0) { options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"]; - options.offset = "lt"; + options.offset = [ top.$(".tab-pane.active").scrollTop() + "px", "0px"]; } Layer.open(options); return false; diff --git a/public/assets/js/require-backend.min.js b/public/assets/js/require-backend.min.js index 90ab9f8c..80de1aec 100644 --- a/public/assets/js/require-backend.min.js +++ b/public/assets/js/require-backend.min.js @@ -1999,9 +1999,9 @@ define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, u Fast.events.onAjaxError(ret, error); } }, - error: function (err) { + error: function (xhr) { Layer.close(index); - var ret = {code: err.code, msg: err.message, data: null}; + var ret = {code: xhr.status, msg: xhr.statusText, data: null}; Fast.events.onAjaxError(ret, error); } }, options); @@ -2086,7 +2086,7 @@ define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, u }, options ? options : {}); if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").size() > 0) { options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"]; - options.offset = "lt"; + options.offset = [ top.$(".tab-pane.active").scrollTop() + "px", "0px"]; } Layer.open(options); return false; @@ -7812,7 +7812,6 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr table.on('post-body.bs.table', function (e, settings, json, xhr) { $(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin"); $(Table.config.disabledbtn, toolbar).toggleClass('disabled', true); - if ($(Table.config.firsttd, table).find("input[type='checkbox'][data-index]").size() > 0) { // 挺拽选择,需要重新绑定事件 require(['drag', 'drop'], function () { @@ -7841,18 +7840,15 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr }); } }); - // 处理选中筛选框后按钮的状态统一变更 table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table fa.event.check', function () { var ids = Table.api.selectedids(table); $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !ids.length); }); - // 刷新按钮事件 $(toolbar).on('click', Table.config.refreshbtn, function () { table.bootstrapTable('refresh'); }); - // 添加按钮事件 $(toolbar).on('click', Table.config.addbtn, function () { var ids = Table.api.selectedids(table); @@ -7941,9 +7937,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr Layer.close(index); } ); - }); - var id = table.attr("id"); Table.list[id] = table; return table; @@ -7992,6 +7986,11 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr } } }, + auth: { + check: function (name) { + + } + }, // 单元格数据格式化 formatter: { icon: function (value, row, index) { @@ -8071,26 +8070,32 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr datetime: function (value, row, index) { return value ? Moment(parseInt(value) * 1000).format("YYYY-MM-DD HH:mm:ss") : __('None'); }, - operate: function (value, row, index, table) { - var showweigh = true; - var showedit = true; - var showdel = true; - if (typeof table != 'undefined') { - var options = table.bootstrapTable('getOptions'); - if (options.extend.del_url == '') - showdel = false; - if (options.extend.edit_url == '') - showedit = false; - } - showweigh = typeof row[Table.config.dragsortfield] != 'undefined' ? true : false; - //行操作 + operate: function (value, row, index) { + var table = this.table; + // 操作配置 + var options = table ? table.bootstrapTable('getOptions') : {}; + // 默认按钮组 + var buttons = $.extend([], this.buttons || []); + buttons.push({name: 'dragsort', icon: 'fa fa-arrows', classname: 'btn btn-xs btn-primary btn-dragsort'}); + buttons.push({name: 'edit', icon: 'fa fa-pencil', classname: 'btn btn-xs btn-success btn-editone'}); + buttons.push({name: 'del', icon: 'fa fa-trash', classname: 'btn btn-xs btn-danger btn-delone'}); var html = []; - if (showweigh) - html.push(''); - if (showedit) - html.push(''); - if (showdel) - html.push(''); + $.each(buttons, function (i, j) { + var attr = table.data("operate-" + j.name); + if ((typeof attr === 'undefined' || attr) || (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] == 'undefined')) { + if (['add', 'edit', 'del', 'multi'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) { + return true; + } + //自动加上ids + j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : ''; + url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;'; + classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one'; + icon = j.icon ? j.icon : ''; + text = j.text ? j.text : ''; + title = j.title ? j.title : text; + html.push('' + (text ? ' ' + text : '') + ''); + } + }); return html.join(' '); } }, diff --git a/public/assets/js/require-frontend.min.js b/public/assets/js/require-frontend.min.js index 5f260c07..108628c4 100644 --- a/public/assets/js/require-frontend.min.js +++ b/public/assets/js/require-frontend.min.js @@ -2011,9 +2011,9 @@ define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, u Fast.events.onAjaxError(ret, error); } }, - error: function (err) { + error: function (xhr) { Layer.close(index); - var ret = {code: err.code, msg: err.message, data: null}; + var ret = {code: xhr.status, msg: xhr.statusText, data: null}; Fast.events.onAjaxError(ret, error); } }, options); @@ -2098,7 +2098,7 @@ define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, u }, options ? options : {}); if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").size() > 0) { options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"]; - options.offset = "lt"; + options.offset = [ top.$(".tab-pane.active").scrollTop() + "px", "0px"]; } Layer.open(options); return false; diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 759a77f7..69b57711 100644 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -113,7 +113,6 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table table.on('post-body.bs.table', function (e, settings, json, xhr) { $(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin"); $(Table.config.disabledbtn, toolbar).toggleClass('disabled', true); - if ($(Table.config.firsttd, table).find("input[type='checkbox'][data-index]").size() > 0) { // 挺拽选择,需要重新绑定事件 require(['drag', 'drop'], function () { @@ -142,18 +141,15 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table }); } }); - // 处理选中筛选框后按钮的状态统一变更 table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table fa.event.check', function () { var ids = Table.api.selectedids(table); $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !ids.length); }); - // 刷新按钮事件 $(toolbar).on('click', Table.config.refreshbtn, function () { table.bootstrapTable('refresh'); }); - // 添加按钮事件 $(toolbar).on('click', Table.config.addbtn, function () { var ids = Table.api.selectedids(table); @@ -242,9 +238,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table Layer.close(index); } ); - }); - var id = table.attr("id"); Table.list[id] = table; return table; @@ -293,6 +287,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table } } }, + auth: { + check: function (name) { + + } + }, // 单元格数据格式化 formatter: { icon: function (value, row, index) { @@ -372,26 +371,32 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table datetime: function (value, row, index) { return value ? Moment(parseInt(value) * 1000).format("YYYY-MM-DD HH:mm:ss") : __('None'); }, - operate: function (value, row, index, table) { - var showweigh = true; - var showedit = true; - var showdel = true; - if (typeof table != 'undefined') { - var options = table.bootstrapTable('getOptions'); - if (options.extend.del_url == '') - showdel = false; - if (options.extend.edit_url == '') - showedit = false; - } - showweigh = typeof row[Table.config.dragsortfield] != 'undefined' ? true : false; - //行操作 + operate: function (value, row, index) { + var table = this.table; + // 操作配置 + var options = table ? table.bootstrapTable('getOptions') : {}; + // 默认按钮组 + var buttons = $.extend([], this.buttons || []); + buttons.push({name: 'dragsort', icon: 'fa fa-arrows', classname: 'btn btn-xs btn-primary btn-dragsort'}); + buttons.push({name: 'edit', icon: 'fa fa-pencil', classname: 'btn btn-xs btn-success btn-editone'}); + buttons.push({name: 'del', icon: 'fa fa-trash', classname: 'btn btn-xs btn-danger btn-delone'}); var html = []; - if (showweigh) - html.push(''); - if (showedit) - html.push(''); - if (showdel) - html.push(''); + $.each(buttons, function (i, j) { + var attr = table.data("operate-" + j.name); + if ((typeof attr === 'undefined' || attr) || (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] == 'undefined')) { + if (['add', 'edit', 'del', 'multi'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) { + return true; + } + //自动加上ids + j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : ''; + url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;'; + classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one'; + icon = j.icon ? j.icon : ''; + text = j.text ? j.text : ''; + title = j.title ? j.title : text; + html.push('' + (text ? ' ' + text : '') + ''); + } + }); return html.join(' '); } },