Browse Source

添加模具供应商批量上传附件功能

wangmh 8 years ago
parent
commit
50e52e1519

+ 16 - 1
src/main/java/com/uas/platform/b2b/model/PurchaseInquiryMould.java

@@ -239,12 +239,19 @@ public class PurchaseInquiryMould implements Serializable {
     private Short valid;
 
     /**
-     * 附件
+     * 买家附件
      */
     @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
     @JoinTable(name = "purc$inquirymouldattach", joinColumns = @JoinColumn(name = "im_id", referencedColumnName = "im_id"), inverseJoinColumns = @JoinColumn(name = "at_id", referencedColumnName = "at_id"))
     private Set<Attach> attachs;
 
+    /**
+     * 卖家附件
+     */
+    @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
+    @JoinTable(name = "purc$inquirymouldsellattach", joinColumns = @JoinColumn(name = "im_id", referencedColumnName = "im_id"), inverseJoinColumns = @JoinColumn(name = "at_id", referencedColumnName = "at_id"))
+    private Set<Attach> sellAttachs;
+
     /**
      * erp sourceId
      */
@@ -498,6 +505,14 @@ public class PurchaseInquiryMould implements Serializable {
         this.attachs = attachs;
     }
 
+    public Set<Attach> getSellAttachs() {
+        return sellAttachs;
+    }
+
+    public void setSellAttachs(Set<Attach> sellAttachs) {
+        this.sellAttachs = sellAttachs;
+    }
+
     public Long getErpSourceId() {
         return erpSourceId;
     }

+ 1 - 0
src/main/java/com/uas/platform/b2b/service/impl/PurchaseInquiryMouldServiceImpl.java

@@ -261,6 +261,7 @@ public class PurchaseInquiryMouldServiceImpl implements PurchaseInquiryMouldServ
 		mould.setReplySendStatus((short) Status.NOT_UPLOAD.value());
 		mould.setReplyDate(new Date());
 		mould.setAttachs(inquiryMould.getAttachs());
+		mould.setSellAttachs(inquiryMould.getSellAttachs());
 		Long userUU = mould.getVendUserUU();
 		if (userUU == null) {
 			userUU = mould.getRecorderuu();

+ 50 - 14
src/main/webapp/resources/js/index/app.js

@@ -5301,9 +5301,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             }
         };
 
-        $scope.uploadAttach = function (mould) {
+        var uploadAttach = function (mould, file) {
 //			var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
-            var file = mould.attachs[0];
             $scope.mould = mould;
             $upload.upload({
                 url: 'sale/mould/' + mould.id + '/send',
@@ -5313,10 +5312,47 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                     json: $scope.mould
                 }
             }).success(function (res) {
+                $scope.mould.sellAttachs.push(res);
             }).error(function (res) {
             });
         }
 
+        $scope.pushFile = function(mould, file) {
+            // var file = $scope.myFiles;
+            if (file.length > 0) {
+                for (var i = 0; i < file.length; i++) {
+                    console.log(file[i].name);
+                    var flag = true;
+
+                    if (mould.sellAttachs.length > 0) {
+                        for (var j = 0; j < mould.sellAttachs.length; j++) {
+                            if (mould.sellAttachs[j].name == file[i].name
+                                && mould.sellAttachs[j].size == file[i].size) {
+                                flag = false;
+                                break;
+                            }
+                        }
+                    }
+                    if (flag) {
+                        uploadAttach(mould, file[i]);
+                        $scope.canSave = true;
+                    }
+                }
+            }
+            document.getElementById("inquiryMould.sellAttachs").value = "";
+        };
+
+        $scope.removeFile = function(mould, file) {
+            $scope.inquiryMould = mould;
+            if ($scope.inquiryMould.sellAttachs != null && $scope.inquiryMould.sellAttachs.length > 0) {
+                for (var i = 0; i < $scope.inquiryMould.sellAttachs.length; i++) {
+                    if ($scope.inquiryMould.sellAttachs[i].name == file.name
+                        && $scope.inquiryMould.sellAttachs[i].size == file.size) {
+                        $scope.inquiryMould.sellAttachs.splice(i, 1);
+                    }
+                }
+            }
+        };
 
         // 保存并确认报价
         $scope.onReplyClick = function (mould, withSteps) {
@@ -5502,7 +5538,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				}
 			}).success(function(attach){
                 if (attach){
-                    $scope.inquiryMould.attachs.push(attach);
+                    $scope.inquiryMould.sellAttachs.push(attach);
                 }
 			}).error(function(res){
 				console.log("failure");
@@ -5510,17 +5546,17 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			});
 		}
 
-        $scope.pushFile = function() {
-            var file = $scope.myFiles;
+        $scope.pushFile = function(file) {
+            // var file = $scope.myFiles;
             if (file.length > 0) {
                 for (var i = 0; i < file.length; i++) {
                     console.log(file[i].name);
                     var flag = true;
 
-                    if ($scope.inquiryMould.attachs.length > 0) {
-                        for (var j = 0; j < $scope.inquiryMould.attachs.length; j++) {
-                            if ($scope.inquiryMould.attachs[j].name == file[i].name
-                                && $scope.inquiryMould.attachs[j].size == file[i].size) {
+                    if ($scope.inquiryMould.sellAttachs.length > 0) {
+                        for (var j = 0; j < $scope.inquiryMould.sellAttachs.length; j++) {
+                            if ($scope.inquiryMould.sellAttachs[j].name == file[i].name
+                                && $scope.inquiryMould.sellAttachs[j].size == file[i].size) {
                                 flag = false;
                                 break;
                             }
@@ -5534,11 +5570,11 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
 
         $scope.removeFile = function(file) {
-            if ($scope.files != null && $scope.files.length > 0) {
-                for (var i = 0; i < $scope.files.length; i++) {
-                    if ($scope.files[i].name == file.name
-                        && $scope.files[i].size == file.size) {
-                        $scope.files.splice(i, 1);
+            if ($scope.inquiryMould.sellAttachs != null && $scope.inquiryMould.sellAttachs.length > 0) {
+                for (var i = 0; i < $scope.inquiryMould.sellAttachs.length; i++) {
+                    if ($scope.inquiryMould.sellAttachs[i].name == file.name
+                        && $scope.inquiryMould.sellAttachs[i].size == file.size) {
+                        $scope.inquiryMould.sellAttachs.splice(i, 1);
                         document.getElementById("file").value = "";
                     }
                 }

+ 16 - 9
src/main/webapp/resources/tpl/index/sale/inquiry_mould.html

@@ -443,21 +443,28 @@ tbody td div.text-mould {
 					<div ng-if="inquiryMould.attachs.length" class="text-muted">
 						附件:<a class="file" ng-repeat="attach in inquiryMould.attachs" href="file/{{attach.id}}">{{::attach.name}}</a>
 					</div>
+					<div ng-if="inquiryMould.sellAttachs.length" class="text-muted">
+						供应商附件:
+						<div ng-repeat="attach in inquiryMould.sellAttachs track by $index">
+							<a class="file"  href="file/{{attach.id}}">{{::attach.name}}</a>
+							<a style="color: #ff2222" ng-click="removeFile(inquiryMould, attach)">删除</a>
+						</div>
+					</div>
 				<!-- 	<div ng-if="inquiryMould.$editing && inquiryMould.attachs.length" class="text-muted">
 						附件:<a class="file" ng-repeat="attach in inquiryMould.attachs" href="" title="编辑报价时无法获取附件">{{::attach.name}}</a>
-					</div>
-					<div ng-if="inquiryMould.$editing && !inquiryMould.attachs.length"
+					</div>-->
+					<div ng-if="inquiryMould.$editing"
 						 class="input-group input-group-sm col-sm-10" style="padding-top: 5px;">
 						<span class="input-group-addon">上传附件:</span>
-						<input type="file" ng-model="inquiryMould.attachs" ng-file-select
-							ng-multiple="false" class="form-control input-sm" name="inquiryMould.attachs"
-							id="inquiryMould.attachs">
+						<input type="file" ng-model="myFiles" ng-file-select
+							ng-multiple="true" class="form-control input-sm" name="inquiryMould.sellAttachs"
+							id="inquiryMould.sellAttachs">
 						<span class="input-group-btn">
-							<button ng-click="uploadAttach(mould)"
-								ng-disabled="!inquiryMould.attachs.length"
-								class="btn btn-success" type="button">确认上传</button>
+							<button ng-click="pushFile(inquiryMould, myFiles);notZero(inquiryMould)"
+								ng-disabled="!myFiles"
+								class="btn btn-success" type="button" >确认上传</button>
 						</span>
-					</div> -->
+					</div>
 				</td>
 				<td class="text-center">
 				</td>

+ 33 - 3
src/main/webapp/resources/tpl/index/sale/inquiry_mould_detail.html

@@ -118,7 +118,7 @@ a:hover{
 				<tr class="header">
 					<th width="380">模具资料</th>
 					<th width="300">币别:<span ng-bind="inquiryMould.currency"></span>&nbsp;&nbsp;&nbsp;价格&nbsp;&nbsp;&nbsp;<span>税率:</span><input class="taxrate-input" ng-model="inquiryMould.taxrate" ng-pattern="/^[0-9][0-9]{0,1}$/" style="width: 30px;" ng-disabled="!inquiryMould.$editing">%</th>
-					<th width="150">附件</th>
+					<!--<th width="150">附件</th>-->
 					<th width="100"></th>
 				</tr>
 				</thead>
@@ -186,7 +186,7 @@ a:hover{
 							</div>
 						</div>
 					</td>
-					<td width="150" style="vertical-align: top" class="text-center">
+					<!--<td width="150" style="vertical-align: top" class="text-center">
 						<div class="input-group form-group" style="width: 300px; position: relative;">
 							<a style="color: #327ebe">上传附件</a>
 							<input type="file" ng-model="myFiles" ng-file-select multiple="multiple"
@@ -196,7 +196,7 @@ a:hover{
 								<p class="text-left"><a style="color: #0000cc">{{file.name}}</a></p>
 							</div>
 						</div>
-					</th>
+					</td>-->
 					<td class="text-center" width="100">
 						<div ng-if="inquiryMould.status == 200 && inquiryMould.overdue == 0 && inquiryMould.valid != 0 && inquiryMould.adoptStatus == null" class="block">
 							<span class="text-waiting">待报价</span>
@@ -228,6 +228,36 @@ a:hover{
 				</tbody>
 			</table>
 		</div>
+		<div class="title-div" style="border-bottom: 1px dashed #327ebe;">
+			<span class="f14">供应商附件</span>&nbsp;
+		</div>
+		<div class="block">
+			<table class="block table table-default table-striped" style="margin-bottom: 0;">
+				<td width="150" style="vertical-align: top" class="text-center">
+					<div class="input-group form-group" style="width: 300px; position: relative;">
+						<div ng-if="inquiryMould.$editing">
+							<a style="color: #327ebe">上传附件</a>
+							<input type="file" ng-model="myFiles" ng-file-select multiple="multiple"
+								   ng-multiple="false" class="form-control input-sm input-group uploadFile" name="file"
+								   ng-change="pushFile(myFiles);notZero(inquiryMould)">
+							<div ng-repeat="file in inquiryMould.sellAttachs track by $index">
+								<p class="text-left">
+									<a style="color: #0000cc" target="_blank" href="file/{{file.id}}">{{file.name}}</a>&nbsp;&nbsp;&nbsp;
+									<a style="color: #ff2222" ng-click="removeFile(file)">删除</a>
+								</p>
+							</div>
+						</div>
+						<div ng-if="!inquiryMould.$editing">
+							<div ng-repeat="file in inquiryMould.sellAttachs track by $index">
+								<p class="text-left">
+									<a style="color: #0000cc" target="_blank" href="file/{{file.id}}">{{file.name}}</a>&nbsp;&nbsp;&nbsp;
+								</p>
+							</div>
+						</div>
+					</div>
+				</td>
+			</table>
+		</div>
 	</div>
 </div>
 <div ng-if="inquiryMould.status == 200 && inquiryMould.overdue != 1 && inquiryMould.adoptStatus == null && inquiryMould.valid != 0">