mirror of https://gitee.com/karson/fastadmin.git
新增安装脚本自动创建数据库
更新左侧菜单没按权限显示的BUG 更新后台语言包 更新JS中错误提示调用字段不正确的BUG 提示方法统一都采用Toastr来提示pull/279748/MERGE
parent
41075e2d34
commit
368e95430e
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace app\admin\command;
|
namespace app\admin\command;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use think\Config;
|
||||||
use think\console\Command;
|
use think\console\Command;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\input\Option;
|
use think\console\input\Option;
|
||||||
|
|
@ -36,6 +38,12 @@ class Install extends Command
|
||||||
|
|
||||||
$sql = file_get_contents(__DIR__ . '/Install/fastadmin.sql');
|
$sql = file_get_contents(__DIR__ . '/Install/fastadmin.sql');
|
||||||
|
|
||||||
|
// 先尝试能否自动创建数据
|
||||||
|
$config = Config::get('database');
|
||||||
|
$pdo = new PDO("{$config['type']}:host={$config['hostname']}", $config['username'], $config['password']);
|
||||||
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$pdo->query("CREATE DATABASE IF NOT EXISTS `{$config['database']}` CHARACTER SET utf8 COLLATE utf8_general_ci;");
|
||||||
|
|
||||||
// 查询一次SQL,判断连接是否正常
|
// 查询一次SQL,判断连接是否正常
|
||||||
Db::execute("SELECT 1");
|
Db::execute("SELECT 1");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class Index extends Backend
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
$this->auth->logout();
|
$this->auth->logout();
|
||||||
$this->success(__('Logout success!'), 'index/login');
|
$this->success(__('Logout successful'), 'index/login');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,13 +102,6 @@ return [
|
||||||
'Please enter your username' => '请输入你的用户名',
|
'Please enter your username' => '请输入你的用户名',
|
||||||
'Please enter your password' => '请输入你的密码',
|
'Please enter your password' => '请输入你的密码',
|
||||||
'Please login first' => '请登录后操作',
|
'Please login first' => '请登录后操作',
|
||||||
'You\'ve logged in, do not login again' => '你已经登录,无需重复登录',
|
|
||||||
'Username or password can not be empty' => '用户名密码不能为空',
|
|
||||||
'Username or password is incorrect' => '用户名或密码不正确',
|
|
||||||
'Username is incorrect' => '用户名不正确',
|
|
||||||
'Password is incorrect' => '密码不正确',
|
|
||||||
'Login successful' => '登录成功!',
|
|
||||||
'Verification code is incorrect' => '验证码不正确',
|
|
||||||
'An unexpected error occurred' => '发生了一个意外错误,程序猿正在紧急处理中',
|
'An unexpected error occurred' => '发生了一个意外错误,程序猿正在紧急处理中',
|
||||||
'This page will be re-directed in %s seconds' => '页面将在 %s 秒后自动跳转',
|
'This page will be re-directed in %s seconds' => '页面将在 %s 秒后自动跳转',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,12 @@ return [
|
||||||
'Disable top menu badge' => '禁用顶部彩色小角标',
|
'Disable top menu badge' => '禁用顶部彩色小角标',
|
||||||
'Disable top menu badge without left menu' => '左边菜单栏的彩色小角标不受影响',
|
'Disable top menu badge without left menu' => '左边菜单栏的彩色小角标不受影响',
|
||||||
'Skins' => '皮肤',
|
'Skins' => '皮肤',
|
||||||
|
'You\'ve logged in, do not login again' => '你已经登录,无需重复登录',
|
||||||
|
'Username or password can not be empty' => '用户名密码不能为空',
|
||||||
|
'Username or password is incorrect' => '用户名或密码不正确',
|
||||||
|
'Username is incorrect' => '用户名不正确',
|
||||||
|
'Password is incorrect' => '密码不正确',
|
||||||
|
'Login successful' => '登录成功!',
|
||||||
|
'Logout successful' => '退出成功!',
|
||||||
|
'Verification code is incorrect' => '验证码不正确',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,6 @@ class Auth extends \fast\Auth
|
||||||
|
|
||||||
// 读取管理员当前拥有的权限节点
|
// 读取管理员当前拥有的权限节点
|
||||||
$userRule = $this->getRuleList();
|
$userRule = $this->getRuleList();
|
||||||
|
|
||||||
$select_id = 0;
|
$select_id = 0;
|
||||||
$dashboard = '/' . $module . '/dashboard';
|
$dashboard = '/' . $module . '/dashboard';
|
||||||
// 必须将结果集转换为数组
|
// 必须将结果集转换为数组
|
||||||
|
|
@ -256,7 +255,10 @@ class Auth extends \fast\Auth
|
||||||
foreach ($ruleList as $k => &$v)
|
foreach ($ruleList as $k => &$v)
|
||||||
{
|
{
|
||||||
if (!in_array($v['name'], $userRule))
|
if (!in_array($v['name'], $userRule))
|
||||||
|
{
|
||||||
|
unset($ruleList[$k]);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
$select_id = $v['name'] == $dashboard ? $v['id'] : $select_id;
|
$select_id = $v['name'] == $dashboard ? $v['id'] : $select_id;
|
||||||
$v['url'] = $v['name'];
|
$v['url'] = $v['name'];
|
||||||
$v['badge'] = isset($badgeList[$v['name']]) ? $badgeList[$v['name']] : '';
|
$v['badge'] = isset($badgeList[$v['name']]) ? $badgeList[$v['name']] : '';
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,10 @@ return [
|
||||||
* 可上传的文件类型
|
* 可上传的文件类型
|
||||||
*/
|
*/
|
||||||
'mimetype' => '*',
|
'mimetype' => '*',
|
||||||
|
/**
|
||||||
|
* 是否支持批量上传
|
||||||
|
*/
|
||||||
|
'multiple' => true,
|
||||||
/**
|
/**
|
||||||
* 又拍云操作员用户名
|
* 又拍云操作员用户名
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,21 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config'], function ($
|
||||||
options = $.extend({
|
options = $.extend({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
Backend.api.layer.close(index);
|
Backend.api.layer.close(index);
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code === 1) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
|
if (ret.code === 1) {
|
||||||
if (typeof success == 'function') {
|
if (typeof success == 'function') {
|
||||||
var onAfterResult = success.call(undefined, content);
|
var onAfterResult = success.call(undefined, data);
|
||||||
if (!onAfterResult) {
|
if (!onAfterResult) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -87,14 +88,23 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config'], function ($
|
||||||
processData: false,
|
processData: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code === 1) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
$('.summernote').summernote("insertImage", data.content, 'filename');
|
if (ret.code === 1) {
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
var onAfterResult = success.call(undefined, data);
|
||||||
|
if (!onAfterResult) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($('.summernote').size() > 0 && data && typeof data.url !== 'undefined') {
|
||||||
|
$('.summernote').summernote("insertImage", data.url, 'filename');
|
||||||
|
}
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
||||||
var data = get_children($("#treeview").jstree('get_json'));
|
var data = get_children($("#treeview").jstree('get_json'));
|
||||||
Backend.api.ajax({url: "auth/rule/rebuild", data: {step: 2, data: data}}, function (content) {
|
Backend.api.ajax({url: "auth/rule/rebuild", data: {step: 2, data: data}}, function (content) {
|
||||||
Backend.api.layer.close(index);
|
Backend.api.layer.close(index);
|
||||||
Backend.api.success(function () {
|
top.location.reload();
|
||||||
//刷新页面
|
|
||||||
top.location.reload();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
url: 'ajax/clearcache'
|
url: 'ajax/clearcache'
|
||||||
}, function (ret) {
|
}, function (ret) {
|
||||||
Layer.closeAll();
|
Layer.closeAll();
|
||||||
Backend.api.success();
|
Toastr.success(__('Operation completed'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'sortable'], function
|
||||||
$.post("wechat/menu/edit", {menu: JSON.stringify(getMenuList())}, function (data) {
|
$.post("wechat/menu/edit", {menu: JSON.stringify(getMenuList())}, function (data) {
|
||||||
if (data['code'] == 1) {
|
if (data['code'] == 1) {
|
||||||
} else {
|
} else {
|
||||||
Backend.api.error();
|
Toastr.error(__('Operation failed'));
|
||||||
}
|
}
|
||||||
}, 'json');
|
}, 'json');
|
||||||
};
|
};
|
||||||
|
|
@ -253,11 +253,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'sortable'], function
|
||||||
updateChangeMenu();
|
updateChangeMenu();
|
||||||
});
|
});
|
||||||
$(document).on('click', "#menuSyn", function () {
|
$(document).on('click', "#menuSyn", function () {
|
||||||
$.post("wechat/menu/sync", {}, function (data) {
|
$.post("wechat/menu/sync", {}, function (ret) {
|
||||||
if (data['code'] == 1) {
|
|
||||||
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
|
if (ret.code == 1) {
|
||||||
Backend.api.toastr.success('菜单同步更新成功,生效时间看微信官网说明,或者你重新关注微信号!');
|
Backend.api.toastr.success('菜单同步更新成功,生效时间看微信官网说明,或者你重新关注微信号!');
|
||||||
} else {
|
} else {
|
||||||
Backend.api.toastr.error(data['content']);
|
Backend.api.toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
}, 'json');
|
}, 'json');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefined, Toastr, Layer, Config) {
|
define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config'], function ($, undefined, Toastr, Layer, Lang, Config) {
|
||||||
var Frontend = {
|
var Frontend = {
|
||||||
config: {
|
config: {
|
||||||
//toastr默认配置
|
//toastr默认配置
|
||||||
|
|
@ -26,20 +26,21 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefi
|
||||||
options = $.extend({
|
options = $.extend({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
Frontend.api.layer.close(index);
|
Frontend.api.layer.close(index);
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code == 0) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
|
if (ret.code === 1) {
|
||||||
if (typeof success == 'function') {
|
if (typeof success == 'function') {
|
||||||
var onAfterResult = success.call(undefined, content);
|
var onAfterResult = success.call(undefined, data);
|
||||||
if (!onAfterResult) {
|
if (!onAfterResult) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -56,11 +57,25 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefi
|
||||||
if (url.substr(0, 1) !== "/") {
|
if (url.substr(0, 1) !== "/") {
|
||||||
var r = new RegExp('^(?:[a-z]+:)?//', 'i');
|
var r = new RegExp('^(?:[a-z]+:)?//', 'i');
|
||||||
if (!r.test(url)) {
|
if (!r.test(url)) {
|
||||||
url = (Config.moduleurl) + "/" + url;
|
url = Config.moduleurl + "/" + url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
//查询Url参数
|
||||||
|
query: function (name, url) {
|
||||||
|
if (!url) {
|
||||||
|
url = window.location.href;
|
||||||
|
}
|
||||||
|
name = name.replace(/[\[\]]/g, "\\$&");
|
||||||
|
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||||
|
results = regex.exec(url);
|
||||||
|
if (!results)
|
||||||
|
return null;
|
||||||
|
if (!results[2])
|
||||||
|
return '';
|
||||||
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||||
|
},
|
||||||
//上传文件
|
//上传文件
|
||||||
upload: function (file, callback) {
|
upload: function (file, callback) {
|
||||||
var data = new FormData();
|
var data = new FormData();
|
||||||
|
|
@ -73,14 +88,23 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefi
|
||||||
processData: false,
|
processData: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code == 0) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
$('.summernote').summernote("insertImage", data.content, 'filename');
|
if (ret.code === 1) {
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
var onAfterResult = success.call(undefined, data);
|
||||||
|
if (!onAfterResult) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($('.summernote').size() > 0 && data && typeof data.url !== 'undefined') {
|
||||||
|
$('.summernote').summernote("insertImage", data.url, 'filename');
|
||||||
|
}
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -152,7 +176,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefi
|
||||||
}
|
}
|
||||||
return Frontend.api.layer.msg(__('Operation completed'), $.extend({
|
return Frontend.api.layer.msg(__('Operation completed'), $.extend({
|
||||||
offset: 0, icon: 1
|
offset: 0, icon: 1
|
||||||
}, type ? {} : options));
|
}, type ? {} : options), callback);
|
||||||
},
|
},
|
||||||
error: function (options, callback) {
|
error: function (options, callback) {
|
||||||
var type = typeof options === 'function';
|
var type = typeof options === 'function';
|
||||||
|
|
@ -161,7 +185,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefi
|
||||||
}
|
}
|
||||||
return Frontend.api.layer.msg(__('Operation failed'), $.extend({
|
return Frontend.api.layer.msg(__('Operation failed'), $.extend({
|
||||||
offset: 0, icon: 2
|
offset: 0, icon: 2
|
||||||
}, type ? {} : options));
|
}, type ? {} : options), callback);
|
||||||
},
|
},
|
||||||
toastr: Toastr,
|
toastr: Toastr,
|
||||||
layer: Layer
|
layer: Layer
|
||||||
|
|
@ -170,7 +194,26 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefi
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
string = args[0],
|
string = args[0],
|
||||||
i = 1;
|
i = 1;
|
||||||
string = Lang[string] != undefined ? Lang[string] : string;
|
string = string.toLowerCase();
|
||||||
|
//string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
|
||||||
|
if (typeof Lang[string] != 'undefined') {
|
||||||
|
if (typeof Lang[string] == 'object')
|
||||||
|
return Lang[string];
|
||||||
|
string = Lang[string];
|
||||||
|
} else if (string.indexOf('.') !== -1) {
|
||||||
|
var arr = string.split('.');
|
||||||
|
var current = Lang[arr[0]];
|
||||||
|
for (var i = 1; i < arr.length; i++) {
|
||||||
|
current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
|
||||||
|
if (typeof current != 'object')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (typeof current == 'object')
|
||||||
|
return current;
|
||||||
|
string = current;
|
||||||
|
} else {
|
||||||
|
string = args[0];
|
||||||
|
}
|
||||||
return string.replace(/%((%)|s|d)/g, function (m) {
|
return string.replace(/%((%)|s|d)/g, function (m) {
|
||||||
// m is the matched format, e.g. %s, %d
|
// m is the matched format, e.g. %s, %d
|
||||||
var val = null;
|
var val = null;
|
||||||
|
|
@ -199,7 +242,9 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefi
|
||||||
window.Toastr = Toastr;
|
window.Toastr = Toastr;
|
||||||
//将语言方法暴露到全局中去
|
//将语言方法暴露到全局中去
|
||||||
window.__ = Frontend.lang;
|
window.__ = Frontend.lang;
|
||||||
|
//将Frontend渲染至全局,以便于在子框架中调用
|
||||||
|
window.Frontend = Frontend;
|
||||||
//Toastr定义
|
//Toastr定义
|
||||||
Toastr.options = Frontend.config.toastr;
|
Toastr.options = Frontend.config.toastr;
|
||||||
return Frontend;
|
return Frontend;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1939,20 +1939,21 @@ define('backend',['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config'], f
|
||||||
options = $.extend({
|
options = $.extend({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
Backend.api.layer.close(index);
|
Backend.api.layer.close(index);
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code === 1) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
|
if (ret.code === 1) {
|
||||||
if (typeof success == 'function') {
|
if (typeof success == 'function') {
|
||||||
var onAfterResult = success.call(undefined, content);
|
var onAfterResult = success.call(undefined, data);
|
||||||
if (!onAfterResult) {
|
if (!onAfterResult) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -2000,14 +2001,23 @@ define('backend',['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config'], f
|
||||||
processData: false,
|
processData: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code === 1) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
$('.summernote').summernote("insertImage", data.content, 'filename');
|
if (ret.code === 1) {
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
var onAfterResult = success.call(undefined, data);
|
||||||
|
if (!onAfterResult) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($('.summernote').size() > 0 && data && typeof data.url !== 'undefined') {
|
||||||
|
$('.summernote').summernote("insertImage", data.url, 'filename');
|
||||||
|
}
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -7381,7 +7391,7 @@ define('table',['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment',
|
||||||
table: table.bootstrapTable('getOptions').extend.table
|
table: table.bootstrapTable('getOptions').extend.table
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Backend.api.ajax(options, function (content) {
|
Backend.api.ajax(options, function (data) {
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
table.bootstrapTable('refresh');
|
table.bootstrapTable('refresh');
|
||||||
});
|
});
|
||||||
|
|
@ -7400,7 +7410,7 @@ define('table',['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment',
|
||||||
var url = action == "del" ? options.extend.del_url : options.extend.multi_url;
|
var url = action == "del" ? options.extend.del_url : options.extend.multi_url;
|
||||||
url = url + "/ids/" + ($.isArray(ids) ? ids.join(",") : ids);
|
url = url + "/ids/" + ($.isArray(ids) ? ids.join(",") : ids);
|
||||||
var options = {url: url, data: {action: action, ids: ids, params: element ? $(element).data("params") : ''}};
|
var options = {url: url, data: {action: action, ids: ids, params: element ? $(element).data("params") : ''}};
|
||||||
Backend.api.ajax(options, function (content) {
|
Backend.api.ajax(options, function (data) {
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
table.bootstrapTable('refresh');
|
table.bootstrapTable('refresh');
|
||||||
});
|
});
|
||||||
|
|
@ -7438,6 +7448,8 @@ define('table',['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment',
|
||||||
// 单元格数据格式化
|
// 单元格数据格式化
|
||||||
formatter: {
|
formatter: {
|
||||||
icon: function (value, row, index) {
|
icon: function (value, row, index) {
|
||||||
|
if (!value)
|
||||||
|
return '';
|
||||||
value = value.indexOf(" ") > -1 ? value : "fa fa-" + value;
|
value = value.indexOf(" ") > -1 ? value : "fa fa-" + value;
|
||||||
//渲染fontawesome图标
|
//渲染fontawesome图标
|
||||||
return '<i class="' + value + '"></i> ' + value;
|
return '<i class="' + value + '"></i> ' + value;
|
||||||
|
|
@ -7564,6 +7576,7 @@ define('upload',['jquery', 'bootstrap', 'backend', 'config', 'plupload'], functi
|
||||||
var maxsize = $(this).data("maxsize");
|
var maxsize = $(this).data("maxsize");
|
||||||
var mimetype = $(this).data("mimetype");
|
var mimetype = $(this).data("mimetype");
|
||||||
var multipart = $(this).data("multipart");
|
var multipart = $(this).data("multipart");
|
||||||
|
var multiple = $(this).data("multiple");
|
||||||
//上传URL
|
//上传URL
|
||||||
url = url ? url : Config.upload.uploadurl;
|
url = url ? url : Config.upload.uploadurl;
|
||||||
//最大可上传
|
//最大可上传
|
||||||
|
|
@ -7572,10 +7585,13 @@ define('upload',['jquery', 'bootstrap', 'backend', 'config', 'plupload'], functi
|
||||||
mimetype = mimetype ? mimetype : Config.upload.mimetype;
|
mimetype = mimetype ? mimetype : Config.upload.mimetype;
|
||||||
//请求的表单参数
|
//请求的表单参数
|
||||||
multipart = multipart ? multipart : Config.upload.multipart;
|
multipart = multipart ? multipart : Config.upload.multipart;
|
||||||
|
//是否支持批量上传
|
||||||
|
multiple = multiple ? multiple : Config.upload.multiple;
|
||||||
|
//生成Plupload实例
|
||||||
Upload.list[id] = new Plupload.Uploader({
|
Upload.list[id] = new Plupload.Uploader({
|
||||||
runtimes: 'html5,flash,silverlight,html4',
|
runtimes: 'html5,flash,silverlight,html4',
|
||||||
multi_selection: false, //是否允许多选批量上传
|
multi_selection: multiple, //是否允许多选批量上传
|
||||||
browse_button: id, // you can pass an id...
|
browse_button: id, // 浏览按钮的ID
|
||||||
container: $(this).parent().get(0), //取按钮的上级元素
|
container: $(this).parent().get(0), //取按钮的上级元素
|
||||||
flash_swf_url: '/assets/libs/plupload/js/Moxie.swf',
|
flash_swf_url: '/assets/libs/plupload/js/Moxie.swf',
|
||||||
silverlight_xap_url: '/assets/libs/plupload/js/Moxie.xap',
|
silverlight_xap_url: '/assets/libs/plupload/js/Moxie.xap',
|
||||||
|
|
@ -7612,13 +7628,13 @@ define('upload',['jquery', 'bootstrap', 'backend', 'config', 'plupload'], functi
|
||||||
//document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML += (' [Url]: ' + '<a href="' + url + '" target="_blank">' + url + '</a>');
|
//document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML += (' [Url]: ' + '<a href="' + url + '" target="_blank">' + url + '</a>');
|
||||||
//这里建议不修改
|
//这里建议不修改
|
||||||
try {
|
try {
|
||||||
var data = JSON.parse(info.response);
|
var ret = JSON.parse(info.response);
|
||||||
if (data.hasOwnProperty('code')) {
|
if (ret.hasOwnProperty('code')) {
|
||||||
data.code = data.code == 200 ? 0 : data.code;
|
ret.data = ret.code == 200 ? ret : ret.data;
|
||||||
if (data.hasOwnProperty("url")) {
|
ret.code = ret.code == 200 ? 1 : ret.code;
|
||||||
data.content = data.url;
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
}
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
$("input[data-plupload-id='" + id + "-text']").val(data.content);
|
$("input[data-plupload-id='" + id + "-text']").val(data.url);
|
||||||
var afterUpload = $("#" + id).data("after-upload");
|
var afterUpload = $("#" + id).data("after-upload");
|
||||||
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
||||||
Upload.api.custom[afterUpload].call(info, id, data);
|
Upload.api.custom[afterUpload].call(info, id, data);
|
||||||
|
|
@ -7656,22 +7672,21 @@ define('upload',['jquery', 'bootstrap', 'backend', 'config', 'plupload'], functi
|
||||||
processData: false,
|
processData: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
data.code = data.code == 200 ? 1 : data.code;
|
ret.data = ret.code == 200 ? ret : ret.data;
|
||||||
if (data.hasOwnProperty("url")) {
|
ret.code = ret.code == 200 ? 1 : ret.code;
|
||||||
data.content = data.url;
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
}
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
if (ret.code === 1) {
|
||||||
if (data.code === 1) {
|
|
||||||
// 如果回调存在,则直接调用回调
|
// 如果回调存在,则直接调用回调
|
||||||
if (typeof callback == 'function') {
|
if (typeof callback == 'function') {
|
||||||
callback.call(this, data);
|
callback.call(this, data);
|
||||||
} else {
|
} else {
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -8251,28 +8266,29 @@ define('form',['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', '
|
||||||
url: url,
|
url: url,
|
||||||
data: form.serialize(),
|
data: form.serialize(),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code === 1) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
|
if (ret.code === 1) {
|
||||||
$('.form-group', form).removeClass('has-feedback has-success has-error');
|
$('.form-group', form).removeClass('has-feedback has-success has-error');
|
||||||
//成功提交后事件
|
//成功提交后事件
|
||||||
var afterSubmit = form.data("after-submit");
|
var afterSubmit = form.data("after-submit");
|
||||||
//元素绑定函数
|
//元素绑定函数
|
||||||
if (afterSubmit && typeof Form.api.custom[afterSubmit] == 'function') {
|
if (afterSubmit && typeof Form.api.custom[afterSubmit] == 'function') {
|
||||||
if (!Form.api.custom[afterSubmit].call(form, content)) {
|
if (!Form.api.custom[afterSubmit].call(form, data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//自定义函数
|
//自定义函数
|
||||||
if (typeof onAfterSubmit == 'function') {
|
if (typeof onAfterSubmit == 'function') {
|
||||||
if (!onAfterSubmit.call(form, content)) {
|
if (!onAfterSubmit.call(form, data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -8289,19 +8305,16 @@ define('form',['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', '
|
||||||
if (e.isDefaultPrevented()) {
|
if (e.isDefaultPrevented()) {
|
||||||
//验证不通过
|
//验证不通过
|
||||||
Toastr.error("验证失败,请检查表单输入是否正确");
|
Toastr.error("验证失败,请检查表单输入是否正确");
|
||||||
//Backend.api.error();
|
|
||||||
} else {
|
} else {
|
||||||
//验证通过提交表单
|
//验证通过提交表单
|
||||||
Form.api.submit(form, onBeforeSubmit, function (content) {
|
Form.api.submit(form, onBeforeSubmit, function (data) {
|
||||||
if (typeof onAfterSubmit == 'function') {
|
if (typeof onAfterSubmit == 'function') {
|
||||||
if (!onAfterSubmit.call(form, content)) {
|
if (!onAfterSubmit.call(form, data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//提示及关闭当前窗口
|
//提示及关闭当前窗口
|
||||||
parent.Layer.msg(__('Operation completed'), {
|
parent.Toastr.success(__('Operation completed'));
|
||||||
offset: 0, icon: 1
|
|
||||||
});
|
|
||||||
parent.$(".btn-refresh").trigger("click");
|
parent.$(".btn-refresh").trigger("click");
|
||||||
var index = parent.Layer.getFrameIndex(window.name);
|
var index = parent.Layer.getFrameIndex(window.name);
|
||||||
parent.Layer.close(index);
|
parent.Layer.close(index);
|
||||||
|
|
@ -8336,8 +8349,8 @@ define('form',['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', '
|
||||||
remote: {
|
remote: {
|
||||||
url: '/ajax/typeahead?search=%QUERY&field=' + $(input).attr("name"),
|
url: '/ajax/typeahead?search=%QUERY&field=' + $(input).attr("name"),
|
||||||
wildcard: '%QUERY',
|
wildcard: '%QUERY',
|
||||||
transform: function (data) {
|
transform: function (ret) {
|
||||||
return data.content.searchlist;
|
return ret.data.searchlist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -8437,7 +8450,7 @@ define('form',['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', '
|
||||||
//依次上传图片
|
//依次上传图片
|
||||||
for (var i = 0; i < files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
Upload.api.send(files[i], function (data) {
|
Upload.api.send(files[i], function (data) {
|
||||||
var url = Config.upload.cdnurl + data.content;
|
var url = Config.upload.cdnurl + data.url;
|
||||||
$(that).summernote("insertImage", url, 'filename');
|
$(that).summernote("insertImage", url, 'filename');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,28 +29,29 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', 'bootstr
|
||||||
url: url,
|
url: url,
|
||||||
data: form.serialize(),
|
data: form.serialize(),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code === 1) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
|
if (ret.code === 1) {
|
||||||
$('.form-group', form).removeClass('has-feedback has-success has-error');
|
$('.form-group', form).removeClass('has-feedback has-success has-error');
|
||||||
//成功提交后事件
|
//成功提交后事件
|
||||||
var afterSubmit = form.data("after-submit");
|
var afterSubmit = form.data("after-submit");
|
||||||
//元素绑定函数
|
//元素绑定函数
|
||||||
if (afterSubmit && typeof Form.api.custom[afterSubmit] == 'function') {
|
if (afterSubmit && typeof Form.api.custom[afterSubmit] == 'function') {
|
||||||
if (!Form.api.custom[afterSubmit].call(form, content)) {
|
if (!Form.api.custom[afterSubmit].call(form, data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//自定义函数
|
//自定义函数
|
||||||
if (typeof onAfterSubmit == 'function') {
|
if (typeof onAfterSubmit == 'function') {
|
||||||
if (!onAfterSubmit.call(form, content)) {
|
if (!onAfterSubmit.call(form, data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -67,19 +68,16 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', 'bootstr
|
||||||
if (e.isDefaultPrevented()) {
|
if (e.isDefaultPrevented()) {
|
||||||
//验证不通过
|
//验证不通过
|
||||||
Toastr.error("验证失败,请检查表单输入是否正确");
|
Toastr.error("验证失败,请检查表单输入是否正确");
|
||||||
//Backend.api.error();
|
|
||||||
} else {
|
} else {
|
||||||
//验证通过提交表单
|
//验证通过提交表单
|
||||||
Form.api.submit(form, onBeforeSubmit, function (content) {
|
Form.api.submit(form, onBeforeSubmit, function (data) {
|
||||||
if (typeof onAfterSubmit == 'function') {
|
if (typeof onAfterSubmit == 'function') {
|
||||||
if (!onAfterSubmit.call(form, content)) {
|
if (!onAfterSubmit.call(form, data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//提示及关闭当前窗口
|
//提示及关闭当前窗口
|
||||||
parent.Layer.msg(__('Operation completed'), {
|
parent.Toastr.success(__('Operation completed'));
|
||||||
offset: 0, icon: 1
|
|
||||||
});
|
|
||||||
parent.$(".btn-refresh").trigger("click");
|
parent.$(".btn-refresh").trigger("click");
|
||||||
var index = parent.Layer.getFrameIndex(window.name);
|
var index = parent.Layer.getFrameIndex(window.name);
|
||||||
parent.Layer.close(index);
|
parent.Layer.close(index);
|
||||||
|
|
@ -114,8 +112,8 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', 'bootstr
|
||||||
remote: {
|
remote: {
|
||||||
url: '/ajax/typeahead?search=%QUERY&field=' + $(input).attr("name"),
|
url: '/ajax/typeahead?search=%QUERY&field=' + $(input).attr("name"),
|
||||||
wildcard: '%QUERY',
|
wildcard: '%QUERY',
|
||||||
transform: function (data) {
|
transform: function (ret) {
|
||||||
return data.content.searchlist;
|
return ret.data.searchlist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -215,7 +213,7 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'upload', 'bootstr
|
||||||
//依次上传图片
|
//依次上传图片
|
||||||
for (var i = 0; i < files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
Upload.api.send(files[i], function (data) {
|
Upload.api.send(files[i], function (data) {
|
||||||
var url = Config.upload.cdnurl + data.content;
|
var url = Config.upload.cdnurl + data.url;
|
||||||
$(that).summernote("insertImage", url, 'filename');
|
$(that).summernote("insertImage", url, 'filename');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1912,7 +1912,7 @@ window.layui && layui.define ? (
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function ($, undefined, Toastr, Layer, Config) {
|
define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config'], function ($, undefined, Toastr, Layer, Lang, Config) {
|
||||||
var Frontend = {
|
var Frontend = {
|
||||||
config: {
|
config: {
|
||||||
//toastr默认配置
|
//toastr默认配置
|
||||||
|
|
@ -1940,20 +1940,21 @@ define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function
|
||||||
options = $.extend({
|
options = $.extend({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
Frontend.api.layer.close(index);
|
Frontend.api.layer.close(index);
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code == 0) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
|
if (ret.code === 1) {
|
||||||
if (typeof success == 'function') {
|
if (typeof success == 'function') {
|
||||||
var onAfterResult = success.call(undefined, content);
|
var onAfterResult = success.call(undefined, data);
|
||||||
if (!onAfterResult) {
|
if (!onAfterResult) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -1970,11 +1971,25 @@ define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function
|
||||||
if (url.substr(0, 1) !== "/") {
|
if (url.substr(0, 1) !== "/") {
|
||||||
var r = new RegExp('^(?:[a-z]+:)?//', 'i');
|
var r = new RegExp('^(?:[a-z]+:)?//', 'i');
|
||||||
if (!r.test(url)) {
|
if (!r.test(url)) {
|
||||||
url = (Config.moduleurl) + "/" + url;
|
url = Config.moduleurl + "/" + url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
//查询Url参数
|
||||||
|
query: function (name, url) {
|
||||||
|
if (!url) {
|
||||||
|
url = window.location.href;
|
||||||
|
}
|
||||||
|
name = name.replace(/[\[\]]/g, "\\$&");
|
||||||
|
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||||
|
results = regex.exec(url);
|
||||||
|
if (!results)
|
||||||
|
return null;
|
||||||
|
if (!results[2])
|
||||||
|
return '';
|
||||||
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||||
|
},
|
||||||
//上传文件
|
//上传文件
|
||||||
upload: function (file, callback) {
|
upload: function (file, callback) {
|
||||||
var data = new FormData();
|
var data = new FormData();
|
||||||
|
|
@ -1987,14 +2002,23 @@ define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function
|
||||||
processData: false,
|
processData: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
if (data.code == 0) {
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
$('.summernote').summernote("insertImage", data.content, 'filename');
|
if (ret.code === 1) {
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
var onAfterResult = success.call(undefined, data);
|
||||||
|
if (!onAfterResult) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($('.summernote').size() > 0 && data && typeof data.url !== 'undefined') {
|
||||||
|
$('.summernote').summernote("insertImage", data.url, 'filename');
|
||||||
|
}
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
@ -2066,7 +2090,7 @@ define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function
|
||||||
}
|
}
|
||||||
return Frontend.api.layer.msg(__('Operation completed'), $.extend({
|
return Frontend.api.layer.msg(__('Operation completed'), $.extend({
|
||||||
offset: 0, icon: 1
|
offset: 0, icon: 1
|
||||||
}, type ? {} : options));
|
}, type ? {} : options), callback);
|
||||||
},
|
},
|
||||||
error: function (options, callback) {
|
error: function (options, callback) {
|
||||||
var type = typeof options === 'function';
|
var type = typeof options === 'function';
|
||||||
|
|
@ -2075,7 +2099,7 @@ define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function
|
||||||
}
|
}
|
||||||
return Frontend.api.layer.msg(__('Operation failed'), $.extend({
|
return Frontend.api.layer.msg(__('Operation failed'), $.extend({
|
||||||
offset: 0, icon: 2
|
offset: 0, icon: 2
|
||||||
}, type ? {} : options));
|
}, type ? {} : options), callback);
|
||||||
},
|
},
|
||||||
toastr: Toastr,
|
toastr: Toastr,
|
||||||
layer: Layer
|
layer: Layer
|
||||||
|
|
@ -2084,7 +2108,26 @@ define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
string = args[0],
|
string = args[0],
|
||||||
i = 1;
|
i = 1;
|
||||||
string = Lang[string] != undefined ? Lang[string] : string;
|
string = string.toLowerCase();
|
||||||
|
//string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
|
||||||
|
if (typeof Lang[string] != 'undefined') {
|
||||||
|
if (typeof Lang[string] == 'object')
|
||||||
|
return Lang[string];
|
||||||
|
string = Lang[string];
|
||||||
|
} else if (string.indexOf('.') !== -1) {
|
||||||
|
var arr = string.split('.');
|
||||||
|
var current = Lang[arr[0]];
|
||||||
|
for (var i = 1; i < arr.length; i++) {
|
||||||
|
current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
|
||||||
|
if (typeof current != 'object')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (typeof current == 'object')
|
||||||
|
return current;
|
||||||
|
string = current;
|
||||||
|
} else {
|
||||||
|
string = args[0];
|
||||||
|
}
|
||||||
return string.replace(/%((%)|s|d)/g, function (m) {
|
return string.replace(/%((%)|s|d)/g, function (m) {
|
||||||
// m is the matched format, e.g. %s, %d
|
// m is the matched format, e.g. %s, %d
|
||||||
var val = null;
|
var val = null;
|
||||||
|
|
@ -2113,7 +2156,10 @@ define('frontend',['jquery', 'bootstrap', 'toastr', 'layer', 'config'], function
|
||||||
window.Toastr = Toastr;
|
window.Toastr = Toastr;
|
||||||
//将语言方法暴露到全局中去
|
//将语言方法暴露到全局中去
|
||||||
window.__ = Frontend.lang;
|
window.__ = Frontend.lang;
|
||||||
|
//将Frontend渲染至全局,以便于在子框架中调用
|
||||||
|
window.Frontend = Frontend;
|
||||||
//Toastr定义
|
//Toastr定义
|
||||||
Toastr.options = Frontend.config.toastr;
|
Toastr.options = Frontend.config.toastr;
|
||||||
return Frontend;
|
return Frontend;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment', 'bootstr
|
||||||
table: table.bootstrapTable('getOptions').extend.table
|
table: table.bootstrapTable('getOptions').extend.table
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Backend.api.ajax(options, function (content) {
|
Backend.api.ajax(options, function (data) {
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
table.bootstrapTable('refresh');
|
table.bootstrapTable('refresh');
|
||||||
});
|
});
|
||||||
|
|
@ -215,7 +215,7 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment', 'bootstr
|
||||||
var url = action == "del" ? options.extend.del_url : options.extend.multi_url;
|
var url = action == "del" ? options.extend.del_url : options.extend.multi_url;
|
||||||
url = url + "/ids/" + ($.isArray(ids) ? ids.join(",") : ids);
|
url = url + "/ids/" + ($.isArray(ids) ? ids.join(",") : ids);
|
||||||
var options = {url: url, data: {action: action, ids: ids, params: element ? $(element).data("params") : ''}};
|
var options = {url: url, data: {action: action, ids: ids, params: element ? $(element).data("params") : ''}};
|
||||||
Backend.api.ajax(options, function (content) {
|
Backend.api.ajax(options, function (data) {
|
||||||
Toastr.success(__('Operation completed'));
|
Toastr.success(__('Operation completed'));
|
||||||
table.bootstrapTable('refresh');
|
table.bootstrapTable('refresh');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -67,19 +67,19 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
|
||||||
//document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML += (' [Url]: ' + '<a href="' + url + '" target="_blank">' + url + '</a>');
|
//document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML += (' [Url]: ' + '<a href="' + url + '" target="_blank">' + url + '</a>');
|
||||||
//这里建议不修改
|
//这里建议不修改
|
||||||
try {
|
try {
|
||||||
var response = JSON.parse(info.response);
|
var ret = JSON.parse(info.response);
|
||||||
if (response.hasOwnProperty('code')) {
|
if (ret.hasOwnProperty('code')) {
|
||||||
response.code = response.code == 200 ? 1 : response.code;
|
ret.data = ret.code == 200 ? ret : ret.data;
|
||||||
if (response.hasOwnProperty("url")) {
|
ret.code = ret.code == 200 ? 1 : ret.code;
|
||||||
response.data = response.url;
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
}
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
$("input[data-plupload-id='" + id + "-text']").val(response.data);
|
$("input[data-plupload-id='" + id + "-text']").val(data.url);
|
||||||
var afterUpload = $("#" + id).data("after-upload");
|
var afterUpload = $("#" + id).data("after-upload");
|
||||||
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
||||||
Upload.api.custom[afterUpload].call(info, id, response);
|
Upload.api.custom[afterUpload].call(info, id, data);
|
||||||
}
|
}
|
||||||
if (typeof onAfterUpload == 'function') {
|
if (typeof onAfterUpload == 'function') {
|
||||||
onAfterUpload.call(info, id, response);
|
onAfterUpload.call(info, id, data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(e.message + "(code:-2)");
|
Toastr.error(e.message + "(code:-2)");
|
||||||
|
|
@ -111,22 +111,21 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
|
||||||
processData: false,
|
processData: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (ret) {
|
||||||
if (data.hasOwnProperty("code")) {
|
if (ret.hasOwnProperty("code")) {
|
||||||
data.code = data.code == 200 ? 1 : data.code;
|
ret.data = ret.code == 200 ? ret : ret.data;
|
||||||
if (data.hasOwnProperty("url")) {
|
ret.code = ret.code == 200 ? 1 : ret.code;
|
||||||
data.content = data.url;
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
}
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
var content = data.hasOwnProperty("content") && data.content != "" ? data.content : "";
|
if (ret.code === 1) {
|
||||||
if (data.code === 1) {
|
|
||||||
// 如果回调存在,则直接调用回调
|
// 如果回调存在,则直接调用回调
|
||||||
if (typeof callback == 'function') {
|
if (typeof callback == 'function') {
|
||||||
callback.call(this, data);
|
callback.call(this, data);
|
||||||
} else {
|
} else {
|
||||||
Toastr.success(content ? content : __('Operation completed'));
|
Toastr.success(msg ? msg : __('Operation completed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(content ? content : __('Operation failed'));
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(__('Unknown data format'));
|
Toastr.error(__('Unknown data format'));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue