|
|
//var jq = jQuery.noConflict();
|
|
|
/**
|
|
|
* 增删改工具栏
|
|
|
*/
|
|
|
window.onerror = function() {
|
|
|
return true;
|
|
|
};
|
|
|
var iframe;// iframe操作对象
|
|
|
var win;//窗口对象
|
|
|
var gridname="";//操作datagrid对象名称
|
|
|
var windowapi = frameElement.api, W = windowapi.opener;//内容页中调用窗口实例对象接口
|
|
|
function upload(curform) {
|
|
|
upload();
|
|
|
}
|
|
|
/**
|
|
|
* 添加事件打开窗口
|
|
|
* @param title 编辑框标题
|
|
|
* @param addurl//目标页面地址
|
|
|
*/
|
|
|
function add(title,addurl,gname,width,height) {
|
|
|
gridname=gname;
|
|
|
createwindow(title, addurl,width,height);
|
|
|
}
|
|
|
/**
|
|
|
* 树列表添加事件打开窗口
|
|
|
* @param title 编辑框标题
|
|
|
* @param addurl//目标页面地址
|
|
|
*/
|
|
|
function addTreeNode(title,addurl,gname) {
|
|
|
if (rowid != '') {
|
|
|
addurl += '&id='+rowid;
|
|
|
}
|
|
|
gridname=gname;
|
|
|
createwindow(title, addurl);
|
|
|
}
|
|
|
/**
|
|
|
* 更新事件打开窗口
|
|
|
* @param title 编辑框标题
|
|
|
* @param addurl//目标页面地址
|
|
|
* @param id//主键字段
|
|
|
*/
|
|
|
function update(title,url, id,width,height) {
|
|
|
gridname=id;
|
|
|
var rowsData = $('#'+id).datagrid('getSelections');
|
|
|
if (!rowsData || rowsData.length==0) {
|
|
|
tip('请选择编辑项目');
|
|
|
return;
|
|
|
}
|
|
|
if (rowsData.length>1) {
|
|
|
tip('请选择一条记录再编辑');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
url += '&id='+rowsData[0].id;
|
|
|
createwindow(title,url,width,height);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 如果页面是详细查看页面,无效化所有表单元素,只能进行查看
|
|
|
*/
|
|
|
$(function(){
|
|
|
if(location.href.indexOf("load=detail")!=-1){
|
|
|
$(":input").attr("disabled","true");
|
|
|
$(":input").attr("style","border:0;border-bottom:1 solid black;background:white;");
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 查看详细事件打开窗口
|
|
|
* @param title 查看框标题
|
|
|
* @param addurl//目标页面地址
|
|
|
* @param id//主键字段
|
|
|
*/
|
|
|
function detail(title,url, id,width,height) {
|
|
|
var rowsData = $('#'+id).datagrid('getSelections');
|
|
|
// if (rowData.id == '') {
|
|
|
// tip('请选择查看项目');
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
if (!rowsData || rowsData.length == 0) {
|
|
|
tip('请选择查看项目');
|
|
|
return;
|
|
|
}
|
|
|
if (rowsData.length > 1) {
|
|
|
tip('请选择一条记录再查看');
|
|
|
return;
|
|
|
}
|
|
|
url += '&load=detail&id='+rowsData[0].id;
|
|
|
createdetailwindow(title,url,width,height);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 多记录刪除請求
|
|
|
* @param title
|
|
|
* @param url
|
|
|
* @param gname
|
|
|
* @return
|
|
|
*/
|
|
|
function deleteALLSelect(title,url,gname) {
|
|
|
gridname=gname;
|
|
|
var ids = [];
|
|
|
var rows = $("#"+gname).datagrid('getSelections');
|
|
|
if (rows.length > 0) {
|
|
|
$.dialog.confirm('你确定永久删除该数据吗?', function(r) {
|
|
|
if (r) {
|
|
|
for ( var i = 0; i < rows.length; i++) {
|
|
|
ids.push(rows[i].id);
|
|
|
}
|
|
|
$.ajax({
|
|
|
url : url,
|
|
|
type : 'post',
|
|
|
data : {
|
|
|
ids : ids.join(',')
|
|
|
},
|
|
|
cache : false,
|
|
|
success : function(data) {
|
|
|
var d = $.parseJSON(data);
|
|
|
if (d.success) {
|
|
|
var msg = d.msg;
|
|
|
tip(msg);
|
|
|
reloadTable();
|
|
|
$("#"+gname).datagrid('unselectAll');
|
|
|
ids='';
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
tip("请选择需要删除的数据");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看时的弹出窗口
|
|
|
*
|
|
|
* @param title
|
|
|
* @param addurl
|
|
|
* @param saveurl
|
|
|
*/
|
|
|
function createdetailwindow(title, addurl,width,height) {
|
|
|
width = width?width:700;
|
|
|
height = height?height:400;
|
|
|
if(width=="100%" || height=="100%"){
|
|
|
width = document.body.offsetWidth;
|
|
|
height =document.body.offsetHeight-100;
|
|
|
}
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
content: 'url:'+addurl,
|
|
|
lock : true,
|
|
|
width:width,
|
|
|
height: height,
|
|
|
title:title,
|
|
|
opacity : 0.3,
|
|
|
cache:false,
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}else{
|
|
|
W.$.dialog({
|
|
|
content: 'url:'+addurl,
|
|
|
lock : true,
|
|
|
width:width,
|
|
|
height: height,
|
|
|
parent:windowapi,
|
|
|
title:title,
|
|
|
opacity : 0.3,
|
|
|
cache:false,
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* 全屏编辑
|
|
|
* @param title 编辑框标题
|
|
|
* @param addurl//目标页面地址
|
|
|
* @param id//主键字段
|
|
|
*/
|
|
|
function editfs(title,url) {
|
|
|
var name=gridname;
|
|
|
if (rowid == '') {
|
|
|
tip('请选择编辑项目');
|
|
|
return;
|
|
|
}
|
|
|
url += '&id='+rowid;
|
|
|
openwindow(title,url,name,800,500);
|
|
|
}
|
|
|
// 删除调用函数
|
|
|
function delObj(url,name) {
|
|
|
gridname=name;
|
|
|
createdialog('删除确认 ', '确定删除该记录吗 ?', url,name);
|
|
|
}
|
|
|
// 删除调用函数
|
|
|
function confuploadify(url, id) {
|
|
|
$.dialog.confirm('确定删除吗', function(){
|
|
|
deluploadify(url, id);
|
|
|
}, function(){
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 执行删除附件
|
|
|
*
|
|
|
* @param url
|
|
|
* @param index
|
|
|
*/
|
|
|
function deluploadify(url, id) {
|
|
|
$.ajax({
|
|
|
async : false,
|
|
|
cache : false,
|
|
|
type : 'POST',
|
|
|
url : url,// 请求的action路径
|
|
|
error : function() {// 请求失败处理函数
|
|
|
},
|
|
|
success : function(data) {
|
|
|
var d = $.parseJSON(data);
|
|
|
if (d.success) {
|
|
|
$("#" + id).remove();// 移除SPAN
|
|
|
m.remove(id);// 移除MAP对象内字符串
|
|
|
}
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
// 普通询问操作调用函数
|
|
|
function confirm(url, content,name) {
|
|
|
createdialog('提示信息 ', content, url,name);
|
|
|
}
|
|
|
/**
|
|
|
* 提示信息
|
|
|
*/
|
|
|
function tip_old(msg) {
|
|
|
$.dialog.setting.zIndex = 1980;
|
|
|
$.dialog.tips(msg, 1);
|
|
|
}
|
|
|
/**
|
|
|
* 提示信息
|
|
|
*/
|
|
|
function tip(msg) {
|
|
|
$.dialog.setting.zIndex = 1980;
|
|
|
$.messager.show({
|
|
|
title : '提示信息',
|
|
|
msg : msg,
|
|
|
timeout : 1000 * 1.5
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 提示信息像alert一样
|
|
|
*/
|
|
|
function alertTip(msg,title) {
|
|
|
$.dialog.setting.zIndex = 1980;
|
|
|
title = title?title:"提示信息";
|
|
|
$.dialog({
|
|
|
title:title,
|
|
|
icon:'tips.gif',
|
|
|
content: msg
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 创建添加或编辑窗口
|
|
|
*
|
|
|
* @param title
|
|
|
* @param addurl
|
|
|
* @param saveurl
|
|
|
*/
|
|
|
function createwindow(title, addurl,width,height) {
|
|
|
width = width?width:700;
|
|
|
height = height?height:400;
|
|
|
if(width=="100%" || height=="100%"){
|
|
|
width = document.body.offsetWidth;
|
|
|
height =document.body.offsetHeight-100;
|
|
|
}
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
content: 'url:'+addurl,
|
|
|
lock : true,
|
|
|
width:width,
|
|
|
height:height,
|
|
|
title:title,
|
|
|
opacity : 0.3,
|
|
|
cache:false,
|
|
|
ok: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
saveObj();
|
|
|
return false;
|
|
|
},
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}else{
|
|
|
W.$.dialog({
|
|
|
content: 'url:'+addurl,
|
|
|
lock : true,
|
|
|
width:width,
|
|
|
height:height,
|
|
|
parent:windowapi,
|
|
|
title:title,
|
|
|
opacity : 0.3,
|
|
|
cache:false,
|
|
|
ok: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
saveObj();
|
|
|
return false;
|
|
|
},
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* 创建上传页面窗口
|
|
|
*
|
|
|
* @param title
|
|
|
* @param addurl
|
|
|
* @param saveurl
|
|
|
*/
|
|
|
function openuploadwin(title, url,name,width, height) {
|
|
|
gridname=name;
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
cache:false,
|
|
|
button: [
|
|
|
{
|
|
|
name: '开始上传',
|
|
|
callback: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
iframe.upload();
|
|
|
return false;
|
|
|
},
|
|
|
focus: true
|
|
|
},
|
|
|
{
|
|
|
name: '取消上传',
|
|
|
callback: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
iframe.cancel();
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 创建查询页面窗口
|
|
|
*
|
|
|
* @param title
|
|
|
* @param addurl
|
|
|
* @param saveurl
|
|
|
*/
|
|
|
function opensearchdwin(title, url, width, height) {
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
lock : true,
|
|
|
height : height,
|
|
|
cache:false,
|
|
|
width : width,
|
|
|
opacity : 0.3,
|
|
|
button : [ {
|
|
|
name : '查询',
|
|
|
callback : function() {
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
iframe.searchs();
|
|
|
},
|
|
|
focus : true
|
|
|
}, {
|
|
|
name : '取消',
|
|
|
callback : function() {
|
|
|
|
|
|
}
|
|
|
} ]
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 创建不带按钮的窗口
|
|
|
*
|
|
|
* @param title
|
|
|
* @param addurl
|
|
|
* @param saveurl
|
|
|
*/
|
|
|
function openwindow(title, url,name, width, height) {
|
|
|
gridname=name;
|
|
|
if (typeof (width) == 'undefined'&&typeof (height) != 'undefined')
|
|
|
{
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
cache:false,
|
|
|
lock : true,
|
|
|
width: 'auto',
|
|
|
height: height
|
|
|
});
|
|
|
}else{
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
cache:false,
|
|
|
parent:windowapi,
|
|
|
lock : true,
|
|
|
width: 'auto',
|
|
|
height: height
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
if (typeof (height) == 'undefined'&&typeof (width) != 'undefined')
|
|
|
{
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
lock : true,
|
|
|
width: width,
|
|
|
cache:false,
|
|
|
height: 'auto'
|
|
|
});
|
|
|
}else{
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
lock : true,
|
|
|
parent:windowapi,
|
|
|
width: width,
|
|
|
cache:false,
|
|
|
height: 'auto'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
if (typeof (width) == 'undefined'&&typeof (height) == 'undefined')
|
|
|
{
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
lock : true,
|
|
|
width: 'auto',
|
|
|
cache:false,
|
|
|
height: 'auto'
|
|
|
});
|
|
|
}else{
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
lock : true,
|
|
|
parent:windowapi,
|
|
|
width: 'auto',
|
|
|
cache:false,
|
|
|
height: 'auto'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (typeof (width) != 'undefined'&&typeof (height) != 'undefined')
|
|
|
{
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
width: width,
|
|
|
height:height,
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
cache:false,
|
|
|
lock : true
|
|
|
});
|
|
|
}else{
|
|
|
$.dialog({
|
|
|
width: width,
|
|
|
height:height,
|
|
|
content: 'url:'+url,
|
|
|
parent:windowapi,
|
|
|
title : title,
|
|
|
cache:false,
|
|
|
lock : true
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 创建询问窗口
|
|
|
*
|
|
|
* @param title
|
|
|
* @param content
|
|
|
* @param url
|
|
|
*/
|
|
|
function createdialog(title, content, url,name) {
|
|
|
$.dialog.confirm(content, function(){
|
|
|
doSubmit(url,name);
|
|
|
rowid = '';
|
|
|
}, function(){
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 执行保存
|
|
|
*
|
|
|
* @param url
|
|
|
* @param gridname
|
|
|
*/
|
|
|
function saveObj() {
|
|
|
$('#btn_sub', iframe.document).click();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 执行AJAX提交FORM
|
|
|
*
|
|
|
* @param url
|
|
|
* @param gridname
|
|
|
*/
|
|
|
function ajaxSubForm(url) {
|
|
|
$('#myform', iframe.document).form('submit', {
|
|
|
url : url,
|
|
|
onSubmit : function() {
|
|
|
iframe.editor.sync();
|
|
|
},
|
|
|
success : function(r) {
|
|
|
tip('操作成功');
|
|
|
reloadTable();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 执行查询
|
|
|
*
|
|
|
* @param url
|
|
|
* @param gridname
|
|
|
*/
|
|
|
function search() {
|
|
|
|
|
|
$('#btn_sub', iframe.document).click();
|
|
|
iframe.search();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 执行操作
|
|
|
*
|
|
|
* @param url
|
|
|
* @param index
|
|
|
*/
|
|
|
function doSubmit(url,name) {
|
|
|
gridname=name;
|
|
|
$.ajax({
|
|
|
async : false,
|
|
|
cache : false,
|
|
|
type : 'POST',
|
|
|
url : url,// 请求的action路径
|
|
|
error : function() {// 请求失败处理函数
|
|
|
},
|
|
|
success : function(data) {
|
|
|
var d = $.parseJSON(data);
|
|
|
if (d.success) {
|
|
|
var msg = d.msg;
|
|
|
tip(msg);
|
|
|
reloadTable();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 退出确认框
|
|
|
*
|
|
|
* @param url
|
|
|
* @param content
|
|
|
* @param index
|
|
|
*/
|
|
|
function exit(url, content) {
|
|
|
$.dialog.confirm(content, function(){
|
|
|
window.location = url;
|
|
|
}, function(){
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 模板页面ajax提交
|
|
|
*
|
|
|
* @param url
|
|
|
* @param gridname
|
|
|
*/
|
|
|
function ajaxdoSub(url, formname) {
|
|
|
$('#' + formname).form('submit', {
|
|
|
url : url,
|
|
|
onSubmit : function() {
|
|
|
editor.sync();
|
|
|
},
|
|
|
success : function(r) {
|
|
|
tip('操作成功');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* ajax提交FORM
|
|
|
*
|
|
|
* @param url
|
|
|
* @param gridname
|
|
|
*/
|
|
|
function ajaxdoForm(url, formname) {
|
|
|
$('#' + formname).form('submit', {
|
|
|
url : url,
|
|
|
onSubmit : function() {
|
|
|
},
|
|
|
success : function(r) {
|
|
|
tip('操作成功');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function opensubwin(title, url, saveurl, okbutton, closebutton) {
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
lock : true,
|
|
|
opacity : 0.3,
|
|
|
button : [ {
|
|
|
name : okbutton,
|
|
|
callback : function() {
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
win = frameElement.api.opener;// 来源页面
|
|
|
$('#btn_sub', iframe.document).click();
|
|
|
return false;
|
|
|
}
|
|
|
}, {
|
|
|
name : closebutton,
|
|
|
callback : function() {
|
|
|
}
|
|
|
} ]
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function openauditwin(title, url, saveurl, okbutton, backbutton, closebutton) {
|
|
|
$.dialog({
|
|
|
content: 'url:'+url,
|
|
|
title : title,
|
|
|
lock : true,
|
|
|
opacity : 0.3,
|
|
|
button : [ {
|
|
|
name : okbutton,
|
|
|
callback : function() {
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
win = $.dialog.open.origin;// 来源页面
|
|
|
$('#btn_sub', iframe.document).click();
|
|
|
return false;
|
|
|
}
|
|
|
}, {
|
|
|
name : backbutton,
|
|
|
callback : function() {
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
win = frameElement.api.opener;// 来源页面
|
|
|
$('#formobj', iframe.document).form('submit', {
|
|
|
url : saveurl + "&code=exit",
|
|
|
onSubmit : function() {
|
|
|
$('#code').val('exit');
|
|
|
},
|
|
|
success : function(r) {
|
|
|
$.dialog.tips('操作成功', 2);
|
|
|
win.location.reload();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
}, {
|
|
|
name : closebutton,
|
|
|
callback : function() {
|
|
|
}
|
|
|
} ]
|
|
|
|
|
|
});
|
|
|
}
|
|
|
// 添加标签
|
|
|
function addOneTab(subtitle, url, icon) {
|
|
|
if (icon == '') {
|
|
|
icon = 'icon folder';
|
|
|
}
|
|
|
window.top.$.messager.progress({
|
|
|
text : '页面加载中....',
|
|
|
interval : 300
|
|
|
});
|
|
|
window.top.$('#maintabs').tabs({
|
|
|
onClose : function(subtitle, index) {
|
|
|
window.top.$.messager.progress('close');
|
|
|
}
|
|
|
});
|
|
|
if (window.top.$('#maintabs').tabs('exists', subtitle)) {
|
|
|
window.top.$('#maintabs').tabs('select', subtitle);
|
|
|
window.top.$('#maintabs').tabs('update', {
|
|
|
tab : window.top.$('#maintabs').tabs('getSelected'),
|
|
|
options : {
|
|
|
title : subtitle,
|
|
|
href:url,
|
|
|
//content : '<iframe name="tabiframe" scrolling="no" frameborder="0" src="' + url + '" style="width:100%;height:99%;"></iframe>',
|
|
|
closable : true,
|
|
|
icon : icon
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
if (url.indexOf('isIframe') != -1) {
|
|
|
window.top.$('#maintabs').tabs('add', {
|
|
|
title : subtitle,
|
|
|
content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
|
|
|
closable : true,
|
|
|
icon : icon
|
|
|
});
|
|
|
}else {
|
|
|
window.top.$('#maintabs').tabs('add', {
|
|
|
title : subtitle,
|
|
|
href:url,
|
|
|
closable : true,
|
|
|
icon : icon
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 关闭自身TAB刷新父TABgrid
|
|
|
function closetab(title) {
|
|
|
//暂时先不刷新
|
|
|
//window.top.document.getElementById('tabiframe').contentWindow.reloadTable();
|
|
|
//window.top.document.getElementById('maintabs').contentWindow.reloadTable();
|
|
|
window.top.$('#maintabs').tabs('close', title);
|
|
|
//tip("添加成功");
|
|
|
}
|
|
|
|
|
|
//popup
|
|
|
//object: this name:需要选择的列表的字段 code:动态报表的code
|
|
|
function inputClick(obj,name,code) {
|
|
|
$.dialog.setting.zIndex = 2000;
|
|
|
if(name==""||code==""){
|
|
|
alert("popup参数配置不全");
|
|
|
return;
|
|
|
}
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
content: "url:cgReportController.do?popup&id="+code,
|
|
|
lock : true,
|
|
|
title:"选择",
|
|
|
width:800,
|
|
|
height: 400,
|
|
|
cache:false,
|
|
|
ok: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
var selected = iframe.getSelectRows();
|
|
|
if (selected == '' || selected == null ){
|
|
|
alert("请选择");
|
|
|
return false;
|
|
|
}else {
|
|
|
var str = "";
|
|
|
$.each( selected, function(i, n){
|
|
|
if (i==0)
|
|
|
str+= n[name];
|
|
|
else
|
|
|
str+= ","+n[name];
|
|
|
});
|
|
|
$(obj).val("");
|
|
|
//$('#myText').searchbox('setValue', str);
|
|
|
$(obj).val(str);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}else{
|
|
|
$.dialog({
|
|
|
content: "url:cgReportController.do?popup&id="+code,
|
|
|
lock : true,
|
|
|
title:"选择",
|
|
|
width:800,
|
|
|
height: 400,
|
|
|
parent:windowapi,
|
|
|
cache:false,
|
|
|
ok: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
var selected = iframe.getSelectRows();
|
|
|
if (selected == '' || selected == null ){
|
|
|
alert("请选择");
|
|
|
return false;
|
|
|
}else {
|
|
|
var str = "";
|
|
|
$.each( selected, function(i, n){
|
|
|
if (i==0)
|
|
|
str+= n[name];
|
|
|
else
|
|
|
str+= ","+n[name];
|
|
|
});
|
|
|
$(obj).val("");
|
|
|
//$('#myText').searchbox('setValue', str);
|
|
|
$(obj).val(str);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
自定义url的弹出
|
|
|
obj:要填充的控件,可以为多个,以逗号分隔
|
|
|
name:列表中对应的字段,可以为多个,以逗号分隔(与obj要对应)
|
|
|
url:弹出页面的Url
|
|
|
*/
|
|
|
function popClick(obj,name,url) {
|
|
|
$.dialog.setting.zIndex = 2001;
|
|
|
var names = name.split(",");
|
|
|
var objs = obj.split(",");
|
|
|
if(typeof(windowapi) == 'undefined'){
|
|
|
$.dialog({
|
|
|
content: "url:"+url,
|
|
|
lock : true,
|
|
|
title:"选择",
|
|
|
width:700,
|
|
|
height: 400,
|
|
|
cache:false,
|
|
|
ok: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
var selected = iframe.getSelectRows();
|
|
|
if (selected == '' || selected == null ){
|
|
|
alert("请选择");
|
|
|
return false;
|
|
|
}else {
|
|
|
for(var i1=0;i1<names.length;i1++){
|
|
|
var str = "";
|
|
|
$.each( selected, function(i, n){
|
|
|
if (i==0)
|
|
|
str+= n[names[i1]];
|
|
|
else{
|
|
|
str+= ",";
|
|
|
str+=n[names[i1]];
|
|
|
}
|
|
|
});
|
|
|
if($("#"+objs[i1]).length>=1){
|
|
|
$("#"+objs[i1]).val("");
|
|
|
$("#"+objs[i1]).val(str);
|
|
|
}else{
|
|
|
$("input[name='"+objs[i1]+"']").val("");
|
|
|
$("input[name='"+objs[i1]+"']").val(str);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}else{
|
|
|
$.dialog({
|
|
|
content: "url:"+url,
|
|
|
lock : true,
|
|
|
title:"选择",
|
|
|
width:700,
|
|
|
height: 400,
|
|
|
parent:windowapi,
|
|
|
cache:false,
|
|
|
ok: function(){
|
|
|
iframe = this.iframe.contentWindow;
|
|
|
var selected = iframe.getSelectRows();
|
|
|
if (selected == '' || selected == null ){
|
|
|
alert("请选择");
|
|
|
return false;
|
|
|
}else {
|
|
|
for(var i1=0;i1<names.length;i1++){
|
|
|
var str = "";
|
|
|
$.each( selected, function(i, n){
|
|
|
if (i==0)
|
|
|
str+= n[names[i1]];
|
|
|
else{
|
|
|
str+= ",";
|
|
|
str+=n[names[i1]];
|
|
|
}
|
|
|
});
|
|
|
if($("#"+objs[i1]).length>=1){
|
|
|
$("#"+objs[i1]).val("");
|
|
|
$("#"+objs[i1]).val(str);
|
|
|
}else{
|
|
|
$("[name='"+objs[i1]+"']").val("");
|
|
|
$("[name='"+objs[i1]+"']").val(str);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
cancelVal: '关闭',
|
|
|
cancel: true /*为true等价于function(){}*/
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* Jeecg Excel 导出
|
|
|
* 代入查询条件
|
|
|
*/
|
|
|
function JeecgExcelExport(url,datagridId){
|
|
|
var queryParams = $('#'+datagridId).datagrid('options').queryParams;
|
|
|
$('#'+datagridId+'tb').find('*').each(function() {
|
|
|
queryParams[$(this).attr('name')] = $(this).val();
|
|
|
});
|
|
|
var params = '&';
|
|
|
$.each(queryParams, function(key, val){
|
|
|
params+='&'+key+'='+val;
|
|
|
});
|
|
|
var fields = '&field=';
|
|
|
$.each($('#'+ datagridId).datagrid('options').columns[0], function(i, val){
|
|
|
if(val.field != 'opt'){
|
|
|
fields+=val.field+',';
|
|
|
}
|
|
|
});
|
|
|
window.location.href = url+ encodeURI(fields+params);
|
|
|
}
|
|
|
/**
|
|
|
* 自动完成的解析函数
|
|
|
* @param data
|
|
|
* @returns {Array}
|
|
|
*/
|
|
|
function jeecgAutoParse(data){
|
|
|
var parsed = [];
|
|
|
$.each(data.rows,function(index,row){
|
|
|
parsed.push({data:row,result:row,value:row.id});
|
|
|
});
|
|
|
return parsed;
|
|
|
}
|