|
@@ -6909,23 +6909,74 @@ define('backend',['fast', 'moment'], function (Fast, Moment) {
|
|
|
Toastr.options.positionClass = Config.controllername === 'index' ? "toast-top-right-index" : "toast-top-right";
|
|
Toastr.options.positionClass = Config.controllername === 'index' ? "toast-top-right-index" : "toast-top-right";
|
|
|
//点击包含.btn-dialog的元素时弹出dialog
|
|
//点击包含.btn-dialog的元素时弹出dialog
|
|
|
$(document).on('click', '.btn-dialog,.dialogit', function (e) {
|
|
$(document).on('click', '.btn-dialog,.dialogit', function (e) {
|
|
|
- var options = $(this).data() || {};
|
|
|
|
|
- Backend.api.open(Backend.api.replaceids(this, $(this).attr('href')), $(this).attr('title'), options);
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var options = $(that).data() || {};
|
|
|
|
|
+ if (typeof options.tableId !== 'undefined' && typeof options.columnIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
|
|
|
|
|
+ var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
|
|
|
|
|
+ if (tableOptions) {
|
|
|
|
|
+ var button = tableOptions.columns[0][options.columnIndex]['buttons'][options.buttonIndex];
|
|
|
|
|
+ if (button && typeof button.callback === 'function') {
|
|
|
|
|
+ options.callback = button.callback;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (typeof options.confirm !== 'undefined') {
|
|
|
|
|
+ Layer.confirm(options.confirm, function (index) {
|
|
|
|
|
+ Backend.api.open(Backend.api.replaceids(that, $(that).attr('href')), $(that).attr('title'), options);
|
|
|
|
|
+ Layer.close(index);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Backend.api.open(Backend.api.replaceids(that, $(that).attr('href')), $(that).attr('title'), options);
|
|
|
|
|
+ }
|
|
|
return false;
|
|
return false;
|
|
|
});
|
|
});
|
|
|
//点击包含.btn-addtabs的元素时新增选项卡
|
|
//点击包含.btn-addtabs的元素时新增选项卡
|
|
|
$(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
|
|
$(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
|
|
|
- Backend.api.addtabs(Backend.api.replaceids(this, $(this).attr('href')), $(this).attr("title"));
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var options = $(that).data() || {};
|
|
|
|
|
+ if (typeof options.confirm !== 'undefined') {
|
|
|
|
|
+ Layer.confirm(options.confirm, function (index) {
|
|
|
|
|
+ Backend.api.addtabs(Backend.api.replaceids(that, $(that).attr('href')), $(that).attr("title"));
|
|
|
|
|
+ Layer.close(index);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Backend.api.addtabs(Backend.api.replaceids(that, $(that).attr('href')), $(that).attr("title"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return false;
|
|
return false;
|
|
|
});
|
|
});
|
|
|
//点击包含.btn-ajax的元素时发送Ajax请求
|
|
//点击包含.btn-ajax的元素时发送Ajax请求
|
|
|
$(document).on('click', '.btn-ajax,.ajaxit', function (e) {
|
|
$(document).on('click', '.btn-ajax,.ajaxit', function (e) {
|
|
|
- var options = $(this).data();
|
|
|
|
|
- if (typeof options.url === 'undefined' && $(this).attr("href")) {
|
|
|
|
|
- options.url = $(this).attr("href");
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var options = $(that).data() || {};
|
|
|
|
|
+ if (typeof options.url === 'undefined' && $(that).attr("href")) {
|
|
|
|
|
+ options.url = $(that).attr("href");
|
|
|
}
|
|
}
|
|
|
options.url = Backend.api.replaceids(this, options.url);
|
|
options.url = Backend.api.replaceids(this, options.url);
|
|
|
- Backend.api.ajax(options);
|
|
|
|
|
|
|
+ var success = typeof options.success === 'function' ? options.success : null;
|
|
|
|
|
+ var error = typeof options.error === 'function' ? options.error : null;
|
|
|
|
|
+ delete options.success;
|
|
|
|
|
+ delete options.error;
|
|
|
|
|
+ if (typeof options.tableId !== 'undefined' && typeof options.columnIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
|
|
|
|
|
+ var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
|
|
|
|
|
+ if (tableOptions) {
|
|
|
|
|
+ var button = tableOptions.columns[0][options.columnIndex]['buttons'][options.buttonIndex];
|
|
|
|
|
+ if (button && typeof button.success === 'function') {
|
|
|
|
|
+ success = button.success;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (button && typeof button.error === 'function') {
|
|
|
|
|
+ error = button.error;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (typeof options.confirm !== 'undefined') {
|
|
|
|
|
+ Layer.confirm(options.confirm, function (index) {
|
|
|
|
|
+ Backend.api.ajax(options, success, error);
|
|
|
|
|
+ Layer.close(index);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Backend.api.ajax(options, success, error);
|
|
|
|
|
+ }
|
|
|
return false;
|
|
return false;
|
|
|
});
|
|
});
|
|
|
//修复含有fixed-footer类的body边距
|
|
//修复含有fixed-footer类的body边距
|
|
@@ -9707,10 +9758,10 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|
|
$(toolbar).on('click', Table.config.delbtn, function () {
|
|
$(toolbar).on('click', Table.config.delbtn, function () {
|
|
|
var that = this;
|
|
var that = this;
|
|
|
var ids = Table.api.selectedids(table);
|
|
var ids = Table.api.selectedids(table);
|
|
|
- var index = Layer.confirm(
|
|
|
|
|
|
|
+ Layer.confirm(
|
|
|
__('Are you sure you want to delete the %s selected item?', ids.length),
|
|
__('Are you sure you want to delete the %s selected item?', ids.length),
|
|
|
{icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
|
|
{icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
|
|
|
- function () {
|
|
|
|
|
|
|
+ function (index) {
|
|
|
Table.api.multi("del", ids, table, that);
|
|
Table.api.multi("del", ids, table, that);
|
|
|
Layer.close(index);
|
|
Layer.close(index);
|
|
|
}
|
|
}
|
|
@@ -9765,10 +9816,10 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
var id = $(this).data("id");
|
|
var id = $(this).data("id");
|
|
|
var that = this;
|
|
var that = this;
|
|
|
- var index = Layer.confirm(
|
|
|
|
|
|
|
+ Layer.confirm(
|
|
|
__('Are you sure you want to delete this item?'),
|
|
__('Are you sure you want to delete this item?'),
|
|
|
{icon: 3, title: __('Warning'), shadeClose: true},
|
|
{icon: 3, title: __('Warning'), shadeClose: true},
|
|
|
- function () {
|
|
|
|
|
|
|
+ function (index) {
|
|
|
Table.api.multi("del", id, table, that);
|
|
Table.api.multi("del", id, table, that);
|
|
|
Layer.close(index);
|
|
Layer.close(index);
|
|
|
}
|
|
}
|
|
@@ -9811,10 +9862,10 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|
|
if ($(window).width() < 480) {
|
|
if ($(window).width() < 480) {
|
|
|
top = left = undefined;
|
|
top = left = undefined;
|
|
|
}
|
|
}
|
|
|
- var index = Layer.confirm(
|
|
|
|
|
|
|
+ Layer.confirm(
|
|
|
__('Are you sure you want to delete this item?'),
|
|
__('Are you sure you want to delete this item?'),
|
|
|
{icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true},
|
|
{icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true},
|
|
|
- function () {
|
|
|
|
|
|
|
+ function (index) {
|
|
|
var table = $(that).closest('table');
|
|
var table = $(that).closest('table');
|
|
|
var options = table.bootstrapTable('getOptions');
|
|
var options = table.bootstrapTable('getOptions');
|
|
|
Table.api.multi("del", row[options.pk], table, that);
|
|
Table.api.multi("del", row[options.pk], table, that);
|
|
@@ -9916,65 +9967,69 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|
|
buttons.push({name: 'dragsort', icon: 'fa fa-arrows', classname: 'btn btn-xs btn-primary btn-dragsort'});
|
|
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', url: options.extend.edit_url});
|
|
buttons.push({name: 'edit', icon: 'fa fa-pencil', classname: 'btn btn-xs btn-success btn-editone', url: options.extend.edit_url});
|
|
|
buttons.push({name: 'del', icon: 'fa fa-trash', classname: 'btn btn-xs btn-danger btn-delone'});
|
|
buttons.push({name: 'del', icon: 'fa fa-trash', classname: 'btn btn-xs btn-danger btn-delone'});
|
|
|
- var html = [];
|
|
|
|
|
- var url, classname, icon, text, title, extend;
|
|
|
|
|
- $.each(buttons, function (i, j) {
|
|
|
|
|
|
|
+ return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
|
|
|
|
|
+ },
|
|
|
|
|
+ buttons: function (value, row, index) {
|
|
|
|
|
+ // 默认按钮组
|
|
|
|
|
+ var buttons = $.extend([], this.buttons || []);
|
|
|
|
|
+ return Table.api.buttonlink(this, buttons, value, row, index, 'buttons');
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ buttonlink: function (column, buttons, value, row, index, type) {
|
|
|
|
|
+ var table = column.table;
|
|
|
|
|
+ type = typeof type === 'undefined' ? 'buttons' : type;
|
|
|
|
|
+ // 操作配置
|
|
|
|
|
+ var options = table ? table.bootstrapTable('getOptions') : {};
|
|
|
|
|
+ var html = [];
|
|
|
|
|
+ var url, classname, icon, text, title, extend;
|
|
|
|
|
+ var columnIndex = options.columns[0].findIndex(function (element) {
|
|
|
|
|
+ return element === column;
|
|
|
|
|
+ });
|
|
|
|
|
+ $.each(buttons, function (i, j) {
|
|
|
|
|
+ if (type === 'operate') {
|
|
|
if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
|
|
if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
|
|
if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
- var attr = table.data("operate-" + j.name);
|
|
|
|
|
- if (typeof attr === 'undefined' || attr) {
|
|
|
|
|
- url = j.url ? j.url : '';
|
|
|
|
|
- if (url.indexOf("{ids}") === -1) {
|
|
|
|
|
- url = url ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
|
|
|
|
|
- }
|
|
|
|
|
- url = Table.api.replaceurl(url, value, row, table);
|
|
|
|
|
- url = url ? Fast.api.fixurl(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;
|
|
|
|
|
- extend = j.extend ? j.extend : '';
|
|
|
|
|
- html.push('<a href="' + url + '" class="' + classname + '" ' + extend + ' title="' + title + '"><i class="' + icon + '"></i>' + (text ? ' ' + text : '') + '</a>');
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- return html.join(' ');
|
|
|
|
|
- },
|
|
|
|
|
- buttons: function (value, row, index) {
|
|
|
|
|
- var table = this.table;
|
|
|
|
|
- // 操作配置
|
|
|
|
|
- var options = table ? table.bootstrapTable('getOptions') : {};
|
|
|
|
|
- // 默认按钮组
|
|
|
|
|
- var buttons = $.extend([], this.buttons || []);
|
|
|
|
|
- var html = [];
|
|
|
|
|
- var url, classname, icon, text, title, extend;
|
|
|
|
|
- $.each(buttons, function (i, j) {
|
|
|
|
|
- var attr = table.data("buttons-" + j.name);
|
|
|
|
|
- if (typeof attr === 'undefined' || attr) {
|
|
|
|
|
- url = j.url ? j.url : '';
|
|
|
|
|
- if (url.indexOf("{ids}") === -1) {
|
|
|
|
|
- url = url ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
|
|
|
|
|
- }
|
|
|
|
|
- url = Table.api.replaceurl(url, value, row, table);
|
|
|
|
|
- url = url ? Fast.api.fixurl(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;
|
|
|
|
|
- extend = j.extend ? j.extend : '';
|
|
|
|
|
- html.push('<a href="' + url + '" class="' + classname + '" ' + extend + ' title="' + title + '"><i class="' + icon + '"></i>' + (text ? ' ' + text : '') + '</a>');
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ var attr = table.data(type + "-" + j.name);
|
|
|
|
|
+ if (typeof attr === 'undefined' || attr) {
|
|
|
|
|
+ url = j.url ? j.url : '';
|
|
|
|
|
+ if (!url.match(/\{(.*?)\}/i)) {
|
|
|
|
|
+ url = url ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- return html.join(' ');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ url = Table.api.replaceurl(url, value, row, table);
|
|
|
|
|
+ url = url ? Fast.api.fixurl(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;
|
|
|
|
|
+ confirm = j.confirm ? 'data-confirm="' + j.confirm + '"' : '';
|
|
|
|
|
+ extend = j.extend ? j.extend : '';
|
|
|
|
|
+ html.push('<a href="' + url + '" class="' + classname + '" ' + (confirm ? confirm + ' ' : '') + extend + ' title="' + title + '" data-table-id="' + (table ? table.attr("id") : '') + '" data-column-index="' + columnIndex + '" data-button-index="' + i + '"><i class="' + icon + '"></i>' + (text ? ' ' + text : '') + '</a>');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return html.join(' ');
|
|
|
},
|
|
},
|
|
|
- //替换URL中的{ids}和{value}
|
|
|
|
|
|
|
+ //替换URL中的数据
|
|
|
replaceurl: function (url, value, row, table) {
|
|
replaceurl: function (url, value, row, table) {
|
|
|
- url = url ? url : '';
|
|
|
|
|
url = url.replace(/\{value\}/ig, value);
|
|
url = url.replace(/\{value\}/ig, value);
|
|
|
|
|
+ url = url.replace(/\{(.*?)\}/gi, function (matched) {
|
|
|
|
|
+ matched = matched.substring(1, matched.length - 1);
|
|
|
|
|
+ if (matched.indexOf(".") !== -1) {
|
|
|
|
|
+ var temp = row;
|
|
|
|
|
+ var arr = matched.split(/\./);
|
|
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
|
|
+ if (typeof temp[arr[i]] !== 'undefined') {
|
|
|
|
|
+ temp = temp[arr[i]];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return typeof temp === 'object' ? '' : temp;
|
|
|
|
|
+ }
|
|
|
|
|
+ return row[matched];
|
|
|
|
|
+ });
|
|
|
if (table) {
|
|
if (table) {
|
|
|
var options = table.bootstrapTable('getOptions');
|
|
var options = table.bootstrapTable('getOptions');
|
|
|
url = url.replace(/\{ids\}/ig, row[options.pk]);
|
|
url = url.replace(/\{ids\}/ig, row[options.pk]);
|
|
@@ -12836,7 +12891,7 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
|
|
|
url = url ? url : location.href;
|
|
url = url ? url : location.href;
|
|
|
//修复当存在多选项元素时提交的BUG
|
|
//修复当存在多选项元素时提交的BUG
|
|
|
var params = {};
|
|
var params = {};
|
|
|
- var multipleList = $("[name$='[]']");
|
|
|
|
|
|
|
+ var multipleList = $("[name$='[]']", form);
|
|
|
if (multipleList.size() > 0) {
|
|
if (multipleList.size() > 0) {
|
|
|
var postFields = form.serializeArray().map(function (obj) {
|
|
var postFields = form.serializeArray().map(function (obj) {
|
|
|
return $(obj).prop("name");
|
|
return $(obj).prop("name");
|
|
@@ -12851,7 +12906,7 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
|
|
|
Fast.api.ajax({
|
|
Fast.api.ajax({
|
|
|
type: type,
|
|
type: type,
|
|
|
url: url,
|
|
url: url,
|
|
|
- data: form.serialize() + (params ? '&' + $.param(params) : ''),
|
|
|
|
|
|
|
+ data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
|
|
|
dataType: 'json',
|
|
dataType: 'json',
|
|
|
complete: function (xhr) {
|
|
complete: function (xhr) {
|
|
|
var token = xhr.getResponseHeader('__token__');
|
|
var token = xhr.getResponseHeader('__token__');
|