Parcourir la source

物料申请前端验证修改

wangyc il y a 8 ans
Parent
commit
fd5643ba27

+ 50 - 4
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -1,12 +1,13 @@
 define([ 'app/app' ], function(app) {
 	'use strict';
-	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal) {
+	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI) {
 		$rootScope.active = 'vendor_material';
 
 		$scope.tab = 'material';
 		$scope.standard_tab = $stateParams.standardParam?$stateParams.standardParam:'standard';
 		$scope.choosedIds = [];
 		$scope.deleteDiv = false;
+		$scope.submitProduct = {};
 
         $scope.param = {
             page : 1,
@@ -1048,6 +1049,7 @@ define([ 'app/app' ], function(app) {
 			}
 		}
 
+		// 获取品牌联想词
 		$scope.getSimilarBrands = function(keyword) {
 			if (keyword) {
 				return Search.getSimilarBrands({keyword : keyword}).$promise.then(function(data) {
@@ -1058,6 +1060,11 @@ define([ 'app/app' ], function(app) {
 			}
 		};
 
+		// 选择品牌
+		$scope.onAssociateClickBrand = function (brand) {
+			$scope.submitProduct.brand = brand
+		};
+
 		// 获取器件联想词
 		$scope.getSimilarCmps = function(code) {
 			if (code) {
@@ -1068,6 +1075,15 @@ define([ 'app/app' ], function(app) {
 				});
 			}
 		};
+		// 选择器件
+		$scope.onAssociateClickCmp = function (cmp) {
+			$scope.submitProduct.component = cmp;
+			ComponentActiveAPI.get({uuid : cmp.uuid}, {}, function(data) {
+				var component = data;
+				$scope.submitProduct.brand = component.brand;
+				$scope.submitProduct.kind = component.kind;
+			});
+		};
 
 		// 获取末级类目联想词
 		$scope.getSimilarKinds = function(name) {
@@ -1080,6 +1096,10 @@ define([ 'app/app' ], function(app) {
 			}
 		};
 
+		$scope.onAssociateClickKind = function (kind) {
+			$scope.submitProduct.kind = kind;
+		};
+
 		// 选择类目
 		$scope.selectKind = function() {
 			$modal.open({
@@ -1093,18 +1113,44 @@ define([ 'app/app' ], function(app) {
 					}
 				}
 			}).result.then(function(data){
-				$scope.activesString = data.actives[data.actives.length - 1].nameCn;;
+				$scope.submitProduct.kind = data.actives[data.actives.length - 1];
 			}, function(){
 
 			});
 		};
 
+		// 提交申请
+		$scope.submit = function () {
+			if (typeof $scope.submitProduct.brand == 'undefined' || $scope.submitProduct.brand.nameEn == null) {
+				toaster.pop('warning', '请填写品牌英文名');
+				return;
+			}
+			if (typeof $scope.submitProduct.component == 'undefined' || $scope.submitProduct.component.code == null) {
+				toaster.pop('warning', '请填写原厂型号');
+				return;
+			}
+			if (typeof $scope.submitProduct.website == 'undefined' || $scope.submitProduct.website == null) {
+				toaster.pop('warning', '请填写品牌官网');
+				return;
+			}
+			if (typeof $scope.submitProduct.kind == 'undefined' || $scope.submitProduct.kind.id == null) {
+				toaster.pop('warning', '请填写或选择商城已有类目');
+				return;
+			}
+			if ($scope.attachName == '') {
+				toaster.pop('warning', '请填上传规格书');
+				return;
+			} else {
+				$scope.submitProduct.attach = $scope.attachName;
+			}
+
+			console.log($scope.submitProduct);
+		};
+
 		$scope.attachName = '';
 		//上传规格书
 		$scope.onAttachInput = function (event) {
-			console.log(event.target.files[0]);
 			$scope.attachName = event.target.files[0].name;
-			console.log($scope.attachName);
 		}
 		$scope.deleteAttach = function () {
 			$scope.attachName = '';

+ 8 - 8
src/main/webapp/resources/view/vendor/forstore/erp/vendor_material_unstandard_erp.html

@@ -579,27 +579,27 @@
 							<div class="content">
 								<div class="material-form-line">
 									<span>*品牌英文名:</span>
-									<input type="text" class="form-control" name="nameEn" ng-model="brand.nameEn"
-										   placeholder="输入品牌名称,例如:Panasonic" autocomplete="off" typeahead="brand.nameEn for brand in getSimilarBrands($viewValue) | limitTo:2"                                              typeahead-on-select="onAssociateClick($item)"
+									<input type="text" class="form-control" name="nameEn" ng-model="submitProduct.brand.nameEn"
+										   placeholder="输入品牌名称,例如:Panasonic" autocomplete="off" typeahead="brand.nameEn for brand in getSimilarBrands($viewValue) | limitTo:2"                                              typeahead-on-select="onAssociateClickBrand($item)"
 										   required autofocus />
 								</div>
 								<div class="material-form-line">
 									<span>*品牌官网:</span>
-									<input type="text" class="form-control">
+									<input type="text" class="form-control" ng-model="submitProduct.website">
 								</div>
 							</div>
 							<div class="content">
 								<div class="material-form-line">
 									<span>*原厂标准型号:</span>
-									<input type="text" name="code" ng-model="component.code" class="form-control"
-										   placeholder="请输入标准原厂型号"
+									<input type="text" name="code" ng-model="submitProduct.component.code" class="form-control"
+										   placeholder="请输入标准原厂型号" typeahead-on-select="onAssociateClickCmp($item)"
 										   typeahead="component.code for component in getSimilarCmps($viewValue)" autocomplete="off"
 										   required>
 								</div>
 								<div class="material-form-line">
 									<span>*器件分类:</span>
-									<input type="text" class="form-control" name="kindName" ng-model="activesString"  required
-										   placeholder="请输入或选择分类" autocomplete="off"
+									<input type="text" class="form-control" name="kindName" ng-model="submitProduct.kind.nameCn"  required
+										   placeholder="请输入或选择分类" autocomplete="off" typeahead-on-select="onAssociateClickKind($item)"
 										   typeahead="kind.nameCn for kind in getSimilarKinds($viewValue)"
 										   />
 									<div class="search-more-kind" ng-click="selectKind()">
@@ -623,7 +623,7 @@
 								<div class="input-list">
 									<button class="ok" ng-click="closeShelArea(material)" style="margin-bottom: 5px">取消</button>
 									<!--<button class="ok" ng-click="publishGoods(material)" style="margin-bottom: 5px">保存</button>-->
-									<button class="ok" ng-click="publishGoods(material)">提交申请</button>
+									<button class="ok" ng-click="submit()">提交申请</button>
 								</div>
 							</div>
 						</td>