整理对话框相关逻辑,封装部分js方法
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+11
-24
@@ -295,15 +295,9 @@ function getPanelHeight(v) {
|
||||
rowSelection: 'multiple',
|
||||
localeText: localeText,
|
||||
suppressAnimationFrame: true,
|
||||
// suppressAutoSize: true,
|
||||
suppressContextMenu: true,
|
||||
// 关闭参数检查
|
||||
suppressPropertyNamesCheck: true,
|
||||
// pagination: true,
|
||||
// rowModelType: 'infinite',
|
||||
// paginationPageSize: 25,
|
||||
// cacheBlockSize: 25,
|
||||
// suppressPaginationPanel: true,
|
||||
suppressCellSelection: true,
|
||||
enableCellTextSelection: true,
|
||||
// 自定义后端数据地址
|
||||
@@ -324,10 +318,11 @@ function getPanelHeight(v) {
|
||||
onCellEditingStarted(params) {
|
||||
this.lastEditCell = params;
|
||||
},
|
||||
remoteSuccessed() {},
|
||||
onGridSizeChanged(params) {
|
||||
remoteBeforeSuccess() {},
|
||||
remoteAfterSuccess() {},
|
||||
onGridSizeChanged() {
|
||||
},
|
||||
onGridReady(params) {
|
||||
onGridReady() {
|
||||
},
|
||||
onFirstDataRendered(params) {
|
||||
var me = this;
|
||||
@@ -370,20 +365,7 @@ function getPanelHeight(v) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof me.onCustomRowSelected == "function") {
|
||||
me.onCustomRowSelected.call(me, params);
|
||||
}
|
||||
},
|
||||
onRowDoubleClicked(params) {
|
||||
console.log('onRowDoubleClicked');
|
||||
},
|
||||
/*
|
||||
getRowNodeId_bak(data) {
|
||||
if (data.id) {
|
||||
return data.id;
|
||||
}
|
||||
},
|
||||
*/
|
||||
columnTypes: {
|
||||
number: {
|
||||
cellClass: 'ag-cell-number',
|
||||
@@ -504,10 +486,11 @@ function getPanelHeight(v) {
|
||||
gridOptions.api.showLoadingOverlay();
|
||||
$.post(gridOptions.remoteDataUrl, remoteParams, function (res) {
|
||||
|
||||
gridOptions.remoteBeforeSuccess.call(gridOptions, res);
|
||||
|
||||
if (typeof success === 'function') {
|
||||
success(res);
|
||||
}
|
||||
gridOptions.remoteSuccessed.call(gridOptions, res);
|
||||
|
||||
if (res.per_page) {
|
||||
if (me.pagerDom === null) {
|
||||
@@ -536,6 +519,7 @@ function getPanelHeight(v) {
|
||||
gridOptions.api.setRowData(res.data);
|
||||
gridOptions.generatePinnedBottomData();
|
||||
|
||||
gridOptions.remoteAfterSuccess.call(gridOptions, res);
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
@@ -548,14 +532,17 @@ function getPanelHeight(v) {
|
||||
gridOptions.api.showLoadingOverlay();
|
||||
$.post(gridOptions.remoteDataUrl, remoteParams, function (res) {
|
||||
|
||||
gridOptions.remoteBeforeSuccess.call(gridOptions, res);
|
||||
|
||||
if (typeof success === 'function') {
|
||||
success(res);
|
||||
}
|
||||
gridOptions.remoteSuccessed.call(gridOptions, res);
|
||||
|
||||
gridOptions.api.hideOverlay();
|
||||
gridOptions.api.setRowData(res.data);
|
||||
gridOptions.generatePinnedBottomData();
|
||||
|
||||
gridOptions.remoteAfterSuccess.call(gridOptions, res);
|
||||
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
function refreshDropMenu($input, data, options) {
|
||||
showDropMenu($input, options);
|
||||
grid.remoteParams.q = $input.val();
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
return $input;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
grid.remoteDataUrl = app.url(params.url);
|
||||
grid.remoteParams = params;
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
return $input;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,80 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 对话框字段写入选中
|
||||
*/
|
||||
gdoo.writeSelected = function(event, params, option, grid) {
|
||||
var rows = grid.api.getSelectedRows();
|
||||
if (params.is_grid) {
|
||||
var list = gdoo.forms[params.form_id];
|
||||
list.api.dialogSelected(params);
|
||||
} else {
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
|
||||
var id = [];
|
||||
var text = [];
|
||||
$.each(rows, function(k, row) {
|
||||
id.push(row[sid]);
|
||||
text.push(row.name);
|
||||
});
|
||||
|
||||
var doc = getIframeDocument(params.iframe_id);
|
||||
if (doc) {
|
||||
var $option_id = $('#' + option.id, doc);
|
||||
var $option_text = $('#'+option.id + '_text', doc);
|
||||
} else {
|
||||
var $option_id = $('#' + option.id);
|
||||
var $option_text = $('#' + option.id + '_text');
|
||||
}
|
||||
|
||||
$option_id.val(id.join(','));
|
||||
$option_text.val(text.join(','));
|
||||
|
||||
if (event.exist('onSelect')) {
|
||||
return event.trigger('onSelect', multiple ? rows : rows[0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化选择
|
||||
*/
|
||||
gdoo.initSelected = function(params, option, grid) {
|
||||
if (params.is_grid) {
|
||||
} else {
|
||||
var doc = getIframeDocument(params.iframe_id);
|
||||
if (doc) {
|
||||
var $option_id = $('#' + option.id, doc);
|
||||
} else {
|
||||
var $option_id = $('#' + option.id);
|
||||
}
|
||||
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var id = $option_id.val();
|
||||
var rows = {};
|
||||
if (id) {
|
||||
var ids = id.split(',');
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
rows[ids[i]] = ids[i];
|
||||
}
|
||||
}
|
||||
|
||||
grid.api.forEachNode(function(node) {
|
||||
var key = node.data[sid];
|
||||
if (rows[key] != undefined) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* grid列表显示构建
|
||||
* @param {*} table
|
||||
*/
|
||||
gdoo.grid = function(table) {
|
||||
var root = this;
|
||||
this.table = table;
|
||||
|
||||
@@ -130,10 +130,9 @@ $(function() {
|
||||
text: "确定",
|
||||
'class': "btn-default",
|
||||
click: function() {
|
||||
var me = this;
|
||||
var list = gdoo.dialogs[option.id] || {};
|
||||
if (typeof list.writeSelected == 'function') {
|
||||
var ret = list.writeSelected();
|
||||
var list = gdoo.dialogs[option.id];
|
||||
if (list) {
|
||||
var ret = gdoo.writeSelected(event, params, option, list);
|
||||
if (ret === true) {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
@@ -875,11 +874,32 @@ function ajaxSubmit(table, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取框架的name
|
||||
* @returns
|
||||
*/
|
||||
function getIframeName() {
|
||||
var name = window.name;
|
||||
return name ? name.replace('iframe_', '') : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取框架的document
|
||||
* @param {*} iframe_id
|
||||
* @returns
|
||||
*/
|
||||
function getIframeDocument(iframe_id) {
|
||||
if (iframe_id) {
|
||||
var iframe = window.frames['iframe_' + iframe_id];
|
||||
if (iframe) {
|
||||
return iframe.document;
|
||||
} else {
|
||||
//toastrError('iframe_id参数无效。');
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化文件大小
|
||||
* @param {*} fileSize
|
||||
|
||||
Reference in New Issue
Block a user