Browse Source

更新平台物料上传批量导入的方法,新增采购po增加商品批量上传

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@8491 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq 9 years ago
parent
commit
469599fe0a

+ 79 - 7
src/main/webapp/resources/js/index/app.js

@@ -9764,6 +9764,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				orderItems : {
 					product : {},
 				},
+				rate: 17
 		};
 		
 		//商品信息
@@ -9787,6 +9788,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				$scope.order.cust.enName = data.vendorEnterprise.enName;
 				$scope.order.cust.enAddress = data.vendorEnterprise.enAddress;
 				$scope.order.cust.uu = data.vendorEnterprise.uu;
+				$scope.order.paymethods = data.paymethod;
 				$rootScope.venduu = data.vendorEnterprise.uu;
 				Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
 					$scope.contacts = data;
@@ -9811,10 +9813,12 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			});
 			
 			modalInstance.result.then(function(data) {
+				console.log(data);
 				$rootScope.venduu = data.vendorEnterprise.uu;
 				$scope.id = data.id;
 				$scope.order.cust = data.vendorEnterprise;
 				$scope.order.custUser = data.vendorUser;
+				$scope.order.payments = data.paymethod;
 				$scope.order.orderItems = [];
 				var item = {
 						code: null,
@@ -9879,7 +9883,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			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});
+				$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});
 			}
 		};
 		//删除商品
@@ -9924,9 +9928,33 @@ 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});
+  			$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.uplodaByBatch = function() {
+			var modalInstance = $modal.open({
+				templateUrl: 'static/tpl/index/purc/modal/purc_uplodaByBatch.html',
+				controller: 'PurcUploadByBatchCtrl',
+				size: 'lg',
+				resolve: {
+				}
+			});
+			
+			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);
+//						}
+//					}
+				})
+				
+			}, function(){
+				
+			});
+		}
 		// 监听custuu发生变化,重新加载物料信息
 		$scope.$watch('order.cust.uu', function(n, o) {
 			if(n==o) {
@@ -10077,6 +10105,42 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		
 	}]);
 	
+	/**
+	 * 采购批量导入
+	 */
+	app.controller('PurcUploadByBatchCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function($scope, toaster, $upload, $modalInstance) {
+		// 通过excel批量上传物料
+		$scope.result = null;
+		$scope.upload = function() {
+			var file = $scope.myFiles[0];
+			$upload.upload({
+				url: 'purchase/release/excel',
+				file: file,
+				method: 'POST'
+			}).success(function(data) {
+				$scope.result = data;
+				$scope.success = $scope.result.success;
+				$scope.total = $scope.result.total;
+				$scope.alters = $scope.result.alters;
+			}).error(function(response) {
+				toaster.pop('error', response.data || response);
+			});
+		};
+		
+		// 下载模板
+		$scope.download = function() {
+			window.location.href = 'purchase/upload/template';
+		};
+		
+		$scope.enSure = function() {
+			$modalInstance.close($scope.result.products);
+		}
+		
+		$scope.cancel = function() {
+			$modalInstance.dismiss();
+		}
+	}]);
+	
 	// 查找供应商
 	app.controller('DbfindVendorInfoCtrl', ['$scope', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'Vendor', '$rootScope', 'orderItems', function($scope, BaseService, ngTableParams, toaster, $modalInstance, Vendor, $rootScope, orderItems){
 		$scope.prod = false;
@@ -13633,7 +13697,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		// 取消合作关系
 		$scope.disableCust = function(id) {
 			VendorInfo.disableCust({id: id}, {}, function(data) {
-				toaster.pop('success', '提示', '取消合作关系成功');
+				if(data.success) {
+					toaster.pop('success', '提示', data.success);
+				}
 				$scope.customerParams.page(1);
 	  			$scope.customerParams.reload();
 			}, function(response) {
@@ -13644,7 +13710,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		// 解除禁用
 		$scope.activeCust = function(id) {
 			VendorInfo.activeCust({id: id}, {}, function(data) {
-				toaster.pop('success', '提示', '取消合作关系成功');
+				if(data.success) {
+					toaster.pop('success', '提示', data.success);
+				}
 				$scope.customerParams.page(1);
 	  			$scope.customerParams.reload();
 			}, function(response) {
@@ -13706,7 +13774,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		// 取消合作关系
 		$scope.relieve = function(id) {
 			VendorInfo.relieve({id: id}, {}, function(data) {
-				toaster.pop('success', '提示', '取消合作关系成功');
+				if(data.success) {
+					toaster.pop('success', '提示', data.success);
+				}
 				$scope.customerParams.page(1);
 				$scope.customerParams.reload();
 			}, function(response) {
@@ -13714,10 +13784,12 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			});
 		}
 		
-		// 取消合作关系
+		// 建立合作关系
 		$scope.activeVend = function(id) {
 			VendorInfo.activeVend({id: id}, {}, function(data) {
-				toaster.pop('success', '提示', '取消禁用成功');
+				if(data.success) {
+					toaster.pop('success', '提示', data.success);
+				}
 				$scope.customerParams.page(1);
 				$scope.customerParams.reload();
 			}, function(response) {

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

@@ -331,6 +331,10 @@ define(['ngResource'], function() {
 					'Content-Type' : 'application/text;charset=UTF-8'
 				}
 			},
+			method: {
+				url: 'paymethod/method',
+				method: 'GET'
+			}
 		})
 	}]).factory('SearchProd', ['$resource', function($resource) {
 		return $resource('product/baseInfo/SearchProd', {}, {

+ 2 - 2
src/main/webapp/resources/tpl/index/baseInfo/customersInfo.html

@@ -108,8 +108,8 @@
 			<tbody ng-repeat="customer in $data" ng-if="customerParams.total() > 0">
 					<tr class="customer-hd">
 						<td colspan="4" class="text-left"><span ng-bind="::customer.myEnterprise.enName"></span></td>
-						<td width="200" class="text-center" ng-if="customer.custswitch == 1 "><a ng-click="disableCust(customer.id)">禁用客户</a></td>
-						<td width="200" class="text-center" ng-if="customer.custswitch == 0 "><a ng-click="activeCust(customer.id)">取消禁用</a></td>
+						<td width="200" class="text-center" ng-if="customer.custswitch == 1 "><a ng-click="disableCust(customer.id)">已启用</a></td>
+						<td width="200" class="text-center" ng-if="customer.custswitch == 0 "><a ng-click="activeCust(customer.id)">禁用</a></td>
 					</tr>
 					<tr class="customer-bd">
 						<td  class="first" colspan="4">

+ 2 - 2
src/main/webapp/resources/tpl/index/baseInfo/vendorsInfo.html

@@ -132,8 +132,8 @@
 			<tbody ng-repeat="vendor in $data">
 					<tr class="customer-hd">
 						<td colspan="4" class="text-left"><span ng-bind="::vendor.vendorEnterprise.enName"></span></td>
-						<td width="200" class="text-center" ng-if="vendor.vendswitch == 1"><a ng-click="relieve(vendor.id)">禁用供应商</a></td>
-						<td width="200" class="text-center" ng-if="vendor.vendswitch == 0"><a ng-click="activeVend(vendor.id)">取消禁用</a></td>
+						<td width="200" class="text-center" ng-if="vendor.vendswitch == 1"><a ng-click="relieve(vendor.id)">已启用</a></td>
+						<td width="200" class="text-center" ng-if="vendor.vendswitch == 0"><a ng-click="activeVend(vendor.id)">禁用</a></td>
 					</tr>
 					<tr class="customer-bd">
 						<td  class="first" colspan="4">

+ 21 - 3
src/main/webapp/resources/tpl/index/purc/addOrder.html

@@ -123,10 +123,28 @@
                         <span><input type="text" ng-model="order.remark" class="bor01" placeholder="请填写备注" style="cursor: pointer; width: 568px;"/></span>
                     </div>
                 </li>
+                 <li>
+                    <div class="fl">
+                        <em>税率:</em>
+                        <span class="fl" required="required" ng-if="order.currency == 'RMB'">
+                             <select class="select02 wid100" ng-model="order.rate" required="required">
+								<option value="17">17</option>
+								<option value="0">0</option>
+							</select>
+                        </span>
+                        <span class="fl" required="required" ng-if="order.currency != 'RMB'">
+                        	<input class="text select02 wid100" value="0" readonly>
+                        </span>
+                    </div>
+                </li>
             </ul>
             <div class="com_title01" ng-if="order.orderItems[0].code == null && !order.cust.uu"><span>请先选择供应商</span></div>
-            <div class="com_title01" ng-if="order.orderItems[0].code == null && order.cust.uu"><span>请先选择供应商产品</span></div>
-            <div class="com_title01" ng-if="order.orderItems[0].code != null && order.cust.uu"><span>产品信息</span></div>
+            <div class="com_title01" ng-if="order.orderItems[0].code == null && order.cust.uu"><span>请先选择供应商产品</span>
+            	<a ng-click="uplodaByBatch()">批量导入</a>
+            </div>
+            <div class="com_title01" ng-if="order.orderItems[0].code != null && order.cust.uu"><span>产品信息</span>
+            	<a ng-click="uplodaByBatch()">批量导入</a>
+            </div>
             <!--产品信息-->
             <dl ng-if="order.orderItems[0].code != null">
                 <dt>
@@ -151,7 +169,7 @@
                      <b><input class="editable" type="text" ng-model="item.qty"  placeholder="数量" style="cursor: pointer;" required="true" ng-pattern="/^(([0-9]+\.[0-9]{1,2})|([0-9]*[1-9][0-9]*\.[0-9]{1,3})|([0-9]*[1-9][0-9]*))$/"/></b>
                     <b><input class="editable" type="text" ng-model="item.price" placeholder="单价" style="cursor: pointer;" required="true" ng-pattern="/^(([0-9]+\.[0-9]{1,6})|([0-9]*[1-9][0-9]*\.[0-9]{1,6})|([0-9]*[1-9][0-9]*))$/"/></b>
                     <b ng-if="order.currency == 'RMB'"><input class="editable" type="text" ng-model="item.rate" placeholder="税率" style="cursor: pointer;" ng-pattern="/^[0-9][0-9]{0,1}$/"/></b>
-                    <b ng-if="order.currency != 'RMB'"><input class="editable" type="text" style="cursor: pointer;" value="0" readonly="readonly"/></b>
+                    <b ng-if="order.currency != 'RMB'"><input class="editable" type="text" style="cursor: pointer;" value="0" readonly="readonly" /></b>
                     <b>
 						<input ng-model="item.delivery" type="text" class="editable" 
 							placeholder="选择时间" datepicker-popup="yyyy-MM-dd" is-open="item.$endDateOpen"

+ 68 - 0
src/main/webapp/resources/tpl/index/purc/modal/purc_uplodaByBatch.html

@@ -0,0 +1,68 @@
+<style>
+.Deputy button {
+	border-radius: 0px;
+}
+
+.Deputy div {
+	margin-left: 6px;
+	padding-top: 6px;
+}
+</style>
+<div class="modal-header Deputy" style="min-height: 50px;">
+	<div class="content f16 text-bold">批量导入 
+		<a style="padding-left: 780px;" ng-click="cancel()"><i class="fa fa-close"></i></a>
+	</div>
+</div>
+<div class="modal-body Deputy" style="min-height: 200px;">
+	<div class="content f14 text-bold">第一步、下载Excel模板</div>
+	<div class="box-item">
+		<p>
+			<button class="btn btn-success btn-sm" ng-click="download()">下载Excel模板 <i
+				class="fa fa-download"></i></button> 在Excel模板上录入商品信息。
+		</p>
+	</div>
+	<div id="image-box" style="display: none">
+		<div class="x-close-wrap" title="关闭">
+			<a href="javascript:void(0);">&times;</a>
+		</div>
+		<div class="x-floating-wrap"></div>
+		<div class="x-floating">
+			<img />
+		</div>
+	</div>
+	<div class="content f14 text-bold">第二步、上传已经填好的Excel文件</div>
+	<div class="box-item">
+		<form class="form-horizontal">
+			<div class="form-group">
+				<label class="control-label col-xs-3" for="xlsFile">请上传已经填写好的Excel文件</label>
+				<div class="col-xs-4">
+					<input required ng-file-select accept="*.xls,*.xlsx"
+						ng-model="myFiles" type="file" ng-multiple="false"
+						class="form-control input-sm" id="xlsFile" name="xlsFile"
+						placeholder="请上传.xls或.xlsx文件" />
+				</div>
+				<div class="col-xs-4">
+					<button ng-click="upload()" class="btn btn-success btn-sm">
+						确认上传 <i class="fa fa-upload"></i>
+					</button>
+				</div class="col-xs-4">
+			</div>
+			<div>
+			</div>
+			<!-- 分页 Start -->
+		</form>
+	</div>
+	<div class="content f14 text-bold">第三步、信息提示</div>
+	<div class="box-item">
+		<p ng-if="result.total">
+			<span>总共上传{{result.total}}个,成功{{result.success}}个</span>
+		</p>
+	</div>
+</div>
+<div class="modal-footer Deputy">
+	<div class="text-center">
+		<button class="btn btn-success btn-sm" ng-click="enSure()" type="button">确定</button>
+		<button class="btn btn-danger btn-sm" ng-click="cancel()" type="button">取消</button>
+	</div>
+</div>
+<!-- block end -->