瀏覽代碼

巡检增加图片

seimin 3 年之前
父節點
當前提交
7a7f8d057a
共有 2 個文件被更改,包括 113 次插入5 次删除
  1. 53 2
      src/views/InspectionDetail.vue
  2. 60 3
      src/views/inspectionDoneDetail.vue

+ 53 - 2
src/views/InspectionDetail.vue

@@ -50,6 +50,20 @@
50 50
         <cube-switch v-if="index%2==1" v-model="param[item.key]" :class="{'abnormal':param[item.key]}" :data-label="forms[index-1].templateOptions.placeholder" ></cube-switch>
51 51
       </p>
52 52
     </div>
53
+    <div class="label formLabel">
54
+      图片上传
55
+      <span>(最多可上传3张JPG或PNG,每张不能超过10M)</span>
56
+    </div>
57
+    <div class="uplod">
58
+      <cube-upload
59
+        ref="upload"
60
+        :max="3"
61
+        :action="action"
62
+        :simultaneous-uploads="3"
63
+        @files-added="filesAdded"
64
+        @file-submitted="fileSubmitted"
65
+      />
66
+    </div>
53 67
     <div class="btns">
54 68
       <div class="btn" @click="createIncident()">生成事件</div>
55 69
       <div class="btn submit" @click="submit()">提交</div>
@@ -61,6 +75,11 @@
61 75
 export default {
62 76
   data() {
63 77
     return {
78
+      action: {
79
+        target:
80
+          this.$host + "/service/common/common/uploadAttachment/inspection/",
81
+        data: {}
82
+      },
64 83
       loginUser: JSON.parse(localStorage.getItem("loginUser")),
65 84
       valConfig: JSON.parse(localStorage.getItem("valConfig")) - 0, //报修主体
66 85
       baseInfo: {}, //巡检基础信息
@@ -76,6 +95,26 @@ export default {
76 95
     };
77 96
   },
78 97
   methods: {
98
+    fileSubmitted(files) {
99
+      this.action.data = { fileName: files.name };
100
+    },
101
+    filesAdded(files) {
102
+      let hasIgnore = false;
103
+      const maxSize = 10 * 1024 * 1024; // 10M
104
+      for (let k in files) {
105
+        const file = files[k];
106
+        if (file.size > maxSize) {
107
+          file.ignore = true;
108
+          hasIgnore = true;
109
+        }
110
+      }
111
+      hasIgnore &&
112
+        this.$createToast({
113
+          type: "warn",
114
+          time: 1000,
115
+          txt: "不能上传超过10M的文件"
116
+        }).show();
117
+    },
79 118
     // 获取项目异常状态
80 119
     getItems() {
81 120
       var that = this;
@@ -138,6 +177,10 @@ export default {
138 177
         .then(function(res) {
139 178
           console.log(res.data);
140 179
           if (res.data.status == 200) {
180
+            that.action.target = that.action.target + that.param.inspectionProcessActual.processInstanceId;
181
+            setTimeout(function() {
182
+              that.$refs.upload.start();
183
+            }, 100);
141 184
             $("#fade").fadeIn();
142 185
             that.promptingConent = "恭喜您,提交成功!";
143 186
             that.promptingStatus = true;
@@ -176,11 +219,18 @@ export default {
176 219
     this.forms=JSON.parse( window.localStorage.getItem('forms'))||[];
177 220
     this.title = this.baseInfo.inspectionType.type;
178 221
     this.getItems();
222
+  },
223
+  mounted(){
224
+    this.$refs.upload.pause();
179 225
   }
180 226
 };
181 227
 </script>
182 228
 <style lang="less" scoped>
183 229
 .inspedtionDetail {
230
+  .uplod {
231
+    padding: 0.24rem;
232
+    border-bottom: 0.02rem solid rgb(245, 245, 245);
233
+  }
184 234
   .label {
185 235
     background-color: #eee;
186 236
     height: 0.6rem;
@@ -245,17 +295,18 @@ export default {
245 295
     justify-content: space-between;
246 296
     align-items: center;
247 297
     padding: 0.24rem;
298
+    display: flex;
248 299
     .btn {
249 300
       border: 0.01rem solid #005395;
250 301
       color: #005395;
251 302
       background-color: #fff;
252
-      width: 1.8rem;
303
+      flex: 1;
304
+      margin: 0 0.1rem;
253 305
       height: 0.88rem;
254 306
       line-height: 0.88rem;
255 307
       text-align: center;
256 308
       border-radius: 0.1rem;
257 309
       &.submit {
258
-        width: 3.06rem;
259 310
         background-color: #005395;
260 311
         color: #fff;
261 312
       }

+ 60 - 3
src/views/inspectionDoneDetail.vue

@@ -52,12 +52,36 @@
52 52
         <span v-if="index%2==1" class="colorGray">{{param[item.key]?'不正常':'正常'}}</span>
53 53
       </p>
54 54
     </div>
55
+    <div class="label">图片列表</div>
56
+    <div class="imgs-c">
57
+      <div class="imgs-container" v-if="imgs.length">
58
+        <div class="imgs-cont">
59
+          <img
60
+            v-if="
61
+              img.suffix == 'jpeg' ||
62
+              img.suffix == 'jpg' ||
63
+              img.suffix == 'gif' ||
64
+              img.suffix == 'png' ||
65
+              img.suffix == 'svg' ||
66
+              img.suffix == 'pdf'
67
+            "
68
+            :src="img.previewUrl"
69
+            v-for="(img, index) in imgs"
70
+            class="imgs"
71
+          />
72
+          <p v-else>
73
+            <a :href="[img.previewUrl]">{{ img.name }}</a>
74
+          </p>
75
+        </div>
76
+      </div>
77
+    </div>
55 78
   </div>
56 79
 </template>
57 80
 <script>
58 81
 export default {
59 82
   data() {
60 83
     return {
84
+      imgs:[],//图片
61 85
       loginUser: JSON.parse(localStorage.getItem("loginUser")),
62 86
       valConfig: JSON.parse(localStorage.getItem("valConfig")) - 0, //报修主体
63 87
       baseInfo: {}, //巡检基础信息
@@ -169,7 +193,20 @@ export default {
169 193
         name: "NewIncident",
170 194
         params: { data: this.baseInfo, abnormal: this.abnormal }
171 195
       });
172
-    }
196
+    },
197
+    // 获取图片
198
+    getImgs() {
199
+      var that = this;
200
+      that.$http
201
+        .get(
202
+          "service/common/common/listAttachment/inspection/" +
203
+            that.baseInfo.processInstanceId,
204
+          {}
205
+        )
206
+        .then(function (res) {
207
+          that.imgs = res.data.data.splice(0, 3);
208
+        });
209
+    },
173 210
   },
174 211
   created() {
175 212
     this.baseInfo =
@@ -178,14 +215,34 @@ export default {
178 215
     this.forms = JSON.parse(window.localStorage.getItem("forms")) || [];
179 216
     this.title = this.baseInfo.inspectionType.type;
180 217
     this.getItems();
218
+    this.getImgs();//获取图片
181 219
   }
182 220
 };
183 221
 </script>
184 222
 <style lang="less" scoped>
185 223
 .inspedtionDetail {
186
-    .colorGray{
187
-        color: #999;
224
+  .imgs-c{
225
+    padding: 0.28rem;
226
+  }
227
+  .imgs-container {
228
+    a {
229
+      color: #03c !important;
230
+      &:visited {
231
+        color: #551a8b !important;
232
+      }
188 233
     }
234
+    .imgs-cont{
235
+      display: flex;
236
+    }
237
+    img {
238
+      width: 1.5rem;
239
+      height: 1.5rem;
240
+      margin-right: 0.5rem;
241
+    }
242
+  }
243
+  .colorGray{
244
+      color: #999;
245
+  }
189 246
   .label {
190 247
     background-color: #eee;
191 248
     height: 0.6rem;