فهرست منبع

修改采购订单

shenjj 8 سال پیش
والد
کامیت
a70b6b9a7a

+ 131 - 0
src/main/webapp/resources/js/common/b2bServices.js

@@ -951,4 +951,135 @@ define([ 'angular', 'common/services', 'common/utils', 'big'], function(angular,
             }
           });
         }])
+        .factory('B2bPagingRelease', ['$resource', 'BaseService', function($resource, BaseService){
+          var b2bPath = BaseService.getB2bUrl();
+          return $resource(b2bPath + 'api/paging', {}, {
+            getTodo: {
+              params: {
+                _state: 'todo'
+              }
+            },
+            getDone:{
+              params: {
+                _state: 'done'
+              }
+            },
+            // 设置消息已读(公共消息服务)
+            setMessageRead: {
+              url: b2bPath + 'api/paging/message/setRead',
+              method: 'POST'
+            },
+            // 设置当前页已读(公共消息服务)
+            setPageRead: {
+              url: b2bPath + 'api/paging/message/setRead/page',
+              method: 'POST'
+            },
+            setRead:{
+              url: b2bPath + 'api/paging/setRead',
+              method: 'POST'
+            },
+            getUnreadIds:{
+              url: b2bPath + 'api/paging/getUnreadIds',
+              method: 'POST'
+            },
+            setReadByOrder:{
+              url: b2bPath + 'api/paging/setRead/order',
+              method: 'POST'
+            },
+            setOneRead:{
+              url: b2bPath + 'api/paging/setOneRead/:id',
+              method: 'POST'
+            }
+          });
+        }])
+        .factory('B2bSnapshotService', ['$http', 'BaseService', function($http, BaseService) {
+          var rootPath = BaseService.getB2bUrl();
+          return {
+            getTodo: function(success) {
+              var request = $http.get(rootPath + '/snapshot/todo', {cache: true});
+              request.success(function(data) {
+                success.call(null, data);
+              });
+            },
+            getUnread: function(type, success) {
+              var request = $http.get(rootPath + '/snapshot/unread/'+(type==null?'all':type), {cache: false});
+              request.success(function(data) {
+                success.call(null, data);
+              });
+            },
+            getNotice: function(count, useruu, success) {
+              var request = $http.get(rootPath + '/public/notice?page=1&count=' + count + '&useruu=' + useruu); // NoticeController.java
+              request.success(function(data) {
+                success.call(null, data.content);
+              });
+            },
+            getOpenTender: function(count, success) {
+              var request = $http.get(rootPath + '/tender/latestOpenTender?page=1&count=' + count);
+              request.success(function(data) {
+                success.call(null, data.content);
+              });
+            },
+            getMessage: function(success) {
+              var request = $http.get(rootPath + '/snapshot/message');
+              request.success(function(data) {
+                success.call(null, data);
+              });
+            },
+            setNoticeStatusAfterRead: function (id, useruu, success) {
+              var url = rootPath + '/public/notice/setReadStatus?id=' + id + '&useruu=' + useruu;
+              $http({method: 'post', url: url, headers:{'Content-Type': 'application/json'},
+              }).success(function () {
+                success.call(null);
+              });
+
+            }
+          };
+        }])
+        .factory('B2bPurcOrderItemInfo', ['$resource', 'BaseService', function($resource, BaseService){
+          var rootPath = BaseService.getB2bUrl();
+          return $resource(rootPath + 'sale/orders/info/nosearch', {}, {
+            getTodo: {
+              params: {
+                _state: 'todo'
+              }
+            },
+            getDone: {
+              params: {
+                _state: 'done'
+              }
+            },
+            getEnd: {
+              params: {
+                _state: 'end'
+              }
+            },
+            getReceived:{
+              params: {
+                _state: 'received'
+              }
+            },
+            getWaiting: {
+              params: {
+                _state: 'waiting'
+              }
+            },
+            getPublicInquiry: {
+              params: {
+                _state: 'teams'
+              }
+            },
+            getUnreadIds:{
+              url: rootPath + 'sale/orders/getUnreadIds',
+              method: 'GET'
+            },
+            getUnreadCount:{
+              url: rootPath + 'sale/orders/unread',
+              method: 'GET'
+            },
+            setRead:{
+              url:rootPath +  'sale/orders/setRead',
+              method: 'POST'
+            }
+          });
+        }])
 });

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

@@ -151,7 +151,8 @@ define([ 'angular', 'common/utils', 'big'], function(angular, utils, Big) {
 					// defer.promise.then(function (resolve) {
 					// 	$rootScope.b2bUrl = resolve.url;
 					// });
-					$rootScope.b2bUrl = this.getRootPath().indexOf('usoftmall.com') > -1 ? 'http://uas.ubtob.com' : 'http://192.168.253.12:9000/b2b-test';
+          // http://192.168.253.12:9000/b2b-test
+					$rootScope.b2bUrl = this.getRootPath().indexOf('usoftmall.com') > -1 ? 'http://uas.ubtob.com' : 'http://10.1.51.91:8090/platform-b2b/';
 				}
 				return $rootScope.b2bUrl;
 			}

+ 445 - 409
src/main/webapp/resources/js/vendor/controllers/b2b/saleOrderCtrl.js

@@ -10,419 +10,455 @@ define(['app/app'], function (app) {
     /**
      * 客户采购订单
      */
-    app.register.controller('saleOrderCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', '$timeout', '$modal', 'B2bSearchFilter', '$http', '$rootScope', 'B2bCommerce',
-        function ($scope, $filter, ngTableParams, toaster, BaseService, $timeout, $modal, SearchFilter, $http, $rootScope, B2bCommerce) {
-            BaseService.scrollBackToTop();
-            $rootScope.active = 'vendor_order';
-            $rootScope.autoMonth = false;
-            $scope.storeType = 'order';
-            $scope.active = 'todo';
-            $scope.dateZoneText = '不限';
-            $scope.deliveryZoneText = '不限';
-            $scope.condition = {dateZone: 1, deliveryZone: -1};
-            /* 时间筛选初始化*/
-            var fromDate = new Date();
-            var toDate = new Date();
-            fromDate.setMonth(fromDate.getMonth() - 1);
-            fromDate.setHours(0, 0, 0, 0);
-            toDate.setHours(23, 59, 59, 999);
-            $scope.condition.dateFrom = fromDate;
-            $scope.condition.dateTo = toDate;
-
-            $scope.changeDateZone = function (zone) {
-                $scope.condition.dateZone = zone;
-                $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
-                $scope.condition.$dateZoneOpen = false;
-                SearchFilter.getDateCondition(zone, $scope.condition);
-                $scope.tableParams.page(1);
-                $scope.tableParams.reload();
-            };
-            $scope.changeDeliveryZone = function (zone) {
-                $scope.condition.deliveryZoneText = zone;
-                $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
-                $scope.condition.$delievryZoneOpen = false;
-                SearchFilter.getDeliveryCondition(zone, $scope.condition);
-                $scope.tableParams.reload();
-            };
-            $scope.nowdate = new Date();
-            // 切换单据类型
-            $scope.setActive = function (state) {
-                if ($scope.active != state) {
-                    $scope.active = state;
-                    if ($scope.tableParams.page() == 1)
-                        $scope.tableParams.reload();
-                    else
-                        $scope.tableParams.page(1);
-                }
-            };
-
-            // 打开日期选择框
-            $scope.openChooseDatePicker = function ($event, item, openParam, status) {
-                if (status != null) {
-                    if (status == 1) {
-                        if ($scope.startDate != null) {
-                            return;
-                        }
-                    }
-                    if (status == 2) {
-                        if ($scope.endDate != null) {
-                            return;
-                        }
-                    }
-                }
-                $event.preventDefault();
-                $event.stopPropagation();
-                item[openParam] = !item[openParam];
-                if (openParam == 'startDateOpen'){
-                    if (item['endDateOpen']){
-                        item['endDateOpen'] = !item['endDateOpen'];
-                    }
-                } else if(openParam == 'endDateOpen'){
-                    if (item['startDateOpen']){
-                        item['startDateOpen'] = !item['startDateOpen'];
-                    }
-                }
-            };
-
-            // 选择查找日期
-            $scope.onDateCondition = function () {
-                $scope.param.page = 1;
-                $scope.tableParams.page(1);
-                $scope.tableParams.reload();
-            };
-
-            /**
-             *  先获取B2B访问路径再进行下一步操作
-             */
-            B2bCommerce.accessUrl({}, function (data) {
-                var b2bUrl = data.url;
-
-                // 分页获取列表数据
-                 $scope.tableParams = new ngTableParams({ // ng-Table参数
-                     page: 1,
-                     count: 20,
-                     sorting: {
-                         date: 'desc',
-                         id: 'desc'
-                     }
-                     }, {
-                     total: 0,
-                     counts: [5, 10, 15, 25, 50],
-                     getData: function ($defer, params) { // 获取数据的方法
-                        $scope.loading = true;
-                        var param = BaseService.parseParams(params.url());
-                         param.searchFilter = { // 筛选条件
-                            keyword: $scope.keyword,
-                            fromDate: SearchFilter.getDateTime($scope.condition.dateFrom),
-                            endDate: SearchFilter.getDateTime($scope.condition.dateTo)
-                         };
-                         param._state = $scope.active;
-                        $http({
-                            method: 'get',
-                            dataType: 'json',
-                            url: b2bUrl + "/sale/orders/info/nosearch",
-                            params: param
-                        }).success(function (data) {
-                            params.total(data.totalElement);
-                            $defer.resolve(data.content);
-                            $scope.searchFilterXls = angular.copy(param.searchFilter);//保存当前取值的条件
-                        }).error(function (response) {
-                            toaster.pop('error', response);
-                        });
-                     }
-                 });
-
-                //获得各分类未阅读数量
-                /* var getUnreadCount = function () {
-                 PurcOrderItem.getUnreadCount(null, function (data) {
-                 $scope.unread = data;
-                 });
-                 };
-                 getUnreadCount();*/
-
-                //设置单据已读
-                /* $scope.setOrdersRead = function (id) {
-                 // 如果单据本身已读,则不发送请求修改数据
-                 if (!$scope.isUnread(id)){
-                 return;
-                 }
-                 var sourceId = [];
-                 sourceId.push(id);
-                 PurcOrderItem.setRead({}, sourceId, function (message) {
-                 getUnreadCount();
-                 });
-                 };*/
-
-                //批量设置单据已读
-                /*  $scope.setOrdersReadByBatch = function () {
-                 var sourceId = [];
-                 angular.forEach($scope.tableParams.data, function (order) {
-                 if (order.$selected == true) {
-                 sourceId.push(order.id);
-                 }
-                 });
-                 PurcOrderItem.setRead({}, sourceId, function (message) {
-                 getUnreadCount();
-                 });
-                 };*/
-
-                /*  $scope.setOrdersReadByState = function () {
-                 if (!$scope.unread.replied || $scope.unread.replied == 0) {
-                 return;
-                 }
-                 PurcOrderItem.setReadByState({}, function () {
-                 getUnreadIds();
-                 getUnreadCount();
-                 });
-                 };*/
-
-                /* var getUnreadIds = function () {
-                 PurcOrderItem.getUnreadIds({}, "", function (message) {
-                 $scope.unreadCode = message.content;
-                 });
-                 };*/
-                // getUnreadIds();
-                /*$scope.isUnread = function (id) {
-                 for (var i in $scope.unreadCode) {
-                 if (id == $scope.unreadCode[i]) {
-                 return true;
-                 }
-                 }
-                 };*/
-
-                $scope.getOrderTotal = function (items) {
-                    var sum = 0;
-                    angular.forEach(items, function (item) {
-                        sum += item.qty * item.price;
-                    });
-                    return sum;
-                };
-
-                $scope.openDatePicker = function ($event, item, openParam) {
-                    $event.preventDefault();
-                    $event.stopPropagation();
-                    item[openParam] = !item[openParam];
-                };
-
-                $scope.openFilterDatePicker = function ($event, item, openParam) {
-                    $event.preventDefault();
-                    $event.stopPropagation();
-                    item[openParam] = !item[openParam];
-                    if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
-                        $scope.tableParams.reload();
-                    }
-                };
-
-                $scope.parseDate = function (dateStr) {
-                    if (dateStr) {
-                        return Date.parse(dateStr, 'yyyy-MM-dd');
-                    }
-                    return new Date();
-                };
-
-                // 获取token信息
-                $scope.getToken = function() {
-                    $http({
-                        method: 'get',
-                        dataType: 'json',
-                        url: b2bUrl + "/token?userType=sale"
-                    }).success(function (data) {
-                        $scope.token = data.token;
-                    }).error(function (response) {
-                        toaster.pop('error', response.data);
-                    });
-                }
+    app.register.controller('saleOrderCtrl', ['$scope', '$filter', 'B2bPurcOrderItem', 'B2bPurcOrder', 'ngTableParams', 'toaster', 'B2bReportService', 'BaseService', 'B2bPagingRelease', 'B2bSnapshotService', 'B2bPurcOrderItemInfo', 'token', 'B2bCurrentRole', '$timeout', '$modal', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PagingRelease, SnapshotService, PurcOrderItemInfo, token, CurrentRole, $timeout, $modal) {
+      BaseService.scrollBackToTop();
+
+      // 判断是否为普通用户
+      CurrentRole.isUser({}, {}, function (data) {
+        $scope.isUser = data.isUser;
+      });
+
+      $scope.active = 'todo';
+      $scope.dateZoneText = '不限';
+      $scope.deliveryZoneText = '不限';
+      $scope.condition = {dateZone: 1, deliveryZone: -1};
+      /* 时间筛选初始化*/
+      var fromDate = new Date();
+      var toDate = new Date();
+      fromDate.setMonth(fromDate.getMonth() - 1);
+      fromDate.setHours(0, 0, 0, 0);
+      toDate.setHours(23, 59, 59, 999);
+      $scope.condition.dateFrom = fromDate;
+      $scope.condition.dateTo = toDate;
+
+      $scope.changeDateZone = function (zone) {
+        $scope.condition.dateZone = zone;
+        $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
+        $scope.condition.$dateZoneOpen = false;
+        getDateCondition(zone, $scope.condition);
+        $scope.tableParams.page(1);
+        $scope.tableParams.reload();
+      };
+      $scope.changeDeliveryZone = function (zone) {
+        $scope.condition.deliveryZoneText = zone;
+        $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
+        $scope.condition.$delievryZoneOpen = false;
+        getDelveryCondition(zone, $scope.condition);
+        $scope.tableParams.reload();
+      };
+      $scope.nowdate = new Date();
+      // 切换单据类型
+      $scope.setActive = function (state) {
+        if ($scope.active != state) {
+          $scope.active = state;
+          if ($scope.tableParams.page() == 1)
+            $scope.tableParams.reload();
+          else
+            $scope.tableParams.page(1);
+        }
+      };
+
+      $scope.searchMethod = false;
+      // 切换数据来源(正常数据 or 历史数据)
+      var getService = function () {
+        return $scope.searchMethod ? PurcOrderItem : PurcOrderItemInfo;
+      };
+      $scope.tableParams = new ngTableParams({ // ng-Table参数
+        page: 1,
+        count: 10,
+        sorting: {
+          date: 'desc',
+          id: 'desc'
+        }
+      }, {
+        total: 0,
+        counts: [5, 10, 15, 25, 50],
+        getData: function ($defer, params) { // 获取数据的方法
+          $scope.loading = true;
+          var pageParams = params.url();
+          pageParams.searchFilter = { // 筛选条件
+            keyword: $scope.keyword,
+            fromDate: getDateTime($scope.condition.dateFrom),
+            endDate: getDateTime($scope.condition.dateTo)
+          };
+          getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
+            $scope.loading = false;
+            if (page) {
+              $defer.resolve(page.content);
+              params.total(page.totalElement);
+              $scope.infoCommon = page
+              $scope.infoCommon.all = page.content.length
+              $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
+            }
+          }, function (response) {
+            $scope.loading = false;
+            toaster.pop('error', '数据加载失败', response.data);
+          });
+        }
+      });
 
-                $scope.onReplyClick = function (item, inverse) {
-                    if (item.reply) {
-                        if (!item.reply.qty || item.reply.qty < 0 /*|| item.reply.qty > item.qty*/) {
-                            toaster.pop('warning', '提示', '请填写有效的回复数量!');
-                            return;
-                        }
-                        var reply = angular.copy(item.reply);
-                        if (reply.delivery) {
-                            if (typeof reply.delivery == 'object') {
-                                reply.delivery = reply.delivery.getTime();
-                            }
-                        } else {
-                            reply.delivery = item.delivery;
-                        }
-                        // 取相反
-                        if (inverse && inverse == -1) {
-                            reply.qty = -1 * reply.qty;
-                        }
-                        $scope.loading = true;
-                        if($scope.token != null) {
-                            $http({
-                                method: 'post',
-                                dataType: 'json',
-                                url: b2bUrl + "/sale/orders/items/" + item.id + "/reply?token=" + $scope.token,
-                                data: reply
-                            }).success(function () {
-                                $scope.loading = false;
-                                toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
-                                $scope.tableParams.reload();
-                            }).error(function (response) {
-                                $scope.loading = false;
-                                toaster.pop('error', '回复失败', response.data);
-                            });
-                        }
-                    }
-                };
-
-                //打印    采购单
-                /* $scope.print = function (order) {
-                 var newPage = window.open("about:blank");
-                 PurcOrder.printPermission({}, function () {
-                 PurcOrder.printCount({id: order.id}, {});//增加打印此次 // 在此方法内添加记录日志
-                 if (order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
-                 ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id , newPage);
-                 $scope.tableParams.reload();
-                 },function (response) {
-                 newPage.close();
-                 toaster.pop('error', '打印失败', response.data);
-                 });
-                 };*/
-
-                $scope.getReply = function (item) {
-                    if (!item.replies) {
-                        $http({
-                            method: 'get',
-                            dataType: 'json',
-                            url: b2bUrl + "/sale/orders/items/" + item.id + "/reply/all"
-                        }).success(function (replies) {
-                            item.replies = replies;
-                        });
-                    }
-                };
-
-                $scope.checkboxes = {
-                    checked: false
-                };
-
-                // 点击勾选全部的复选框
-                $scope.checkAll = function () {
-                    angular.forEach($scope.tableParams.data, function (item) {
-                        item.$selected = $scope.checkboxes.checked;
-                    });
-                };
-
-                // 点击其中一个明细的复选框
-                $scope.checkOne = function (order) {
-                    var result = true;
-                    angular.forEach($scope.tableParams.data, function (item) {
-                        if (item.$selected != true) {
-                            result = false;
-                            return;
-                        }
-                    });
-                    $scope.checkboxes.checked = result;
-                };
-
-                //批量回复采购订单
-                $scope.replyByBatch = function () {
-                    $scope.loading = true;
-                    var str = '';
-                    angular.forEach($scope.tableParams.data, function (order) {
-                        if (order.$selected == true) {
-                            str += order.id;
-                            str += ',';
-                        }
-                    });
-                    if (!(str == '')) {
-                        $scope.loading = false;
-                        str = str.substr(0, str.length - 1);
-                        var modalInstance = $modal.open({
-                            animation: true,
-                            templateUrl: 'static/view/vendor/b2b/modal/reply_bybatch.html',
-                            controller: 'ReplyByBatchCtrl',
-                            resolve: {}
-                        });
-                        modalInstance.result.then(function(data) {
-                            $scope.loading = true;
-                            var reply = data;
-                            var date = null;
-                            if (reply.date && reply.method == 1) {
-                                date = reply.date.getTime();
-                            }
-                            $http({
-                                method: 'post',
-                                dataType: 'json',
-                                url: b2bUrl + "/sale/orders/items/reply?date=" + date,
-                                data: str
-                            }).success(function () {
-                                $scope.loading = false;
-                                $scope.tableParams.reload();
-                                toaster.pop('success', '提示', '批量回复成功');
-                            }), error(function () {
-                                $scope.loading = false;
-                                toaster.pop('error', '提示', '批量回复失败');
-                            });
-                        });
-                    } else {//没有勾选其中的明细
-                        toaster.pop('error', '提示', '请先选择需要回复的单据');
-                        $scope.loading = false;
-                    }
-                };
-
-                // 搜索框回车
-                $scope.onSearch = function () {
-                    // 每次搜索重置获取数据方法
-                    $scope.tableParams.page(1);
-                    $scope.tableParams.reload();
-                };
-
-                // 选择查找日期
-                $scope.onDateCondition = function () {
-                    $scope.tableParams.page(1);
-                    $scope.tableParams.reload();
-                };
-
-                //设置为已查看
-                /*$scope.setDisplay = function (state, orderId) {
-                 if (orderId) {//设置单个
-                 PurcOrder[state].call({}, {ids: '' + orderId}, function () {
-                 $scope.tableParams.reload();
-                 }, function () {
-                 toaster.pop('error', '错误', "设置失败");
-                 });
-                 } else {//设置已勾选的
-                 var str = null;
-                 angular.forEach($scope.tableParams.data, function (order) {
-                 if (order.$selected == true) {
-                 if (str != null && str != '') str += ',';
-                 str += order.id;
-                 }
-                 });
-                 if (str != null && str != '') {
-                 PurcOrder[state].call({}, {ids: '' + str}, function () {
-                 $scope.tableParams.reload();
-                 }, function () {
-                 toaster.pop('error', '错误', "设置失败");
-                 });
-                 }
-                 }
-                 };*/
-
-                // 导出
-                $scope.exportXls = function () {
-                    $http({
-                        method: 'get',
-                        dataType: 'json',
-                        url: b2bUrl + "/sale/orders/xls/permission"
-                    }).success(function (data) {
-                        if (data.success){
-                            window.location.href = b2bUrl + 'sale/orders/xls?_state=' + $scope.active + '&searchFilter='
-                                + encodeURIComponent(angular.toJson($scope.searchFilterXls));
-                        }
-                    }), error(function (response) {
-                        toaster.pop('error', '数据加载失败', response.data);
-                    });
-                }
+      //获得各分类未阅读数量
+      var getUnreadCount = function () {
+        PurcOrderItem.getUnreadCount(null, function (data) {
+          $scope.unread = data;
+        });
+      };
+      getUnreadCount();
+
+      //设置单据已读
+      $scope.setOrdersRead = function (id) {
+        // 如果单据本身已读,则不发送请求修改数据
+        if (!$scope.isUnread(id)){
+          return;
+        }
+        var sourceId = [];
+        sourceId.push(id);
+        PurcOrderItem.setRead({}, sourceId, function (message) {
+          getUnreadCount();
+        });
+      };
+
+      //批量设置单据已读
+      $scope.setOrdersReadByBatch = function () {
+        var sourceId = [];
+        angular.forEach($scope.tableParams.data, function (order) {
+          if (order.$selected == true) {
+            sourceId.push(order.id);
+          }
+        });
+        PurcOrderItem.setRead({}, sourceId, function (message) {
+          getUnreadCount();
+        });
+      };
+
+      $scope.setOrdersReadByState = function () {
+        if (!$scope.unread.replied || $scope.unread.replied == 0) {
+          return;
+        }
+        PurcOrderItem.setReadByState({}, function () {
+          getUnreadIds();
+          getUnreadCount();
+        });
+      };
+
+      var getUnreadIds = function () {
+        PurcOrderItem.getUnreadIds({}, "", function (message) {
+          $scope.unreadCode = message.content;
+        });
+      };
+      getUnreadIds();
+      $scope.isUnread = function (id) {
+        for (var i in $scope.unreadCode) {
+          if (id == $scope.unreadCode[i]) {
+            return true;
+          }
+        }
+      };
+
+      $scope.getOrderTotal = function (items) {
+        var sum = 0;
+        angular.forEach(items, function (item) {
+          sum += item.qty * item.price;
+        });
+        return sum;
+      };
+
+      $scope.openDatePicker = function ($event, item, openParam) {
+        $event.preventDefault();
+        $event.stopPropagation();
+        item[openParam] = !item[openParam];
+      };
+
+      $scope.openFilterDatePicker = function ($event, item, openParam) {
+        $event.preventDefault();
+        $event.stopPropagation();
+        item[openParam] = !item[openParam];
+        if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
+          $scope.tableParams.reload();
+        }
+      };
+
+      $scope.parseDate = function (dateStr) {
+        if (dateStr)
+          return Date.parse(dateStr, 'yyyy-MM-dd');
+        return new Date();
+      };
+
+      // 获取token信息
+      $scope.getToken = function() {
+        token.info({userType: 'sale'}, {}, function(data) {
+          $scope.token = data.token;
+        }, function(response) {
+          toaster.pop('error', '提示', response.data);
+        });
+      }
+
+      $scope.onReplyClick = function (item, inverse) {
+        if (item.reply) {
+          if (!item.reply.qty || item.reply.qty < 0 /*|| item.reply.qty > item.qty*/) {
+            toaster.pop('warning', '提示', '请填写有效的回复数量!');
+            return;
+          }
+          var reply = angular.copy(item.reply);
+          if (reply.delivery) {
+            if (typeof reply.delivery == 'object')
+              reply.delivery = reply.delivery.getTime();
+          } else {
+            reply.delivery = item.delivery;
+          }
+          if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
+          $scope.loading = true;
+          if($scope.token != null) {
+            PurcOrderItem.reply({orderItemId: item.id, token: $scope.token}, reply, function () {
+              $scope.loading = false;
+              toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
+              $scope.tableParams.reload();
+            }, function (response) {
+              $scope.loading = false;
+              toaster.pop('error', '回复失败', response.data);
             });
+          }
+        }
+      };
+
+      //打印    采购单
+      $scope.print = function (order) {
+        var newPage = window.open("about:blank");
+        PurcOrder.printPermission({}, function () {
+          PurcOrder.printCount({id: order.id}, {});//增加打印此次 // 在此方法内添加记录日志
+          if (order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
+          ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id , newPage);
+          $scope.tableParams.reload();
+        },function (response) {
+          newPage.close();
+          toaster.pop('error', '打印失败', response.data);
+        });
+      };
+
+      $scope.getReply = function (item) {
+        if (!item.replies) {
+          PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
+            item.replies = replies;
+          });
+        }
+      };
+
+      $scope.checkboxes = {
+        checked: false
+      };
+
+      // 点击勾选全部的复选框
+      $scope.checkAll = function () {
+        angular.forEach($scope.tableParams.data, function (item) {
+          item.$selected = $scope.checkboxes.checked;
+        });
+      };
+
+      // 点击其中一个明细的复选框
+      $scope.checkOne = function (order) {
+        var result = true;
+        angular.forEach($scope.tableParams.data, function (item) {
+          if (item.$selected != true) {
+            result = false;
+            return;
+          }
+        });
+        $scope.checkboxes.checked = result;
+      };
+
+      //批量回复采购订单
+      $scope.replyByBatch = function () {
+        $scope.loading = true;
+        var str = '';
+        angular.forEach($scope.tableParams.data, function (order) {
+          if (order.$selected == true) {
+            str += order.id;
+            str += ',';
+          }
+        });
+        if (!(str == '')) {
+          $scope.loading = false;
+          str = str.substr(0, str.length - 1);
+          var modalInstance = $modal.open({
+            animation: true,
+            templateUrl: 'static/view/vendor/b2b/modal/reply_bybatch.html',
+            controller: 'ReplyByBatchCtrl',
+            resolve: {}
+          });
+          modalInstance.result.then(function(data) {
+            $scope.loading = true;
+            var reply = data;
+            var date = null;
+            if (reply.date && reply.method == 1) {
+              date = reply.date.getTime();
+            }
+            PurcOrderItem.replyByBatch({date: date}, str, function () {
+              $scope.loading = false;
+              $scope.tableParams.reload();
+              toaster.pop('success', '提示', '批量回复成功');
+            }, function (response) {
+              $scope.loading = false;
+              toaster.pop('error', '提示', '批量回复失败');
+            });
+          });
+        } else {//没有勾选其中的明细
+          toaster.pop('error', '提示', '请先选择需要回复的单据');
+          $scope.loading = false;
+        }
+      };
+      // 搜索框回车
+      $scope.onSearch = function (keyword) {
+        // 每次搜索重置获取数据方法
+        $scope.searchMethod = false;
+        if(keyword != null && keyword != '') {
+          $scope.searchMethod = true;
+        }
+        $scope.tableParams.page(1);
+        $scope.tableParams.reload();
+      };
+      // 选择查找日期
+      $scope.onDateCondition = function () {
+        $scope.tableParams.page(1);
+        $scope.tableParams.reload();
+      };
+      //设置为已查看
+      $scope.setDisplay = function (state, orderId) {
+        if (orderId) {//设置单个
+          PurcOrder[state].call({}, {ids: '' + orderId}, function () {
+            $scope.tableParams.reload();
+          }, function () {
+            toaster.pop('error', '错误', "设置失败");
+          });
+        } else {//设置已勾选的
+          var str = null;
+          angular.forEach($scope.tableParams.data, function (order) {
+            if (order.$selected == true) {
+              if (str != null && str != '') str += ',';
+              str += order.id;
+            }
+          });
+          if (str != null && str != '') {
+            PurcOrder[state].call({}, {ids: '' + str}, function () {
+              $scope.tableParams.reload();
+            }, function () {
+              toaster.pop('error', '错误', "设置失败");
+            });
+          }
+        }
+      };
+
+      // 导出
+      $scope.exportXls = function () {
+        PurcOrderItem.exportXls({}, {}, function (data) {
+          if (data.success){
+            window.location.href = 'sale/orders/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
+          }
+        }, function (response) {
+          toaster.pop('error', '数据加载失败', response.data);
+        });
+      }
+
+      /**
+       * 将日期转化为整数日期
+       */
+      var getDateTime = function (date) {
+        if (angular.isDate(date)) {
+          return date.getTime();
+        } else {
+          return null;
+        }
+      }
+
+      /**
+       * 页面状态按钮过滤
+       */
+      var getState = function (active) {
+        var fn = 'get';
+        switch (active) {
+          case 'done':
+            fn = 'getDone';
+            break;
+          case 'todo':
+            fn = 'getTodo';
+            break;
+          case 'end':
+            fn = 'getEnd';
+            break;
+          case 'waiting':
+            fn = 'getWaiting';
+            break;
+          case 'received':
+            fn = 'getReceived';
+            break;
+          case 'invalid':
+            fn = 'getInvalid';
+            break;
+            // 已采纳
+          case 'agreed':
+            fn = 'getAgreed';
+            break;
+            // 未采纳
+          case 'refused':
+            fn = 'getRefused';
+            break;
+            // 个人
+          case 'personal':
+            fn = 'getPersonal';
+            break;
+            // 集体
+          case 'teams':
+            fn = 'getTeams';
+            break;
+            // 非标准
+          case 'nonstandard':
+            fn = 'getNonstandard';
+            break;
+            // 标准
+          case 'standard':
+            fn = 'getStandard';
+            break;
+            // 变更单无需确认
+          case 'unread':
+            fn = 'getUnread';
+            break;
+        }
+        return fn;
+      };
+
+      /**
+       * 改变单据日期范围
+       */
+      var getDateCondition = function (zone, condition) {
+        var fromDate = new Date();
+        var toDate = new Date();
+        //去除时分秒限制,dateFrom设置成0时0分0秒,dateTo设置成23时59分59秒
+        fromDate.setHours(0, 0, 0, 0);
+        toDate.setHours(23, 59, 59, 999);
+        if (zone == -1) { // 自定义时间,什么都不做
+
+        } else if (zone == 1) {
+          fromDate.setMonth(fromDate.getMonth() - 1);
+          condition.dateFrom = fromDate;
+          condition.dateTo = toDate;
+        } else if (zone == 3) {
+          fromDate.setMonth(fromDate.getMonth() - 3);
+          condition.dateFrom = fromDate;
+          condition.dateTo = toDate;
+        } else if (zone == 6) {
+          fromDate.setMonth(fromDate.getMonth() - 6);
+          condition.dateFrom = fromDate;
+          condition.dateTo = toDate;
+        } else {
+          condition.dateFrom = null;
+          condition.dateTo = null;
+        }
+      };
+
     }]);
 
-    /**
+
+
+  /**
      * 批量回复模态框
      */
     app.register.controller('ReplyByBatchCtrl', ['$scope', '$modalInstance', '$filter', 'toaster', function($scope, $modalInstance, $filter, toaster) {

+ 1 - 1
src/main/webapp/resources/view/vendor/b2b/sale_change.html

@@ -579,7 +579,7 @@
 			</tbody>
 
 		</table>
-		<div ng-if="infoCommon.totalElement > 0" class="text-mns text-right"  ng-class="infoCommon.size > 20 ? '': 'Boom18'" >
+		<div ng-if="infoCommon.totalElement > 0" class="text-mns text-right"  ng-class="infoCommon.totalElement > 20 ? '': 'Boom18'" >
 		显示&nbsp;{{(infoCommon .page - 1 ) * infoCommon.size + 1}}-{{infoCommon.all >= 20 ? infoCommon.page *  infoCommon.size: (infoCommon.page - 1 ) * infoCommon.size + infoCommon.all}}&nbsp;条,共&nbsp;{{infoCommon.totalElement}}&nbsp;条
 		</div>
 	</div>

+ 40 - 9
src/main/webapp/resources/view/vendor/b2b/sale_order.html

@@ -111,7 +111,7 @@
 
 	.order-table{
 		background: #fff;
-		margin-bottom:15px;
+		/*margin-bottom:15px;*/
 	}
 	.order-table .product div.text-over {
 		width: 340px;
@@ -166,9 +166,26 @@
 	.order-table .order-bd td {
 		border-right: 1px solid #e8e8e8;
 	}
+	.ng-table-pager::after {
+		clear: both;
+		content: ' ';
+		zoom: 1;
+		display: block;
+		visibility: hidden;
+	}
+	.ng-table-pager {
+		padding-right: 20px;
+		padding-top: 50px;
+		margin-right: 0 !important;
+	}
+	.order-table {
+		background: #fff;
+		width: 100%;
+		/*margin-bottom: 10px;*/
+	}
 </style>
 
-<div class="user_right fr">
+<div class="user_right fr" style="position: relative">
 	<!--订单中心-->
 	<div class="sellOder oder" id="sellOder">
 		<div class="com_tab" style="margin-bottom: 10px">
@@ -197,12 +214,12 @@
 		</div>
 		<div class="oder01" style="margin-bottom: 0px">
 			<ul ng-controller="SnapShotCtrl">
-				<li ng-class="{'active': active=='all'}" ng-click="setActive('all')"><a> 全部(<em ng-class="{'color-black': !snapShot.saleOrderAll }" ng-bind="snapShot.saleOrderAll || 0"></em>)</a></li>
-				<li ng-class="{'active': active=='done'}" ng-click="setActive('done')"><a>已回复(<em ng-class="{'color-black': !snapShot.saleOrderDone }" ng-bind="snapShot.saleOrderDone || 0"></em>)</a></li>
-				<li ng-class="{'active': active=='todo'}" ng-click="setActive('todo')"><a>待回复(<em ng-class="{'color-black': !snapShot.saleOrderTodo }" ng-bind="snapShot.saleOrderTodo || 0"></em>)</a></li>
-				<li ng-class="{'active': active=='received'}" ng-click="setActive('received')"><a>已收货(<em ng-class="{'color-black': !snapShot.saleOrderReceived }" ng-bind="snapShot.saleOrderReceived || 0"></em>)</a></li>
-				<li ng-class="{'active': active=='waiting'}" ng-click="setActive('waiting')"><a>待交货(<em ng-class="{'color-black': !snapShot.saleOrderWaiting }" ng-bind="snapShot.saleOrderWaiting || 0"></em>)</a></li>
-				<li ng-class="{'active': active=='end'}" ng-click="setActive('end')"><a>已结案(<em ng-class="{'color-black': !snapShot.saleOrderEnd }" ng-bind="snapShot.saleOrderEnd || 0"></em>)</a></li>
+				<li ng-class="{'active': active=='all'}" ng-click="setActive('all')"><a> 全部(<em ng-class="{'color-black': !unread.all }" ng-bind="unread.all || 0"></em>)</a></li>
+				<li ng-class="{'active': active=='done'}" ng-click="setActive('done');setOrdersReadByState()"><a>已回复(<em ng-class="{'color-black': !unread.replied }" ng-bind="unread.replied || 0"></em>)</a></li>
+				<li ng-class="{'active': active=='todo'}" ng-click="setActive('todo')"><a>待回复(<em ng-class="{'color-black': !unread.notReply }" ng-bind="unread.notReply || 0"></em>)</a></li>
+				<li ng-class="{'active': active=='received'}" ng-click="setActive('received')"><a>已收货</a></li>
+				<li ng-class="{'active': active=='waiting'}" ng-click="setActive('waiting')"><a>待交货</a></li>
+				<li ng-class="{'active': active=='end'}" ng-click="setActive('end')"><a>已结案</a></li>
 			</ul>
 		</div>
 		<!--搜索时间筛选-->
@@ -501,6 +518,9 @@
 			</tr>
 			</tbody>
 		</table>
+		<div ng-if="infoCommon.totalElement > 0" class="text-mns text-right" ng-class="infoCommon.totalElement >= 10 ? '': 'Boom18'">
+			显示&nbsp;{{(infoCommon .page - 1 ) * infoCommon.size + 1}}-{{infoCommon.all >= 10 ? infoCommon.page *  infoCommon.size: (infoCommon.page - 1 ) * infoCommon.size + infoCommon.all}}&nbsp;条,共&nbsp;{{infoCommon.totalElement}}&nbsp;条
+		</div>
 		<div class="reply-box" ng-show="showRateBoxFlag">
 			<img src="static/img/vendor/images/rate-box-del.png" ng-click="setShowRateBoxFlag(false)" alt="">
 			<div class="vendor-modal-header" ng-show="boxStatus == 1 || boxStatus == 2">
@@ -780,4 +800,15 @@
 			};
 		});
 	})
-</script>
+</script>
+<style>
+	.Boom18 {
+		bottom: 18px;
+	}
+	.text-mns {
+		padding-right: 15px;
+		position: absolute;
+		bottom: 64px;
+		right: 20px;
+	}
+</style>