瀏覽代碼

bug:修改用户信息

温红权 8 年之前
父節點
當前提交
fa46e8c57c

二進制
.DS_Store


+ 107 - 84
VisualInspection/js/term_management/charge_terms_m.js

@@ -1,168 +1,191 @@
-    var user = $.zui.store.get("user") ;  // 缓存用户信息,取出dept_id
-    var dept_id=user.organid;
+    var user = $.zui.store.get("user"); // 缓存用户信息,取出dept_id
+    var dept_id = user.organid;
     var team_id;
     var idUpdate;
     var type = 1;
     var organid = user.organid;
-    function queryTable(){
+
+    function queryTable() {
         var data = {
-            "dept_id":dept_id
+            "dept_id": dept_id
         }
         data.type = type;
         var name = $("#select_name").val();
-        if(name!=''){
-            data.name = name ;
+        if (name != '') {
+            data.name = name;
         }
         var cols = [
-                        {width: 30, text: '序号', flex: false, colClass: 'text-center',field:'num'},
-                        {width: 50, text: '班组名称', flex: false,colClass: '',field:'name'},
-                        {width: 50, text: '所属人员分类',  flex: false, colClass: '',field:'type',func:function(obj){
-                            if(obj==1){
-                                return "收费人员";
-                            }else if(obj == 2){
-                                return "稽查人员";
-                            }
-                        }},
-                        {width: 50, text: '班长', type: 'string', flex: false, sort: 'down',field:'monitor_name'},
-                        {width: 50, text: '副班长', type: 'string', flex: false, colClass: '',field:'sub_monitor_name'},
-                        {width: 200, text: '人员',  flex: false, colClass: '',field:'user_ids_name'},
-                        {width: 80, text: '操作',  flex: false, colClass: '',field:'id',oper:[
-                            {func:'updateCheckTeam',text:'修改',icon_class:'icon-edit'},{func:'deleteCheckTeam',text:'删除',icon_class:'icon-remove-circle'}
-                        ]},
-                    ] ;
-        
-        $('.datatable').mytable({'cols':cols,
-                                'url':"team/getTeamByName",
-                                'param':data}
-                                );
+            { width: 30, text: '序号', flex: false, colClass: 'text-center', field: 'num' },
+            { width: 50, text: '班组名称', flex: false, colClass: '', field: 'name' },
+            {
+                width: 50,
+                text: '所属人员分类',
+                flex: false,
+                colClass: '',
+                field: 'type',
+                func: function(obj) {
+                    if (obj == 1) {
+                        return "收费人员";
+                    } else if (obj == 2) {
+                        return "稽查人员";
+                    }
+                }
+            },
+            { width: 50, text: '班长', type: 'string', flex: false, sort: 'down', field: 'monitor_name' },
+            { width: 50, text: '副班长', type: 'string', flex: false, colClass: '', field: 'sub_monitor_name' },
+            { width: 200, text: '人员', flex: false, colClass: '', field: 'user_ids_name' },
+            {
+                width: 80,
+                text: '操作',
+                flex: false,
+                colClass: '',
+                field: 'id',
+                oper: [
+                    { func: 'updateCheckTeam', text: '修改', icon_class: 'icon-edit' }, { func: 'deleteCheckTeam', text: '删除', icon_class: 'icon-remove-circle' }
+                ]
+            },
+        ];
+
+        $('.datatable').mytable({
+            'cols': cols,
+            'url': "team/getTeamByName",
+            'param': data
+        });
     }
-    function deleteCheckTeam(id){
-        deleteItem4Common(id,"team/delete",queryTable);
+
+    function deleteCheckTeam(id) {
+        deleteItem4Common(id, "team/delete", queryTable);
     }
-     $(document).ready(function() {
-         queryTable();
-         getUser();
+    $(document).ready(function() {
+        queryTable();
+        getUser();
     })
-    function getUser(){
-        data ={
-            "organid":organid
+
+    function getUser() {
+        data = {
+            "organid": organid
         }
-        post_common_service("user/getUserList", data, function(data){
+        post_common_service("user/getUserList", data, function(data) {
             $("#team_name").val("");
             $("#monitor").empty();
             $("#second-monitor").empty();
             $("#member").empty();
             $("#monitor").append('<option value="0">请选择班长</option>');
             $("#second-monitor").append('<option value="0">请选择副班长</option>');
-            for(i=0;i<data.length;i++){
-                $("#monitor").append('<option value="'+data[i].id+'">'+data[i].truename+'</option>');
-                $("#second-monitor").append('<option value="'+data[i].id+'">'+data[i].truename+'</option>');
+            for (i = 0; i < data.length; i++) {
+                $("#monitor").append('<option value="' + data[i].id + '">' + data[i].truename + '</option>');
+                $("#second-monitor").append('<option value="' + data[i].id + '">' + data[i].truename + '</option>');
                 $("#member").append('<div style="width:78px;float:left;">\
-                                         <input type="checkbox" value="'+data[i].id+'" class="chkItem"><span>'+data[i].truename+'</span>\
+                                         <input type="checkbox" value="' + data[i].id + '" class="chkItem"><span>' + data[i].truename + '</span>\
                                      </div>');
             }
-        }, function(){
+        }, function() {
 
         });
     }
-    function updateCheckTeam(id){
+
+    function updateCheckTeam(id) {
         team_id = id;
         data = {
-            "id":id
+            "id": id
         }
-        post_common_service("team/getTeamById", data, function(data){
+        post_common_service("team/getTeamById", data, function(data) {
             $("#team_name").val(data.name);
             $("#monitor").val(data.monitor);
             $("#second-monitor").val(data.sub_monitor);
-             var ids = data.user_ids.split(",");
-              $(".chkItem").prop("checked",false);
-             for(i=0;i<ids.length;i++){
+            var ids = data.user_ids.split(",");
+            $(".chkItem").prop("checked", false);
+            for (i = 0; i < ids.length; i++) {
                 // console.log(ids[i])
-                $(".chkItem").each(function(){ 
-                    if($(this).attr('value') == ids[i]){
+                $(".chkItem").each(function() {
+                    if ($(this).attr('value') == ids[i]) {
                         $(this).prop("checked", true);
                     }
                 });
             }
             idUpdate = true;
-            layerUpdateTeam('form-div','班组修改','550px');
-        }, function(){
+            layerUpdateTeam('form-div', '班组修改', '550px');
+        }, function() {
 
         });
-        
+
     }
-    function layerUpdateTeam(domId,title,area){
+
+    function layerUpdateTeam(domId, title, area) {
         //  $(".chkItem").attr("checked", false);
         layer.open({
             type: 1,
             title: false,
             closeBtn: 1,
-            title:title,
+            title: title,
             shadeClose: true,
             skin: 'yourclass',
-            area:area,
-            content: $("#"+domId)
+            area: area,
+            content: $("#" + domId)
         });
     }
     //关闭弹窗
-    $("#close-layer").click(function(){
-        layer.closeAll();
-    })
-    //保存修改或添加
-    $("#save-team").click(function(){
+    $("#close-layer").click(function() {
+            layer.closeAll();
+        })
+        //保存修改或添加
+    $("#save-team").click(function() {
         var user_ids = "";
-         $.each($('input:checkbox'),function(){
-                if(this.checked){
-                    user_ids = user_ids + $(this).val() + ",";
+        $.each($('input:checkbox'), function() {
+            if (this.checked) {
+                if (numberreg.test($(this).val())) {
+                    user_ids = user_ids +  $(this).val() + ",";
                 }
+
+            }
         });
-        if(user_ids != ""){
-            user_ids = user_ids.substring(0,user_ids.length-1);
-        }else{
+        if (user_ids != "") {
+            user_ids = user_ids.substring(0, user_ids.length - 1);
+        } else {
             layer.msg('请选择人员');
             return;
         }
         data = {
-            "id":team_id,
-            "dept_id":dept_id,
-            "name":$("#team_name").val(),
-            "user_ids":user_ids,
-            "type":type,
-            "monitor":$("#monitor").val(),
-            "sub_monitor":$("#second-monitor").val()
+            "id": team_id,
+            "dept_id": dept_id,
+            "name": $("#team_name").val(),
+            "user_ids": user_ids,
+            "type": type,
+            "monitor": $("#monitor").val(),
+            "sub_monitor": $("#second-monitor").val()
         }
-        if(idUpdate){
+        if (idUpdate) {
             //修改
-            post_common_service("team/update", data, function(data){
+            post_common_service("team/update", data, function(data) {
                 layer.closeAll();
                 queryTable();
-            }, function(){
+            }, function() {
 
             });
-        }else{
+        } else {
             //添加
-            post_common_service("team/add", data, function(data){
+            post_common_service("team/add", data, function(data) {
                 layer.closeAll();
                 queryTable();
-            }, function(){
+            }, function() {
 
             });
         }
-        
+
     })
 
     //条件查询
-    $("#conditional_query").click(function(){
+    $("#conditional_query").click(function() {
         queryTable();
     })
 
 
     //添加班组
-    $("#addTeam").click(function(){
+    $("#addTeam").click(function() {
         idUpdate = false;
         $("#team_name").val("");
         $("#monitor").val(0);
         $("#second-monitor").val(0);
         $(".chkItem").attr("checked", false);
-        layerUpdateTeam('form-div','班组新增','550px');
+        layerUpdateTeam('form-div', '班组新增', '550px');
     })

+ 7 - 2
VisualInspection/js/user/addUser.js

@@ -10,6 +10,7 @@ function loadUserData(nodedata) {
     var enable = true;
 
     if (edittype == "update") {
+        $("#user_title").html("修改用户信息")
         enable = false;
     } else {
         enable = true;
@@ -17,7 +18,13 @@ function loadUserData(nodedata) {
 
     if (edittype == "add") {
         $("#dept_name").val("")
+        $("#user_title").html("添加用户")
     }
+
+    if (edittype == "edit") {
+        $("#user_title").html("修改用户")
+    }
+
     if (role_selectinput == null) {
         role_selectinput = $('#user_role_select').comboTree({
             source: roles,
@@ -40,8 +47,6 @@ function loadUserData(nodedata) {
         usertemp = nodedata;
         pnode = [{ "id": usertemp.organid }]
         initUserInfo()
-
-
     }
 
 

+ 3 - 0
VisualInspection/js/util/util.js

@@ -1,3 +1,6 @@
+var numberreg = new RegExp(
+    "^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$");
+
 function doajax(method, dataurl, data, sucessCallBack, errorCallBack) {
     var user_key = undefined;
     var user = $.zui.store.get("user")

+ 1 - 1
VisualInspection/view/common/head.html

@@ -34,7 +34,7 @@
         <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" id="user_title">修改用户信息</h4>
             </div>
             <div class="modal-body">
                 <link rel="import" href="/view/user/addUser.html?__inline">