123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- /**
- * 组织管理
- *
- */
- $.namespace("org.main");
- org.main.treeData=null;
- org.main.typeData=null;
- org.main.init=function(){
- org.main.inittree();
- org.main.inittable();
- org.main.inittype(null);
- }
- org.main.inittype=function(existdata){
- var str = "";
- str+="<select class='selectpicker' name='orgType' >";
- str+="<option></option>";
- if(org.main.typeData){
- var jsonselectdata=$.parseJSON(org.main.typeData);
- for(var i=0;i<jsonselectdata.length;i++){
- var has=false;
- var select = jsonselectdata[i];
- if(existdata){
- if(select.codeValue==existdata){
- has=true;
- }
- }
- if(has){
- str+=" <option value='"+select.codeValue+"' selected='selected'>"+select.codeName+"</option>";
- }else{
- str+=" <option value='"+select.codeValue+"' >"+select.codeName+"</option>";
- }
- }
- }
- str+="</select>";
- $("#typedata").empty();
- $("#typedata").append(str);
-
- $('.selectpicker').selectpicker({
- width:300
- });
- }
- org.main.inittree=function(){
- $('#treeview').treeview({
- color: "#428bca",
- showBorder: false,
- nodeIcon: 'glyphicon glyphicon-user',
- levels: 2,
- data: org.main.treeData,
- onNodeSelected:function(event, node) {
- $("#editpid").val(node.id);
- $("#editorgLevel").val(parseInt(node.level)+1);
- org.main.inittable();
- }
- });
- }
- org.main.inittable=function(){
- $.post($.app + "/org/getOrgData", {
- pid : $("#editpid").val()
- }, function(data) {
- if(data){
- var str="";
- for(var i=0;i<data.length;i++){
- var org = data[i];
- str+=" <tr >";
- str+="<td >"+org.orgName+"</td>";
- str+="<td >"+org.orgCode+"</td>";
- str+="<td >"+org.orgLevel+"</td>";
- str+="<td >"+org.sortno+"</td>";
- str+="<td ><a class='btn btn-default btn-xs' href='#' data-toggle='modal' data-target='#myModal' onclick=\"org.main.edit('"+org.id+"')\">"+
- "<i class='glyphicon glyphicon-wrench'></i>修改</a> "+
- "<a class='btn btn-default btn-xs' href='#' onclick=\"org.main.del('"+org.id+"')\">"+
- "<i class='glyphicon glyphicon-wrench'></i>删除</a> "+
- "</td>";
- str+=" </tr >";
- }
- $("#orgdata").empty();
- $("#orgdata").append(str);
- }
- }, "json");
- }
- org.main.del=function(data){
- $.confirm({
- title: '确认框',
- content: '删除会导致下级组织一同被删除,确认删除吗',
- confirm: function(){
- $.post($.app + "/org/delete", {
- id : data
- }, function(data) {
- if (data.success) {
- $.alert({
- title: '提示',
- content: '删除成功',
- confirm: function(){
- location.href=$.app+"/org/main";
- }
- });
- } else {
- $.alert({
- title: '提示',
- content: data.message,
- confirm: function(){
-
- }
- });
- }
- }, "json");
- },
- cancel: function(){
-
- }
- });
- }
- org.main.edit=function(data){
- $.post($.app + "/org/edit", {
- id : data
- }, function(data) {
- if(data){
- for(var a in data){
- if($("#edit"+a)){
- $("#edit"+a).val(data[a]);
- }
- }
- }
- org.main.inittype(data["orgType"]);
- }, "json");
- }
- org.main.save=function(){
- $.ajax({
- url:$.app+"/org/save",
- data:$("#addform").serialize(),
- type:"post",
- dataType:"json",
- success:function(data){//ajax返回的数据
- if (data.success) {
- $.alert({
- title: '提示',
- content: '保存成功',
- confirm: function(){
- location.href=$.app+"/org/main";
- }
- });
- }else {
- $.alert({
- title: '提示',
- content: data.message,
- confirm: function(){
-
- }
- });
- }
- }
- });
- }
- org.main.clear=function(){
- $("#editid").val("");
- $("#editorgName").val("");
- $("#editorgCode").val("");
- $("#editsortno").val("");
- org.main.inittype(null);
- }
|