|
@@ -0,0 +1,374 @@
|
|
|
+/**
|
|
|
+ * 列管理定义引用的js
|
|
|
+ */
|
|
|
+
|
|
|
+var grid_selector = "#grid-table";
|
|
|
+var pager_selector = "#grid-pager";
|
|
|
+jQuery(function($) {
|
|
|
+ //初始化日期控件
|
|
|
+ initDateTime();
|
|
|
+ // 初始化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 + '/column/initColumn',
|
|
|
+ mtype : "POST", //提交方式
|
|
|
+ datatype : "json",
|
|
|
+ autowidth: false,
|
|
|
+ height :"auto",
|
|
|
+ shrinkToFit: true,
|
|
|
+ sortname : "", //默认的排序列
|
|
|
+ sortorder : "", //默认的排序列
|
|
|
+ colNames : [ '','id','列名称', '所属任务','映射代码','是否可用'],
|
|
|
+ colModel : [ {
|
|
|
+ name:'Edit',
|
|
|
+ index:'Edit',
|
|
|
+ width:30,
|
|
|
+ sortable : false,
|
|
|
+ fixed : true
|
|
|
+ },{
|
|
|
+ name : 'id',
|
|
|
+ index : 'id',
|
|
|
+ key : true,
|
|
|
+ hidden:true,
|
|
|
+ editable : false,
|
|
|
+ sortable : false
|
|
|
+ },{
|
|
|
+ name : 'columnName',
|
|
|
+ index : 'columnName',
|
|
|
+ editable : false,
|
|
|
+ sortable : true
|
|
|
+ },{
|
|
|
+ name : 'taskName',
|
|
|
+ index : 'taskName',
|
|
|
+ editable : false,
|
|
|
+ sortable : true
|
|
|
+ }, {
|
|
|
+ name : 'mapCode',
|
|
|
+ index : 'mapCode',
|
|
|
+ editable : false,
|
|
|
+ sortable : true
|
|
|
+ }, {
|
|
|
+ name : 'valid',
|
|
|
+ index : 'valid',
|
|
|
+ editable : false,
|
|
|
+ sortable : true
|
|
|
+ ,formatter:function(cellvalue, options, rowObject){
|
|
|
+ if(cellvalue == "Y"){
|
|
|
+ return '是';
|
|
|
+ } else if(cellvalue == "N"){
|
|
|
+ return '否';
|
|
|
+ } else{
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } ],
|
|
|
+ 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 + '/task/getTaskForDdl',//请求的路径
|
|
|
+ dataType : "json",
|
|
|
+ success : function(data) {
|
|
|
+ var option1="<option selected value=''>----请选择----</option>";
|
|
|
+ $("#taskId").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].id).appendTo("#taskId");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 初始化操作按钮
|
|
|
+ */
|
|
|
+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");
|
|
|
+ $("#valid").val("Y");
|
|
|
+ console.info($("#valid").selectedIndex);
|
|
|
+ $("#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:'QY'},
|
|
|
+ url : basePath + '/column/delColumn',//请求的路径
|
|
|
+ success : function(data) {
|
|
|
+ // 成功后刷新页面
|
|
|
+ if (data == "SUCCESS") {
|
|
|
+ showMsgDialog("数据已删除!");
|
|
|
+ }
|
|
|
+ jQuery(grid_selector).trigger("reloadGrid");
|
|
|
+ },
|
|
|
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
+ showMsgDialog("error:" + errorThrown);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ showMsgDialog("请至少选择一条记录");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ position : "last"
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 初始化日期控件
|
|
|
+ */
|
|
|
+function initDateTime() {
|
|
|
+ $('#startTime').datetimepicker({
|
|
|
+ format : 'yyyy-mm-dd hh:ii:ss',
|
|
|
+ minView: 1
|
|
|
+ }).next().on(ace.click_event, function(){
|
|
|
+ $(this).prev().focus();
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#endTime').datetimepicker({
|
|
|
+ format : 'yyyy-mm-dd hh:ii:ss',
|
|
|
+ minView: 1
|
|
|
+ }).next().on(ace.click_event, function(){
|
|
|
+ $(this).prev().focus();
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 编辑
|
|
|
+ * @param rid
|
|
|
+ */
|
|
|
+function editRecord(rid) {
|
|
|
+ var data = jQuery("#grid-table").jqGrid('getRowData', rid);
|
|
|
+ $("#btnSave").show();
|
|
|
+ // 隐藏校验图标
|
|
|
+ hideValidateTip();
|
|
|
+ // 启用元素
|
|
|
+ comEnableElements("modal-table");
|
|
|
+ $("#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 + '/column/save',
|
|
|
+ dataType:'json',
|
|
|
+ data : $('#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 + '/column/initEditColumn', //请求的路径
|
|
|
+ success : function(data) {
|
|
|
+ // 填充信息
|
|
|
+ $('#id').val(data.id);
|
|
|
+ $('#columnName').val(data.columnName);
|
|
|
+ $('#taskId').val(data.taskId);
|
|
|
+ $('#mapCode').val(data.mapCode);
|
|
|
+ $('#valid').val(data.valid);
|
|
|
+ if(flg && flg=="VIEW") {
|
|
|
+ comDisableElements("modal-table");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
+ showMsgDialog("error:" + errorThrown);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('#modal-table').modal('show');
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 隐藏校验图标
|
|
|
+ */
|
|
|
+function hideValidateTip() {
|
|
|
+}
|