yangc 8 лет назад
Родитель
Сommit
869e11a182

+ 164 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -1,6 +1,6 @@
 define([ 'app/app' ], function(app) {
 	'use strict';
-	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams) {
+	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) {
 		$rootScope.active = 'vendor_material';
 
 		$scope.tab = 'material';
@@ -1018,6 +1018,169 @@ define([ 'app/app' ], function(app) {
 				}
 			}
 		}
+
+		$scope.getSimilarBrands = function(keyword) {
+			if (keyword) {
+				return Search.getSimilarBrands({keyword : keyword}).$promise.then(function(data) {
+					return data.map(function(item) {
+						return item;
+					});
+				});
+			}
+		};
+
+		// 获取器件联想词
+		$scope.getSimilarCmps = function(code) {
+			if (code) {
+				return Search.getSimilarComponents({keyword : code}).$promise.then(function(data) {
+					return data.map(function(item) {
+						return item;
+					})
+				});
+			}
+		};
+
+		// 获取末级类目联想词
+		$scope.getSimilarKinds = function(name) {
+			if (name) {
+				return Search.getSimilarLeafKinds({keyword: name}).$promise.then(function(data) {
+					return data.map(function(item) {
+						return item;
+					})
+				})
+			}
+		};
+
+		// 选择类目
+		$scope.selectKind = function() {
+			$modal.open({
+				animation: true,
+				size: 'lg',
+				templateUrl: 'static/view/prod/product_kindChoose_modal.html',
+				controller: 'KindChooseCtrl',
+				resolve: {
+					actives: function() {
+						return $scope.actives;
+					}
+				}
+			}).result.then(function(data){
+				$scope.activesString = data.actives[data.actives.length - 1].nameCn;;
+			}, function(){
+
+			});
+		};
+
+		$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 = '';
+		}
+
 	}]);
 
+	//类目选择模态框
+	app.register.controller('KindChooseCtrl', ['$scope', 'KindAPI', 'actives', 'toaster', '$modalInstance', function($scope, KindAPI, actives, toaster, $modalInstance) {
+		$scope.actives = actives;
+		$scope.kinds = [[], [], [], []];
+		// 获取子类目
+		var getChildren = function(pid, deep) {
+			KindAPI.getChildren({parentId: pid}, function(data) {
+				$scope.kinds[deep] = data;
+			}, function(response) {
+				toaster.pop('error', '获取子类目失败', response.data);
+			});
+		};
+
+		// 改变节点选中状态
+		var changeStatus = function(item, deep) {
+			var actives = [], level = 0;
+			angular.forEach($scope.kinds, function(ks, i) {
+				if(i > deep) {
+					$scope.kinds[i] = [];
+				} else {
+					angular.forEach(ks, function(k, j) {
+						if(i == deep) {
+							if(k.id == item.id) {
+								$scope.kinds[i][j].$active = true;
+								actives.push(k);
+							} else {
+								k.$active = null;
+							}
+						} else {
+							if(k.$active) {
+								actives.push(k);
+							}
+						}
+					});
+				}
+			});
+			// 选择的节点
+			$scope.actives = actives;
+			$scope.active = item;
+			// 当前可操作的层级
+			if(deep < 3) {
+				$scope.activeDeep = deep + 1;
+			}
+		};
+
+		// 节点点击后获取子类目,节点被选中
+		$scope.onItemClick = function(item, deep) {
+			changeStatus(item, deep);
+			if (!item.isLeaf) {
+				getChildren(item.id, deep + 1);
+			}
+		};
+
+		// 重新加载数据
+		function reload(deep) {
+			var pid;
+			if(deep) {
+				pid = $scope.actives[deep - 1].id;
+			} else {
+				pid = 0;
+				deep = 0;
+			}
+			getChildren(pid, deep);
+		}
+
+		// 初始加载数据,获取第一层的类目
+		if($scope.actives) {
+			angular.forEach($scope.actives, function(v, k) {
+				KindAPI.getChildren({parentId: v.parentid}, function(data) {
+					$scope.kinds[k] = data;
+					angular.forEach($scope.kinds[k], function(kind, i){
+						if(kind.id == v.id) {
+							$scope.kinds[k][i].$active = true;
+							$scope.actives[k] = $scope.kinds[k][i];
+						}
+					})
+				}, function(response) {
+					toaster.pop('error', '获取子类目失败', response.data);
+				});
+			});
+		} else {
+			reload();
+		}
+
+		// 取消
+		$scope.cancel = function() {
+			$modalInstance.dismiss();
+		};
+
+		// 确认选择
+		$scope.check = function() {
+			var a = {
+				active: $scope.active,
+				actives: $scope.actives
+			};
+			$modalInstance.close(a);
+		};
+	}]);
+
+
 });

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

@@ -390,6 +390,8 @@
 	}
 	.edit-content .content .material-form-line {
 		margin-bottom: 10px;
+		text-align: left;
+		position: relative;
 	}
 	.edit-content .content .material-form-line >span {
 		font-size: 12px;
@@ -401,7 +403,7 @@
 	}
 	.edit-content .content .material-form-line >input {
 		display: inline-block;
-		width: 145px;
+		width: 280px;
 		border-radius: 0;
 		text-align: left;
 		padding: 0 5px;
@@ -417,6 +419,7 @@
 		color: #fff;
 		font-size: 12px;
 		border-radius: 5px;
+		text-align: center;
 	}
 	.wanted_list01 .tab table tr.active{
 		height: 35px;
@@ -466,7 +469,24 @@
 	.com_tab ul li.active a {
 		color: #1687ff;
 	}
-	.
+	.material-form-line .dropdown-menu li {
+		width: 279px;
+		overflow: hidden;
+	}
+	.material-form-line .dropdown-menu li.active a {
+		color: #fff!important;
+	}
+	.material-form-line .search-more-kind {
+		position: absolute;
+		right: 0;
+		top: 0;
+		width: 24px;
+		height: 24px;
+		background: #eee;
+		text-align: center;
+		border: 1px solid #ccc;
+		cursor: pointer;
+	}
 </style>
 <div class="user_right fr">
 	<!--货品管理-->
@@ -488,13 +508,6 @@
 			<div class="check fr">
 				<!--<a ng-show="!isBatch && standard_tab == 'unstandard'" ng-click="matchAll()"><span ng-show="!isBatch && standard_tab == 'unstandard'">一键匹配</span></a>-->
 				<a ng-show="!isBatch" ng-click="enterBatch()"><span ng-show="!isBatch">批量操作:</span></a>
-				<!--<label class="check-active">
-				<input type="checkbox"  ng-click="chooseAll()" ng-checked="isChoosedAll" id="AllChoose"/>
-				<label for="AllChoose"></label>
-				<span>全选</span>
-				</label>
-				<a>提交申请</a>
-				<a>忽略选中</a>-->
 				<span class="check-btn" ng-show="isBatch">
                     <label class="check-active">
                         <input type="checkbox"  ng-click="chooseAll()" ng-checked="isChoosedAll" id="AllChoose"/>
@@ -547,15 +560,10 @@
 							<span ng-if="!material.cmpUuId" ng-bind="material.pcmpcode" title="{{material.pcmpcode}}"></span>
 						</td>
 						<td>
-							<!--<a ng-show="!material.selected&&!isBatch && standard_tab == 'standard'" ng-click="showShelfArea(material)"><span ng-show="!isBatch">去上架</span></a>-->
+							<a ng-show="!material.selected&&!isBatch" ng-click="material.selected = true;"><span ng-show="!isBatch">编辑</span></a>
 							<!--<a ng-show="!material.selected&&!isBatch && standard_tab == 'unstandard'" ng-click="match(material)"><span ng-show="!isBatch">匹配</span></a>-->
-							<!--<a ng-show="!material.selected&&!isBatch" ng-click="deleteMaterial(material)"><span ng-show="!isBatch">删除</span></a>-->
+							<a ng-show="!material.selected&&!isBatch" ng-click="deleteMaterial(material)"><span ng-show="!isBatch">删除</span></a>
 							<!--<a ng-if="material.selected">取消</a>-->
-							<a ng-show="!material.selected&&!isBatch && standard_tab == 'standard'" ng-click="showShelfArea(material)"><span ng-show="!isBatch">编辑</span></a>
-							<a ng-show="!material.selected&&!isBatch && standard_tab == 'unstandard'" ng-click="match(material)"><span ng-show="!isBatch">保存</span></a>
-							<a ng-show="!material.selected&&!isBatch" ng-click="deleteMaterial(material)"><span ng-show="!isBatch">查看</span></a>
-							<a ng-if="material.selected">忽略</a>
-							<!--<span class="remind-notice">审核中</span>-->
 						</td>
 					</tr>
 					<!--编辑内容-->
@@ -568,27 +576,42 @@
 							<div class="content">
 								<div class="material-form-line">
 									<span>*品牌英文名:</span>
-									<input type="text" class="form-control">
+									<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)"
+										   required autofocus />
 								</div>
 								<div class="material-form-line">
 									<span>*品牌官网:</span>
 									<input type="text" class="form-control">
 								</div>
 							</div>
-							<div class="content" style="margin-left: 257px;">
+							<div class="content">
 								<div class="material-form-line">
 									<span>*原厂标准型号:</span>
-									<input type="text" class="form-control">
+									<input type="text" name="code" ng-model="component.code" class="form-control"
+										   placeholder="请输入标准原厂型号"
+										   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">
+									<input type="text" class="form-control" name="kindName" ng-model="activesString"  required
+										   placeholder="请输入或选择分类" autocomplete="off"
+										   typeahead="kind.nameCn for kind in getSimilarKinds($viewValue)"
+										   />
+									<div class="search-more-kind" ng-click="selectKind()">
+										<i class="fa fa-search" aria-hidden="true"></i>
+									</div>
 								</div>
 								<div class="material-form-line">
 									<span>*规格书:</span>
-									<label>
-										<input type="file" class="form-control">
-										<p>上传规格书(pdf格式)</p>
+									<label ng-show="attachName == ''">
+										<input type="file" onchange="angular.element(this).scope().onAttachInput(event)" class="form-control">
+										<p>上传规格书(pdf格式)</p>{{attachName}}
+									</label>
+									<label  ng-show="attachName != ''">
+										<p>{{attachName}}</p>
+										<a style="margin-left: 5px;" href="javascript:void(0)" ng-click="deleteAttach()">删除</a>
 									</label>
 								</div>
 							</div>