Browse Source

处理客户资料详情分配问题

wangcz 7 years ago
parent
commit
429c731874

+ 2 - 0
src/main/webapp/resources/js/common/services.js

@@ -155,6 +155,8 @@ define([ 'angular', 'common/utils', 'big'], function(angular, utils, Big) {
                         $rootScope.b2bUrl = 'https://test-b2b.uuzcc.cn'
 					} else if (this.getRootPath().indexOf('rel-b2c.uuzcc.cn') > -1 || this.getRootPath().indexOf('rel-mall.uuzcc.cn') > -1) {
                         $rootScope.b2bUrl = 'https://rel-b2b.uuzcc.cn'
+                    } else if (this.getRootPath().indexOf('pre-b2c.uuzcc.cn') > -1 || this.getRootPath().indexOf('pre-mall.uuzcc.cn') > -1) {
+                        $rootScope.b2bUrl = 'https://pre-b2b.uuzcc.cn'
                     } else if (this.getRootPath().indexOf('b2c.usoftchina.com') > -1 || this.getRootPath().indexOf('mall.usoftchina.com') > -1) {
                         $rootScope.b2bUrl = 'https://b2b.usoftchina.com'
 					} else {

+ 107 - 73
src/main/webapp/resources/js/vendor/controllers/b2b/sale/saleCustomerDetailCtrl.js

@@ -160,6 +160,9 @@ define(['app/app'], function (app) {
                     resolve: {
                         customer: function () {
                             return $scope.customerInfo;
+                        },
+                        thisUser: function () {
+                            return $scope.thisUser
                         }
                     }
                 });
@@ -185,87 +188,118 @@ define(['app/app'], function (app) {
         }
     }]);
 
-    app.register.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'B2bAccountUser', 'toaster', function ($scope, $modalInstance, customer, AccountUser, toaster) {
-        $scope.checkboxes = {
-            checked: false
-        };
-        $scope.loading = true;
-        $scope.distribute = [];
-        AccountUser.findUsers({uu: customer.myEnterprise.uu}, null, function (data) {
-            $scope.userinfos = data;
-            var distribute = [];
-            angular.forEach($scope.userinfos, function (user, index) {
-                if (user.distribute) {
-                    distribute.push({num: index});
+    app.register.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'B2bAccountUser', 'toaster', 'ngTableParams', 'BaseService', 'thisUser',
+        function ($scope, $modalInstance, customer, AccountUser, toaster, ngTableParams, BaseService, thisUser) {
+            $scope.checkboxes = {
+                checked: false
+            };
+            $scope.thisUser = thisUser;
+            $scope.userParams = new ngTableParams({
+                page: 1,
+                count: 10,
+                sorting: {}
+            }, {
+                total: 0,
+                counts:[5,10,15,25,50],
+                getData: function ($defer, params) {
+                    $scope.loading = true;
+                    $scope.distribute = [];
+                    var pageParams = params.url();
+                    pageParams.keyword = $scope.keyword;
+                    pageParams.id = customer.id
+                    AccountUser.findUsers(BaseService.parseParams(pageParams), function (data) {
+                        $scope.loading = false;
+                        if(data) {
+                            $defer.resolve(data.content);
+                            $scope.userinfos = data.content;
+                            var distribute = [];
+                            angular.forEach($scope.userinfos, function (user, index) {
+                                if (user.distribute) {
+                                    distribute.push({num: index});
+                                }
+                            });
+                            $scope.distribute = distribute;
+                            $scope.havedone = angular.copy($scope.distribute);
+                            $scope.total = data.totalElement;
+                            params.total(data.totalElement);
+                            $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
+                        }
+                    }, function (err) {
+                        $scope.loading = false;
+                        toaster.pop('error', '数据加载失败', err.data);
+                    });
                 }
             });
-            $scope.distribute = distribute;
-            $scope.havedone = angular.copy($scope.distribute);
-            $scope.loading = false;
-        })
 
-        var checkStatus = function (userinfos) {
-            var distribute = [];
-            angular.forEach(userinfos, function (user, index) {
-                if (user.distribute) {
-                    distribute.push({num: index});
-                }
-            });
-            $scope.distribute = distribute;
-            $scope.isChanged = !angular.equals($scope.havedone, $scope.distribute);
-        }
-        $scope.isChanged = false;
-        $scope.isChangedAll = false;
-        $scope.changes = [];
-        // 点击勾选全部的复选框
-        $scope.checkAll = function () {
-            angular.forEach($scope.userinfos, function (item, index) {
-                item.distribute = $scope.checkboxes.checked;
-            });
-            checkStatus($scope.userinfos);
-        };
+            $scope.onSearch = function () {
+                $scope.userParams.page(1);
+                $scope.userParams.reload();
+                $scope.isChanged = false;
+                $scope.isChangedAll = false;
+            };
 
-        // 点击其中一个明细的复选框
-        $scope.checkOne = function () {
-            var result = true;
-            angular.forEach($scope.userinfos, function (item) {
-                if (item.distribute != true) {
-                    result = false;
-                    return;
-                }
-            });
-            $scope.checkboxes.checked = result;
-            checkStatus($scope.userinfos);
-        };
-        $scope.close = function (save) {
-            var chooseResult = [];
-            if (save) {
-                if (customer.myEnterprise.uu) {
-                    angular.forEach($scope.userinfos, function (item, i) {
-                        chooseResult.push(item);
-                    });
-                    if (chooseResult.length > 0) {
-                        $scope.loading = true;
-                        AccountUser.addUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
-                            $scope.loading = false;
-                            toaster.pop('success', '提示', '保存成功');
-                            $modalInstance.close(false);
-                        }, function (response) {
-                            $scope.loading = false;
-                            toaster.pop('error', '保存失败', response.data);
-                            $modalInstance.close(false);
-                        })
+            var checkStatus = function (userinfos) {
+                var distribute = [];
+                angular.forEach(userinfos, function (user, index) {
+                    if (user.distribute) {
+                        distribute.push({num: index});
+                    }
+                });
+                $scope.distribute = distribute;
+                $scope.isChanged = !angular.equals($scope.havedone, $scope.distribute);
+            }
+            $scope.isChanged = false;
+            $scope.isChangedAll = false;
+            $scope.changes = [];
+            // 点击勾选全部的复选框
+            $scope.checkAll = function () {
+                angular.forEach($scope.userinfos, function (item, index) {
+                    item.distribute = $scope.checkboxes.checked;
+                });
+                checkStatus($scope.userinfos);
+            };
+
+            // 点击其中一个明细的复选框
+            $scope.checkOne = function () {
+                var result = true;
+                angular.forEach($scope.userinfos, function (item) {
+                    if (item.distribute != true) {
+                        result = false;
+                        return;
+                    }
+                });
+                $scope.checkboxes.checked = result;
+                checkStatus($scope.userinfos);
+            };
+            $scope.close = function (save) {
+                var chooseResult = [];
+                if (save) {
+                    if (customer.id) {
+                        angular.forEach($scope.userinfos, function (item, i) {
+                            chooseResult.push(item);
+                        });
+                        if (chooseResult.length > 0) {
+                            $scope.loading = true;
+                            AccountUser.addUserToVendor({id: customer.id}, chooseResult, function (data) {
+                                $scope.loading = false;
+                                toaster.pop('success', '提示', '保存成功');
+                                $modalInstance.close(false);
+                            }, function (response) {
+                                $scope.loading = false;
+                                toaster.pop('error', '保存失败', response.data);
+                                $modalInstance.close(false);
+                            })
+                        } else {
+                            toaster.pop('error', '保存失败', "您未勾选任何记录");
+                        }
                     } else {
-                        toaster.pop('error', '保存失败', "您未勾选任何记录");
+                        $modalInstance.close(true, $scope.checkboxes.checked);
                     }
                 } else {
-                    $modalInstance.close(true, $scope.checkboxes.checked);
+                    $modalInstance.close(false);
                 }
-            } else {
-                $modalInstance.close(false);
-            }
-        };
+            };
 
-    }]);
+        }]);
 
 });