Explorar o código

代采订单保存方法更新

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@10164 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq %!s(int64=8) %!d(string=hai) anos
pai
achega
998699b581

+ 1 - 1
src/main/java/com/uas/platform/b2b/controller/DeputyOrderController.java

@@ -124,7 +124,7 @@ public class DeputyOrderController {
 	 * @return
 	 */
 	@RequestMapping(value = "/saveDeOrder", method = RequestMethod.POST)
-	public ModelMap saveDeOrder(String deOrder) {
+	public ModelMap saveDeOrder(@RequestBody String deOrder) {
 		DeputyOrder deorder = JSON.parseObject(deOrder, DeputyOrder.class);
 		return deputyOrderService.saveDeOrder(deorder);
 	}

+ 108 - 67
src/main/webapp/resources/js/index/app.js

@@ -108,7 +108,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             controller : 'CartController'
         }).state('purc.cartDetail', {
             url : "/cart/:id",
-            templateUrl : "static/tpl/index/purc/cart_detail.html",
+            templateUrl : "static/tpl/index/purc/addOrder2.html",
             controller : 'CartDetailController'
         }).state('purc.deputy', {
 			url : "/deputy",
@@ -11422,7 +11422,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 	 */
 	app.controller('PurcNewOrderCtrl',['$scope', '$modal', 'toaster', '$filter', 'addtoCart', '$rootScope', 'VendorInfo', 'ngTableParams', 'BaseService', 'Product', 'newPurcOrder', 'cartOperation', 'ShipAddress', 'Vendor', '$http', '$window', function($scope, $modal, toaster, $filter, addtoCart, $rootScope, VendorInfo, ngTableParams, BaseService, Product, newPurcOrder, cartOperation, ShipAddress, Vendor, $http, $window) {
 		BaseService.scrollBackToTop();
-		// 每次进入时先清除掉rootScope下的venuu
+		// 每次进入时先清除掉rootScope下的venduu
 		$rootScope.venduu = null;
 		// 获取收货地址列表
 		ShipAddress.shipAddList({}, function(data) {
@@ -11462,10 +11462,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				price: null,
 				remark: null, 
 				delivery: null,
-				id: null,
+				prid: null,
 				};
 		
-		
 		if($rootScope.businessCode) {
 			VendorInfo.getVendorInfo({businessCode: $rootScope.businessCode}, {}, function(data) {
 				$scope.id = data.id;
@@ -11484,7 +11483,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		};
 		
 		// 查找供应商
-		$scope.dbfindCust = function(){
+		$scope.dbfindVend = function(){
 			var modalInstance = $modal.open({
 				templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
 				controller: 'DbfindVendorInfoCtrl',
@@ -11513,7 +11512,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 						remark: null, 
 						delivery: null,
 						};
-//				$scope.order.orderItems.push(item);
 				Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
 					$scope.contacts = data;
 					$scope.order.vendor = $scope.contacts[0];
@@ -11600,7 +11598,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 						params.total(page.totalElement);
 						$scope.total = page.totalElement;
 						$defer.resolve(page.content);
-						$scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
 					}
 				}, function(response){
 					$scope.loading = false;
@@ -11612,7 +11609,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		
 		// 选择
   		$scope.check = function(data) {
-  			$scope.order.orderItems.push({code: data.code, title: data.title, spec: data.spec, unit: data.unit, qty: null, price: null, remark: null, delivery: null, id: data.id, rate: $scope.order.rate});
+  			$scope.order.orderItems.push({code: data.code, title: data.title, spec: data.spec, unit: data.unit, qty: null, price: null, remark: null, delivery: null, prid: data.id, rate: $scope.order.rate});
   		};
   		
   		// 导入商品信息
@@ -11627,12 +11624,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			
 			modalInstance.result.then(function(data) {
 				angular.forEach(data, function(prod) {
-					$scope.order.orderItems.push({code: prod.code, title: data.title, unit: 'PCS', spec: prod.spec, qty: prod.amount, price: prod.price, remark: prod.remark, delivery: prod.date, id: prod.id, rate: prod.rate});
-//					for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
-//						if($scope.order.orderItems[i].qty == null && $scope.order.orderItems[i].price == null && $scope.order.orderItems[i].qty == null && $scope.order.orderItems[i].delivery == null && $scope.order.orderItems[i].remark == null) { // 如果没有填写就删除这行数据
-//							$scope.inquiry.inquiryItems.splice(i, 1);
-//						}
-//					}
+					$scope.order.orderItems.push({code: prod.code, title: data.title, unit: 'PCS', spec: prod.spec, qty: prod.amount, price: prod.price, remark: prod.remark, delivery: prod.date, prid: prod.id, rate: prod.rate});
 				})
 				
 			}, function(){
@@ -11649,34 +11641,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			}
 		}, true);
 		
-		// 查找客户物料
-		$scope.dbfindCustProd = function(index){
-			if($scope.order.cust.uu) {
-				var modalInstance = $modal.open({
-					templateUrl: 'static/tpl/index/purc/modal/purc_order_custProd.html',
-					controller: 'DbfindCustProdCtrl',
-					size: 'lg',
-					resolve: {
-						custUU: function() {
-							return $scope.order.cust.uu
-							}
-					}
-				});
-				
-				modalInstance.result.then(function(data) {
-					$scope.order.orderItems.push(data);
-					for(var i = 0; i < $scope.order.orderItems.length; i++) {
-						if($scope.order.orderItems[i].code == null || i == index) {
-							$scope.order.orderItems.splice(i, 1);
-						}
-					}
-				}, function() {
-					
-				});
-			} else {
-				toaster.pop('info', '提示', '请先选择供应商');
-			}
-		};
 		$scope.getMinDate = function(item) {
 			return $filter('date')(new Date, 'yyyy-MM-dd');
 		};
@@ -12837,12 +12801,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		};
 		$scope.searchMethod = false;
 		var getService = function() {
-			if($scope.searchMethod) {
-				return getCartList;
-			} else {
-				return cartList;
-			}
-//			 return getCartList;
+			return $scope.searchMethod ? cartList : getCartList;
 		};
 		var getTodoCartCount = function() {
             cartOperation.getTodoCartCount({}, function(data) {
@@ -12967,17 +12926,21 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 	/**
 	 * 购物车详情
 	 */
-	app.controller('CartDetailController', ['$scope', 'cartOperation', '$stateParams', 'toaster', '$timeout', 'BaseService', function($scope, cartOperation, $stateParams, toaster, $timeout, BaseService) {
+	app.controller('CartDetailController', ['$scope', 'cartOperation', '$stateParams', 'toaster', '$timeout', 'BaseService', 'ngTableParams', '$filter', 'Product', 'Vendor', 'ShipAddress', function($scope, cartOperation, $stateParams, toaster, $timeout, BaseService, ngTableParams, $filter, Product, Vendor, ShipAddress) {
 		BaseService.scrollBackToTop();
 		var loadData = function() {
 			cartOperation.getCartDetail({id: $stateParams.id}, function(data) {
 				if(data.code) {
-					$scope.cart = data;
+					$scope.order = data;
 					var sum = 0;
-					angular.forEach($scope.cart.cartDetails, function(item) {
+					angular.forEach($scope.order.orderItems, function(item) {
 						sum += item.qty * item.price;
 					});
-					$scope.cart.total = sum;
+					$scope.order.total = sum;
+					Vendor.contacts({venduu: $scope.order.receiveCode}, {}, function(data) {
+						$scope.contacts = data;
+						$scope.order.vendor = $scope.contacts[0];
+					});
 					$scope.loading = false;
 				} else {
 					window.location.hash = '#/purc/cart';
@@ -12986,19 +12949,97 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		};
 		loadData();
 		
-		// 删除一条明细
-		$scope.deleteDetail = function(id) {
-			cartOperation.deleteCartDetail({id: id}, {}, function(data) {
-				if(data.success) {
-					toaster.pop('success', '提示', data.success);
-					loadData();
-				}
-				if(data.error) {
-					toaster.pop('error', '提示', data.error);
+		// 获取收货地址列表
+		ShipAddress.shipAddList({}, function(data) {
+			$scope.ships = data;
+			$scope.order.shipadd = $scope.ships[0];
+		});
+		
+		//增加商品
+		$scope.addProduct = function(index) {
+			if($scope.order.orderItems[index].code == null) {
+				toaster.pop('info', '提示', '请先选择商品');
+			} else {
+				$scope.order.orderItems.push({code: null, title: null, spec: null, unit: null, qty: null, price: null, remark: null, delivery: null, $endDateOpen: false, rate: $scope.order.rate});
+			}
+		};
+		
+		//删除商品
+		$scope.deleteProduct = function(index, id) {
+			$scope.order.orderItems.splice(index, 1);
+			if(id != null) {
+				cartOperation.deleteCartDetail({id: id}, {}, function(data) {
+					if(data.success) {
+						loadData();
+					}
+					if(data.error) {
+						toaster.pop('error', '提示', data.error);
+					}
+				}, function(response) {
+					toaster.pop('erroer', '提示', response.data);
+				});
+			}
+		};
+		
+		// 搜索框回车
+		$scope.onSearch = function(keyword) {
+			$scope.keyword = keyword;
+			$scope.tableParams.page(1);
+			$scope.tableParams.reload();
+		};
+		
+		$scope.tableParams = new ngTableParams({
+			page : 1, 
+			count : 20
+		}, {
+			total : 0, 
+			counts: [5, 10, 25, 50],
+			getData : function($defer, params) {
+				$scope.loading = true;
+				var pageParams = params.url();
+				pageParams.keyword = $scope.keyword;
+				$scope.tip = $scope.keyword;
+				pageParams.custUU = $scope.order.receiveCode;
+				Product.get.call(null, BaseService.parseParams(pageParams), function(page){
+					$scope.loading = false;
+					if(page) {
+						params.total(page.totalElement);
+						$scope.total = page.totalElement;
+						$defer.resolve(page.content);
+					}
+				}, function(response){
+					$scope.loading = false;
+					toaster.pop('error', '数据加载失败', response.data);
+				});
+			}
+		});
+		
+		// 选择
+  		$scope.check = function(data) {
+  			$scope.order.orderItems.push({code: data.code, title: data.title, spec: data.spec, unit: data.unit, qty: null, price: null, remark: null, delivery: null, prid: data.id, rate: $scope.order.rate});
+  		};
+  		
+  		// 导入商品信息
+		$scope.uplodaByBatch = function() {
+			var modalInstance = $modal.open({
+				templateUrl: 'static/tpl/index/purc/modal/purc_uplodaByBatch.html',
+				controller: 'PurcUploadByBatchCtrl',
+				size: 'lg',
+				resolve: {
 				}
-			}, function(response) {
-				toaster.pop('erroer', '提示', response.data);
 			});
+			
+			modalInstance.result.then(function(data) {
+				angular.forEach(data, function(prod) {
+					$scope.order.orderItems.push({code: prod.code, title: data.title, unit: 'PCS', spec: prod.spec, qty: prod.amount, price: prod.price, remark: prod.remark, delivery: prod.date, prid: prod.id, rate: prod.rate});
+				})
+				
+			}, function(){
+				
+			});
+		}
+		$scope.getMinDate = function(item) {
+			return $filter('date')(new Date, 'yyyy-MM-dd');
 		};
 		
 		// 删除一条主记录
@@ -13768,7 +13809,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				if($scope.deOrder.deputyOrderItems[0].prodcode == null) {
 					toaster.pop('info', '提示', '您还未填写任何商品信息');
 				} else {
-					DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
+					DeputyOrder.saveDeOrder({}, $scope.deOrder, function(data) {
 						if(data.id) {
 							toaster.pop('success', '提示', '保存成功');
 							window.location.hash = "#/purc/deputy/"+data.id;
@@ -13802,7 +13843,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				if($scope.deOrder.deputyOrderItems[0].prodcode == null) {
 					toaster.pop('info', '提示', '您还未填写任何商品信息');
 				} else {
-					DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
+					DeputyOrder.saveDeOrder({}, {deOrder: $scope.deOrder}, function(data) {
 						if(data.id) {
 							toaster.pop('success', '提示', '提交成功');
 							window.location.hash = "#/purc/deputy/"+data.id;
@@ -14228,7 +14269,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				if($scope.deOrder.deputyOrderItems[0].prodcode == null) {
 					toaster.pop('info', '提示', '您还未填写任何商品信息');
 				} else {
-					DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
+					DeputyOrder.saveDeOrder({}, $scope.deOrder, function(data) {
 						if(data.id) {
 							toaster.pop('success', '提示', '保存成功');
 							loadData();
@@ -14259,7 +14300,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 					$scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
 					$scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
 				});
-				DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
+				DeputyOrder.saveDeOrder({}, $scope.deOrder, function(data) {
 					if(data.id) {
 						toaster.pop('success', '提示', '提交成功');
 						window.location.hash = "#/purc/deputy/"+data.id;