Procházet zdrojové kódy

bug:修改用户

温红权 před 8 roky
rodič
revize
faa693a0ab

+ 144 - 140
VisualInspection/js/lib/combotree/comboTreePlugin.js

@@ -1,58 +1,59 @@
 /*!
- * jQuery ComboTree Plugin 
+ * jQuery ComboTree Plugin
  * Author:  Erhan FIRAT
  * Mail:    erhanfirat@gmail.com
  * Licensed under the MIT license
  */
 
 
-;(function ( $, window, document, undefined ) {
-    
+;
+(function($, window, document, undefined) {
+
     // Create the defaults once
     var comboTreePlugin = 'comboTree',
         defaults = {
-            source: [], 
+            source: [],
             isMultiple: false
         };
 
     // The actual plugin constructor
-    function ComboTree( element, options ) {
+    function ComboTree(element, options) {
         this.elemInput = element;
         this._elemInput = $(element);
 
-        this.options = $.extend( {}, defaults, options) ;
-        
+        this.options = $.extend({}, defaults, options);
+
         this._defaults = defaults;
         this._name = comboTreePlugin;
-        
+
         this.init();
     }
 
-    ComboTree.prototype.init = function () {
+    ComboTree.prototype.init = function() {
         // Setting Doms
         this.comboTreeId = 'comboTree' + Math.floor(Math.random() * 999999);
 
-        if(this._elemInput.attr('id') === undefined)
+        if (this._elemInput.attr('id') === undefined)
             this._elemInput.attr('id', this.comboTreeId + 'Input');
         this.elemInputId = this._elemInput.attr('id');
 
-        this._elemInput.wrap('<div id="'+ this.comboTreeId + 'Wrapper" class="comboTreeWrapper"></div>');
-        this._elemInput.wrap('<div id="'+ this.comboTreeId + 'InputWrapper" class="comboTreeInputWrapper"></div>');
+        this._elemInput.wrap('<div id="' + this.comboTreeId + 'Wrapper" class="comboTreeWrapper"></div>');
+        this._elemInput.wrap('<div id="' + this.comboTreeId + 'InputWrapper" class="comboTreeInputWrapper"></div>');
         this._elemWrapper = $('#' + this.comboTreeId + 'Wrapper');
 
         this._elemArrowBtn = $('<button id="' + this.comboTreeId + 'ArrowBtn" class="comboTreeArrowBtn"><span class="comboTreeArrowBtnImg">▼</span></button>')
-                        .css({
-                            left: this._elemInput.outerWidth(),
-                            height: this._elemInput.outerHeight()
-                        });
+            .css({
+                left: this._elemInput.outerWidth(),
+                height: this._elemInput.outerHeight()
+            });
         this._elemInput.after(this._elemArrowBtn);
         this._elemWrapper.css({ width: this._elemInput.outerWidth() + this._elemArrowBtn.outerWidth() });
         this._elemWrapper.append('<div id="' + this.comboTreeId + 'DropDownContainer" class="comboTreeDropDownContainer"><div class="comboTreeDropDownContent"></div>');
-        
+
         // DORP DOWN AREA
         this._elemDropDownContainer = $('#' + this.comboTreeId + 'DropDownContainer');
         this._elemDropDownContainer.html(this.createSourceHTML());
-        
+
         this._elemItems = this._elemDropDownContainer.find('li');
         this._elemItemsTitle = this._elemDropDownContainer.find('span.comboTreeItemTitle');
 
@@ -69,30 +70,30 @@
     // SOURCES CODES
     // *********************************
 
-    ComboTree.prototype.removeSourceHTML = function () {
+    ComboTree.prototype.removeSourceHTML = function() {
         this._elemDropDownContainer.html('');
     };
 
-    ComboTree.prototype.createSourceHTML = function () {
+    ComboTree.prototype.createSourceHTML = function() {
         var htmlText = this.createSourceSubItemsHTML(this.options.source);
         return htmlText;
     };
 
-    ComboTree.prototype.createSourceSubItemsHTML = function (subItems) {
+    ComboTree.prototype.createSourceSubItemsHTML = function(subItems) {
         var subItemsHtml = '<UL>';
-        for (var i=0; i<subItems.length; i++){
+        for (var i = 0; i < subItems.length; i++) {
             subItemsHtml += this.createSourceItemHTML(subItems[i]);
         }
         subItemsHtml += '</UL>'
         return subItemsHtml;
     }
 
-    ComboTree.prototype.createSourceItemHTML = function (sourceItem) {
+    ComboTree.prototype.createSourceItemHTML = function(sourceItem) {
         var itemHtml = "",
             isThereSubs = sourceItem.hasOwnProperty("subs");
-        
-        itemHtml = '<LI class="ComboTreeItem' + (isThereSubs?'Parent':'Chlid') + '"> ';
-        
+
+        itemHtml = '<LI class="ComboTreeItem' + (isThereSubs ? 'Parent' : 'Chlid') + '"> ';
+
         if (isThereSubs)
             itemHtml += '<span class="comboTreeParentPlus">&minus;</span>';
 
@@ -111,32 +112,39 @@
 
     // BINDINGS
     // *****************************
-    ComboTree.prototype.bindings = function () {
+    ComboTree.prototype.bindings = function() {
         var _this = this;
 
-        this._elemArrowBtn.on('click', function(e){
+        if (_this.options.enable != null && _this.options.enable != undefined && _this.options.enable == false) {
+            _this._elemInput.attr("disabled", true);
+            return;
+        } else {
+            _this._elemInput.attr("disabled", false);
+        }
+
+        this._elemArrowBtn.on('click', function(e) {
             e.stopPropagation();
             _this.toggleDropDown();
         });
-        this._elemInput.on('click', function(e){
+        this._elemInput.on('click', function(e) {
             e.stopPropagation();
             if (!_this._elemDropDownContainer.is(':visible'))
                 _this.toggleDropDown();
         });
-        this._elemItems.on('click', function(e){
+        this._elemItems.on('click', function(e) {
             e.stopPropagation();
-            if ($(this).hasClass('ComboTreeItemParent')){
+            if ($(this).hasClass('ComboTreeItemParent')) {
                 _this.toggleSelectionTree(this);
             }
-        });        
-        this._elemItemsTitle.on('click', function(e){
+        });
+        this._elemItemsTitle.on('click', function(e) {
             e.stopPropagation();
             if (_this.options.isMultiple)
                 _this.multiItemClick(this);
             else
                 _this.singleItemClick(this);
         });
-        this._elemItemsTitle.on("mousemove", function (e) {
+        this._elemItemsTitle.on("mousemove", function(e) {
             e.stopPropagation();
             _this.dropDownMenuHover(this);
         });
@@ -147,14 +155,18 @@
 
             switch (e.keyCode) {
                 case 27:
-                    _this.closeDropDownMenu(); break;
-                case 13:                  
-                case 39: case 37: case 40: case 38:
-                    e.preventDefault(); 
+                    _this.closeDropDownMenu();
                     break;
-                default: 
+                case 13:
+                case 39:
+                case 37:
+                case 40:
+                case 38:
+                    e.preventDefault();
+                    break;
+                default:
                     if (!_this.options.isMultiple)
-                        _this.filterDropDownMenu(); 
+                        _this.filterDropDownMenu();
                     break;
             }
         });
@@ -162,29 +174,33 @@
             e.stopPropagation();
 
             switch (e.keyCode) {
-            case 9:
-                _this.closeDropDownMenu(); break;
-            case 40: case 38:
-                e.preventDefault(); 
-                _this.dropDownInputKeyControl(e.keyCode - 39); break;
-            case 37: case 39:
-                e.preventDefault(); 
-                _this.dropDownInputKeyToggleTreeControl(e.keyCode - 38);
-                break;
-            case 13:
-                if (_this.options.isMultiple)
-                    _this.multiItemClick(_this._elemHoveredItem);
-                else
-                    _this.singleItemClick(_this._elemHoveredItem);
-                e.preventDefault(); 
-                break;
-            default: 
-                if (_this.options.isMultiple)
+                case 9:
+                    _this.closeDropDownMenu();
+                    break;
+                case 40:
+                case 38:
                     e.preventDefault();
-        }
+                    _this.dropDownInputKeyControl(e.keyCode - 39);
+                    break;
+                case 37:
+                case 39:
+                    e.preventDefault();
+                    _this.dropDownInputKeyToggleTreeControl(e.keyCode - 38);
+                    break;
+                case 13:
+                    if (_this.options.isMultiple)
+                        _this.multiItemClick(_this._elemHoveredItem);
+                    else
+                        _this.singleItemClick(_this._elemHoveredItem);
+                    e.preventDefault();
+                    break;
+                default:
+                    if (_this.options.isMultiple)
+                        e.preventDefault();
+            }
         });
         // ON FOCUS OUT CLOSE DROPDOWN
-        $(document).on('mouseup.' + _this.comboTreeId, function (e){
+        $(document).on('mouseup.' + _this.comboTreeId, function(e) {
             if (!_this._elemWrapper.is(e.target) && _this._elemWrapper.has(e.target).length === 0 && _this._elemDropDownContainer.is(':visible'))
                 _this.closeDropDownMenu();
         });
@@ -193,48 +209,45 @@
 
 
 
-    // EVENTS HERE 
+    // EVENTS HERE
     // ****************************
 
     // DropDown Menu Open/Close
-    ComboTree.prototype.toggleDropDown = function () {
+    ComboTree.prototype.toggleDropDown = function() {
         this._elemDropDownContainer.slideToggle(50);
         this._elemInput.focus();
     };
-    ComboTree.prototype.closeDropDownMenu = function () {
+    ComboTree.prototype.closeDropDownMenu = function() {
         this._elemDropDownContainer.slideUp(50);
     };
     // Selection Tree Open/Close
-    ComboTree.prototype.toggleSelectionTree = function (item, direction) {
+    ComboTree.prototype.toggleSelectionTree = function(item, direction) {
         var subMenu = $(item).children('ul')[0];
-        if (direction === undefined){
+        if (direction === undefined) {
             if ($(subMenu).is(':visible'))
                 $(item).children('span.comboTreeParentPlus').html("+");
             else
                 $(item).children('span.comboTreeParentPlus').html("&minus;");
 
             $(subMenu).slideToggle(50);
-        }
-        else if (direction == 1 && !$(subMenu).is(':visible')){
-                $(item).children('span.comboTreeParentPlus').html("&minus;");
-                $(subMenu).slideDown(50);
-        }
-        else if (direction == -1){
-            if ($(subMenu).is(':visible')){
+        } else if (direction == 1 && !$(subMenu).is(':visible')) {
+            $(item).children('span.comboTreeParentPlus').html("&minus;");
+            $(subMenu).slideDown(50);
+        } else if (direction == -1) {
+            if ($(subMenu).is(':visible')) {
                 $(item).children('span.comboTreeParentPlus').html("+");
                 $(subMenu).slideUp(50);
-            }
-            else {
+            } else {
                 this.dropDownMenuHoverToParentItem(item);
             }
         }
-            
+
     };
 
 
     // SELECTION FUNCTIONS
     // *****************************
-    ComboTree.prototype.singleItemClick = function (ctItem) {
+    ComboTree.prototype.singleItemClick = function(ctItem) {
         this._selectedItem = {
             id: $(ctItem).attr("data-id"),
             title: $(ctItem).text()
@@ -243,18 +256,17 @@
         this.refreshInputVal();
         this.closeDropDownMenu();
     };
-    ComboTree.prototype.multiItemClick = function (ctItem) {
+    ComboTree.prototype.multiItemClick = function(ctItem) {
         this._selectedItem = {
             id: $(ctItem).attr("data-id"),
             title: $(ctItem).text()
         };
 
         var index = this.isItemInArray(this._selectedItem, this._selectedItems);
-        if (index){
+        if (index) {
             this._selectedItems.splice(parseInt(index), 1);
             $(ctItem).find("input").prop('checked', false);
-        }
-        else {
+        } else {
             this._selectedItems.push(this._selectedItem);
             $(ctItem).find("input").prop('checked', true);
         }
@@ -262,33 +274,32 @@
         this.refreshInputVal();
     };
 
-    ComboTree.prototype.isItemInArray = function (item, arr) {
+    ComboTree.prototype.isItemInArray = function(item, arr) {
 
-        for (var i=0; i<arr.length; i++)
+        for (var i = 0; i < arr.length; i++)
             if (item.id == arr[i].id && item.title == arr[i].title)
                 return i + "";
 
         return false;
     }
 
-    ComboTree.prototype.refreshInputVal = function () {
+    ComboTree.prototype.refreshInputVal = function() {
         var tmpTitle = "";
-        
+
         if (this.options.isMultiple) {
-            for (var i=0; i<this._selectedItems.length; i++){
+            for (var i = 0; i < this._selectedItems.length; i++) {
                 tmpTitle += this._selectedItems[i].title;
-                if (i<this._selectedItems.length-1)
+                if (i < this._selectedItems.length - 1)
                     tmpTitle += ", ";
             }
-        }
-        else {
+        } else {
             tmpTitle = this._selectedItem.title;
         }
 
         this._elemInput.val(tmpTitle);
     }
 
-    ComboTree.prototype.dropDownMenuHover = function (itemSpan, withScroll) {
+    ComboTree.prototype.dropDownMenuHover = function(itemSpan, withScroll) {
         this._elemItems.find('span.comboTreeItemHover').removeClass('comboTreeItemHover');
         $(itemSpan).addClass('comboTreeItemHover');
         this._elemHoveredItem = $(itemSpan);
@@ -296,20 +307,20 @@
             this.dropDownScrollToHoveredItem(this._elemHoveredItem);
     }
 
-    ComboTree.prototype.dropDownScrollToHoveredItem = function (itemSpan) {
+    ComboTree.prototype.dropDownScrollToHoveredItem = function(itemSpan) {
         var curScroll = this._elemDropDownContainer.scrollTop();
         this._elemDropDownContainer.scrollTop(curScroll + $(itemSpan).parent().position().top - 80);
     }
 
-    ComboTree.prototype.dropDownMenuHoverToParentItem = function (item) {
+    ComboTree.prototype.dropDownMenuHoverToParentItem = function(item) {
         var parentSpanItem = $($(item).parents('li.ComboTreeItemParent')[0]).children("span.comboTreeItemTitle");
         if (parentSpanItem.length)
             this.dropDownMenuHover(parentSpanItem, true);
-        else 
+        else
             this.dropDownMenuHover(this._elemItemsTitle[0], true);
     }
 
-    ComboTree.prototype.dropDownInputKeyToggleTreeControl = function (direction) {
+    ComboTree.prototype.dropDownInputKeyToggleTreeControl = function(direction) {
         var item = this._elemHoveredItem;
         if ($(item).parent('li').hasClass('ComboTreeItemParent'))
             this.toggleSelectionTree($(item).parent('li'), direction);
@@ -317,68 +328,65 @@
             this.dropDownMenuHoverToParentItem(item);
     }
 
-    ComboTree.prototype.dropDownInputKeyControl = function (step) {
-        if (!this._elemDropDownContainer.is(":visible")) 
-            this.toggleDropDown();
-
-        var list = this._elemItems.find("span.comboTreeItemTitle:visible");
-        i = this._elemHoveredItem?list.index(this._elemHoveredItem) + step:0;
-        i = (list.length + i) % list.length;
-
-        this.dropDownMenuHover(list[i], true);        
-    },
-
-    ComboTree.prototype.filterDropDownMenu = function () {
-        var searchText = this._elemInput.val();
-        if (searchText != ""){
-            this._elemItemsTitle.hide();
-            this._elemItemsTitle.siblings("span.comboTreeParentPlus").hide();
-            list = this._elemItems.find("span:icontains('" + this._elemInput.val() + "')").each(function (i, elem) {
-                $(this).show();
-                $(this).siblings("span.comboTreeParentPlus").show();
-            });    
-        }
-        else{
-            this._elemItemsTitle.show();
-            this._elemItemsTitle.siblings("span.comboTreeParentPlus").show();
+    ComboTree.prototype.dropDownInputKeyControl = function(step) {
+            if (!this._elemDropDownContainer.is(":visible"))
+                this.toggleDropDown();
+
+            var list = this._elemItems.find("span.comboTreeItemTitle:visible");
+            i = this._elemHoveredItem ? list.index(this._elemHoveredItem) + step : 0;
+            i = (list.length + i) % list.length;
+
+            this.dropDownMenuHover(list[i], true);
+        },
+
+        ComboTree.prototype.filterDropDownMenu = function() {
+            var searchText = this._elemInput.val();
+            if (searchText != "") {
+                this._elemItemsTitle.hide();
+                this._elemItemsTitle.siblings("span.comboTreeParentPlus").hide();
+                list = this._elemItems.find("span:icontains('" + this._elemInput.val() + "')").each(function(i, elem) {
+                    $(this).show();
+                    $(this).siblings("span.comboTreeParentPlus").show();
+                });
+            } else {
+                this._elemItemsTitle.show();
+                this._elemItemsTitle.siblings("span.comboTreeParentPlus").show();
+            }
         }
-    }
 
     // Retuns Array (multiple), Integer (single), or False (No choice)
-    ComboTree.prototype.getSelectedItemsId = function () {
-        if (this.options.isMultiple && this._selectedItems.length>0){
+    ComboTree.prototype.getSelectedItemsId = function() {
+        if (this.options.isMultiple && this._selectedItems.length > 0) {
             var tmpArr = [];
-            for (i=0; i<this._selectedItems.length; i++)
+            for (i = 0; i < this._selectedItems.length; i++)
                 tmpArr.push(this._selectedItems[i].id);
 
             return tmpArr;
-        }
-        else if (!this.options.isMultiple && this._selectedItem.hasOwnProperty('id')){
+        } else if (!this.options.isMultiple && this._selectedItem.hasOwnProperty('id')) {
             return this._selectedItem.id;
         }
         return false;
     }
 
     // Retuns Array (multiple), Integer (single), or False (No choice)
-    ComboTree.prototype.getSelectedItemsTitle = function () {
-        if (this.options.isMultiple && this._selectedItems.length>0){
+    ComboTree.prototype.getSelectedItemsTitle = function() {
+        if (this.options.isMultiple && this._selectedItems.length > 0) {
             var tmpArr = [];
-            for (i=0; i<this._selectedItems.length; i++)
+            for (i = 0; i < this._selectedItems.length; i++)
                 tmpArr.push(this._selectedItems[i].title);
 
             return tmpArr;
-        }
-        else if (!this.options.isMultiple && this._selectedItem.hasOwnProperty('id')){
+        } else if (!this.options.isMultiple && this._selectedItem.hasOwnProperty('id')) {
             return this._selectedItem.title;
         }
         return false;
     }
 
 
-    ComboTree.prototype.unbind = function () {
+    ComboTree.prototype.unbind = function() {
         this._elemArrowBtn.off('click');
         this._elemInput.off('click');
-        this._elemItems.off('click');        
+        this._elemItems.off('click');
         this._elemItemsTitle.off('click');
         this._elemItemsTitle.off("mousemove");
         this._elemInput.off('keyup');
@@ -387,7 +395,7 @@
         $(document).off('mouseup.' + this.comboTreeId);
     }
 
-    ComboTree.prototype.destroy = function () {
+    ComboTree.prototype.destroy = function() {
         this.unbind();
         this._elemWrapper.before(this._elemInput);
         this._elemWrapper.remove();
@@ -395,12 +403,12 @@
     }
 
 
-    $.fn[comboTreePlugin] = function ( options) {
+    $.fn[comboTreePlugin] = function(options) {
         var ctArr = [];
-        this.each(function () {
+        this.each(function() {
             if (!$.data(this, 'plugin_' + comboTreePlugin)) {
-               $.data(this, 'plugin_' + comboTreePlugin, new ComboTree( this, options));
-               ctArr.push($(this).data()['plugin_' + comboTreePlugin]);
+                $.data(this, 'plugin_' + comboTreePlugin, new ComboTree(this, options));
+                ctArr.push($(this).data()['plugin_' + comboTreePlugin]);
             }
         });
 
@@ -410,8 +418,4 @@
             return ctArr;
     }
 
-})( jQuery, window, document );
-
-
-
-
+})(jQuery, window, document);

+ 6 - 6
VisualInspection/js/main.js

@@ -66,12 +66,6 @@ $(document).ready(function() {
         });
     });
 
-    $("#update_user").on("click", function() {
-        edittype = "update"
-        user = $.zui.store.get("user")
-        loadUserData(user)
-        $('#updateUserModal').modal('show')
-    })
 
 
 
@@ -130,6 +124,12 @@ $(document).ready(function() {
 
 });
 
+function update_user_info_data() {
+    edittype = "update"
+    user = $.zui.store.get("user")
+    loadUserData(user)
+    $('#addUserModal').modal('show')
+}
 
 var roles = [];
 var zdata = [];

+ 21 - 1
VisualInspection/js/user/addUser.js

@@ -7,6 +7,14 @@ function loadUserData(nodedata) {
     var pnode = nodedata;
     resetform()
 
+    var enable = true;
+
+    if (edittype == "update") {
+        enable = false;
+    } else {
+        enable = true;
+    }
+
     if (edittype == "add") {
         $("#dept_name").val("")
     }
@@ -18,6 +26,14 @@ function loadUserData(nodedata) {
     }
     role_selectinput.closeDropDownMenu();
 
+    if (!enable) {
+        role_selectinput.unbind();
+        $("#user_role_select").attr("disabled", true)
+    } else {
+        $("#user_role_select").attr("disabled", false)
+        role_selectinput.bindings()
+    }
+
     $(".ComboTreeItemChlid").find("input").prop('checked', false);
 
     if (edittype == "edit" || edittype == "update") {
@@ -35,6 +51,7 @@ function loadUserData(nodedata) {
         element: '#user_dept_select',
         data: zdata,
         valueKey: "id",
+        enable: enable,
         placeholder: "选择部门",
         selectvalue: pnode.length > 0 ? pnode[0].id : null
     });
@@ -70,6 +87,9 @@ function resetform() {
 
 
 
+
+
+
 }
 
 function initUserInfo() {
@@ -219,7 +239,7 @@ function addUser() {
                     $('#addUserModal').modal('hide')
                 }
                 if (edittype == "update") {
-                    $('#updateUserModal').modal('hide')
+                    $('#addUserModal').modal('hide')
                     GetUserInfo(function(data) {
                         var html = "<i class=\"icon icon-user\"></i>  " + data.truename + " " + data.organname + ",欢迎您"
                         $("#user").html(html);

+ 3 - 13
VisualInspection/view/common/head.html

@@ -14,17 +14,7 @@
         <ul class="nav navbar-nav navbar-right">
             <li>
 
-                <div class="btn-group dropdown ">
-
-                    <p id="user" class="header_font" data-toggle="dropdown" style="padding-right:20px;cursor:pointer;"></p>
-
-                    <ul class="dropdown-menu" role="menu">
-                        <li><a href="javascript:void(0)" id="update_user">修改个人信息</a></li>
-                        <!-- <li><a href="###">另一个操作</a></li>
-                        <li class="divider"></li>
-                        <li><a href="###">更多操作</a></li> -->
-                    </ul>
-                </div>
+                <p id="user" onclick="update_user_info_data()" class="header_font" style="padding-right:20px;cursor:pointer;"></p>
 
                 <!-- <p id="user" class="header_font" style="padding-right:20px;cursor:pointer;"></p> -->
             </li>
@@ -39,12 +29,12 @@
     </div>
 </div>
 
-<div class="modal fade" id="updateUserModal">
+<div class="modal fade" id="addUserModal">
     <div class="modal-dialog modal-lg">
         <div class="modal-content">
             <div class="modal-header">
                 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
-                <h4 class="modal-title">添加用户</h4>
+                <h4 class="modal-title">修改用户信息</h4>
             </div>
             <div class="modal-body">
                 <link rel="import" href="/view/user/addUser.html?__inline">

+ 4 - 4
VisualInspection/view/user/userManager.html

@@ -64,7 +64,7 @@
     </div>
 </div>
 
-<div class="modal fade" id="addUserModal">
+<!-- <div class="modal fade" id="addUserModal">
     <div class="modal-dialog">
         <div class="modal-content">
             <div class="modal-header">
@@ -79,15 +79,15 @@
             </div>
         </div>
     </div>
-</div>
+</div> -->
 <div id="transfer_div" style="display:none;text-align:center;padding:5px;">
     <form class="form-horizontal" style="margin-top:10px;">
         <div class="form-group">
             <label for="exampleInputAccount1" class="col-sm-5">选择转移目标收费站</label>
             <div class="col-sm-7">
-                <select class="form-control" id="tansferFsList">                   
+                <select class="form-control" id="tansferFsList">
                 </select>
             </div>
-        </div>     
+        </div>
     </form>
 </div>