Procházet zdrojové kódy

处理增加附件

seimin před 11 měsíci
rodič
revize
c2ceb56f7d

+ 85 - 1
assets/js/controllers/incident/incidentCtrl.js

@@ -1087,7 +1087,7 @@ app.controller('incidentListCtrl', ["$scope", "$http", "i18nService", "$rootScop
1087 1087
         var modalInstance = $modal.open({
1088 1088
             backdrop: false,
1089 1089
             templateUrl: 'assets/views/incident/tpl/doing.tpl.html',
1090
-            controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
1090
+            controller: function ($scope,$rootScope, $modalInstance,FileUploader, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
1091 1091
                 console.log(model,loginUser);
1092 1092
                 $scope.model = model;
1093 1093
 
@@ -1101,6 +1101,90 @@ app.controller('incidentListCtrl', ["$scope", "$http", "i18nService", "$rootScop
1101 1101
                 $scope.incidentClosecodeList = [];
1102 1102
                 $scope.synergeticList = [];
1103 1103
 
1104
+
1105
+                // 附件上传--start
1106
+                //附件上传数据
1107
+                let uploader = ($scope.uploader = new FileUploader({url: "/uploader"}));
1108
+
1109
+                // FILTERS
1110
+                uploader.filters.push({
1111
+                    name: "customFilter",
1112
+                    fn: function (item /*{File|FileLikeObject}*/, options) {
1113
+                    return this.queue.length < 10;
1114
+                    },
1115
+                });
1116
+
1117
+                $scope.dropfile = function (
1118
+                    APIService,
1119
+                    processInstanceId,
1120
+                    taskId,
1121
+                    userId
1122
+                ) {
1123
+                    uploader.onBeforeUploadItem = function (item) {
1124
+                    angular.extend(item.headers, $rootScope.getSession());
1125
+                    item.url = APIService.addFile(
1126
+                        processInstanceId,
1127
+                        taskId,
1128
+                        userId
1129
+                    ).getRequestedUrl();
1130
+                    item.formData.push({
1131
+                        fileName: item.file.name,
1132
+                    });
1133
+                    console.info("onBeforeUploadItem", item);
1134
+                    };
1135
+                    uploader.uploadAll();
1136
+                };
1137
+
1138
+                // CALLBACKS
1139
+                uploader.onWhenAddingFileFailed = function (
1140
+                    item /*{File|FileLikeObject}*/,
1141
+                    filter,
1142
+                    options
1143
+                ) {
1144
+                    console.info("onWhenAddingFileFailed", item, filter, options);
1145
+                };
1146
+                uploader.onAfterAddingFile = function (fileItem) {
1147
+                    console.info("onAfterAddingFile", fileItem);
1148
+                };
1149
+                uploader.onAfterAddingAll = function (addedFileItems) {
1150
+                    console.info("onAfterAddingAll", addedFileItems);
1151
+                };
1152
+                uploader.onBeforeUploadItem = function (item) {
1153
+                    console.info("onBeforeUploadItem", item);
1154
+                };
1155
+                uploader.onProgressItem = function (fileItem, progress) {
1156
+                    console.info("onProgressItem", fileItem, progress);
1157
+                };
1158
+                uploader.onProgressAll = function (progress) {
1159
+                    console.info("onProgressAll", progress);
1160
+                };
1161
+                uploader.onSuccessItem = function (
1162
+                    fileItem,
1163
+                    response,
1164
+                    status,
1165
+                    headers
1166
+                ) {
1167
+                    console.info("onSuccessItem", fileItem, response, status, headers);
1168
+                };
1169
+                uploader.onErrorItem = function (fileItem, response, status, headers) {
1170
+                    console.info("onErrorItem", fileItem, response, status, headers);
1171
+                };
1172
+                uploader.onCancelItem = function (fileItem, response, status, headers) {
1173
+                    console.info("onCancelItem", fileItem, response, status, headers);
1174
+                };
1175
+                uploader.onCompleteItem = function (
1176
+                    fileItem,
1177
+                    response,
1178
+                    status,
1179
+                    headers
1180
+                ) {
1181
+                    console.info("onCompleteItem", fileItem, response, status, headers);
1182
+                };
1183
+                uploader.onCompleteAll = function () {
1184
+                    console.info("onCompleteAll");
1185
+                };
1186
+                // 附件上传--end
1187
+
1104 1188
                 // 获取处理方式
1105 1189
                 $scope.getIncidentHandleCategory = function(){
1106 1190
                     api_wechatfile.getDictionary({"key":"incident_handleCategory","type":"list"}).then(function (data) {

+ 34 - 0
assets/views/incident/tpl/doing.tpl.html

@@ -62,6 +62,40 @@
62 62
             </div>
63 63
         </div>
64 64
     </div>
65
+    <div class="form-group incidentsearch" style="margin:0 auto;width: 300px;">
66
+        <div class="panel panel-white">
67
+            <div class="panel-heading">
68
+                <div style="width: 120px;" class="btn btn-blue btn-o btn-file col-md-2"><i class="fa fa-plus"></i><span translate="form.button.SELECTFILE"></span><input name="uploadedFile" type="file" nv-file-select="" uploader="uploader" />
69
+                </div>
70
+            </div>
71
+            <div class="panel-body">
72
+                <table class="table table-striped table-hover">
73
+                    <thead>
74
+                        <tr>
75
+                            <th style="text-align: center;width: 100px;display: inline-block;" class="ellipsis">名称</th>
76
+                            <th style="text-align: center;" class="ellipsis" ng-show="uploader.isHTML5">大小</th>
77
+                            <th style="text-align: center;" class="ellipsis">操作</th>
78
+                        </tr>
79
+                    </thead>
80
+                    <tbody>
81
+                        <tr ng-repeat="item in uploader.queue">
82
+                            <td style="text-align: center;width: 100px;display: inline-block;" class="ellipsis"><strong>{{ item.file.name }}</strong></td>
83
+                            <td style="text-align: center;" ng-show="uploader.isHTML5">{{ item.file.size/1024/1024|number:2 }} MB</td>
84
+                            <td style="text-align: center;">
85
+                                <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
86
+                                    <span class="glyphicon glyphicon-trash"></span>
87
+                                </button>
88
+                            </td>
89
+                        </tr>
90
+                    </tbody>
91
+                </table>
92
+
93
+                <button type="button" ng-if="to.isupdata" class="btn btn-success btn-s" ng-click="dropfile(to.ApiService,to.processInstanceId, to.taskId, to.userId)" ng-disabled="!uploader.getNotUploadedItems().length">
94
+                    <span class="glyphicon glyphicon-upload"></span> 上传
95
+                </button>
96
+            </div>
97
+        </div>
98
+    </div>
65 99
 </div>
66 100
 <div class="modal-footer modelfooter-hint" style="cursor: pointer;">
67 101
     <div class="hintfooterleft pull-left" ng-click="ok()" style="cursor: pointer;">确定</div>