فهرست منبع

处理供应商增加分配与转移

wangcz 7 سال پیش
والد
کامیت
3b1905ad8a

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

@@ -369,10 +369,23 @@ define(['angular', 'toaster', 'big'], function(angular, big) {
                 method: 'POST',
                 isArray: true
             },
+            findSaleUsers: {
+                url: 'vendor/distribute/:id',
+                method: 'POST',
+                isArray: true
+            },
+            addSaleUserToVendor: {
+                url: 'vendor/bindVendor/:uu',
+                method: 'POST'
+            },
             addUserToVendor: {
                 url: 'account/user/bindUserToVendor/:uu',
                 method: 'POST'
             },
+            transferSaleUserToVendor: {
+                url: 'vendor/bindUserToVendor/:uu',
+                method: 'POST'
+            },
             transferUserToVendor: {
                 url: 'account/user/transferUserToVendor/:uu',
                 method: 'POST'

+ 173 - 11
src/main/webapp/resources/js/index/app.js

@@ -2156,6 +2156,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         resolve: {
                             customer: function () {
                                 return customer;
+                            },
+                            type: function () {
+                                return 'purchase'
                             }
                         }
                     });
@@ -2193,6 +2196,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         resolve: {
                             customer: function () {
                                 return customer;
+                            },
+                            type: function () {
+                                return 'purchase'
                             }
                         }
                     });
@@ -2440,6 +2446,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                     resolve: {
                         customer: function () {
                             return $scope.customerInfo;
+                        },
+                        type: function () {
+                            return 'purchase'
                         }
                     }
                 });
@@ -2466,18 +2475,32 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         }
     }]);
 
-    app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService',
-        function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
+    app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type',
+        function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type) {
         AuthenticationService.getAuthentication().success(function (data) {
             $scope.thisUser = data;
         });
 
+        var urlData, urlSaveData, uuData;
+        var params = {};
+        if (type === 'sale') {
+            params = {id : customer.id};
+            urlSaveData = 'addSaleUserToVendor';
+            urlData = 'findSaleUsers';
+            uuData = customer.vendorEnterprise.uu;
+        } else {
+            params = {uu : customer.myEnterprise.uu};
+            urlSaveData = 'addUserToVendor';
+            urlData = 'findUsers';
+            uuData = customer.myEnterprise.uu;
+        }
+
         $scope.checkboxes = {
             checked: false
         };
         $scope.loading = true;
         $scope.distribute = [];
-        AccountUser.findUsers({uu: customer.myEnterprise.uu}, null, function (data) {
+        AccountUser[urlData](params, null, function (data) {
             $scope.userinfos = data;
             var distribute = [];
             angular.forEach($scope.userinfos, function (user, index) {
@@ -2526,13 +2549,13 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         $scope.close = function (save) {
             var chooseResult = [];
             if (save) {
-                if (customer.myEnterprise.uu) {
+                if (uuData) {
                     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) {
+                        AccountUser[urlSaveData]({uu: uuData}, chooseResult, function (data) {
                             $scope.loading = false;
                             toaster.pop('success', '提示', '保存成功');
                             $modalInstance.close(false);
@@ -2555,7 +2578,21 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     }]);
 
     // 转移权限
-    app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
+    app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type) {
+        var urlData, urlSaveData, uuData;
+        var params = {};
+        if (type === 'sale') {
+            params = {id : customer.id};
+            urlSaveData = 'transferSaleUserToVendor';
+            urlData = 'findSaleUsers';
+            uuData = customer.vendorEnterprise.uu;
+        } else {
+            params = {uu : customer.myEnterprise.uu};
+            urlSaveData = 'transferUserToVendor';
+            urlData = 'findUsers';
+            uuData = customer.myEnterprise.uu;
+        }
+
         AuthenticationService.getAuthentication().success(function (data) {
             $scope.loading = false;
             $scope.thisUser = data;
@@ -2565,7 +2602,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
         $scope.loading = true;
         $scope.transfer = [];
-        AccountUser.findUsers({uu: customer.myEnterprise.uu}, {}, function (data) {
+        AccountUser[urlData](params, {}, function (data) {
             $scope.userinfos = data;
             var transfer = [];
             angular.forEach($scope.userinfos, function (user, index) {
@@ -2642,7 +2679,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         $scope.close = function (save) {
             var chooseResult = [];
             if (save) {
-                if (customer.myEnterprise.uu) {
+                if (uuData) {
                     // 当前用户是管理员时
                     if ($scope.thisUser.sys) {
                         angular.forEach($scope.userinfos, function (item, i) {
@@ -2650,7 +2687,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         });
                         if (chooseResult.length > 0) {
                             $scope.loading = true;
-                            AccountUser.transferUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
+                            AccountUser[urlSaveData]({uu: uuData}, chooseResult, function (data) {
                                 $scope.loading = false;
                                 toaster.pop('success', '提示', '保存成功');
                                 $modalInstance.close(false);
@@ -2663,6 +2700,10 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                             toaster.pop('error', '保存失败', "您未勾选任何记录");
                         }
                     } else {
+                        if(type === 'sale') {
+                            toaster.pop('info', '提示', "您没有权限转移对象");
+                            return
+                        }
                         // 非管理员转移自己的权限时
                         angular.forEach($scope.userinfos, function (item, i) {
                             if (item.transfer && item.userUU !== $scope.thisUser.userUU) {
@@ -2673,7 +2714,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                             toaster.pop('error', '保存失败', "您未选择权限转移对象");
                         } else {
                             $scope.loading = true;
-                            AccountUser.transferMyDistribute({custUU: customer.myEnterprise.uu, userUU: $scope.target.userUU}, {} ,function (data) {
+                            AccountUser.transferMyDistribute({custUU: uuData, userUU: $scope.target.userUU}, {} ,function (data) {
                                 $scope.loading = false;
                                 toaster.pop('success', '提示', '保存成功');
                                 $modalInstance.close(false);
@@ -14591,6 +14632,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                     resolve: {
                         customer: function () {
                             return customer;
+                        },
+                        type: function () {
+                            return 'purchase'
                         }
                     }
                 });
@@ -14694,7 +14738,125 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         $scope.purcByEn = function (businessCode) {
             $rootScope.businessCode = businessCode;
             window.location.hash = "#/purc/addOrder";
-        }
+        };
+
+        // 分配用户
+        $scope.addUserInfo = function (customer) {
+            var modalInstance = $modal.open({
+                animation: true,
+                templateUrl: 'static/tpl/index/account/add_userInfo.html',
+                controller: 'AddUserInfoCtrl',
+                resolve: {
+                    customer: function () {
+                        return customer;
+                    },
+                    type: function () {
+                        return 'sale'
+                    }
+                }
+            });
+            modalInstance.result.then(function (changed, checked) {
+                if (changed) {
+                    if (checked)
+                        $scope.newUser.roles = checked;
+                    else
+                        loadUsers();
+                }
+                $scope.customerParams.reload();
+            });
+            // if (!$scope.enabled) {
+            //     toaster.pop('error', '您没有为当前客户分配用户的权限!');
+            //     return;
+            // }
+            // 获取当前用户在当前企业是否被转移权限
+            // AccountUser.getEnTransfer({custUU: customer.myEnterprise.uu}, function (data) {
+            //     customer.enTransfer = data.result;
+            //     //是管理员,或者被转移了权限时
+            //     if ($scope.enabled || customer.enTransfer) {
+            //         var modalInstance = $modal.open({
+            //             animation: true,
+            //             templateUrl: 'static/tpl/index/account/add_userInfo.html',
+            //             controller: 'AddUserInfoCtrl',
+            //             resolve: {
+            //                 customer: function () {
+            //                     return customer;
+            //                 }
+            //             }
+            //         });
+            //         modalInstance.result.then(function (changed, checked) {
+            //             if (changed) {
+            //                 if (checked)
+            //                     $scope.newUser.roles = checked;
+            //                 else
+            //                     loadUsers();
+            //             }
+            //             $scope.customerParams.reload();
+            //         });
+            //     } else {
+            //         toaster.pop('error', '您没有为当前客户分配用户的权限!');
+            //     }
+            // });
+        };
+
+        // 转移权限
+        $scope.transferUserInfo = function (customer) {
+            var modalInstance = $modal.open({
+                animation: true,
+                templateUrl: 'static/tpl/index/account/transfer_userInfo.html',
+                controller: 'TransferUserInfoCtrl',
+                resolve: {
+                    customer: function () {
+                        return customer;
+                    },
+                    type: function () {
+                        return 'sale'
+                    }
+                }
+            });
+            modalInstance.result.then(function (changed, checked) {
+                if (changed) {
+                    if (checked)
+                        $scope.newUser.roles = checked;
+                    else
+                        loadUsers();
+                }
+                $scope.customerParams.reload();
+            });
+
+            // customer.enDistribute = null;
+            // if (!$scope.enabled) {
+            //     toaster.pop('error', '您没有转移当前客户权限的权限!');
+            //     return;
+            // }
+            // 获取当前用户在当前企业是否被转移权限
+            // AccountUser.getDistribute ({custUU: customer.myEnterprise.uu}, function(data) {
+            //     customer.enDistribute = data.result;
+            //     //是管理员,或者被分配时
+            //     if ($scope.enabled || customer.enDistribute) {
+            //         var modalInstance = $modal.open({
+            //             animation: true,
+            //             templateUrl: 'static/tpl/index/account/transfer_userInfo.html',
+            //             controller: 'TransferUserInfoCtrl',
+            //             resolve: {
+            //                 customer: function () {
+            //                     return customer;
+            //                 }
+            //             }
+            //         });
+            //         modalInstance.result.then(function (changed, checked) {
+            //             if (changed) {
+            //                 if (checked)
+            //                     $scope.newUser.roles = checked;
+            //                 else
+            //                     loadUsers();
+            //             }
+            //             $scope.customerParams.reload();
+            //         });
+            //     } else {
+            //         toaster.pop('error', '您没有转移当前客户权限的权限!');
+            //     }
+            // });
+        };
 
     }]);
 

+ 13 - 9
src/main/webapp/resources/tpl/index/purc/vendor.html

@@ -111,13 +111,12 @@
 			ng-table="customerParams">
 			<thead>
 				<tr class="pane-header">
-					<th width="80" class="text-center">UU</th>
-					<th width="180" class="text-center">供应商名称</th>
-					<th width="120" class="text-center">简称</th>
+					<th width="250" class="text-center">供应商名称</th>
 					<th width="200" class="text-center">地址</th>
 					<th width="100" class="text-center">联系人</th>
-					<th width="80" class="text-center">联系电话</th>
-					<th width="170" class="text-center">操作</th>
+					<th width="80" class="text-center">供应商电话</th>
+					<th width="200" class="text-center">采购对接人</th>
+					<th width="100" class="text-center">操作</th>
 				</tr>
 			</thead>
 			<tbody ng-if="$data.length === 0">
@@ -137,15 +136,20 @@
 			</tbody>
 			<tbody>
 					<tr ng-repeat="vendor in $data">
-						<td ng-bind="::vendor.vendorEnterprise.uu"></td>
 						<td class="text-center"><a href="#/purc/vendor/{{vendor.id}}" ng-bind="::vendor.vendorEnterprise.enName" title="查看供应商资料" class="color32 order-detail"></a></td>
-						<td class="text-center" ng-bind="::vendor.vendorEnterprise.enShortname"></td>
 						<td class="text-center" ng-bind="::vendor.vendorEnterprise.enAddress"></td>
 						<td class="text-center" ng-bind="::vendor.vendorUser.userName"></td>
 						<td class="text-center" ng-bind="::vendor.vendorUser.userTel"></td>
 						<td class="text-center">
-							<a ng-click="purcByEn(vendor.vendorEnterprise.enBussinessCode)">下采购单</a>
-							<a href="#/purc/purcinquiry/{{vendor.vendorEnterprise.enBussinessCode}}">立即询价</a>
+							<span ng-repeat="users in vendor.saleContacts | limitTo: 3">{{users}}<br/></span>
+							<span ng-if="vendor.saleContacts.length > 3">...</span>
+							<span ng-if="!vendor.saleContacts || vendor.saleContacts.length === 0">-</span>
+						</td>
+						<td class="text-center">
+							<a ng-click="purcByEn(vendor.vendorEnterprise.enBussinessCode)">下采购单</a><br/>
+							<a href="#/purc/purcinquiry/{{vendor.vendorEnterprise.enBussinessCode}}">立即询价</a><br/>
+							<a title="被分配的用户享有查看和操作权限" ng-click="addUserInfo(vendor)">分配</a><br/>
+							<a title="被转移权限的用户可以分配权限给其他用户" ng-click="transferUserInfo(vendor)">转移</a>
 						</td>
 					</tr>
 			</tbody>

+ 9 - 7
src/main/webapp/resources/tpl/index/sale/customer.html

@@ -119,23 +119,25 @@
 			ng-table="customerParams">
 			<thead>
 				<tr class="header">
-					<th width="80">UU</th>
-					<th width="180">客户名称</th>
+					<th width="190">客户名称</th>
 					<th width="180">地址</th>
 					<th width="80">客户联系人</th>
-					<th width="100">联系人电话</th>
-					<th width="80">我方联系人</th>
-					<th width="110">用户分配</th>
+					<th width="100">客户电话</th>
+					<th width="160">业务对接人</th>
+					<th width="100">用户分配</th>
 				</tr>
 			</thead>
 			<tbody ng-repeat="customer in $data" ng-mouseenter="showUserInfo(customer,true)" ng-mouseleave="showUserInfo(customer,false)">
 					<tr>
-						<td class="text-center" ng-bind="::customer.myEnterprise.uu"></td>
 						<td class="text-center"><a ng-click="viewDetail(customer.id)" title="查看客户资料" ng-bind="::customer.myEnterprise.enName" class="color32 order-detail"></a></td>
 						<td class="text-center" ng-bind="::customer.myEnterprise.enAddress"></td>
 						<td class="text-center" ng-bind="::customer.myUser.userName"></td>
 						<td ng-bind="::customer.myUser.userTel"></td>
-						<td class="text-center" ng-bind="::customer.vendorUser.userName"></td>
+						<td class="text-center">
+							<span ng-repeat="users in customer.purchaseContacts | limitTo: 3">{{users}}<br/></span>
+							<span ng-if="customer.purchaseContacts.length > 3">...</span>
+							<span ng-if="!customer.purchaseContacts || customer.purchaseContacts.length === 0">-</span>
+						</td>
 						<td class="text-center">
 								<!--<a title="展开" class="text-muted" ng-click="open(customer,$index)"><i class="fa fa-toggle-down fa-lg"></i></a>-->
 								<!--<a ng-click="viewDetail(customer.id)">查看详情</a><br/>-->