Эх сурвалжийг харах

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@1045 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d

administrator 11 жил өмнө
parent
commit
15ad29e042

+ 25 - 0
src/main/java/com/uas/platform/b2b/controller/TruckController.java

@@ -1,13 +1,19 @@
 package com.uas.platform.b2b.controller;
 
+import java.util.List;
+
 import javax.servlet.http.HttpSession;
 
 import org.apache.commons.lang3.ArrayUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.uas.platform.b2b.model.PurchaseNotice;
+import com.uas.platform.b2b.service.PurchaseNoticeService;
+
 /**
  * 货车
  * 
@@ -20,6 +26,9 @@ public class TruckController {
 
 	private static final String TRUCK = "_session_truck";
 
+	@Autowired
+	private PurchaseNoticeService purchaseNoticeService;
+
 	/**
 	 * 往货车加商品
 	 * 
@@ -72,4 +81,20 @@ public class TruckController {
 		return session.getAttribute(TRUCK);
 	}
 
+	/**
+	 * 查找货车的商品明细
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/items", method = RequestMethod.GET)
+	@ResponseBody
+	public List<PurchaseNotice> getNotices(HttpSession session) {
+		Object track = session.getAttribute(TRUCK);
+		if (track != null) {
+			Long[] noticeArray = (Long[]) track;
+			return purchaseNoticeService.findById(noticeArray);
+		}
+		return null;
+	}
+
 }

+ 9 - 2
src/main/java/com/uas/platform/b2b/dao/PurchaseNoticeDao.java

@@ -37,6 +37,14 @@ public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNoti
 	 */
 	List<PurchaseNotice> findByVendUUAndEndStatus(long vendUU, Short endStatus);
 
+	/**
+	 * 按ID集合查找送货提醒
+	 * 
+	 * @return
+	 */
+	@Query("select n from PurchaseNotice n where n.id IN (:ids) and (n.endQty is null or n.endQty < n.qty)")
+	List<PurchaseNotice> findUnEndByIds(@Param("ids") Long[] ids);
+
 	/**
 	 * 按送货提醒单的供应商企业ID和送货提醒单状态来统计条数
 	 * 
@@ -54,6 +62,5 @@ public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNoti
 	@Modifying(clearAutomatically = true)
 	@Query("update PurchaseNotice n set n.endQty=(select sum(s.qty) from SaleSendItem s where s.notice=n) where n.id= :id")
 	public void updateBySend(@Param("id") long id);
-	
-	
+
 }

+ 8 - 0
src/main/java/com/uas/platform/b2b/service/PurchaseNoticeService.java

@@ -65,6 +65,14 @@ public interface PurchaseNoticeService {
 	 */
 	public PurchaseNotice findById(Long id);
 
+	/**
+	 * 用单据ID查找送货提醒单
+	 * 
+	 * @param ids
+	 * @return
+	 */
+	public List<PurchaseNotice> findById(Long[] ids);
+
 	/**
 	 * 针对送货提醒,填写数量单个发货
 	 * 

+ 13 - 8
src/main/java/com/uas/platform/b2b/service/impl/PurchaseNoticeServiceImpl.java

@@ -203,10 +203,10 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 	@Override
 	public void send(Long noticeId, SaleSend send) {
 		PurchaseNotice notice = purchaseNoticeDao.findOne(noticeId);
-//		//限制同一个供应商发货单号不可以重复,(限制被去掉 -- 2015年6月5日15:23:52)
-//		List<SaleSend> saleSend = saleSendDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), send.getCode());
-//		if (saleSend.size() > 0)
-//			throw new IllegalOperatorException("发货单号重复,无法发货!提示:多个物料一起发货请选择批量发货。");
+		// //限制同一个供应商发货单号不可以重复,(限制被去掉 -- 2015年6月5日15:23:52)
+		// List<SaleSend> saleSend = saleSendDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), send.getCode());
+		// if (saleSend.size() > 0)
+		// throw new IllegalOperatorException("发货单号重复,无法发货!提示:多个物料一起发货请选择批量发货。");
 		if (notice != null) {
 			double thisQty = 0;
 			for (SaleSendItem item : send.getSendItems())
@@ -258,10 +258,10 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 	@Override
 	public SaleSend send(SaleSend saleSend) {
 		if (saleSend != null) {
-//			//限制同一个供应商发货单号不可以重复,(限制被去掉 -- 2015年6月5日15:23:52)
-//			List<SaleSend> saleSends = saleSendDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), saleSend.getCode());
-//			if (saleSends.size() > 0)
-//				throw new IllegalOperatorException("发货单号重复,无法发货!提示:多个物料一起发货请选择批量发货。");
+			// //限制同一个供应商发货单号不可以重复,(限制被去掉 -- 2015年6月5日15:23:52)
+			// List<SaleSend> saleSends = saleSendDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), saleSend.getCode());
+			// if (saleSends.size() > 0)
+			// throw new IllegalOperatorException("发货单号重复,无法发货!提示:多个物料一起发货请选择批量发货。");
 			saleSend.setBackStatus((short) Status.NOT_UPLOAD.value());
 			saleSend.setSendStatus((short) Status.NOT_UPLOAD.value());
 			saleSend.setEnUU(SystemSession.getUser().getEnterprise().getUu());
@@ -325,4 +325,9 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 		}
 	}
 
+	@Override
+	public List<PurchaseNotice> findById(Long[] ids) {
+		return purchaseNoticeDao.findUnEndByIds(ids);
+	}
+
 }

+ 9 - 0
src/main/webapp/resources/css/index.css

@@ -1853,6 +1853,7 @@ a.none:hover {
 
 .table-default .header {
 	background: #f5f5f5;
+	border-left: 1px solid #ddd;
 	border-top: 1px solid #e8e8e8;
 	border-bottom: 1px solid #e8e8e8;
 	-webkit-box-shadow: 0 0 7px 0 rgba(119, 119, 119, 0.2);
@@ -1864,6 +1865,14 @@ a.none:hover {
 	text-align: center;
 }
 
+.table-bordered .header>th {
+	border-right: 1px solid #ddd;
+}
+
+.table-bordered .header>th:hover {
+	background: #e1e1e1;
+}
+
 .table-hover>tbody>tr:hover {
 	background-color: #d0e9c6;
 	-webkit-transition: all 0.15s ease-in-out;

+ 83 - 9
src/main/webapp/resources/js/index/app.js

@@ -35,6 +35,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 				"right-view" : {
 					templateUrl : "static/tpl/index/sale/right.html"
 				}
+			},
+			controller: function($scope) {
+				$scope.truck = [];
 			}
 		}).state('sale.index', {
 			url : "",
@@ -256,11 +259,78 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 			$scope.todo = data;
 		});
 	});
-	app.controller('TruckCtrl', function($scope, $rootScope, SaleTruck){
+	app.controller('TruckCtrl', function($scope, $rootScope, $modal, SaleTruck){
 		SaleTruck.query({}, function(data){
 			$rootScope.truck = data;
 			$scope.truckCount = data ? data.length : 0;
 		});
+		$scope.$watch(function(){
+			return $rootScope.truck;
+		}, function(data) {
+			$scope.truckCount = data ? data.length : 0;
+		}, true);
+		$scope.clearAll = function() {
+			SaleTruck.remove({}, function(){
+				$rootScope.truck = [];
+			});
+		};
+		$scope.openTrack = function() {
+			$modal.open({
+				templateUrl: 'static/tpl/index/sale/track.html',
+				controller: 'TruckModalCtrl',
+				size: 'lg'
+			}).result.then(function(){
+				
+			});
+		};
+	});
+	app.controller('TruckModalCtrl', function($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice){
+		SaleTruck.detail({}, function(data){
+			$scope.notices = data;
+		});
+		$scope.remove = function(index, notice) {
+			SaleTruck.remove({noticeId: notice.id}, function(data){
+				$rootScope.truck = data;
+				$scope.notices.splice(index, 1);
+			});
+		};
+		$scope.cancel = function() {
+			$modalInstance.close();
+		};
+		$scope.send = function() {// 发货
+			$scope.saleSend.sendItems = [];
+			if(!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
+				toaster.pop('error', '错误', '请输入送货单号');
+				return;
+			}
+			var a = 0;
+			var valid = true;
+			angular.forEach($scope.notices, function(item){
+				if(a == 0) {//第一次
+					$scope.saleSend.currency = item.orderItem.order.currency;
+					$scope.saleSend.custUU = item.enUU;
+					$scope.saleSend.payments = item.orderItem.order.payments;
+					a = 1;
+				} else {//其他
+					if($scope.saleSend.currency != item.orderItem.order.currency) valid = false;
+					if($scope.saleSend.custUU != item.enUU) valid = false;
+					if($scope.saleSend.payments != item.orderItem.order.payments) valid = false;
+				}
+				$scope.saleSend.sendItems[$scope.saleSend.sendItems.length] = {
+					noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price
+				};
+			});
+			if(!valid) {
+				toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致、采购员一致才能一起发货。');
+			} else {
+				PurcNotice.sendByBatch({}, $scope.saleSend, function(data){
+					toaster.pop('success', '提示', '发货成功。');
+					$modalInstance.close(true);
+				}, function(response){
+					toaster.pop('error', '错误', response.data);
+				});
+			}
+		};
 	});
 	app.controller('PersonalSaleStatCtrl', function($scope, SaleStat) {
 		SaleStat.cust({}, function(data){
@@ -1202,23 +1272,27 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 		var truck = $rootScope.truck;
 		if(!truck) {
 			SaleTruck.query({}, function(data){
-				truck =  $rootScope.truck = data;
+				$rootScope.truck = data;
 			});
 		}
 		$scope.isInTruck = function(noticeId) {
 			return truck.indexOf(noticeId) > -1;
 		};
-		$scope.addtoTruck = function(noticeId) {
-			SaleTruck.save({noticeId: noticeId}, {}, function(){
-				
+		$scope.addtoTruck = function(notice) {
+			SaleTruck.save({noticeId: notice.id}, {}, function(data){
+				$rootScope.truck = data;
 			});
 		};
-		$scope.delFromTruck = function(noticeId) {
-			SaleTruck.remove({}, {noticeId: noticeId}, function(){
-				
+		$scope.delFromTruck = function(notice) {
+			SaleTruck.remove({noticeId: notice.id}, {}, function(data){
+				$rootScope.truck = data;
 			});
 		};
-		
+		$scope.$watch(function(){
+			return $rootScope.truck;
+		}, function(data) {
+			truck =  $rootScope.truck;
+		}, true);
 	});
 	app.controller('SaleNoticeSendByBatchCtrl', function($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster){
 		$scope.notices = angular.copy(selectedNotices);

+ 4 - 0
src/main/webapp/resources/js/index/services/Purc.js

@@ -299,6 +299,10 @@ define([ 'ngResource'], function() {
 			remove: {
 				isArray: true,
 				method: 'DELETE'
+			},
+			detail: {
+				url: 'sale/truck/items',
+				isArray: true
 			}
 		});
 	});

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

@@ -434,11 +434,12 @@
 								<a ng-click="notice.$editing=!notice.$editing"><i class="fa fa-send-o fa-lg"></i><br>发 货</a>
 							</div>
 							<div>
-								<a ng-click="addtoTruck(notice.id)" class="text-simple"><i class="fa fa-truck fa-lg"></i><br>加入货车</a>
+								<a ng-click="addtoTruck(notice)" class="text-simple"><i class="fa fa-ambulance fa-lg"></i><br>加入货车</a>
 							</div>
 						</div>
 						<div ng-show="isInTruck(notice.id)">
-							已加入货车
+							<div class="text-inverse">已加入<br>货车</div>
+							<div><a ng-click="delFromTruck(notice)" class="text-simple">取出<i class="fa fa-fw fa-share"></i></a></div>
 						</div>
 					</div>
 					<div ng-show="notice.$editing">

+ 41 - 11
src/main/webapp/resources/tpl/index/sale/right.html

@@ -79,13 +79,10 @@
 	position: absolute;
 	opacity: 0;
 	zoom: 1;
-	right: 70px;
-	top: 50%;
-	margin-top: -15px;
+	right: -100px;
+	top: 0;
 	width: 100px;
-	height: 30px;
-	line-height: 30px;
-	padding: 0 3px;
+	height: 100%;
 	background-color: #494949;
 	border-radius: 2px 0 0 2px;
 	-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .2);
@@ -94,16 +91,16 @@
 	font-size: 12px;
 	text-align: center;
 	color: #fff;
-	-webkit-transition: all 0.15s ease-in-out;
-	-moz-transition: all 0.15s ease-in-out;
-	transition: all 0.15s ease-in-out;
+	-webkit-transition: all 0.35s ease-in-out;
+	-moz-transition: all 0.35s ease-in-out;
+	transition: all 0.35s ease-in-out;
 	z-index: 0;
 }
 
 .item-wrap .tip:after {
 	position: absolute;
 	content: '';
-	top: 9px;
+	top: 30%;
 	right: -10px;
 	width: 0;
 	height: 0;
@@ -117,6 +114,28 @@
 	right: 32px;
 }
 
+.item-wrap .tip>ul {
+	margin: 0;
+	padding: 0;
+}
+
+.item-wrap .tip>ul>li {
+	color: #fff;
+	padding: 10px;
+	border-bottom: 1px solid #f6f6f6;
+	-webkit-transition: all 0.15s ease-in-out;
+	-moz-transition: all 0.15s ease-in-out;
+	transition: all 0.15s ease-in-out;
+}
+
+.item-wrap .tip>ul>li>a {
+	color: #fff;
+}
+
+.item-wrap .tip>ul>li:hover {
+	background-color: #56a022;
+}
+
 .rbar .bar-bottom {
 	position: absolute;
 	bottom: 0;
@@ -127,6 +146,12 @@
 .bar-bottom .item-wrap:first-child .item-inner {
 	border-top: 1px solid #f9f9f9;
 }
+
+.rbar .icon-left {
+	margin: 8px 10px 0 0;
+	float: left;
+	width: 30%;
+}
 </style>
 <!-- right static-bar Start -->
 <div class="rbar">
@@ -135,7 +160,12 @@
 			<span class="inner-text"> <!-- <i class="fa fa-fw fa-truck fa-2x"></i> -->我的货车
 			</span> <span class="badge" ng-bind="truckCount"></span>
 		</div>
-		<div class="tip" style="display: none;">发货</div>
+		<div class="tip">
+			<ul class="list-unstyled">
+				<li ng-click="openTrack()"><a><i class="fa fa-cubes fa-2x icon-left"></i>打开<br>货车</a></li>
+				<li ng-click="clearAll()"><a><i class="fa fa-undo fa-2x icon-left"></i>清空<br>货车</a></li>
+			</ul>
+		</div>
 	</div>
 	<div class="bar-center" ng-controller="TodoCtrl">
 		<div class="item-wrap">

+ 79 - 0
src/main/webapp/resources/tpl/index/sale/track.html

@@ -0,0 +1,79 @@
+<div class="modal-body">
+	<div class="headerline">
+		<span class="content"><i class="fa fa-fw fa-edit text-primary"></i>填写送货信息</span>
+	</div>
+	<form class="form-horizontal">
+		<div class="form-group">
+			<label class="col-md-2 col-sm-2 control-label"><span
+				class="text-inverse text-bold">*</span>送货单号:</label>
+			<div class="col-md-4 col-sm-4">
+				<input class="form-control input-sm" ng-model="saleSend.code"
+					required type="text" placeholder="填写本次送货单号">
+			</div>
+		</div>
+		<div class="form-group">
+			<label class="col-md-2 col-sm-2 control-label">备注:</label>
+			<div class="col-md-10 col-sm-10">
+				<input class="form-control input-sm" ng-model="saleSend.remark"
+					type="text" placeholder="填写给客户的备注信息">
+			</div>
+		</div>
+	</form>
+	<div class="headerline">
+		<span class="content"><i class="fa fa-fw fa-truck text-primary"></i>货车商品一览</span>
+	</div>
+	<table class="table table-default table-bordered" style="margin: 0;">
+		<tr class="header">
+			<th width="200">商品</th>
+			<th width="80">剩余未发</th>
+			<th width="120">本次发货</th>
+			<th width="120">单价</th>
+			<th width="100">交货日期</th>
+			<th width="150">订单</th>
+			<th width="49">操作</th>
+			<th width="1"></th>
+		</tr>
+	</table>
+	<div style="max-height: 400px; overflow-y: scroll;">
+		<table class="table table-striped table-bordered table-hover">
+			<tr
+				ng-repeat="notice in notices | orderBy: 'notice.orderItem.product.code'">
+				<td width="200">
+					<div ng-bind="::notice.orderItem.product.code"></div>
+					<div ng-bind="::notice.orderItem.product.title"></div>
+					<div class="text-muted" ng-bind="::notice.orderItem.product.spec"></div>
+				</td>
+				<td width="80">
+					<div>
+						<span class="text-num" ng-bind="notice.qty-notice.endQty"></span>&nbsp;
+						<span ng-bind="notice.orderItem.product.unit"></span>
+					</div>
+				</td>
+				<td width="120"><input ng-model="notice.thisSendQty"
+					ng-init="notice.thisSendQty = notice.qty-notice.endQty"
+					class="form-control input-sm" type="number"></td>
+				<td width="120" class="text-center">
+					<div class="text-num">
+						<span ng-bind="::currency(notice.orderItem.order.currency)"></span>
+						<span ng-bind="::notice.orderItem.price|number:6"></span>
+					</div>
+				</td>
+				<td width="100">
+					<div ng-bind="::notice.delivery | date: 'yyyy-MM-dd'"></div>
+				</td>
+				<td width="150">
+					<div ng-bind="::notice.orderItem.order.code"></div>
+					<div>
+						第 <span ng-bind="::notice.orderItem.number"></span> 行
+					</div>
+				</td>
+				<td width="50" class="text-center"><a ng-click="remove($index, notice)"
+					class="text-muted"><i class="fa fa-trash-o fa-2x"></i>取消</a></td>
+			</tr>
+		</table>
+	</div>
+</div>
+<div class="modal-footer">
+	<button class="btn btn-primary" ng-click="send()" type="button">确认送货</button>
+	<button class="btn btn-default" ng-click="cancel()" type="button">取消</button>
+</div>