Просмотр исходного кода

批量发货翻页记录以前的选择不清除

hejq 8 лет назад
Родитель
Сommit
dd6914bac9

+ 11 - 0
src/main/java/com/uas/platform/b2b/controller/SaleNoticeController.java

@@ -871,4 +871,15 @@ public class SaleNoticeController {
 		modelMap.put("all", all);
 		return modelMap;
 	}
+
+    /**
+     * 通过前端传输的id数组增加
+     * @param ids
+     * @return
+     */
+	@RequestMapping(value = "/findByIds", method = RequestMethod.GET)
+    @ResponseBody
+    public List<PurchaseNotice> findByIds(@RequestBody List<Long> ids) {
+        return null;
+    }
 }

+ 58 - 4
src/main/webapp/resources/js/index/app.js

@@ -6503,6 +6503,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             $scope.isUser = data.isUser;
         });
 
+        // 用来记录已经选择的id
+        $rootScope.ids = [];
+
         $scope.active = 'todo';
         $scope.currency = Symbol.currency;
         $scope.dateZoneText = '不限';
@@ -6564,6 +6567,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
                         $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
                         $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
+
+                        angular.forEach(page.content, function (notice) {
+                            if ($rootScope.ids.indexOf(notice.id) > -1) {
+                                notice.$selected = true;
+                            }
+                        });
                     }
                 }, function (response) {
                     $scope.loading = false;
@@ -6699,13 +6708,47 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         $scope.checkboxes = {
             checked: false
         };
+        angular.forEach($scope.tableParams.data, function (item) {
+            $scope.checkboxes.checked = false;
+            if($rootScope.ids.in_array(item.id)) {
+                $rootScope.ids.remove(item.id);
+                $scope.checkboxes.checked = true;
+            }
+        });
 
         // 点击勾选全部的复选框
         $scope.checkAll = function () {
             angular.forEach($scope.tableParams.data, function (item) {
-                if (!item.waiting)
+                if (!item.waiting) {
                     item.$selected = $scope.checkboxes.checked;
+                    if(item.$selected) {
+                        if(!$rootScope.ids.in_array(item.id)) {
+                            $rootScope.ids.push(item.id);
+                        }
+                    } else {
+                       if($rootScope.ids.in_array(item.id)) {
+                           $rootScope.ids.remove(item.id);
+                       }
+                    }
+
+                }
             });
+            console.log($rootScope.ids);
+        };
+
+        // 判断数组中是否存在某个对象
+        Array.prototype.S = String.fromCharCode(2);
+        Array.prototype.in_array = function(e) {
+            var r = new RegExp(this.S + e + this.S);
+            return (r.test(this.S + this.join(this.S) + this.S));
+        }
+
+        // 从数组中移除某个对象
+        Array.prototype.remove = function(val) {
+            var index = this.indexOf(val);
+            if (index > -1) {
+                this.splice(index, 1);
+            }
         };
 
         // 点击其中一个明细的复选框
@@ -6717,7 +6760,15 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                     return;
                 }
             });
-            $scope.checkboxes.checked = result;
+            if(order.$selected) {
+                if(!$rootScope.ids.in_array(order.id)) {
+                    $rootScope.ids.push(order.id);
+                }
+            } else {
+                if($rootScope.ids.in_array(order.id)) {
+                    $rootScope.ids.remove(order.id);
+                }
+            }
         };
 
         // 打开批量发货模态框
@@ -6733,7 +6784,10 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     				},
     				token: function() {
     					return $scope.token;
-    				}
+    				},
+                    ids: function() {
+                        return $rootScope.ids;
+                    }
     			}
     		});
 			 modalInstance.result.then(function () {
@@ -6829,7 +6883,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         }
     }]);
 
-    app.controller('SaleNoticeSendByBatchCtrl', ['$scope', '$modalInstance', 'Symbol', 'selectedNotices', 'PurcNotice', 'toaster', '$state', '$timeout', 'token', function ($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster, $state, $timeout, token) {
+    app.controller('SaleNoticeSendByBatchCtrl', ['$scope', '$modalInstance', 'Symbol', 'selectedNotices', 'PurcNotice', 'toaster', '$state', '$timeout', 'token', 'ids', function ($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster, $state, $timeout, token, ids) {
         $scope.notices = angular.copy(selectedNotices);
         $scope.currency = Symbol.currency;//将币别转化为对应的符号
         $scope.saleSend = {

+ 6 - 1
src/main/webapp/resources/js/index/services/Purc.js

@@ -856,7 +856,12 @@ define([ 'ngResource'], function() {
 			exportXls: {
 				url: 'sale/notice/xls/permission',
 				method: 'GET'
-			}
+			},
+            findByIds: {
+			    url: 'sale/notice/findByIds',
+                method: 'GET',
+                isArray: true
+            }
 		});
     }]).factory('PurcNoticeInfo', ['$resource', function($resource) {
         return $resource('sale/notice/info/search', {}, {

+ 2 - 3
src/main/webapp/resources/tpl/index/sale/notice.html

@@ -338,7 +338,7 @@
             <td class="first" colspan="3">
                 <div class="order-main">
 					<span> <input type="checkbox" ng-disabled="notice.waiting" class="selector"
-                                         ng-model="notice.$selected" ng-click="checkOne(notice)">
+                              ng-model="notice.$selected" ng-click="checkOne(notice)">
 					</span>
                     <a href="javascript:void(0)" ng-if="!isUnread(notice.id)">
                         <i class="fa fa-circle-thin"></i>
@@ -348,8 +348,7 @@
                     </a>&nbsp;&nbsp;
                     <span class="text-num text-bold"
                           ng-bind="::notice.date | date:'yyyy-MM-dd'"></span>
-                    <span
-                            ng-bind="notice.orderItem.order.enterprise.enName"></span>
+                    <span ng-bind="notice.orderItem.order.enterprise.enName"></span>
                 </div>
             </td>
             <td class="text-right" colspan="2" class="order-sum"><a title="查看采购单详情"