123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
- <jsp:include page="../../common/include.jsp" />
- <% String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
- <script src="<%=basePath %>/js/ajaxfileupload.js"></script>
- <script type="text/javascript">
- /**摊位显示区*/
- $(function() {
- $('#departmentDataGrid').datagrid({
- rownumbers:true,
- fit:true,
- pageSize:20,
- pageList : [ 10, 20, 30, 40, 50 ],
- fitColumns:false,
- border:false,
- sortOrder:'desc',
- pagination:true,
- idField:'id',
- url:whzl.basePath + '/departmentAction_listDepartment',
- toolbar:'#searchtool',
- checkOnSelect:true,
- selectOnCheck:true,
- nowrap:true,
- loadFilter:function(result){
- if(result.success){
- return result.obj;
- }else{
- $.messager.alert('提示',result.message,'error');
- return ;
- }
- }
- }
- );
- });
-
- /**查询*/
- function searchFun(){
- $("#departmentDataGrid").datagrid("load", {
- "department.name":$("#tblQuery").find("input[id='name']").val()
- });
- }
-
- /*清除查询条件**/
- function ClearQuery() {
- $("#tblQuery").find("input").val("");
- $("#tblQuery").find("select").val("-1");
- }
-
- /**详细*/
- var detailsFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/js/easyui/themes/itemicon/detail.png' title='查看详情' onclick=departmentDetails(" + row.id + ") style='cursor:pointer' />";
- };
-
- /**详细页面对话框*/
- var departmentDetails = function(id){
- $("#detailDepartmentDialog").dialog(
- {
- buttons : [
- {
- text : '确定',
- iconCls : 'icon-ok',
- handler : function(){
- $("#detailDepartmentDialog").dialog("close");
- }
- }
- ],
- onLoad : function(){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "departmentAction_findById",//要访问的后台地址
- data: "department.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- $("#name_detail").text(msg.obj.name);
- $("#desc_detail").text(msg.obj.desc);
- $("#parentName_detail").text(msg.obj.parentName);
- $("#responsibleName_detail").text(msg.obj.responsibleName);
- }
- });
- }
- }
- );
- };
-
- /**更新*/
- var updateFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/js/easyui/themes/itemicon/update.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
- };
-
- /**更新事件*/
- function updateRow(id){
- var updateIndex = $('#departmentDataGrid').datagrid('getRowIndex', id);
- $('#updateDepartmentDialog').dialog(
- {
- buttons : [
- {
- text : '提交',
- iconCls : 'icon-ok',
- handler : function(){
- $("#responsibleId_update").val($("#responsibleId").combotree("getValues"));
- $("#responsibleName_update").val($("#responsibleId").combotree("getText"));
- $('#updateDepartmentForm').form('submit',
- {
- url : whzl.basePath+'/departmentAction_updateDepartment',
- success : function(result){
- var parseResult = $.parseJSON(result);
- if(parseResult.success){
- //修改完数据,更新对应行的数据
- $('#departmentDataGrid').datagrid('updateRow',
- {
- index : updateIndex,
- row : parseResult.obj
- }
- );
- $("#updateDepartmentDialog").dialog("close");
- $('#allDepartmentTree').tree('reload');
- }else{
- $.messager.alert('出错了',parseResult.message);
- }
- }
- }
- );
- }
- },
- {
- text : '取消',
- iconCls : 'icon-cancel',
- handler : function(){
- $("#updateDepartmentDialog").dialog("close");
- }
- }
- ],
- onLoad : function(){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "departmentAction_findById",//要访问的后台地址
- data: "department.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- $("#id_update").val(msg.obj.id);
- $("#name_update").val(msg.obj.name);
- $("#desc_update").val(msg.obj.desc);
- if(msg.obj.parentId >0){
- $('#p_id_update').combotree('setValue',msg.obj.parentId);
- }
- if(msg.obj.responsibleId != ""){
- $('#responsibleId').combotree ({
- url:"departmentAction_findByUserIdList?userId=" + msg.obj.responsibleId
- });
- $('#responsibleId').combotree('setValue',msg.obj.responsibleId);
- }
- $("#sort_update").numberbox('setValue',msg.obj.sort);
- }
- });
- }
- }
- );
- }
-
- /**删除*/
- var delFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/js/easyui/themes/itemicon/delete.png' title='删除' onclick=deleteRow(" + row.id + ") style='cursor:pointer' />";
- };
-
- /**删除功能*/
- function deleteRow(id){
- $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
- if (r){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "departmentAction_deleteDepartment",//要访问的后台地址
- data: "department.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- if(msg.success){
- $.messager.alert('提示','删除成功!');
- $('#departmentDataGrid').datagrid('reload');
- $('#allDepartmentTree').tree('reload');
- }else{
- $.messager.alert('提示',msg.message,'error');
- }
- }
- });
- }
- });
- }
-
- /**增加*/
- function departmentAdd(){
- $('#addDepartmentDialog').dialog(
- {
- buttons : [
- {
- text : '保存',
- iconCls : 'icon-add',
- handler : function(){
- $("#responsibleId_add").val($("#responsible_add").combotree("getValues"));
- $("#responsibleName_add").val($("#responsible_add").combotree("getText"));
- $('#addDepartmentForm').form('submit',
- {
- url : whzl.basePath+'/departmentAction_addDepartment',
- success : function(result){
- var parseResult = $.parseJSON(result);
- if(parseResult.success){
- $("#addDepartmentDialog").dialog("close");
- $('#departmentDataGrid').datagrid('reload');
- $('#allDepartmentTree').tree('reload');
- }else{
- $.messager.alert('提示',parseResult.message,'error');
- }
- }
- }
- );
- }
- },
- {
- text : '取消',
- iconCls : 'icon-cancel',
- handler : function(){
- $("#addDepartmentDialog").dialog("close");
- var img = $("#imagePath_add").val();
- }
- }
-
- ]
- }
- );
- }
- $(function(){
- $('#allDepartmentTree').tree({
- url:whzl.basePath+'/departmentAction_tree',
- loadFilter: function(result){
- if(result.success){
- return result.obj;
- }else{
- $.messager.alert('提示',result.message);
- }
- }
- });
- });
-
- /**移动*/
- var moveFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/images/up.png' title='上移' onclick=up(" + row.id + ") style='cursor:pointer' /> <img src='<%=basePath%>/images/down.png' title='下移' onclick=down(" + row.id + ") style='cursor:pointer' />";
- };
-
- function up(id){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "departmentAction_upSort",//要访问的后台地址
- data: "department.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- if(msg.success){
- $('#departmentDataGrid').datagrid('reload');
- }else{
- $.messager.alert('提示','操作失败!');
- }
- }
- });
- }
-
- function down(id){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "departmentAction_downSort",//要访问的后台地址
- data: "department.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- if(msg.success){
- $('#departmentDataGrid').datagrid('reload');
- }else{
- $.messager.alert('提示','操作失败!');
- }
- }
- });
- }
- </script>
- <div style="width: 70%;height: 100%;boreder:1px solid red;float: left;background-color: #E0ECFF;">
- <div class="easyui-layout" data-options="fit:true,border:false">
- <div data-options="region:'center',border:false">
- <div id="searchtool" data-options="region:'north' , border:false">
- <table id="tblQuery" style="width:100%;">
- <tr>
- <td align="right"><span>组织机构名称</span></td>
- <td><input id="name" name="department.name" type="text"/></td>
- <td align="left">
- <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
- <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-emptied',plain:true">清空</a>
- <a href="javascript:departmentAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加部门信息</a>
- </td>
- </tr>
- </table>
- </div>
-
- <table id="departmentDataGrid">
- <thead frozen="true">
- <tr>
- <th data-options="field:'id',checkbox:true,width:30">ID</th>
- <th data-options="field:'parentName',sortable:true,width:150">所属组织机构</th>
- </tr>
- </thead>
- <thead>
- <tr>
- <th data-options="field:'name',sortable:true,width:200">名称</th>
- <th data-options="field:'responsibleName',sortable:true,width:100">负责人</th>
- <th data-options="field:'sort',sortable:true,width:40">排序</th>
- <th data-options="field:'up',align:'center',width:60,formatter:moveFormatter">排序移动</th>
- <th data-options="field:'details',align:'center',formatter:detailsFormatter,width:64">查看详情</th>
- <th data-options="field:'update',align:'center',formatter:updateFormatter,width:40">修改</th>
- <th data-options="field:'delete',align:'center',formatter:delFormatter,width:40">删除</th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- </div>
- <div style="width: 30%;height: 100%;boreder:1px solid red;float: left;background-color: #E0ECFF;">
- <div class="easyui-accordion" data-options="fit:true,border:false">
- <div title="组织机构" data-options="iconCls:'icon-menu'">
- <ul id="allDepartmentTree" class="easyui-tree" data-options="lines:true" style="margin-top:5px;margin-left: 20px;">
- </ul>
- </div>
- </div>
- </div>
- <div id="detailDepartmentDialog" data-options="title:' 部门详细信息',iconCls:'icon-details',width:500,height:300,modal:true,href:'<%=basePath %>/departmentAction_toDetail'">
- </div>
- <div id="updateDepartmentDialog" data-options="title:' 修改部门信息',iconCls:'icon-edit',width:500,height:300,modal:true,href:'<%=basePath %>/departmentAction_toUpdate'">
- </div>
- <div id="addDepartmentDialog" data-options="title:' 增加部门信息',iconCls:'icon-add',width:500,height:300,modal:true,href:'<%=basePath %>/departmentAction_toAdd'">
- </div>
- <script type="text/javascript">
- parent.$.messager.progress('close');
- </script>
|