Browse Source

【器件申请】上传规格书功能修改,不使用flash插件

dongbw 7 years ago
parent
commit
47bed4aa0d

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -152,7 +152,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		int rowNum = sheet.getLastRowNum();
 		int rowNum = sheet.getLastRowNum();
 		if (rowNum > 2000) {
 		if (rowNum > 2000) {
 			throw new IllegalOperatorException
 			throw new IllegalOperatorException
-					("您上传的信息超过2000条,请拆分成2000以再上传");
+					("您上传的信息超过2000条,请拆分成2000以再上传");
 		}
 		}
 		List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
 		List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
 		String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
 		String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);

+ 17 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/controller/ComponentSubmitController.java

@@ -63,6 +63,23 @@ public class ComponentSubmitController {
 		return componentSubmit;
 		return componentSubmit;
 	}
 	}
 
 
+	/**
+	 * 保存标准器件提交信息(来自新增品牌,修改品牌) 2018年4月20日 09:49:19 前台插件禁用flash会失效,新增上传方法 dongbw
+	 *
+	 * @param component 器件申请信息
+	 * @param uploadItem 规格书附件
+	 * @return 器件申请信息
+	 */
+	@RequestMapping(value = "/upload", method = RequestMethod.POST)
+	public ComponentSubmit saveComponentSubmitWithUploadItem(String component, FileUpload uploadItem) {
+		ComponentSubmit componentSubmit = FastjsonUtils.fromJson(component, ComponentSubmit.class);
+		componentSubmit.setId(null);
+		componentSubmit = componentSubmitService.saveComponentSubmit(componentSubmit, uploadItem);
+		operationInfoService.save(componentSubmit, ServiceCode.componentApply.value());
+		logger.log("器件维护", "保存器件申请", "保存器件申请,原厂型号:" + componentSubmit.getCode(), componentSubmit.getCode(), componentSubmit.getId());
+		return componentSubmit;
+	}
+
 	/**
 	/**
 	 * 审核通过
 	 * 审核通过
 	 * 
 	 * 

+ 13 - 1
src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentSubmitService.java

@@ -1,7 +1,10 @@
 package com.uas.platform.b2c.prod.product.component.service;
 package com.uas.platform.b2c.prod.product.component.service;
 
 
 import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.common.base.model.FileUpload;
-import com.uas.platform.b2c.prod.product.component.modal.*;
+import com.uas.platform.b2c.prod.product.component.modal.Component;
+import com.uas.platform.b2c.prod.product.component.modal.ComponentCrawlSubDetail;
+import com.uas.platform.b2c.prod.product.component.modal.ComponentCrawlSubmit;
+import com.uas.platform.b2c.prod.product.component.modal.ComponentSubmit;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageInfo;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -35,6 +38,15 @@ public interface ComponentSubmitService {
 	 */
 	 */
 	public ComponentSubmit saveComponentSubmit(ComponentSubmit componentSubmit);
 	public ComponentSubmit saveComponentSubmit(ComponentSubmit componentSubmit);
 
 
+	/**
+	 * 保存标准器件版本信息(来自新增,更新)
+	 *
+	 * @param componentSubmit  器件申请信息
+	 * @param uploadItem 规格书附件
+	 * @return 器件申请信息
+	 */
+	public ComponentSubmit saveComponentSubmit(ComponentSubmit componentSubmit, FileUpload uploadItem);
+
 	/**
 	/**
 	 * 根据id查找提交的标准器件信息
 	 * 根据id查找提交的标准器件信息
 	 * 
 	 * 

+ 13 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentSubmitServiceImpl.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2c.prod.product.component.service.impl;
 
 
 import com.uas.platform.b2c.common.account.dao.UserBaseInfoDao;
 import com.uas.platform.b2c.common.account.dao.UserBaseInfoDao;
 import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.common.base.model.FileUpload;
+import com.uas.platform.b2c.common.base.service.FileService;
 import com.uas.platform.b2c.common.base.service.SendMessageService;
 import com.uas.platform.b2c.common.base.service.SendMessageService;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
@@ -108,6 +109,9 @@ public class ComponentSubmitServiceImpl implements ComponentSubmitService {
 	@Autowired
 	@Autowired
 	private KindContrastDao kindContrastDao;
 	private KindContrastDao kindContrastDao;
 
 
+	@Autowired
+	private FileService fileService;
+
 	@Override
 	@Override
 	@Transactional
 	@Transactional
 	public Component componentSubmitAudit(ComponentSubmit componentSubmit) {
 	public Component componentSubmitAudit(ComponentSubmit componentSubmit) {
@@ -285,6 +289,15 @@ public class ComponentSubmitServiceImpl implements ComponentSubmitService {
 		return componentSubmitDao.save(componentSubmit);
 		return componentSubmitDao.save(componentSubmit);
 	}
 	}
 
 
+	@Override
+	public ComponentSubmit saveComponentSubmit(ComponentSubmit componentSubmit, FileUpload uploadItem) {
+		if ((uploadItem != null) && (uploadItem.getFile() != null)) {
+			String attachUrl = fileService.save(uploadItem);
+			componentSubmit.setAttach(attachUrl);
+		}
+		return saveComponentSubmit(componentSubmit);
+	}
+
 	@Override
 	@Override
 	public ComponentSubmit findComponentSubmitById(Long id) {
 	public ComponentSubmit findComponentSubmitById(Long id) {
 		return componentSubmitDao.findOne(id);
 		return componentSubmitDao.findOne(id);

+ 53 - 23
src/main/webapp/resources/js/prod/controllers/ComponentEditCtrl.js

@@ -212,22 +212,35 @@ define([ 'app/app', 'jquery-summernote', 'jquery-uploadify' ], function(app) {
 				});
 				});
 			};
 			};
 			
 			
-			// 图片上传成功之后
-			$scope.onAttachUploadSuccess = function(data){
-				$scope.$apply(function() {
-					$scope.component.attachFile = data;
-					$scope.component.attach = data.path;
-					if($scope.component.attachFile.size >= 1024 * 1024) {
-						$scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024 / 1024, 1) + 'Mb';
-					} else if($scope.component.attachFile.size >= 1024) {
-						$scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024, 1) + 'Kb';
-					} else {
-						$scope.component.attachFile.size = $scope.component.attachFile.size + 'b';
-					}
-					$scope.$uploading = false;
-				});
-			};
-			
+			// // 图片上传成功之后
+			// $scope.onAttachUploadSuccess = function(data){
+			// 	$scope.$apply(function() {
+			// 		$scope.component.attachFile = data;
+			// 		$scope.component.attach = data.path;
+			// 		if($scope.component.attachFile.size >= 1024 * 1024) {
+			// 			$scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024 / 1024, 1) + 'Mb';
+			// 		} else if($scope.component.attachFile.size >= 1024) {
+			// 			$scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024, 1) + 'Kb';
+			// 		} else {
+			// 			$scope.component.attachFile.size = $scope.component.attachFile.size + 'b';
+			// 		}
+			// 		$scope.$uploading = false;
+			// 	});
+			// };
+
+            //上传规格书
+            $scope.onAttachUploadSuccess = function () {
+                if($scope.component.attachFile[0].size >= 1024 * 1024) {
+                    $scope.component.attachFile.size = $filter('number')($scope.component.attachFile[0].size / 1024 / 1024, 1) + 'Mb';
+                } else if($scope.component.attachFile.size >= 1024) {
+                    $scope.component.attachFile.size = $filter('number')($scope.component.attachFile[0].size / 1024, 1) + 'Kb';
+                } else {
+                    $scope.component.attachFile.size = $scope.component.attachFile[0].size + 'b';
+                }
+                $scope.component.attach = $scope.component.attachFile[0].name;
+                $scope.$uploading = false;
+            };
+
 			// 重新上传,取消重新上传
 			// 重新上传,取消重新上传
 			$scope.reUpload = function() {
 			$scope.reUpload = function() {
 				$scope.$uploading = !$scope.$uploading;
 				$scope.$uploading = !$scope.$uploading;
@@ -321,13 +334,30 @@ define([ 'app/app', 'jquery-summernote', 'jquery-uploadify' ], function(app) {
 					toaster.pop('error', '提交失败', '详细描述不可为空');
 					toaster.pop('error', '提交失败', '详细描述不可为空');
 					return;
 					return;
 				}
 				}
-				// 提交保存
-				ComponentSubmit.save({}, $scope.component, function(data){
-					toaster.pop('success', '提示', '提交成功,请等待审核');
-					window.location.replace('vendor#/home/componentMaintenance');
-				},function(response){
-					toaster.pop('error', '提交失败', response.data);
-				});
+				// // 提交保存
+				// ComponentSubmit.save({}, $scope.component, function(data){
+				// 	toaster.pop('success', '提示', '提交成功,请等待审核');
+				// 	window.location.replace('vendor#/home/componentMaintenance');
+				// },function(response){
+				// 	toaster.pop('error', '提交失败', response.data);
+				// });
+                var file = null;
+                if($scope.component.attachFile && $scope.component.attachFile[0]) {
+                    file = $scope.component.attachFile[0];
+                }
+                $upload.upload({
+                    url: 'produce/componentSubmit/upload',
+                    file: file,
+                    method: 'POST',
+                    data: {
+                        component: $scope.component
+                    }
+                }).success(function(data){
+                    toaster.pop('success', '提示', '提交成功,请等待审核');
+                    window.location.replace('vendor#/home/componentMaintenance');
+                }).error(function(response){
+                    toaster.pop('error', '提交失败', response.data);
+                });
 			};
 			};
 		}]);
 		}]);
 		
 		

+ 50 - 19
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_component_apply_ctrl.js

@@ -4,7 +4,7 @@
  */
  */
 define(['app/app', 'jquery-uploadify'], function(app) {
 define(['app/app', 'jquery-uploadify'], function(app) {
     "use strict";
     "use strict";
-    app.register.controller('vendorComponentApplyCtrl', ['$scope', '$rootScope', 'Search', 'KindAPI', 'ComponentActive', 'ComponentActiveAPI', '$filter', 'ComponentSubmit', 'toaster', 'BrandActiveAPI', '$modal', function($scope, $rootScope, Search, KindAPI, ComponentActive, ComponentActiveAPI, $filter, ComponentSubmit, toaster, BrandActiveAPI, $modal) {
+    app.register.controller('vendorComponentApplyCtrl', ['$scope', '$rootScope', 'Search', 'KindAPI', 'ComponentActive', 'ComponentActiveAPI', '$filter', 'ComponentSubmit', 'toaster', 'BrandActiveAPI', '$modal', '$upload', function($scope, $rootScope, Search, KindAPI, ComponentActive, ComponentActiveAPI, $filter, ComponentSubmit, toaster, BrandActiveAPI, $modal, $upload) {
         $rootScope.active = "vendor_component_apply";
         $rootScope.active = "vendor_component_apply";
 
 
         document.title = "器件申请" + "-优软商城";
         document.title = "器件申请" + "-优软商城";
@@ -239,21 +239,34 @@ define(['app/app', 'jquery-uploadify'], function(app) {
             toaster.pop('success', '上传成功');
             toaster.pop('success', '上传成功');
         };
         };
 
 
-        // 规格书上传成功之后
-        $scope.onAttachUploadSuccess = function(data){
-            $scope.$apply(function() {
-                $scope.component.attachFile = data;
-                $scope.component.attach = data.path;
-                if($scope.component.attachFile.size >= 1024 * 1024) {
-                    $scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024 / 1024, 1) + 'Mb';
-                } else if($scope.component.attachFile.size >= 1024) {
-                    $scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024, 1) + 'Kb';
-                } else {
-                    $scope.component.attachFile.size = $scope.component.attachFile.size + 'b';
-                }
-                toaster.pop('success', '上传成功');
-                $scope.$uploading = false;
-            });
+        // // 规格书上传成功之后 - 使用uploadify jQuery插件,在禁用flash时,无法正常显示,所以修改 2018年4月20日 09:20:43 dongbw
+        // $scope.onAttachUploadSuccess = function(data){
+        //     $scope.$apply(function() {
+        //         $scope.component.attachFile = data;
+        //         $scope.component.attach = data.path;
+        //         if($scope.component.attachFile.size >= 1024 * 1024) {
+        //             $scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024 / 1024, 1) + 'Mb';
+        //         } else if($scope.component.attachFile.size >= 1024) {
+        //             $scope.component.attachFile.size = $filter('number')($scope.component.attachFile.size / 1024, 1) + 'Kb';
+        //         } else {
+        //             $scope.component.attachFile.size = $scope.component.attachFile.size + 'b';
+        //         }
+        //         toaster.pop('success', '上传成功');
+        //         $scope.$uploading = false;
+        //     });
+        // };
+
+        //上传规格书
+        $scope.onAttachUploadSuccess = function () {
+            if($scope.component.attachFile[0].size >= 1024 * 1024) {
+                $scope.component.attachFile.size = $filter('number')($scope.component.attachFile[0].size / 1024 / 1024, 1) + 'Mb';
+            } else if($scope.component.attachFile.size >= 1024) {
+                $scope.component.attachFile.size = $filter('number')($scope.component.attachFile[0].size / 1024, 1) + 'Kb';
+            } else {
+                $scope.component.attachFile.size = $scope.component.attachFile[0].size + 'b';
+            }
+            $scope.component.attach = $scope.component.attachFile[0].name;
+            $scope.$uploading = false;
         };
         };
 
 
         // 重新上传,取消重新上传
         // 重新上传,取消重新上传
@@ -368,11 +381,29 @@ define(['app/app', 'jquery-uploadify'], function(app) {
 
 
             $scope.component.properties = getProperValues();// 属性
             $scope.component.properties = getProperValues();// 属性
 
 
-            // 提交保存
-            ComponentSubmit.save({}, $scope.component, function(data){
+            // // 提交保存
+            // ComponentSubmit.save({}, $scope.component, function(data){
+            //     toaster.pop('success', '提示', '提交成功,请等待审核');
+            //     window.location.replace('vendor#/component/applylist');
+            // },function(response){
+            //     $scope.submitEnable = true;
+            //     toaster.pop('error', '提交失败', response.data);
+            // });
+            var file = null;
+            if($scope.component.attachFile && $scope.component.attachFile[0]) {
+                file = $scope.component.attachFile[0];
+            }
+            $upload.upload({
+                url: 'produce/componentSubmit/upload',
+                file: file,
+                method: 'POST',
+                data: {
+                    component: $scope.component
+                }
+            }).success(function(data){
                 toaster.pop('success', '提示', '提交成功,请等待审核');
                 toaster.pop('success', '提示', '提交成功,请等待审核');
                 window.location.replace('vendor#/component/applylist');
                 window.location.replace('vendor#/component/applylist');
-            },function(response){
+            }).error(function(response){
                 $scope.submitEnable = true;
                 $scope.submitEnable = true;
                 toaster.pop('error', '提交失败', response.data);
                 toaster.pop('error', '提交失败', response.data);
             });
             });

+ 1 - 1
src/main/webapp/resources/view/prod/product_component_edit_detail.html

@@ -218,7 +218,7 @@
 									</div>
 									</div>
 								</div>
 								</div>
 								<div class="upload-container" ng-if="!component.attachFile || $uploading">
 								<div class="upload-container" ng-if="!component.attachFile || $uploading">
-									<input type="file" id="attachUpload" on-success="onAttachUploadSuccess($data)" uploadify="{}">
+									<input class="input-file-default" type="file" ng-file-select ng-model="component.attachFile" ng-change="onAttachUploadSuccess()" ng-multiple="false" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg,application/pdf,*.pdf">
 								</div>
 								</div>
 								<div class="help-block">请上传器件的官方规格书文档!</div>
 								<div class="help-block">请上传器件的官方规格书文档!</div>
 							</div>
 							</div>

+ 16 - 16
src/main/webapp/resources/view/vendor/forstore/vendor_component_apply.html

@@ -203,22 +203,22 @@
                         <li class="brand_logo">
                         <li class="brand_logo">
                             <span class="fl">规格文档</span>
                             <span class="fl">规格文档</span>
                             <div style="float: left; padding-left: 10px;">
                             <div style="float: left; padding-left: 10px;">
-                                <div class="" ng-if="component.attachFile">
-                                    <div class="alert alert-success alert-sm f14">
-                                        <a href="{{component.attachFile.path}}">
-                                            <i class="fa fa-file"></i>
-                                            <strong ng-bind="component.attachFile.fileName"></strong>
-                                        </a>(<span ng-bind="component.attachFile.size"></span>)
-                                        <a class="pull-right text-muted f12" ng-click="removeAttach()">删除</a>
-                                        <span class="pull-right">&nbsp;&nbsp;&nbsp;</span>
-                                        <a ng-click="reUpload()" class="pull-right text-muted f12">
-                                            <span ng-if="!$uploading">重新上传</span>
-                                            <span ng-if="$uploading">取消重新上传</span>
-                                        </a>
-                                    </div>
-                                </div>
-                                <div class="upload-container" ng-if="!component.attachFile || $uploading">
-                                    <input type="file" id="attachUpload" on-success="onAttachUploadSuccess($data)" uploadify="{}">
+                                <!--<div class="" ng-if="component.attachFile">-->
+                                    <!--<div class="alert alert-success alert-sm f14">-->
+                                        <!--<a href="{{component.attachFile.path}}">-->
+                                            <!--<i class="fa fa-file"></i>-->
+                                            <!--<strong ng-bind="component.attachFile.fileName"></strong>-->
+                                        <!--</a>(<span ng-bind="component.attachFile.size"></span>)-->
+                                        <!--<a class="pull-right text-muted f12" ng-click="removeAttach()">删除</a>-->
+                                        <!--<span class="pull-right">&nbsp;&nbsp;&nbsp;</span>-->
+                                        <!--<a ng-click="reUpload()" class="pull-right text-muted f12">-->
+                                            <!--<span ng-if="!$uploading">重新上传</span>-->
+                                            <!--<span ng-if="$uploading">取消重新上传</span>-->
+                                        <!--</a>-->
+                                    <!--</div>-->
+                                <!--</div>-->
+                                <div class="upload-container">
+                                    <input class="input-file-default" type="file" ng-file-select ng-model="component.attachFile" ng-change="onAttachUploadSuccess()" ng-multiple="false" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg,application/pdf,*.pdf">
                                 </div>
                                 </div>
                                 <div class="help-block">请上传器件的官方规格书文档!</div>
                                 <div class="help-block">请上传器件的官方规格书文档!</div>
                             </div>
                             </div>