Przeglądaj źródła

git-svn-id: https://192.168.57.71/svn/jsgkj@447 931142cf-59ea-a443-aa0e-51397b428577

ld_zhoutl 9 lat temu
rodzic
commit
81881bf79a

+ 0 - 369
xtdsp/trunk/src/main/webapp/js/rwgl/datasource/datasource.js

@@ -1,369 +0,0 @@
-/**
- * 任务管理定义引用的js
- */
-
-var grid_selector = "#grid-table";
-var pager_selector = "#grid-pager";
-var currentOper = "";
-jQuery(function($) {
-	// 初始化Grid
-	initGrid();
-	// 初始化下拉列表
-	initDdl();
-});
-
-/**
- * 初始化Grid
- */
-function initGrid() {
-	//resize to fit page size
-	$(window).on('resize.jqGrid', function() {
-		$(grid_selector).jqGrid('setGridWidth', $(".page-content").width()-1);
-	});
-	//resize on sidebar collapse/expand
-	var parent_column = $(grid_selector).closest('[class*="col-"]');
-	$(document).on(
-			'settings.ace.jqGrid',
-			function(ev, event_name, collapsed) {
-				if (event_name === 'sidebar_collapsed'
-						|| event_name === 'main_container_fixed') {
-					//setTimeout is for webkit only to give time for DOM changes and then redraw!!!
-					setTimeout(function() {
-						$(grid_selector).jqGrid('setGridWidth',
-								parent_column.width());
-					}, 0);
-				}
-			});
-
-	// 数据表格初始化
-	jQuery(grid_selector).jqGrid({
-		url : basePath + '/datasource/initDataSource',
-		mtype : "POST", //提交方式
-		datatype : "json",
-		autowidth: false,
-		height :"auto",
-	    shrinkToFit: true,
-		sortname : "", //默认的排序列
-		sortorder : "", //默认的排序列
-		colNames : [ '','id','ID', 'URL','用户名','密码','驱动','最大连接池数量'],
-		colModel : [ {
-            name:'Edit',
-            index:'Edit',
-            width:30,
-			sortable : false,
-            fixed : true
-        },{
-			name : 'id',
-			index : 'id',
-			key : true,
-			hidden:true,
-			editable : false,
-			sortable : false
-		},{
-			name : 'id',
-			index : 'id',
-            width:80,
-			editable : false,
-			sortable : true
-		},{
-			name : 'url',
-			index : 'url',
-			editable : false,
-			sortable : true
-		},  {
-			name : 'username',
-			index : 'username', 
-            width:100,
-			editable : false,
-			sortable : true
-		},  {
-			name : 'password',
-			index : 'password', 
-            width:100,
-			editable : false,
-			sortable : true
-		},  {
-			name : 'driverclassname',
-			index : 'driverclassname',
-			editable : false,
-			sortable : true
-		},  {
-			name : 'maxactive',
-			index : 'maxactive',
-			editable : false,
-			sortable : true
-		} ],
-		rowNum : _rowNum, //每页显示记录数
-		rowList : _rowList, //用于改变显示行数的下拉列表框的元素数组。
-		pager : pager_selector, //定义翻页用的导航栏
-		page : 1, //设置初始的页码,初始为1
-		pagerpos : 'right', //指定分页栏的位置
-		altRows : true, //设置为交替行表格,默认为false
-		multiselect : true, //可以多选
-		multiboxonly : true, //只有选择checkbox才会起作用 
-		loadComplete : function() {
-			var table = this;
-			setTimeout(function() {
-				updatePagerIcons(table);
-				enableTooltips(table);
-			}, 0);
-		},
-		prmNames : {
-             oper : "oper",
-             page : "page",
-             rows : "rows",
-             sort : "sidx",
-             order : "sord"
-        },
-		postData :{
-			wldwCode : function(){ return ""; },//问题内容
-			wldwName : function(){ return ""; }//服务类型
-		},
-		jsonReader : {
-			root : "list", // json中代表实际模型数据的入口
-			page : "page", // json中代表当前页码的数据
-			total : "pages", // json中代表页码总数的数据
-			records : "total", // json中代表数据行总数的数据
-			repeatitems : false// 如果设为false,则jqGrid在解析json时,会根据name来搜索对应的数据元素
-		},
-        gridComplete: function () {
-            comGridComplete("grid-table", "editRecord");
-        },
-		onPaging: function(){
-			comGridPage("grid-table");
-		}
-	});
-
-	$(window).triggerHandler('resize.jqGrid');//trigger window resize to make the grid get the correct size
-	// 隐藏水平垂直滚动条
-	jQuery(grid_selector).closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'hidden' ,'overflow-y':'hidden'});
-	//navButtons
-	jQuery(grid_selector).jqGrid(
-			'navGrid',
-			pager_selector,
-			{ //navbar options
-				edit : false,
-				editicon : 'ace-icon fa fa-pencil blue',
-				add : false,
-				addicon : 'ace-icon fa fa-plus-circle purple',
-				del : false,
-				delicon : 'ace-icon fa fa-trash-o red',
-				search : false,
-				searchicon : 'ace-icon fa fa-search orange',
-				refresh : false,
-				refreshicon : 'ace-icon fa fa-refresh green',
-				view : false,
-				viewicon : 'ace-icon fa fa-search-plus grey',
-			});
-	//初始化操作按钮
-	intOperButton();
-	$(document).one('ajaxloadstart.page', function(e) {
-		$(grid_selector).jqGrid('GridUnload');
-		$('.ui-jqdialog').remove();
-	});
-	
-	setMulti();
-
-};
-
-
-/**
- * 初始化下拉列表
- */
-function initDdl() {
-	// 初始化所在工作
-	$.ajax({
-		type : "POST",
-		url : basePath + '/job/getJobForDdl',//请求的路径
-		dataType : "json",
-		success : function(data) {
-			var option1="<option selected value=''>----请选择----</option>";
-			$("#jobCode").append(option1);
-			if(data) {
-			    var length=data.length;
-			    if(length > 0) {
-				    for(var i=0;i<length;i++){
-				    	$("<option/>").html(data[i].name).val(data[i].code).appendTo("#jobCode");
-				    }
-			    }
-			}
-		}
-	});
-}
-
-/**
- * 初始化操作按钮
- */
-function intOperButton() {
-	jQuery(grid_selector).navButtonAdd(pager_selector, {
-		caption : "新增",
-		buttonicon : "ui-icon ui-icon  btn-minier ace-icon fa fa-plus-circle",
-		onClickButton : function() {
-			comClearFormData("form");
-			// 隐藏校验图标
-			hideValidateTip();
-			$("#id").val("");
-			$("#btnSave").show();
-			// 启用元素
-			comEnableElements("modal-table");
-			currentOper = "ADD";
-			$('#id').removeAttr("readonly");//去除ID元素的readonly属性
-			$("#modal-table #myModalLabel").text("新增数据源");
-			$('#modal-table').modal('show');
-		},
-		position : "last"
-	});
-	jQuery(grid_selector).navButtonAdd(pager_selector, {
-		caption : "删除",
-		buttonicon : "ui-icon ui-icon ace-icon fa fa-trash-o red",
-		onClickButton : function() {
-			var idsStr = getMultiData();
-			if(idsStr.length >=1 ){
-				showMsgConfimDialog("确定删除吗?",function(){
-					$.ajax({
-						async : false,
-						type : 'POST',
-						dataType : "json",
-						data : {"ids":idsStr, opt:'DEL'},
-						url : basePath + '/datasource/delDataSource',//请求的路径				
-						success : function(data) {
-							// 成功后刷新页面
-							if (data == "SUCCESS") {
-								showMsgDialog("数据已删除!");
-							}
-							jQuery(grid_selector).trigger("reloadGrid");
-						},
-						error: function (XMLHttpRequest, textStatus, errorThrown) {
-				            showMsgDialog("error:" + errorThrown);
-				        }
-					});
-				});
-			} else {
-				showMsgDialog("请至少选择一条记录");
-			}
-		},
-		position : "last"
-	});
-}
-
-/**
- * 编辑
- * @param rid
- */
-function editRecord(rid) {
-	var data = jQuery("#grid-table").jqGrid('getRowData', rid);
-	$("#btnSave").show();
-	// 隐藏校验图标
-	hideValidateTip();
-	// 启用元素
-	comEnableElements("modal-table");
-	currentOper = "EDIT";
-	$('#id').attr("readonly","readonly");//将ID设置为readonly
-	$("#modal-table #myModalLabel").text("编辑数据源");
-	initBaseInfo(rid);
-}
-
-/**
- *	获取多行选中的id 
- */
-function getMultiData(opt){
-	var ids = "";
-	//获取选择行的id
-	var row = jQuery(grid_selector).jqGrid('getGridParam','selarrrow');
-	if (row.length >= 1) {
-		for (var i = 0; i < row.length; i++) {
-			//获取选择的行的数据,只要传入rowId即可
-			var data = jQuery(grid_selector).jqGrid('getRowData', row[i]);
-			ids += data.id +",";
-		}
-		ids = ids.substr(0, ids.length - 1);
-	}
-	return ids;
-}
-
-/**
- * 查询事件
- */
-function searchRecord() {
-	
-	 //$.extend(jQuery(grid_selector)[0].p.postData);
-	 jQuery("#grid-table").trigger("reloadGrid", [{ page: 1 }]);
-};
-
-
-/**
- * form提交事件
- */
-function submitForm() {
-	$.ajax({
-		async:false,
-		type : "post",
-		url : basePath + '/datasource/save',
-		dataType:'json',
-		data : $.param({'opt':currentOper}) + '&' + $('#form').serialize()
-		, //表单序列化,获取数据
-		success : function(data) {
-			// 成功删除后刷新页面
-			if (data) {
-				showMsgDialog("数据已成功保存!");
-				closeWin();
-				searchRecord();
-			} else {
-				showMsgDialog("数据保存失败!");
-			}
-		}, //操作成功后的操作!data是后台传过来的值 
-		error: function (XMLHttpRequest, textStatus, errorThrown) {
-            showMsgDialog("error:" + errorThrown);
-        }
-	});
-};
-
-// 关闭弹出窗口,刷新列表
-function closeWin(){
-	$('.layui-layer').hide();
-	$('#modal-table').modal('hide');
-}
-
-/**
- * 根据id查询所有信息并赋值
- */
-function initBaseInfo(rowid, flg){
-	// 后台获取
-	$.ajax({
-		async : true,
-		type : 'POST',
-		dataType : "json",
-		data : {id:rowid},
-		url : basePath + '/datasource/initEditDataSource', //请求的路径				
-		success : function(data) {
-			// 填充信息
-			$('#id').val(data.id);
-			$('#url').val(data.url);
-			$('#driverclassname').val(data.driverclassname);
-			$('#username').val(data.username);
-			$('#password').val(data.password);
-			$('#initialsize').val(data.initialsize);
-			$('#minidle').val(data.minidle);
-			$('#maxactive').val(data.maxactive);
-			$('#timebetweenevictionrunsmillis').val(data.timebetweenevictionrunsmillis);
-			$('#minevictableidletimemillis').val(data.minevictableidletimemillis);
-			$('#testonreturn').val(data.testonreturn);
-			$('#poolpreparedstatements').val(data.poolpreparedstatements);
-			$('#maxpoolpreparedstatementpercon').val(data.maxpoolpreparedstatementpercon);
-			$('#validationquery').val(data.validationquery);
-			if(flg && flg=="VIEW") {
-				comDisableElements("modal-table");
-			}
-		},
-		error: function (XMLHttpRequest, textStatus, errorThrown) {
-            showMsgDialog("error:" + errorThrown);
-        }
-	});		
-	$('#modal-table').modal('show');					
-};
-
-/**
- * 隐藏校验图标
- */
-function hideValidateTip() {
-}