123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="renderer" content="webkit|ie-comp|ie-stand">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
- <meta http-equiv="Cache-Control" content="no-siteapp" />
- <!--[if lt IE 9]>
- <script type="text/javascript" src="${ctx}/assets/lib/html5.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
- <![endif]-->
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui/css/H-ui.min.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/H-ui.admin.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/Hui-iconfont/1.0.7/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/icheck/icheck.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/skin/default/skin.css" id="skin" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/style.css" />
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
- <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/static/h-ui/js/H-ui.js"></script>
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
- <script type="text/javascript">
- $(function(){
- $(window).resize(function(){
- $("#tree").setGridWidth($(window).width()-40);
- });
- $("#tree").jqGrid({
- caption:'机构管理',
- url:'${ctx}/myconsole/org/getByTree',
- editurl:'${ctx}/myconsole/org/saveOrUpdate',
- mtype:"POST",
- datatype: "json",
- hoverrows:false,
- viewrecords:false,
- gridview:true,
- height:"auto",
- rowNum:100,
- scrollrows:true,
- treeGrid:true,
- ExpandColumn:"orgname",
- treedatatype:"json",
- treeGridModel:"adjacency",
- sortorder:"asc",
- autowidth:true,
- pager:"#pager",
- prmNames:{
- id:"orgid"
- },
- colModel:[{
- label : '编号',
- name : 'orgid',
- hidden : true,
- key : true,
- width : 75
- }, {
- label : '机构名称',
- name : 'orgname',
- edittype : "text",
- editable : true,
- formoptions:{
- elmsuffix:" <span style='color:red'>*<span>",
- },
- editrules:{required:true},
- width : 100,
- editoptions: {
- size:50,
- maxlength: 120
- }
- }, {
- label : '机构编号',
- name : 'orgid',
- edittype : "text",
- editable: true,
- formoptions:{
- elmsuffix:" <span style='color:red'>*<span>",
- },
- editrules:{required:true},
- width : 50,
- editoptions: {
- size:50,
- maxlength: 120
- }
- }, {
- label : '上级机构',
- name:"parentid",
- editable: false,
- width : 50,
- editoptions:{value:"${orgOptions}"}
- }, {
- label : '排序值',
- name : 'sortid',
- editable: true,
- hidden:true,
- edittype : "text",
- editrules:{
- edithidden:true,
- custom:true,
- custom_func: function(strFieldValue, strFieldName){
- var strFloat = /^([-\+]?(((\d+)(\.\d+))|(\.\d+)|(\d*)))?$/;
- if(!strFloat.test(strFieldValue)){
- return [false, strFieldName+"应该为实数"];
- }
- else
- {
- return [true,""];
- }
- }
- },
- formoptions:{
- elmsuffix:' 必须是数字'
- },
- width : 50,
- editoptions: {
- size:50,
- maxlength: 5
- }
- },{
- label : '机构类型',
- name : 'orgtype',
- editable: true,
- edittype: "select",
- editoptions:{
- dataInit: function(elem){
- $(elem).width(334);
- },
- value : "总公司:总公司;分公司:分公司;中支公司:中支公司;内部:内部"
- },
- editrules:{edithidden:true},
- width : 45
- },{
- label : '机构描述',
- name : 'orgdesc',
- editable: true,
- hidden:true,
- width : 100,
- edittype : "textarea",
- editrules:{
- edithidden : true
- },
- editoptions: {
- size:50,
- maxlength: 120,
- rows:"5",
- cols:"48"
- }
- }, {
- label : '创建人',
- name : 'insertusername',
- editable: false,
- width : 35
- }, {
- label : '创建时间',
- name : 'inserttime',
- editable: false,
- width : 50
- }, {
- name:"treelevel",
- hidden:true
- } ],
- treeReader:{
- level_field:"treelevel",
- leaf_field:"isleaf",
- expanded_field:"expanded",
- loaded:"loaded",
- parent_id_field:"parentid",
- icon_field:"icon"
- }
- });
- jQuery('#tree').jqGrid('navGrid','#pager',
- {
- add : true,
- edit : true,
- del : true,
- search : false,
- refresh : true,
- view : false,
- position : "left",
- cloneToTop : true
- },
- //编辑按钮事件处理
- {
- closeAfterEdit : true,
- recreateForm : true,
- width:800,
- afterShowForm : function(formid) {
- var orgidObj = formid.find('#orgid');
- orgidObj.attr('readOnly',true);
- orgidObj.css({'background':'#cccccc'});
-
- },
- beforeSubmit: function(postdata, formid){
- // 编辑时jqgrid 将主键变成 tree_id 手动添加 keyid
- postdata["keyid"] = postdata.tree_id;
-
- $.each(postdata,function (index, value) {
- if(index!="oper"){
- modifyJosnKey(postdata,index,"org."+index);
- }
- })
-
- return [true,'']; //返回值必须这么写 目前没找到原因,用true 和 返回对象都不好使。待查
- },
- afterSubmit: function(response,postdata)
- {
- var res=eval('(' + response.responseText + ')');
- if(res.flag)
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [true,res.message,''];
-
- }
- else
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [false,res.message,''];
-
- }
-
- },
- afterComplete : function (response, postdata, formid) {
- //取消选择
- $("#tree").jqGrid("resetSelection");
- //关闭对话框
- $(".ui-icon-closethick").trigger('click');
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },
- //添加按钮处理事件
- {
- closeAfterAdd : true,
- recreateForm : true,
- checkOnUpdate : true,
- checkOnSubmit : true,
- width:800,
- afterShowForm : function(formid) {
- var orgidObj = formid.find('#orgid');
- orgidObj.blur(function(){
- verifyOrg(orgidObj.val());
- });
- },
- serializeEditData: function(postdata) {
-
- //对主键字段进行赋值传递 韩林平
- var selRowId = $("#tree").jqGrid ('getGridParam', 'selrow');
- if(selRowId == null) selRowId = "";
- //获取选中的父节点主键值,添加下级站点
-
- $.each(postdata,function(index,value){
- if(index!="oper"){
- modifyJosnKey(postdata,index,"org."+index);
- }
- })
- //jqgrid 做添加操作会把主键id的值设置成“_empty”;这里修改成空;
- postdata["org.keyid"] = "";
- postdata["org.parentid"] = selRowId;
- return postdata;
- },
- afterSubmit: function(response,postdata)
- {
- var res=eval('(' + response.responseText + ')');
- if(res.flag)
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [true,res.message,''];
-
- }
- else
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [false,res.message,''];
-
- }
-
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },
- // options for the Delete Dailog
- {
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- },
- afterSubmit: function(response,postdata)
- {
- var res=eval('(' + response.responseText + ')');
- if(res.flag)
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [true,res.message,''];
-
- }
- else
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [false,res.message,''];
-
- }
-
- }
- })
- jQuery('#tree').jqGrid('bindKeys');
- })
-
-
-
- function verifyOrg(orgID){
- if(orgID == "") return ;
- var errorShow = $(".FormError");
- errorShow.html("").hide();
- $.post("${ctx}/myconsole/org/verifyOrg", {'orgID':orgID},
- function(data){
- if(data.length>0){
- $('#orgid').val("");
- errorShow.html("该机构编号["+orgID+"]已存在,请尝试其他编号").show();
- }
- }
- );
- }
-
- </script>
- <title>机构管理</title>
- </head>
- <body>
- <div class="page-container">
- <table id="tree"></table>
- <div id="pager"></div>
- </div>
- <footer class="footer mt-20">
- <div class="container">
- <p></p>
- </div>
- </footer>
- </body>
- </html>
|