gaodd 2 lat temu
rodzic
commit
fb07f6fc8d

+ 2 - 3
src/main/resources/static/app/storage/controller/safeProduceRiskCtrl.js

@@ -92,8 +92,7 @@ angular
92 92
     ) {
93 93
       // $scope.orgName = $rootScope.depotInfo.orgName;
94 94
       $scope.insertRisk = {
95
-        libraryPointName: $rootScope.depotInfo.orgName,
96
-        riskTypeId: 1,
95
+        libraryPointName: $rootScope.depotInfo.orgName
97 96
       };
98 97
       //下面的判断用于查看页面只读状态
99 98
       if ($stateParams.isNotEdit != null) {
@@ -117,7 +116,7 @@ angular
117 116
             .then(function (data) {
118 117
               $scope.insertRisk = data.data;
119 118
               $scope.insertRisk.riskClassification = parseInt($scope.insertRisk.riskClassification);
120
-              $scope.insertRisk.riskTypeID = parseInt($scope.insertRisk.riskTypeId);
119
+              $scope.insertRisk.riskTypeId = parseInt($scope.insertRisk.riskTypeId);
121 120
             });
122 121
         }
123 122
       };

+ 200 - 15
src/main/resources/static/app/storage/safe-manage/controller/safeManageCtrl.js

@@ -47,8 +47,8 @@ angular.module('app.storage').controller("safeManageCtrl", function($scope, $roo
47 47
     }
48 48
 
49 49
 })
50
-.controller("safeManageEditCtrl", function($scope, $state, $rootScope, $http, $filter, $location, $stateParams,
51
-										safeManageService,$uibModal) {
50
+.controller("safeManageEditCtrl", function($scope, $state, $rootScope, $http, $filter, $location, $stateParams,FileUploader,
51
+										safeManageService,$uibModal,APP_CONFIG) {
52 52
 	// 防止重复提交标记
53 53
 	$scope.saveFlag = false;
54 54
 
@@ -84,9 +84,10 @@ angular.module('app.storage').controller("safeManageCtrl", function($scope, $roo
84 84
     
85 85
 	$scope.loadDataById = function(id) {
86 86
 		safeManageService.edit(id).then(function(data){
87
-			$scope.safeManage = data;
88
-			$scope.safeManage.productionDate = $filter('date')(data.productionDate, "yyyy-MM-dd");
89
-			$scope.safeManage.rectificationState = data.rectificationState+"";
87
+			$scope.safeManage = data.storageSafeManageWithBLOBs;
88
+			$scope.safeManage.productionDate = $filter('date')(data.storageSafeManageWithBLOBs.productionDate, "yyyy-MM-dd");
89
+			$scope.safeManage.rectificationState = data.storageSafeManageWithBLOBs.rectificationState+"";
90
+			$scope.fileList = data.fileList;
90 91
 			/*$("#safeManage-form input").attr("disabled",$scope.disabled );
91 92
 			$("#safeManage-form select").attr("disabled",$scope.disabled );
92 93
 			$("#safeManage-form textarea").attr("disabled",$scope.disabled );*/
@@ -109,10 +110,177 @@ angular.module('app.storage').controller("safeManageCtrl", function($scope, $roo
109 110
 		$scope.isEditsbr = false ;
110 111
 	}
111 112
 
113
+	
114
+	// -----------------------------------------------   上传下载相关     开始------------------------------------------------
115
+    var bid = null;
116
+	// 添加一行,取最大值加1放入数组
117
+	$scope.linenumber = 0;
118
+	$scope.linenumbers = [];
119
+	if ($stateParams.id == '') {
120
+		$scope.linenumbers = [0];
121
+	}
122
+	
123
+	// 新增一行
124
+	$scope.addFile = function() {
125
+		if ($scope.linenumbers.length == 0 ) {
126
+			$scope.linenumbers.push(0);
127
+		} else if($scope.fileItem === undefined || $scope.fileItem === null){
128
+			alert("请先添加文件,在添加浏览框.");
129
+			return;
130
+		}else {
131
+			var maxlinenumber = Math.max.apply(null, $scope.linenumbers);
132
+			$scope.linenumbers.push(maxlinenumber + 1);
133
+			$scope.fileItem = null;
134
+		}
135
+	}
136
+	
137
+	// 文件上传实例
138
+	$scope.fileIds = [];
139
+	
140
+	// 以linenumber为key,以新增的附件对应为value.
141
+	$scope.fileMap = new Map();
142
+	
143
+	// 上传.
144
+	$scope.uploader = new FileUploader({
145
+		url : APP_CONFIG.businessUrl + '/depot/business/file/uploadFile',
146
+		//url : APP_CONFIG.basicUrl + '/fileUpload/updateFileBusiness',
147
+		autoUpload : true, // 将文件添加到队列后自动上传.
148
+		formData : [{type : 'safeManage',userId:$rootScope.userInfo.userId,orgId:$rootScope.userInfo.orgId}], // 与文件一起发送的数据
149
+		
150
+		//url : APP_CONFIG.basicUrl + '/fileUpload/uploadFile',
151
+		//headers : {'content-type':"text/plain;charset=UTF-8"},
152
+		//formData : [{type : 'plan'}], // 与文件一起发送的数据
153
+		removeAfterUpload : true, // 从队列上传后删除文件
154
+		// 上传进度
155
+		
156
+		onProgressItem : function(fileItem, progress) {
157
+			$scope.fileItem = fileItem;
158
+			if(progress==100){
159
+				alert("上传成功!");
160
+			}
161
+			// console.info("正在上传:" + progress + "%");
162
+		},
163
+		// 回调函数,在一个文件上传成功后触发
164
+		
165
+		onSuccessItem : function(fileItem, response, status, headers) {
166
+			
167
+			// 将新fileId加入到fileIds.
168
+			$scope.fileIds.push(response.id);
169
+			// 如果已经存在对应的fileId,先从$scope.fileIds中移除,再添加.
170
+			if ($scope.fileMap.has($scope.linenumber)) {
171
+				// 原fileId.
172
+				var fileId = $scope.fileMap.get($scope.linenumber).id;
173
+				// 从$scope.fileIds中移除原fileId.
174
+				var index = $scope.fileIds.indexOf(fileId);
175
+		        if (index != -1) {
176
+		            // 后台删除.
177
+		            $scope.deleteFileByFileId(fileId);
178
+		        }
179
+			}
180
+			
181
+			$scope.fileMap.set($scope.linenumber, response);
182
+			
183
+		}
184
+	});
185
+	
186
+	// 点击文件框
187
+	$scope.clickInput = function(index) {
188
+		$scope.linenumber = index;
189
+        document.activeElement.previousSibling.children[0].click();
190
+		// console.log(angular.element("#fileInputId" + index));
191
+		// angular.element("#fileInputId" + index).trigger('click');
192
+	}
193
+	
194
+	
195
+	// 点击浏览按钮.
196
+	$scope.clickFileInput = function(index) {
197
+		$scope.linenumber = index;
198
+	}
199
+	
200
+	// 下载文件
201
+	$scope.downloads = function(filePath, originalFileName) {
202
+		$("#filePath").val(filePath);
203
+		$("#type").val("business");
204
+		$("#originalFileName").val(originalFileName);
205
+		$("#download-form").attr("action", APP_CONFIG.businessUrl + '/download');
206
+		$("#download-form").submit();
207
+    	
208
+	}
209
+	
210
+	// 文件上传实例
211
+	$scope.deleteFileIds = [];
212
+	// 回显删除.
213
+	$scope.deleteFile = function(file) {
214
+		// 回显删除,先不真正删除,把要删除的附件id保存在数组中,再最后保存的时候传递给后台,进行删除.
215
+		$scope.deleteFileIds.push(file.id);
216
+		
217
+		// 删除文件和数据库信息.
218
+		// $scope.deleteFileByFileId(file.id);
219
+		
220
+		// 从$scope.fileList 移除.
221
+		var index = $scope.fileList.indexOf(file);
222
+		if (index != -1) {
223
+			$scope.fileList.splice(index, 1);
224
+		}
225
+	}
226
+	
227
+	$scope.deleteFileByLinenumber = function(linenumber) {
228
+		var index = $scope.linenumbers.indexOf(linenumber);
229
+        if (index != -1) {
230
+        	// 从linenumbers移除.
231
+            $scope.linenumbers.splice(index, 1);
232
+            
233
+            if ($scope.fileMap.has($scope.linenumber)) {
234
+            	// 以linenumber为key从$scope.fileMap获取fileId.
235
+            	   var fileId = $scope.fileMap.get($scope.linenumber).id;
236
+		        	// 后台删除数据和文件.
237
+		        	$scope.deleteFileByFileId(fileId, index);
238
+		        	
239
+		        	// 从$scope.fileMap移除.
240
+		        	$scope.fileMap.delete(linenumber);
241
+			}
242
+        }
243
+	}
244
+	
245
+	$scope.deleteFileByFileId = function(fileId) {
246
+		businessFileService.remove(fileId).then(function(data){
247
+			if (data.status == "success") {
248
+	    		// 删除成功.
249
+	    		var index = $scope.fileIds.indexOf(fileId);
250
+	        	if (index != -1) {
251
+		        	// 从$scope.fileIds中移除.
252
+		        	$scope.fileIds.splice(index, 1);
253
+	        	}
254
+	    	}
255
+		},function (data) {
256
+			console.log(data);
257
+		});
258
+	}
259
+	
260
+	// 新增预览.
261
+	$scope.showFileByLinenumber = function(linenumber) {
262
+		if ($scope.fileMap.has($scope.linenumber)) {
263
+        	// 以linenumber为key从$scope.fileMap获取filePath.
264
+        	var filePath = $scope.fileMap.get($scope.linenumber).filePath;
265
+        	window.open(filePath);
266
+		}
267
+	}
268
+	
269
+	// 回显预览.
270
+	
271
+	$scope.showFile = function(filePath, originalFileName) {
272
+		var a= "/home/depot/depot-web/apache-tomcat-8.0.53/webapps/ROOT/WEB-INF/classes/static";
273
+		var b = a.concat(filePath);
274
+		window.open(b);
275
+	}
276
+    
277
+	// -----------------------------------------------   上传下载相关     结束           ------------------------------------------------
278
+	
279
+	
280
+	
112 281
 	// 新增或修改保存数据
113 282
 	var validator = $("#safeManage-form").validate();
114 283
 	$scope.saveData = function() {
115
-		if (!$scope.saveFlag) {
116 284
 			if (validator.form()) {
117 285
 				$("input[name='zgsx']").each(function (j, item) {
118 286
 					if (item.value != '' && item.value != null && typeof item.value != 'undefined') {
@@ -122,22 +290,39 @@ angular.module('app.storage').controller("safeManageCtrl", function($scope, $roo
122 290
 				$scope.saveFlag = true;
123 291
 				$scope.safeManage.orgId = $rootScope.orgInfo.orgId;
124 292
 				$scope.safeManage.county = $rootScope.orgInfo.zcCounty;
125
-				safeManageService.save($scope.safeManage).then(function (data) {
126
-					if (data.status == "200") {
127
-						alert(data.msg);
128
-						$state.go('app.storage.safeproduce.safeManage');
129
-					} else {
130
-						alert(data.msg);
131
-						$scope.saveFlag = false;
293
+				if($scope.safeManage.rectificationState == 2){
294
+					//整改状态为已完成的隐患内容提交后不允许修改
295
+					if(confirm("隐患内容提交后不允许修改,请确认各项数据填写准确!")){  
296
+						//deleteFileIds : angular.toJson($scope.deleteFileIds)
297
+						//fileIds : angular.toJson($scope.fileIds),
298
+    					//deleteFileIds : angular.toJson($scope.deleteFileIds)
299
+						safeManageService.save($scope.safeManage,angular.toJson($scope.fileIds),angular.toJson($scope.deleteFileIds)).then(function (data) {
300
+							if (data.status == "200") {
301
+								alert(data.msg);
302
+								$state.go('app.storage.safeproduce.safeManage');
303
+							} else {
304
+								alert(data.msg);
305
+							}
306
+						});
132 307
 					}
133
-				});
308
+				}else{
309
+					safeManageService.save($scope.safeManage,angular.toJson($scope.fileIds),angular.toJson($scope.deleteFileIds)).then(function (data) {
310
+						if (data.status == "200") {
311
+							alert(data.msg);
312
+							$state.go('app.storage.safeproduce.safeManage');
313
+						} else {
314
+							alert(data.msg);
315
+						}
316
+					});
317
+				}
134 318
 			}
135
-		}
136 319
 	};
137 320
 
138 321
 	$scope.retList = function(){
139 322
 		//$rootScope.back();
140 323
 		$state.go('app.storage.safeproduce.safeManage');
141 324
 	};
325
+	
326
+	
142 327
 
143 328
 });

+ 4 - 2
src/main/resources/static/app/storage/safe-manage/service/safeManageService.js

@@ -44,13 +44,15 @@ angular.module('app.storage').service("safeManageService", function($http, $q, $
44 44
 	};
45 45
 
46 46
 	//保存
47
-	this.save = function (safeManage) {
47
+	this.save = function (safeManage,fileIds,deleteFileIds) {
48 48
 		var d = $q.defer();
49 49
 		$http({
50 50
 			method : 'POST',
51 51
 			url : APP_CONFIG.depotStorageUrl + '/StorageSafeManageController/saveAndUpdate',
52 52
 			data : {
53
-				storageSafeManage : angular.toJson(safeManage)
53
+				storageSafeManage : angular.toJson(safeManage),
54
+				fileIds : fileIds,
55
+				deleteFileIds : deleteFileIds
54 56
 			}
55 57
 		}).then(function successCallback(response) {
56 58
 			// 请求成功执行代码

+ 85 - 1
src/main/resources/static/app/storage/safe-manage/views/safeManage-edit.html

@@ -172,13 +172,92 @@
172 172
                                             <label class="select"> 
173 173
                                                 <select ng-model="safeManage.rectificationState"  name="rectificationState" ng-disabled="isEdit"  required>
174 174
                                                 	<option value="">--请选择--</option>
175
+                                                	<option value="0">未整改</option>
175 176
                                                 	<option value="1">整改中</option>
176 177
                                                 	<option value="2">已完成</option>
177 178
                                                 </select>
178 179
                                             </label>
179 180
 		                                </section>
180 181
 									</div>
181
-
182
+							
183
+								<header>
184
+                                	<h3>
185
+                                		<strong>附件信息</strong>
186
+                                		<a href-void class="btn btn-primary" ng-hide="isEdit" ng-click="addFile()"> <i class="fa fa-plus"></i>文件 </a>
187
+                               		</h3>
188
+                          		</header>
189
+								<div>
190
+                                	<table ng-hide="isNotEdit" class="table table-striped table-bordered table-hover" ng-repeat="linenumber in linenumbers" ng-click="clickFileInput(linenumber)" >
191
+		                                <!--第四3个tr开始 -->
192
+										<tr>
193
+											<th width='10%' >
194
+												<label class="label" style="margin-top: 9px;text-align: center;">附件</label>
195
+											</th>
196
+											<th colspan="4">
197
+												<section>
198
+									            	<div class="input input-file" style="margin-top: 9px; text-align: center; margin-right: 22px;">
199
+											            <span class="button" >
200
+											            	<input type="file" nv-file-select="" uploader="uploader" accept="*" options="id" id="fileInputId{{linenumber}}"
201
+											            		onchange="if (this.value != '')this.parentNode.nextSibling.value = this.value">
202
+											                	上传
203
+											            </span><input type="text" name="imgUrl" placeholder="" readonly="">
204
+										        	</div>
205
+									            </section>
206
+											</th>
207
+											<!-- <th width='10%' class="text-align-center">
208
+													<div class="input input-file" style="margin-top: 9px; text-align: center; margin-right: 16px;">
209
+														<span class="button"  ng-click="showFileByLinenumber(linenumber)">预览
210
+											            </span>
211
+													</div>
212
+											</th> -->
213
+											
214
+											<th width='10%'>
215
+	                                                <!-- <span class="button" style="margin-top: 9px; text-align: center; margin-right: 22px;" ng-click="deleteFileByLinenumber(linenumber)">删除
216
+										            </span> -->
217
+										            <div class="input input-file" style="margin-top: 9px; text-align: center; margin-right: 16px;">
218
+														<span class="button"  ng-click="deleteFileByLinenumber(linenumber)">删除
219
+											            </span>
220
+													</div>
221
+											</th>
222
+											
223
+										</tr>
224
+										<!--第四3个tr结束 -->
225
+		                             </table>
226
+                                
227
+                                	<!--回显文件的表格  -->
228
+                                	
229
+                                	<table class="table table-striped table-bordered table-hover" ng-repeat="file in fileList" >
230
+		                                <!--第四3个tr开始 -->
231
+										<tr>
232
+											<th width='10%' >
233
+												<label class="label" style="margin-top: 9px;text-align: center;">附件</label>
234
+											</th>
235
+											<th colspan="5">
236
+												<section >
237
+										            <input class="form-control" type="text" ng-model="file.originalFileName" readonly="">
238
+		                                		</section>
239
+											</th>
240
+											<th width='10%' >
241
+												<section style="margin-top: 9px; text-align: center; margin-right: 22px;">
242
+							                        <a class="btn btn-default" href-void ng-click="downloads(file.filePath, file.originalFileName)"><i class="fa fa-download"></i>下载</a>
243
+		                                		</section>
244
+											</th>
245
+											
246
+											<!-- <th width='10%'>
247
+												<section style="margin-top: 9px; text-align: center; margin-right: 22px;">
248
+							                        <a class="btn btn-default" href-void ng-click="showFile(file.filePath)"><i class="fa fa-download"></i>预览</a>
249
+		                                		</section>
250
+											</th>
251
+											<th width='10%'>
252
+												<section  ng-hide="isNotEdit" style="margin-top: 9px; text-align: center; margin-right: 22px;">
253
+							                        <a class="btn btn-default" href-void ng-click="deleteFile(file)"><i class="fa fa-trash-o"></i>删除</a>
254
+		                                		</section>
255
+											</th> -->
256
+											
257
+										</tr>
258
+										<!--第四3个tr结束 -->
259
+		                             </table>
260
+		                             </div>
182 261
 								</fieldset>
183 262
 
184 263
 								<footer class="text-align-center">
@@ -192,4 +271,9 @@
192 271
 			</article>
193 272
 		</div>
194 273
 	</section>
274
+	<form id="download-form" method="post" target="_blank" style=" border-width:5px; margin-left:2%;position:relative;margin-right:2%;">
275
+		<input type="hidden" name="filePath" id="filePath">
276
+		<input type="hidden" name="originalFileName" id="originalFileName">
277
+		<input type="hidden" name="type" id="type">
278
+	</form>
195 279
 </div>

+ 2 - 1
src/main/resources/static/app/storage/safe-manage/views/safeManage-list.html

@@ -82,13 +82,14 @@
82 82
 											<td style="text-align:center;">{{safeManage.zgsx | date:'yyyy-MM-dd'}}</td>
83 83
 											<td style="text-align:center;">{{safeManage.zrdw}}</td>
84 84
 											<td style="text-align:center;">{{safeManage.createtime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
85
+											<td style="text-align:center;" ng-if="safeManage.rectificationState == 0">未整改</td>
85 86
 											<td style="text-align:center;" ng-if="safeManage.rectificationState == 1">整改中</td>
86 87
 											<td style="text-align:center;" ng-if="safeManage.rectificationState == 2">已完成</td>
87 88
 											<td style="text-align:center;">
88 89
 											    <a href-void ng-click="edit(safeManage.id, 'detail')">
89 90
 													<i class="fa fa-info-circle"></i>查看
90 91
 												</a>
91
-												<a ng-show="safeManage.rectificationState == 1" href-void ng-click="edit(safeManage.id, 'edit')">
92
+												<a ng-show="safeManage.rectificationState != 2" href-void ng-click="edit(safeManage.id, 'edit')">
92 93
 													<i class="fa fa-edit"></i>修改
93 94
 												</a>
94 95
 											</td>

+ 2 - 2
src/main/resources/static/app/storage/views/safeproduce/safeRiskLevelCtrl-edit.html

@@ -49,8 +49,8 @@
49 49
                                           <label class="label">风险类型<span style="color: red;">*</span></label>
50 50
                                           <label class="select">
51 51
                                             <select 
52
-                                                ng-model="insertRisk.riskTypeID" ng-disabled="isNotEdit"
53
-                                                name="riskTypeID" class="form-control input-sm"
52
+                                                ng-model="insertRisk.riskTypeId" ng-disabled="isNotEdit"
53
+                                                name="riskTypeId" class="form-control input-sm"
54 54
                                                 ng-options='enum.enumid as enum.enumname for enum in dicDataList[7512]' required>
55 55
                                                 <option value="">请选择</option>
56 56
                                             </select> <i></i>