Browse Source

compmanage

zhuxc 7 years ago
parent
commit
5bf7357c50

+ 30 - 11
scss/linker.scss

@@ -651,10 +651,10 @@ textarea {
 .init-load {
     margin-top: 70%;
     position: absolute;
-    left:0;
-    right:0;
-    top:0;
-    bottom:0;
+    left: 0;
+    right: 0;
+    top: 0;
+    bottom: 0;
 }
 
 .text-margin {
@@ -1302,7 +1302,7 @@ ion-header-bar {
     padding-right: 0;
     &:last-child {
         padding-bottom: 0;
-        .workflow-item:first-child{
+        .workflow-item:first-child {
             border-bottom: 1px solid #ddd;
         }
     }
@@ -1485,12 +1485,12 @@ ion-header-bar {
     width: 100%;
 }
 
-.popup-header-height{
-    height:50px;
-    padding:0!important;
+.popup-header-height {
+    height: 50px;
+    padding: 0 !important;
     vertical-align: middle;
-    h5{
-        font-size: 15px!important;
+    h5 {
+        font-size: 15px !important;
     }
 
 }
@@ -2177,7 +2177,7 @@ ion-header-bar {
 .circle {
     width: 32px;
     height: 32px;
-    display:inline-block;
+    display: inline-block;
     background: #0092e6;
     -moz-border-radius: 16px;
     -webkit-border-radius: 16px;
@@ -2188,3 +2188,22 @@ ion-header-bar {
     padding: 2px;
     border-color: #fff;
 }
+
+.ion-ask {
+    font-size: 3em;
+    margin-bottom: 15px;
+    //margin: 30% 50%;
+}
+
+.marginTop30 {
+    margin: 30% 0 !important;;
+}
+
+.marginTop10 {
+    margin-top: 10px;
+}
+
+
+
+
+

+ 51 - 0
www/apps/accountMng/index.html

@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
+    <!--     <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> -->
+    <title></title>
+
+    <!-- compiled css output -->
+    <link href="/css/ionic.app.min.css" rel="stylesheet">
+    <link href="/css/linker.min.css" rel="stylesheet">
+
+
+
+    <script src="/lib/ionic/js/ionic.bundle.min.js"></script>
+    <!-- cordova script (this will be a 404 during development) -->
+    <script src="/lib/ngCordova/dist/ng-cordova.min.js"></script>
+    <!-- cordova script (this will be a 404 during development) -->
+    <script src="/cordova.js"></script>
+    <!-- your app's js -->
+    <script src="/lib/underscore/underscore-min.js"></script>
+    <script src="/lib/angular-resource/angular-resource.min.js"></script>
+    <script src="/lib/angular-underscore-module/angular-underscore-module.js"></script>
+    <script src="/lib/angular-translate/angular-translate.min.js"></script>
+    <script src="/lib/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js"></script>
+    <script src="/js/starter.js"></script>
+    <script src="js/route.js"></script>
+    <script src="js/controllers.js"></script>
+    <script src="js/directive.js"></script>
+    <script src="js/factory.js"></script>
+</head>
+
+<body ng-app="starter" ng-cloak>
+<!--
+  The nav bar that will be updated as we navigate between views.
+-->
+<ion-nav-bar class="bar-stable" ng-cloak>
+    <ion-nav-back-button class="button ion-chevron-left button-clear button-dark">
+        {{'backTitle' | translate}}
+    </ion-nav-back-button>
+</ion-nav-bar>
+<!--
+  The views will be rendered in the <ion-nav-view> directive below
+  Templates are in the /templates folder (but you could also
+  have templates inline in this html file if you'd like).
+-->
+<ion-nav-view></ion-nav-view>
+</body>
+</html>
+

+ 881 - 0
www/apps/accountMng/js/controllers.js

@@ -0,0 +1,881 @@
+starter.controller('AccountManageCtrl', function ($scope, global, showPopup, CompManage) {
+    var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
+        $scope.show = {
+            isshow: false
+        };
+        global.fetch_user().then(function (data) {
+            $scope.is_showcurrent = (global.user.compno != null);
+            if (global.user.token != "") {
+                CompManage.get_Compdata().then(function (data) {
+                    data = _.filter(data, function (item) {
+                        return item.usr_status == 2;
+                    });
+                    if (data.length > 0) {
+                        _.each(data, function (c) {
+                            c.check = false;
+                            if (c.id == global.user.compno) {
+                                $scope.currentcomp = c;
+                                c.check = true;
+                            }
+                        });
+                    }
+                    $scope.compdata = data;
+                }, function (err) {
+                    $scope.is_showcurrent = false;
+                    alert(JSON.stringify(err))
+                });
+            } else {
+                $scope.compdata = [];
+            }
+        });
+    });
+
+    $scope.change = function (comp) {
+        if ($scope.compdata.length > 0) {
+            if ($scope.currentcomp != comp) {
+                showPopup.showLoading(1, '', false);
+                var password = global.user.password;
+                CompManage.post_authcheck(global.user.im_usrid, comp.id).then(function (data) {
+                    $scope.currentcomp = comp;
+                    $scope.show.isshow = false;
+                    _.each($scope.compdata, function (_comp) {
+                        if (comp.id != _comp.id) {
+                            _comp.check = false;
+                        }
+                    });
+                    global.user = data;
+                    global.user.password = password;
+                    CompManage.store_user().then(function (data) {
+                        console.log(data);
+                        showPopup.hideLoading();
+                    }, function (error) {
+                        showPopup.hideLoading();
+                        console.log('store error:' + JSON.stringify(error));
+                    });
+                }, function (error) {
+                    showPopup.hideLoading();
+                    alert(JSON.stringify(error));
+                });
+            }
+        }
+    };
+
+    $scope.goBack = function () {
+        global.goBack();
+    };
+
+    $scope.showcomplist = function () {
+        if ($scope.compdata.length > 0) $scope.show.isshow = !$scope.show.isshow;
+    }
+})
+
+.controller('ManageCompCtrl', function ($scope, $state, $ionicPopup, $rootScope, $ionicHistory, $q, $location, $window, global, ImageManage, showPopup, CompManage) {
+    $scope.newcompname = {
+        "compname": ""
+    };
+    var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
+        $scope.loading = ($scope.compdata == undefined);
+        global.fetch_user().then(function (data) {
+            if (global.user.token != "") {
+                getmycomplist();
+            } else {
+                $scope.compdata = [];
+                $scope.loading = false;
+            }
+            $scope.popup = {
+                isSetPopup: false
+            };
+        });
+    });
+
+    $scope.tocompinfo = function (compid, op) {
+        $state.go('compinfo', {
+            'compid': compid,
+            'op': op
+        });
+    };
+
+    $scope.showaddcompmodel = function () {
+        showPopup.modalTemplate('templates/createcomp-modaltemplate.html', 'slide-in-right', $scope).then(function (modal) {
+            $rootScope.commons.modal = modal;
+            $rootScope.commons.modal.show();
+        });
+    };
+
+    $scope.cancel = function () {
+        $rootScope.commons.modal.hide();
+        $scope.logourl = '../../../img/logo.png';
+    };
+
+    $scope.createcomp = function () {
+        var newcompdata = {"compname": "", "cellphone": global.user.cellphone, "username": "", "imid": "", "password": global.user.password};
+        newcompdata.username = global.user.usrname;
+        newcompdata.compname = $scope.newcompname.compname;
+        newcompdata.imid = global.user.im_usrid;
+        showPopup.showLoading(1, '正在提交', true, $scope.logourl != "../../../img/logo.png" ? 20000 : 10000);
+        CompManage.post_Register(newcompdata).then(function (compdata) {
+            if ($scope.logourl != "../../../img/logo.png") {
+                if (global.user.token == "") {
+                    var password = global.user.password;
+                    CompManage.post_authcheck(global.user.im_usrid, compdata.compid).then(function (data) {
+                        global.user = data;
+                        global.user.password = password;
+                        uploadcomplogo(compdata);
+                        CompManage.store_user().then(function () {
+                        }, function (error) {
+                            showPopup.hideLoading();
+                            console.log('store error:' + JSON.stringify(error));
+                        });
+                    }, function (err) {
+                        showPopup.hideLoading();
+                        alert('post_authcheck error:' + JSON.stringify(err))
+                    });
+                } else {
+                    uploadcomplogo(compdata)
+                }
+            } else {
+                get_authcheckInfo(compdata.compid);
+            }
+        }, function (e) {
+            showPopup.hideLoading();
+            if (_.has(e.data, 'msg')) showPopup.PopupWindow(0, e.data.msg, false, 2000);
+            else alert(JSON.stringify(e));
+        });
+    };
+
+    $scope.$on('$destroy', function () {
+        if ($rootScope.commons.modal != null) {
+            $rootScope.commons.modal.remove();
+        }
+        beforeEnter = null;
+    });
+
+    $scope.logourl = '../../../img/logo.png';
+
+    $scope.editlogo = function () {
+        $scope.popup.optionsPopup = showPopup.showSelectImgPopup(Camera, ImagePicker, $scope);
+        $scope.popup.isSetPopup = true;
+    };
+
+    $scope.import = function () {
+        $window.location.href = "http://"+$location.host()+":"+$location.port()+"/apps/compmanage/index.html#/index";
+        // $location.url('http://192.168.1.5:8101/apps/compmanage/index.html#/index');
+    };
+
+    function uploadcomplogo(comp) {
+        ImageManage.uploadImage($scope.logourl, 'comp', comp.compid, 'complogo').then(function (res) {
+            $q.all(res).then(function (res1) {
+                get_authcheckInfo(comp.id);
+            }, function (error) {
+                showPopup.hideLoading();
+                alert('upload error:' + JSON.stringify(error));
+            });
+        }, function (err) {
+            showPopup.hideLoading();
+            alert('upload token error:' + JSON.stringify(err));
+        });
+    }
+
+    function get_authcheckInfo(compid) {
+        if (global.user.token == '') {
+            var password = global.user.password;
+            CompManage.post_authcheck(global.user.im_usrid, compid).then(function (data) {
+                global.user = data;
+                global.user.password = password;
+                getmycomplist();
+                CompManage.store_user().then(function (data) {
+                    console.log(data);
+                    $ionicHistory.goBack();
+                    showPopup.hideLoading();
+                }, function (error) {
+                    showPopup.hideLoading();
+                    console.log('store error:' + JSON.stringify(error));
+                });
+            }, function (err) {
+                showPopup.hideLoading();
+                alert('post_authcheck error:' + JSON.stringify(err))
+            });
+        } else {
+            showPopup.hideLoading();
+            if ($rootScope.commons.modal != null) $rootScope.commons.modal.hide();
+            getmycomplist();
+        }
+    }
+
+    function getmycomplist() {
+        CompManage.get_Compdata().then(function (data) {
+            _.each(data, function (comp) {
+                if (comp.file_thumbnail_path == null) {
+                    comp.file_thumbnail_path = $scope.logourl;
+                }
+                var admin = _.find(comp.compadmin, function (adminitem) {
+                    return adminitem.user_id == global.user.usrid;
+                });
+                comp.op = admin == undefined ? 0 : 1;
+                comp.compadmins = _.pluck(comp.compadmin, 'username').join(',');
+            });
+            $scope.compdata = _.sortBy(data, 'op').reverse();
+            $scope.loading = false;
+            $scope.newcompname.compname = "";
+            $scope.logourl = "../../../img/logo.png"
+        }, function (err) {
+            $scope.loading = false;
+            alert(JSON.stringify(err));
+        });
+    }
+
+    var ImagePicker = function () { //打开相册
+        $scope.popup.optionsPopup.close();
+        ImageManage.ImagePicker_getPictures(1).then(function (results) {
+            if (results.length == 0) return;
+            $q.all(results).then(function (res) {
+                $scope.logourl = res[0];
+            })
+        });
+    };
+
+    var Camera = function () {
+        $scope.popup.optionsPopup.close();
+        ImageManage.Camera_getPicture(true).then(function (result) {
+            $scope.logourl = result;
+        });
+    };
+})
+
+.controller('JoinCompCtrl', function ($scope, $ionicHistory, $timeout, CompManage, global, showPopup) {
+    $scope.data = {
+        "compid": ""
+    };
+    var compdata = _.pick(global.user, 'cellphone', 'password');
+    compdata.username = global.user.usrname;
+    compdata.imid = global.user.im_usrid;
+    $scope.addedcomp = {};
+    $scope.is_show_jointip = false;
+    $scope.joincomp = function () {
+        var complist = CompManage.getComplist();
+        var comp = _.findWhere(complist, {'id': $scope.data.compid});
+        compdata.compid = $scope.data.compid;
+        if (comp == undefined) { //未加入过
+            showPopup.showLoading(1, '正在提交', true);
+            CompManage.post_Joinin(compdata).then(function (res) {
+                showPopup.hideLoading();
+                if (res.status == 201)
+                    $scope.is_show_jointip = true;
+                else
+                    showPopup.PopupWindow(0, res.msg, false, 2000);
+                $timeout(function () {
+                    $scope.is_show_jointip = false;
+                }, 5000);
+            }, function (e) {
+                showPopup.hideLoading();
+                if (_.has(e.data, 'msg')) showPopup.PopupWindow(0, e.data.msg, false, 2000);
+                else alert(JSON.stringify(e));
+            });
+        } else {
+            if (comp.file_thumbnail_path == "") {
+                comp.file_thumbnail_path = '../../../img/logo.png'
+            }
+            showPopup.PopupWindow(0, '你已加入该公司!', false, 2000);
+            $scope.addedcomp = comp;
+        }
+    };
+})
+
+.controller('CompInfoCtrl', function ($scope, $ionicPopup, $state, $ionicHistory, $q, showPopup, ImageManage, CompManage, global) {
+    var compid = $state.params['compid'];
+    $scope.op = $state.params['op'];
+    var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
+        var compdata = CompManage.getComplist();
+        $scope.rdata = _.find(compdata, function (comp) {
+            return comp.id == $state.params['compid'];
+        });
+        console.log($scope.rdata);
+        $scope.data = _.clone($scope.rdata);
+        $scope.popup = {
+            isPopup: false
+        };
+    });
+
+    $scope.$on("$destroy", function () {
+        beforeEnter = null;
+    });
+
+    $scope.selectphoto = function () {
+        if ($scope.op == 0) {
+            return;
+        }
+        $scope.popup.optionsPopup = showPopup.showSelectImgPopup(Camera, ImagePicker, $scope);
+        $scope.popup.isPopup = true;
+    };
+
+    $scope.disbandcomp = function () {
+        showPopup.confirm('确定解散公司吗?', '确定', '取消').then(function (res) {
+            if (res) {
+                //解散
+                showPopup.showLoading(1, '', false);
+                CompManage.dismiss_comp($scope.data.id).then(function () {
+                    CheckComp();
+                    // alert('dismiss_comp success')
+                }, function (error) {
+                    showPopup.hideLoading();
+                    alert('error disbandcomp:' + JSON.stringify(error));
+                });
+            }
+        })
+    };
+
+    $scope.leavecomp = function () {
+        showPopup.confirm('确定退出公司吗?', '确定', '取消').then(function (res) {
+            if (res) {
+                if ($scope.op == 1) { //admin
+                    if ($scope.rdata.compadmin.length > 1) { //admin count>=2
+                        //退出
+                        showPopup.showLoading(1, '', false);
+                        CompManage.leave_comp($scope.data.id).then(function () {
+                            CheckComp();
+                        }, function (error) {
+                            showPopup.hideLoading();
+                            alert('error leavecomp:' + JSON.stringify(error));
+                        })
+                    } else {
+                        showPopup.PopupWindow(0, '你是该公司唯一的管理员不允许退出!', false);
+                    }
+                } else {
+                    //退出
+                    showPopup.showLoading(1, '', false, 20000);
+                    CompManage.leave_comp($scope.data.id).then(function () {
+                        CheckComp();
+                    }, function (error) {
+                        showPopup.hideLoading();
+                        alert('error leavecomp:' + JSON.stringify(error));
+                    });
+                }
+            }
+        })
+    };
+
+    $scope.showeditpopup = function () {
+        if ($scope.op == 0) {
+            return;
+        }
+        $scope.editdata = _.clone($scope.data);
+        var myPopup = $ionicPopup.show({
+            template: '<div class="popup-edit-comp" ><input type="text" ng-model="editdata.name" ><label ></label></div>',
+            title: '<div><h5>修改公司名称</h5></div>',
+            scope: $scope,
+            buttons: [{
+                text: '取消',
+                onTap: function () {
+                    return false;
+                }
+            }, {
+                text: '<b>保存</b>',
+                type: 'button-positive',
+                onTap: function (e) {
+                    if (!$scope.editdata.name) {
+                        e.preventDefault();
+                    } else {
+                        return true;
+                    }
+                }
+            }]
+        });
+
+        myPopup.then(function (res) {
+            if (res) {
+                // alert('editComp');
+                if ($scope.editdata.name != $scope.data.name) {
+                    CompManage.editComp($scope.editdata).then(function (data) {
+                        $scope.data.name = $scope.editdata.name;
+                        // alert(1);
+                    }, function (err) {
+                        alert('Error:' + JSON.stringify(err));
+                    });
+                }
+            }
+        });
+    };
+    $scope.image_list = [];
+
+    var ImagePicker = function () { //打开相册
+        $scope.popup.optionsPopup.close();
+        ImageManage.ImagePicker_getPictures(1).then(function (results) {
+            if (results.length == 0) return;
+            $q.all(results).then(function (res) {
+                uploadimage(res[0]);
+            })
+        });
+    };
+
+    var Camera = function () {
+        $scope.popup.optionsPopup.close();
+        ImageManage.Camera_getPicture(true).then(function (result) {
+            uploadimage(result);
+        });
+    };
+
+    function CheckComp() {
+        var compdata = CompManage.getComplist();
+        compdata.splice(_.findIndex(compdata, {'id': $scope.data.id}), 1);
+        if (compdata.length > 0 && global.user.compno == $scope.data.id) { //退出/解散当前登录的公司
+            var comp = compdata[0];
+            var password = global.user.password;
+            CompManage.post_authcheck(global.user.im_usrid, comp.id).then(function (data) {
+                global.user = data;
+                global.user.password = password;
+                showPopup.hideLoading();
+                $ionicHistory.goBack();
+                CompManage.store_user().then(function (data) {
+                    console.log(data);
+                }, function (error) {
+                    console.log('store error:' + JSON.stringify(error));
+                });
+            });
+        } else if (compdata.length == 0) { //用户没有公司时
+            global.user.token = "";
+            global.user.compno = "";
+            global.user.compname = "";
+            global.user.deptno = "";
+            global.user.deptname = "";
+            global.user.roleid = "";
+            showPopup.hideLoading();
+            $ionicHistory.goBack();
+            CompManage.store_user().then(function (data) {
+                console.log(JSON.stringify(data));
+            }, function (error) {
+                console.log('store error:' + JSON.stringify(error));
+            });
+        } else {
+            showPopup.hideLoading();
+            $ionicHistory.goBack();
+        }
+    }
+
+    function uploadimage(result) {
+        showPopup.showLoading(1, '', false, 20000);
+        ImageManage.uploadImage(result, 'comp', $scope.data.id, 'complogo').then(function (res) {
+            $q.all(res).then(function (res1) {
+                showPopup.hideLoading();
+                $scope.data.file_thumbnail_path = JSON.parse(res1[0].response).file_thumbnail_path;
+            }, function (error) {
+                showPopup.hideLoading();
+                alert('upload error:' + JSON.stringify(error));
+            })
+        }, function (error) {
+            alert('get token error:' + JSON.stringify(error));
+            showPopup.hideLoading();
+        });
+    }
+})
+
+.controller('ApplyCheckCtrl', function ($scope, $ionicPlatform, $cordovaPreferences, $location, global, CompManage, showPopup) {
+    var compid = $location.search().compid;
+    global.fetch_user().then(function (data) {
+        getAuditUsers();
+    }, function (error) {
+        alert(JSON.stringify(error));
+    });
+
+    $scope.check = function (user, op) { //todo:y=0;n=1
+        // alert(JSON.stringify($scope.audituserlst))
+        showPopup.showLoading(1, '正在提交', false);
+        CompManage.auditUser(user, op, compid).then(function (data) {
+            showPopup.hideLoading();
+            $scope.audituserlst.splice(_.indexOf($scope.audituserlst, user), 1);
+        }, function (err) {
+            showPopup.hideLoading();
+            alert(JSON.stringify(err));
+        });
+    };
+    $scope.doRefresh = function () {
+        getAuditUsers();
+    };
+
+    $scope.goBack = function () {
+        global.goBack();
+    }
+
+    function getAuditUsers() {
+        if (global.user.token != "") {
+            CompManage.getUserAuditstatus(1, compid).then(function (data) {
+                $scope.audituserlst = data;
+            }, function (err) {
+                alert(JSON.stringify(err));
+            }).finally(function () {
+                $scope.$broadcast('scroll.refreshComplete');
+            });
+        }
+    }
+})
+
+.controller('ContactsCompanylstCtrl', function ($scope, $cordovaPreferences, $ionicPlatform, $state, global, Dept, CompManage) {
+    $scope.complistdata = [];
+    $scope.logourl = '../../../img/logo.png';
+    $scope.loading = true;
+    var beforeEnter = $scope.$on('$ionicView.beforeEnter', function () {
+        Dept.setdeptlst([]);
+        // alert(Dept.all().length);
+    });
+    $scope.init = function () {
+        global.fetch_user().then(function (data) {
+            if (global.user.token != "") {
+                CompManage.get_Compdata().then(function (data) {
+                    // alert(JSON.stringify(data));
+                    _.each(data, function (c) {
+                        if (c.file_thumbnail_path == null) {
+                            c.file_thumbnail_path = $scope.logourl;
+                        }
+                    })
+                    $scope.complistdata = data;
+                    $scope.loading = false;
+                });
+            } else {
+                $scope.loading = false;
+            }
+        }, function (error) {
+            $scope.loading = false;
+            alert(JSON.stringify(error));
+        });
+    };
+
+    $scope.goBack = function () {
+        global.goBack();
+    }
+
+    $scope.tocompuser = function (compid, compname) {
+        $state.go('deptlst', {
+            id: -1,
+            name: compname,
+            compid: compid
+        })
+    };
+
+    function getcompdata() {
+        if (global.user.token != "") {
+            CompManage.get_Compdata().then(function (data) {
+                $scope.complistdata = data;
+            });
+        }
+    }
+})
+
+.controller('DeptCtrl', function ($scope, $state, $http, $stateParams, Dept, $ionicViewSwitcher) {
+    $scope.deptlst = [];
+    $scope.emplst = [];
+    $scope.titleName = '';
+    $scope.checked = false;
+    $scope.titleName = $stateParams.name;
+    $scope.deptid = -1;
+    $scope.$on('$ionicView.beforeEnter', function () {
+        $scope.deptid = setdeptid();
+        if (Dept.all().length == 0) {
+            $scope.loading = true;
+            Dept.getDep($stateParams.compid).then(function (data) {
+                $scope.deptid = setdeptid();
+                data = _.filter(data, function (item) {
+                    return item.parent == $scope.deptid;
+                });
+                $scope.dept_data = data;
+                $scope.deptlst = data;
+                getemp();
+            }, function (err) {
+                $scope.loading = false;
+            });
+        } else {
+            $scope.loading = false;
+            var data = Dept.getChildDept($scope.deptid);
+            $scope.dept_data = data;
+            $scope.deptlst = data;
+            getemp();
+        }
+    });
+
+    function setdeptid() {
+        var deptid = parseInt($stateParams.id);
+        if (Dept.all().length > 0) {
+            if (deptid < 0) {
+                deptid = _.find(Dept.all(), function (item) {
+                    return item.level == 0
+                }).id;
+            }
+        }
+        return deptid;
+    }
+
+    function getemp() {
+        Dept.getEmp($scope.deptid, $stateParams.compid).then(function (data) {
+            console.log('user json:' + JSON.stringify(data));
+            $scope.emplst = data;
+            $scope.loading = false;
+        }, function (err) {
+            $scope.loading = false;
+            alert(JSON.stringify(err));
+        });
+    }
+
+    $scope.deptdisplay = function () {
+        if ($scope.deptlst.length > 0) {
+            return true;
+        } else {
+            return false;
+        }
+    };
+
+    $scope.empdisplay = function () {
+        if ($scope.emplst.length > 0) {
+            return true;
+        } else {
+            return false;
+        }
+    };
+
+    $scope.search = function () {
+        $state.go('search');
+    };
+
+    $scope.editDep = function () {
+        $state.go('editDep', {
+            id: $scope.deptid,
+            compid: $stateParams.compid,
+            name: $stateParams.name
+        });
+        $ionicViewSwitcher.nextDirection("back");
+    };
+
+    $scope.cancel = function () {
+        $state.go('addGroup2');
+    };
+
+    $scope.lookMsg = function (im_id, name, cellphone) {
+        var data = {
+            'im_id': im_id,
+            'name': name,
+            'cellphone': cellphone
+        }
+        console.log(data)
+        if (window.cordovaLinker != undefined) {
+            window.cordovaLinker.startChat(data, function (s) {
+                console.log(s);
+            }, function (err) {
+                console.error(err);
+            });
+        }
+    };
+
+    $scope.todept = function (dept) {
+        $state.go('deptlst', {id: dept.id, name: dept.depname, compid: $stateParams.compid})
+    };
+})
+
+.controller('EditDepCtrl', function ($scope, $ionicPopup, $stateParams, $timeout, $ionicHistory, Dept, showPopup, Tool) {
+    $scope.deptlst = [];
+    $scope.titleName = $stateParams.name;
+    var del_deptids = [];
+    var dept_data = [];
+    var compid = $stateParams.compid;
+    var beforeenter = $scope.$on('$ionicView.beforeEnter', function () {
+        $scope.deptlst = angular.copy(Dept.getChildDept($stateParams.id));
+        dept_data = angular.copy($scope.deptlst);
+    });
+
+    $scope.add = function () {
+        $timeout(function () {
+            $scope.deptlst.push({
+                depname: '',
+                parent_id: $stateParams.id
+            })
+        })
+    };
+    $scope.remove = function (dept, index) {
+        if (_.has(dept, 'id')) del_deptids.push(dept.id);
+        $scope.deptlst.splice(index, 1);
+    };
+
+    $scope.save = function () {
+        var deptlst = _.filter($scope.deptlst, function (dep) {
+            return Tool.trim(dep.depname).length > 0;
+        });
+        if (deptlst.length > _.uniq(_.pluck(deptlst, 'depname')).length) {
+            showPopup.PopupWindow(0, '名称不能重复!', false);
+            return;
+        }
+        var depts = _.partition(deptlst, 'id');
+        var up_depts = _.map(_.difference(_.map(depts[0], JSON.stringify), _.map(dept_data, JSON.stringify)), JSON.parse);
+        var add_depts = depts[1];
+        if (del_deptids.length > 0 || add_depts.length > 0 || up_depts.length > 0) {
+            showPopup.showLoading(1, '', false);
+            $scope.isdisabled_ok = true;
+            Dept.save(up_depts, del_deptids, add_depts, compid).then(function (data) {
+                Dept.setdeptlst([]);
+                $ionicHistory.goBack();
+            }, function (err) {
+                console.log(err);
+            }).finally(function (f) {
+                showPopup.hideLoading();
+                $scope.isdisabled_ok = false;
+            }); //修改、删除、添加;
+        }
+    };
+
+    $scope.cancel = function () {
+        if (JSON.stringify($scope.deptlst) != JSON.stringify(dept_data)) {
+            showPopup.confirm('是否退出编辑?', '是', '否').then(function (res) {
+                if (res) {
+                    $ionicHistory.goBack();
+                }
+            });
+        } else $ionicHistory.goBack();
+    };
+})
+
+.controller('PersonInfoCtrl', function ($scope, $state, $rootScope, $ionicPopup, $ionicModal, $q, $timeout, $ionicHistory, formatFilter, Dept, showPopup, global, ImageManage, Member) {
+    $scope.personinfo = {value: ''};
+    $scope.selectdatas = [{
+        name: '女',
+        id: 0
+    }, {
+        name: '男',
+        id: 1
+    }];
+    var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
+        global.fetch_user().then(function (data) {
+            $scope.loading = $scope.userinfo == undefined;
+            Dept.getUsrDetail().then(function (data) {
+                $scope.userinfo = angular.copy(data);
+                $scope.userinfo.photo = data.photo == null ? '../../../img/panda.png' : data.photo;
+                $scope.userinfo.compname = global.user.compname;
+                $scope.userinfo.compno = global.user.compno;
+                $scope.loading = false;
+            }, function (err) {
+                alert(JSON.stringify(err))
+            });
+        });
+        $scope.popup = {
+            isPopup: false,
+            optionsPopup: null
+        };
+    });
+
+    $scope.selectimg = function () {
+        $scope.popup.optionsPopup = showPopup.showSelectImgPopup(Camera, ImagePicker, $scope);
+        $scope.popup.isPopup = true;
+    };
+
+    $scope.editInfo = function (title, input_type, field_name, value) {
+        $scope.userinfo[field_name] = value == undefined ? '' : value;
+        $scope.personinfo.value = value == undefined ? '' : value;
+        var template = formatFilter('<div rj-close-back-drop><label class="item item-input"> <input type="{0}" ng-model="personinfo.value" placeholder="输入{1}"></label></div>', input_type, title);
+        $scope.popup.optionsPopup = $ionicPopup.show({
+            template: template,
+            title: '<div><h4>' + title + '</h4></div>',
+            scope: $scope,
+            buttons: [{
+                text: '取消',
+                onTap: function () {
+                    return false;
+                }
+            }, {
+                text: '<b>保存</b>',
+                type: 'button-positive',
+                onTap: function (e) {
+                    if (!$scope.personinfo.value) e.preventDefault(); else  return true;
+                }
+            }]
+        });
+        $scope.popup.optionsPopup.then(function (res) {
+            if (res) {
+                $scope.userinfo[field_name] = $scope.personinfo.value;
+                $scope.updateInfo();
+                $scope.popup.optionsPopup.close();
+            }
+        });
+        $scope.popup.isPopup = true;
+    };
+
+    var ImagePicker = function () {
+        $scope.popup.optionsPopup.close();
+        ImageManage.ImagePicker_getPictures(1).then(function (results) {
+            if (results.length == 0) return;
+            $q.all(results).then(function (res) {
+                uploadimg(res);
+            })
+        });
+    };
+
+    var Camera = function () {
+        $scope.popup.optionsPopup.close();
+        ImageManage.Camera_getPicture(true).then(function (result) {
+            uploadimg([result])
+        });
+    };
+
+    function uploadimg(files) {
+        showPopup.showLoading(1, '', true);
+        ImageManage.uploadImage(files, 'user', global.user.usrid, 'userfile').then(function (ps) {
+            $q.all(ps).then(function (fs) {
+                $scope.userinfo.photo = JSON.parse(fs[0].response).file_thumbnail_path;
+                showPopup.hideLoading();
+            }, function (err) {
+                showPopup.hideLoading();
+            })
+        }, function (err) {
+            showPopup.hideLoading();
+        })
+    }
+
+    $scope.updateInfo = function () {
+        showPopup.showLoading(1, '', false);
+        Dept.putUsrInfo($scope.userinfo).then(function (res) {
+            showPopup.hideLoading();
+        }, function (err) {
+            showPopup.hideLoading();
+        })
+    };
+
+    $scope.$on("$destroy", function () {
+        beforeEnter = null;
+        Member.selecteddepts = [];
+        if ($rootScope.commons.modal != null) $rootScope.commons.modal.remove();
+    })
+})
+
+.controller('EditDeptDegreeCtrl', function ($scope, $state, $rootScope, $ionicHistory, $timeout, global, Member, showPopup, Dept, Tool) {
+    $scope.userinfo = {};
+    var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
+        global.fetch_user().then(function (data) {
+            if (Member.selecteddepts.length > 0) {
+                $scope.userinfo.depname = Member.selecteddepts[0].depname;
+                $scope.userinfo.dept_id = Member.selecteddepts[0].id;
+            } else $scope.userinfo = Tool.getTempData('userinfo');
+        });
+    });
+
+    $scope.selectdept = function () {
+        Member.routename = 'editdeptdegree';
+        Member.titlename = '选择部门';
+        Member.resourcemember = [{'id': $scope.userinfo.dept_id, 'depname': $scope.userinfo.depname}];
+        Member.selecteddepts = [];
+        $state.go('selectsingledept');
+    };
+
+    $scope.ok = function () {
+        showPopup.showLoading(1, '', false);
+        Dept.putUsrInfo($scope.userinfo).then(function (res) {
+            showPopup.hideLoading();
+            $ionicHistory.goBack();
+        }, function (err) {
+            showPopup.hideLoading();
+            alert(JSON.stringify(err));
+        })
+    };
+
+    $scope.cancel = function () {
+        $ionicHistory.goBack();
+    };
+
+    $scope.$on("$destroy", function () {
+        beforeEnter = null;
+        Member.selecteddepts = [];
+    })
+})
+;

+ 0 - 0
www/apps/accountMng/js/directive.js


+ 73 - 0
www/apps/accountMng/js/factory.js

@@ -0,0 +1,73 @@
+starter.factory('CompManage', function ($http, $q, $filter, $ionicPlatform, $cordovaPreferences, cfg, formatFilter, global, Tool) {
+
+    var complist = [];
+
+    return {
+        post_Register: function (data) {
+            console.log(data)
+            var url = formatFilter('{0}register/', cfg.api);
+            return Tool.post(url, data);
+        },
+        post_Joinin: function (data) {
+            var url = formatFilter('{0}joinin/', cfg.api);
+            var deferred = $q.defer();
+            $http.post(url, data).then(function (res) {
+                    deferred.resolve(res);
+                },
+                function (err) {
+                    deferred.reject(err);
+                });
+            return deferred.promise;
+        },
+        getUserAuditstatus: function (auditstatus, compid) {
+            var url = formatFilter('{0}joinin/?auditstatus={1}&compid={2}', cfg.api, auditstatus, compid);
+            return Tool.get(url);
+        },
+        auditUser: function (user, status, compid) {
+            var url = formatFilter('{0}joinin/{1}/?status={2}&compid={3}', cfg.api, user.user_id, status, compid);
+            return Tool.put(url);
+        },
+        get_Compdata: function () {
+            var url = formatFilter('{0}comps/', cfg.api);
+            return Tool.get(url, true, 'complist');
+        },
+        getComplist: function () {
+            complist = Tool.getTempData('complist');
+            return complist;
+        },
+        editComp: function (data) {
+            var url = formatFilter('{0}comps/{1}/', cfg.api, data.id);
+            return Tool.put(url, data);
+        },
+        post_authcheck: function (imid, compid) {
+            var url = formatFilter('{0}authcheck/', cfg.api);
+            var d = $filter('format')("imid={0}&compid={1}&password={2}", imid, compid, global.user.password);
+            return Tool.post(url, d, false);
+        },
+        store_user: function () {
+            var deferred = $q.defer();
+            var user = angular.copy(global.user);
+            user.cfg = {'api': global.api};
+            $cordovaPreferences.store('user', ionic.Platform.isAndroid() ? JSON.stringify(user) : user)
+            .success(function (value) {
+                deferred.resolve(value);
+                // alert("store Success: " + value);
+            })
+            .error(function (error) {
+                deferred.reject(err);
+                alert("store Error: " + error);
+            });
+            return deferred.promise;
+        },
+        leave_comp: function (compid) {
+            var url = formatFilter('{0}comps/{1}/?type={2}', cfg.api, compid, "leave");
+            var d = $filter('format')("imid={0}&compid={1}", global.user.im_usrid, compid);
+            return Tool.put(url, d);
+        },
+        dismiss_comp: function (compid) {
+            var url = formatFilter('{0}comps/{1}/?type={2}', cfg.api, compid, "dismiss");
+            var d = $filter('format')("compid={0}", compid);
+            return Tool.put(url, d);
+        }
+    };
+})

+ 61 - 0
www/apps/accountMng/js/route.js

@@ -0,0 +1,61 @@
+starter.config(function ($stateProvider, $translateProvider) {
+    $stateProvider.state('account-manage', {
+        url: '/index',
+        templateUrl: 'templates/account-manage.html',
+        controller: 'AccountManageCtrl'
+    })
+
+    .state('managecomp', {
+        url: '/managecomp',
+        templateUrl: 'templates/managecomp.html',
+        controller: 'ManageCompCtrl'
+    })
+
+    .state('compinfo', {
+        url: '/compinfo/:compid/:op',
+        templateUrl: 'templates/compinfo.html',
+        controller: 'CompInfoCtrl'
+    })
+
+    .state('joincomp', {
+        url: '/joincomp',
+        templateUrl: 'templates/joincomp.html',
+        controller: 'JoinCompCtrl'
+    })
+
+    .state('applycheck', {
+        url: '/applycheck',
+        templateUrl: 'templates/applycheck.html',
+        controller: 'ApplyCheckCtrl'
+    })
+
+    .state('contacts-companylst', {
+        url: '/contacts-companylst',
+        templateUrl: 'templates/contacts-companylst.html',
+        controller: 'ContactsCompanylstCtrl'
+    })
+
+    .state('deptlst', {
+        url: '/contacts/:id&:name&:compid',
+        templateUrl: 'templates/contacts-deptlst.html',
+        controller: 'DeptCtrl'
+    })
+
+    .state('editDep', {
+        url: '/editDep/:id&:name&:compid',
+        templateUrl: 'templates/editDep.html',
+        controller: 'EditDepCtrl'
+    })
+
+    .state('personinfo', {
+        url: '/personinfo',
+        templateUrl: 'templates/personinfo.html',
+        controller: 'PersonInfoCtrl'
+    })
+
+    .state('editdeptdegree', {
+        url: '/editdeptdegree',
+        templateUrl: 'templates/edit_deptdegree.html',
+        controller: 'EditDeptDegreeCtrl'
+    })
+});

+ 0 - 0
www/apps/compmanage/templates/account-manage.html → www/apps/accountMng/templates/account-manage.html


+ 0 - 0
www/apps/compmanage/templates/applycheck.html → www/apps/accountMng/templates/applycheck.html


+ 0 - 0
www/apps/compmanage/templates/compinfo.html → www/apps/accountMng/templates/compinfo.html


+ 0 - 0
www/apps/compmanage/templates/contacts-companylst.html → www/apps/accountMng/templates/contacts-companylst.html


+ 0 - 0
www/apps/compmanage/templates/contacts-deptlst.html → www/apps/accountMng/templates/contacts-deptlst.html


+ 1 - 0
www/apps/compmanage/templates/createcomp-modaltemplate.html → www/apps/accountMng/templates/createcomp-modaltemplate.html

@@ -2,6 +2,7 @@
     <ion-header-bar>
         <button class="button button-clear" ng-click="cancel()">{{'cancelTitle' | translate}}</button>
         <h1 class="title">{{'createcompTitle' | translate}}</h1>
+        <button class="button button-clear" ng-click="import()">导入</button>
     </ion-header-bar>
     <ion-content class="create-comp-content">
         <div class="comp-logo-box">

+ 0 - 0
www/apps/compmanage/templates/editDep.html → www/apps/accountMng/templates/editDep.html


+ 0 - 0
www/apps/compmanage/templates/edit_deptdegree.html → www/apps/accountMng/templates/edit_deptdegree.html


+ 0 - 0
www/apps/compmanage/templates/joincomp.html → www/apps/accountMng/templates/joincomp.html


+ 0 - 0
www/apps/compmanage/templates/managecomp.html → www/apps/accountMng/templates/managecomp.html


+ 0 - 0
www/apps/compmanage/templates/modal-dept_degree.html → www/apps/accountMng/templates/modal-dept_degree.html


+ 0 - 0
www/apps/compmanage/templates/personinfo.html → www/apps/accountMng/templates/personinfo.html


+ 64 - 0
www/apps/compmanage/js/controllers.js

@@ -0,0 +1,64 @@
+starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDelegate, $rootScope, $ionicHistory, $window, showPopup, global, Comp) {
+    $scope.activeIndex = 0;
+    $scope.titleName = ['填写序列号', '选择公司', '用户信息', '导入部门'];
+    var compmodal = showPopup.modalTemplate('templates/modal-selectcomp.html', 'slide-in-up', $scope);
+
+    global.fetch_user().then(function (res) {
+
+    });
+
+    $scope.lockSlide = function () {
+        $ionicSlideBoxDelegate.enableSlide(false);
+    };
+
+    $scope.next = function (op, serialno) {
+        $ionicSlideBoxDelegate.next();
+        $scope.activeIndex = $ionicSlideBoxDelegate.currentIndex();
+        if (op == 1) {
+            $scope.serialnumber = serialno;
+            Comp.comp().query({"serialno": serialno}, function (data) {
+                $scope.compdata = data;
+                $scope.activecomp = data[0];
+                $scope.showmodal();
+            }, function (err) {
+                console.log(JSON.stringify(err))
+            })
+        }
+    };
+
+
+    $scope.commit = function (r) {
+        $scope.activecomp = _.extend($scope.activecomp, {"cellphone": global.user.cellphone, "imid": global.user.im_usrid, "linkerpassword": global.user.password, "linkerusername": global.user.usrname, "region": 86});
+        showPopup.showLoading(1, '正在提交', false);
+        console.log($scope.activecomp);
+        Comp.comp("PostComp", $scope.serialnumber).save($scope.activecomp, function (res) {
+            $ionicSlideBoxDelegate.next();
+        }, function (err) {
+            console.log(err);
+        }).$promise.finally(function (f) {
+            showPopup.hideLoading();
+        })
+    };
+
+    $scope.showmodal = function () {
+        compmodal.then(function (m) {
+            $rootScope.commons.modal = m;
+            $rootScope.commons.modal.show();
+        })
+    };
+
+    $scope.closeModal = function (comp) {
+        if (comp)
+            $scope.activecomp = comp;
+        $rootScope.commons.modal.hide();
+    };
+
+    $scope.back = function () {
+        if ($scope.activeIndex != 0) {
+            $ionicSlideBoxDelegate.previous();
+            $scope.activeIndex = $ionicSlideBoxDelegate.currentIndex();
+        } else if ($scope.activeIndex == 0) {
+            $window.history.back();
+        }
+    };
+})

+ 5 - 3
www/apps/compmanage/js/factory.js

@@ -1,8 +1,10 @@
-starter.factory('CompManage', function ($http, $q, $filter, $ionicPlatform, $cordovaPreferences, cfg, formatFilter, global, Tool) {
-
+starter.factory('Comp', function ($resource, $q, $filter, cfg, formatFilter, global) {
+    global.erp_api = "http://192.168.1.70:13210/api/";
     var complist = [];
 
     return {
-
+        comp: function (actionname) {
+            return $resource(formatFilter('{0}Comp/{1}', global.erp_api, actionname == undefined ? "" : actionname))
+        }
     };
 })

+ 2 - 2
www/apps/compmanage/js/route.js

@@ -1,7 +1,7 @@
 starter.config(function ($stateProvider, $translateProvider) {
     $stateProvider.state('compmanage', {
         url: '/index',
-        templateUrl: 'templates/account-manage.html',
-        controller: 'AccountManageCtrl'
+        templateUrl: 'templates/compconnect.html',
+        controller: 'CompConnectCtrl'
     })
 });

+ 74 - 10
www/apps/compmanage/templates/compconnect.html

@@ -1,10 +1,74 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <title>Title</title>
-</head>
-<body>
-
-</body>
-</html>
+<ion-view view-title="{{titleName[activeIndex]}}" hide-back-button="true">
+    <ion-nav-buttons side="left">
+        <button class="button button-clear" ng-click="back()">{{activeIndex==0?"取消":"上一步"}}</button>
+    </ion-nav-buttons>
+    <ion-content>
+        <div class="button-bar striped">
+            <button class="button" ng-class="{true:'striped-color',false:'striped-hover'}[activeIndex==0?true:false]"></button>
+            <button class="button" ng-class="{true:'striped-color',false:'striped-hover'}[activeIndex==1?true:false]"></button>
+            <button class="button" ng-class="{true:'striped-color',false:'striped-hover'}[activeIndex==2?true:false]"></button>
+            <button class="button" ng-class="{true:'striped-color',false:'striped-hover'}[activeIndex==3?true:false]"></button>
+        </div>
+        <ion-slide-box show-pager="false" ng-init="lockSlide()" active-slide="activeIndex">
+            <ion-slide>
+                <form name="form" novalidate>
+                    <div class="list list-inset compname-div">
+                        <label class="item item-input" ng-class="{'true':'border-red'}[form.serialnumber.$dirty &&form.serialnumber.$invalid]">
+                            <input type="text" name="serialnumber" ng-model="serialnumber" ng-minlength="2" ng-maxlength="45" required placeholder="请输入序列号" reset-field>
+                        </label>
+                    </div>
+                    <button type="submit" class="create-comp-button button button-block calm" ng-disabled="form.serialnumber.$invalid||form.serialnumber.$pristine" ng-click="next(1,serialnumber)">下一步</button>
+                </form>
+            </ion-slide>
+            <ion-slide>
+                <div class="item item-divider"></div>
+                <ion-item class="item item-icon-right item-text-wrap" ng-click="showmodal()">
+                    公司
+                    <label class="label-right-text item-note">{{activecomp.name}}</label>
+                    <i class="icon ion-chevron-right icon-accessory"></i>
+                </ion-item>
+                <button class="create-comp-button button button-block calm" ng-click="next(2)">下一步</button>
+            </ion-slide>
+            <ion-slide>
+                <div class="item item-divider"></div>
+                <form name="formuser" novalidate>
+                    <div class="list notice-input">
+                        <label class="item item-input">
+                            <span class="input-label notice-title">用户名 :</span>
+                            <input type="text" name="username" required ng-model="activecomp.erpusr">
+                        </label>
+                        <label class="item item-input">
+                            <span class="input-label notice-title">密&nbsp;&nbsp;&nbsp;&nbsp;码 :</span>
+                            <input type="password" name="password" ng-minlength="1" ng-maxlength="45" required ng-model="activecomp.erppwd">
+                        </label>
+                    </div>
+                    <button type="submit" class="create-comp-button button button-block calm" ng-disabled="(formuser.username.$invalid||formuser.username.$pristine)||(formuser.password.$invalid||formuser.password.$pristine)" ng-click="commit(3)">提交</button>
+                </form>
+            </ion-slide>
+            <ion-slide>
+                <div class="marginTop30 ">
+                    <div class="center">
+                        <i class="icon ion-help assertive ion-ask"></i>
+                        <div class="marginTop10">是否需要导入部门信息</div>
+                    </div>
+                    <div class="row">
+                        <div class="col col-20 center">
+                        </div>
+                        <div class="col col-30 center">
+                            <button class="button button-clear button-positive">
+                                跳过
+                            </button>
+                        </div>
+                        <div class="col col-30 center">
+                            <button class="button button-clear button-positive">
+                                导入
+                            </button>
+                        </div>
+                        <div class="col col-20 center">
+                        </div>
+                    </div>
+                </div>
+            </ion-slide>
+        </ion-slide-box>
+    </ion-content>
+</ion-view>

File diff suppressed because it is too large
+ 0 - 0
www/css/linker.min.css


+ 7 - 4
www/js/start/config.js

@@ -66,7 +66,7 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
         if (global.user && global.user.token) {
             usergot(global.user, deferred)
         } else if (ionic.Platform.platform() == 'win32' || ionic.Platform.platform() == 'linux') {
-            $http.post(formatFilter('{0}authcheck/', cfg.api), "imid=zPayHMi6s&password=123456", {
+            $http.post(formatFilter('{0}authcheck/', "http://192.168.1.5:7000/api/"), "imid=zPayHMi6s&password=123456", {
                 headers: {
                     'Content-Type': 'application/x-www-form-urlencoded'
                 }
@@ -93,8 +93,10 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
 
     usergot = function (data, deferred) {
         global.user = data;
-        if (data.cfg) {
+        if (data.cfg && (ionic.Platform.platform() == "ios" || ionic.Platform.platform() == 'android')) {
             global.api = data.cfg.api;
+        } else {
+            global.api = "http://192.168.1.5:7000";
         }
         deferred.resolve(data);
         console.warn(JSON.stringify(global.user));
@@ -243,7 +245,7 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
                         global.refresh = false;
                 }
 
-                if (config.url.startsWith(cfg.api) || config.url.indexOf(global.api) == 0) {//分页时自带了请求路径
+                if (config.url.startsWith(cfg.api) || config.url.indexOf(global.api) == 0 || config.url.indexOf(global.erp_api) == 0) {//分页时自带了请求路径
                     if (config.url.startsWith(cfg.api)) config.url = global.api + config.url;
                     console.log(angular.lowercase(config.method) + " url: " + config.url);
                     if (global.user.token) {
@@ -251,7 +253,7 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
                         console.log(' authorization:' + config.headers['authorization']);
                     }
                 }
-                config.timeout = 10000;
+                config.timeout = 60000;
                 return config;
             },
             'responseError': function (rejection) {
@@ -292,6 +294,7 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
         password: ""
     },
     api: "",
+    erp_api: "",
     debug: true,
     refresh: false
 })

+ 48 - 0
www/js/start/directive.js

@@ -381,4 +381,52 @@ starter.directive('itemMember', function (Dept) {
             }
         }
     }
+}])
+
+.directive('resetField', ['$compile', '$timeout', function($compile, $timeout) {
+    return {
+        require: 'ngModel',
+        scope: {},
+        link: function(scope, el, attrs, ctrl) {
+            // limit to input element of specific types
+            var inputTypes = /text|search|tel|url|email|password/i;
+            if (el[0].nodeName === "INPUT") {
+                if (!inputTypes.test(attrs.type)) {
+                    throw new Error("Invalid input type for resetField: " + attrs.type);
+                }
+            } else if (el[0].nodeName !== "TEXTAREA") {
+                throw new Error("resetField is limited to input and textarea elements");
+            }
+
+            // compiled reset icon template
+            var template = $compile('<i ng-show="enabled" ng-click="reset()" class="icon ion-android-close reset-field-icon"></i>')(scope);
+            el.addClass("reset-field");
+            el.after(template);
+
+            scope.reset = function() {
+                ctrl.$setViewValue(null);
+                ctrl.$render();
+                $timeout(function() {
+                    el[0].focus();
+                }, 0, false);
+                scope.enabled = false;
+            };
+
+            el.bind('input', function() {
+                scope.enabled = !ctrl.$isEmpty(el.val());
+            })
+            .bind('focus', function() {
+                $timeout(function() { //Timeout just in case someone else is listening to focus and alters model
+                    scope.enabled = !ctrl.$isEmpty(el.val());
+                    scope.$apply();
+                }, 0, false);
+            })
+            .bind('blur', function() {
+                $timeout(function() {
+                    scope.enabled = false;
+                    scope.$apply();
+                }, 0, false);
+            });
+        }
+    };
 }])

Some files were not shown because too many files changed in this diff