|
|
@@ -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
|
});
|