loulijun2021
2024-05-17 f16c4fed5e34e5514a564266c500ff382644630a
pages/sbgl/sbwx.vue
@@ -92,7 +92,7 @@
                        <view style="margin: 20rpx 0rpx 20rpx 20rpx;position: relative;">
                           <u-icon name="close" color="#fff" size="13"
                              style="position: absolute;z-index: 10;right: 0;background-color: black;border-radius:50%;"
                              @click="deletePic(pic)"></u-icon>
                              @click="deletePic(pic,'G')"></u-icon>
                           <image :src="pic.uri" @click="imgPreview(pic)" class="upLoadImg"></image>
                        </view>
@@ -167,7 +167,7 @@
                        <view style="margin: 20rpx 0rpx 20rpx 20rpx;position: relative;">
                           <u-icon name="close" color="#fff" size="13"
                              style="position: absolute;z-index: 10;right: 0;background-color: black;border-radius:50%;"
                              @click="deletePic(pic)"></u-icon>
                              @click="deletePic(pic,'B')"></u-icon>
                           <image :src="pic.uri" @click="imgPreview2(pic)" class="upLoadImg"></image>
                        </view>
@@ -201,6 +201,8 @@
<script>
   import {
      RepairScanDeviceQrCodeDataList,
      UploadImageDelete,
      RepairScanDeviceSave
   } from '../../config/api.js'
   import {
      data
@@ -272,19 +274,55 @@
               count: 3,
               success: (res) => {
                  const files = res.tempFiles;
                  const uploadList = []
                  console.log(res, 'res')
                  for (let i = 0; i < files.length; i++) {
                     let obj = new Object();
                     obj.name = 'files1;' + i + new Date().getTime();
                     // obj.files1 = i + new Date().getTime();
                     obj.uri = files[i].path;
                     that.fileList.push(obj);
                     if (obj.src == null || obj.src == '' || obj.src == undefined) {
                        that.imgPreviewSrcs.push(obj.uri)
                     } else {
                        that.imgPreviewSrcs.push(obj.src)
                     uploadList.push(obj);
                     }
                  const header = {
                     'Content-Type': 'multipart/form-data',
                     'Token': uni.getStorageSync('Token')
                  }
                  uni.uploadFile({
                     url: that.$baseUrl + '/DeviceManager/UploadImageSave',
                     files: uploadList.length === 0 ? [{
                        "uri": "/"
                     }] : uploadList,
                     header: header,
                     formData: { //故障描述:G 更换备件:B
                        type: 'G'
                     },
                     success: (res) => {
                        console.log(res, 'res')
                        let result = JSON.parse(res.data)
                        if (res.statusCode == 200 && result.code == '200') {
                           // uni.$u.toast('提交成功!')
                           result.data.forEach(i => {
                              that.fileList.push({
                                 uri: 'http://121.196.36.24:8019/' + i,
                                 name: i
                              })
                              that.imgPreviewSrcs.push(
                                 'http://121.196.36.24:8019/' + i)
                           })
                        } else {
                           uni.$u.toast(result.Message)
                        }
                     },
                     fail(res) {
                        console.log(res, 'res2')
                        uni.$u.toast('图片提交失败!')
                     },
                  })
               }
            })
         },
@@ -295,17 +333,61 @@
               count: 3,
               success: (res) => {
                  const files = res.tempFiles;
                  const uploadList = []
                  for (let i = 0; i < files.length; i++) {
                     let obj = new Object();
                     obj.name = 'files2;' + i + new Date().getTime();
                     // obj.name = 'files2;' + i + new Date().getTime();
                     // obj.files2 = i + new Date().getTime();
                     obj.uri = files[i].path;
                     that.fileList2.push(obj);
                     if (obj.src == null || obj.src == '' || obj.src == undefined) {
                        that.imgPreviewSrcs2.push(obj.uri)
                     } else {
                        that.imgPreviewSrcs2.push(obj.src)
                     uploadList.push(obj);
                     // if (obj.src == null || obj.src == '' || obj.src == undefined) {
                     //    that.imgPreviewSrcs2.push(obj.uri)
                     // } else {
                     //    that.imgPreviewSrcs2.push(obj.src)
                     // }
                     const header = {
                        'Content-Type': 'multipart/form-data',
                        'Token': uni.getStorageSync('Token')
                     }
                     uni.uploadFile({
                        url: that.$baseUrl + '/DeviceManager/UploadImageSave',
                        files: uploadList.length === 0 ? [{
                           "uri": "/"
                        }] : uploadList,
                        header: header,
                        formData: { //故障描述:G 更换备件:B
                           type: 'B'
                        },
                        success: (res) => {
                           console.log(res, 'res')
                           let result = JSON.parse(res.data)
                           if (res.statusCode == 200 && result.code == '200') {
                              // uni.$u.toast('提交成功!')
                              result.data.forEach(i => {
                                 that.fileList2.push({
                                    uri: 'http://121.196.36.24:8019/' +
                                       i,
                                    name: i
                                 })
                                 that.imgPreviewSrcs2.push(
                                    'http://121.196.36.24:8019/' + i)
                              })
                           } else {
                              uni.$u.toast(result.Message)
                           }
                        },
                        fail(res) {
                           console.log(res, 'res2')
                           uni.$u.toast('图片提交失败!')
                        },
                     })
                  }
               }
@@ -330,11 +412,21 @@
            })
         },
         // 删除图片
         deletePic(img) {
         async deletePic(img, type) {
            this.fileList = this.fileList.filter(i => i.name !== img.name)
            this.fileList2 = this.fileList2.filter(i => i.name !== img.name)
            this.imgPreviewSrcs = this.imgPreviewSrcs.filter(i => i !== img.uri)
            this.imgPreviewSrcs2 = this.imgPreviewSrcs2.filter(i => i !== img.uri)
            // 调用接口把相对应的图片删掉
            const data = {
               "type": type,
               "url": img.name
            }
            await UploadImageDelete(data)
         },
         init() {
            uni.stopPullDownRefresh();
@@ -414,39 +506,30 @@
         // 确认提交按钮
         async submit() {
            const header = {
               'Content-Type': 'multipart/form-data',
               'Token': uni.getStorageSync('Token')
            }
            // const header = {
            //    'Content-Type': 'multipart/form-data',
            //    'Token': uni.getStorageSync('Token')
            // }
            const result = this.topContent.find(item => item.docu_code === this.radioValue)
            const formData = {
               // username: uni.getStorageSync('username'),
               docu_code: result.docu_code,
               eqpcode: result.eqpcode,
               wkshpcode: result.wksp_code,
               faultdescr: this.descMessage,
               is_stoprepair: this.isStop,
               filse1: this.fileList.map(i => i.uri).join(','),
               filse2: this.fileList2.map(i => i.uri).join(','),
               groupimage1: this.fileList.map(i => i.name),
               groupimage2: this.fileList2.map(i => i.name),
               repaircontent: this.descMessage2,
               replaceparts: this.descMessage3
            }
            console.log(formData, 123)
            console.log([...this.fileList, ...this.fileList2])
            this.isDisabledSubmitButton = true
            uni.uploadFile({
               url: this.$baseUrl + '/DeviceManager/RepairScanDeviceSave',
               files: [...this.fileList, ...this.fileList2].length === 0 ? [{
                  "uri": "/"
               }] : [...this.fileList, ...this.fileList2],
               name: 'files',
               header: header,
               formData: formData,
               success: (res) => {
                  console.log(res, 'res')
                  let result = JSON.parse(res.data)
                  if (res.statusCode == 200 && result.code == '200') {
            const res = await RepairScanDeviceSave(formData)
            if (res.code == '200') {
                     uni.$u.toast('提交成功!')
                     this.topContent = this.topContent.filter(i => i.docu_code !== this.radioValue)
                     this.radioValue = this.topContent.length === 0 ? '' : this.topContent[0]
@@ -459,17 +542,48 @@
                     this.descMessage3 = ''
                     this.fileList2 = []
                     this.imgPreviewSrcs2 = []
               this.isDisabledSubmitButton = false
                  } else {
                     uni.$u.toast(result.Message)
               this.isDisabledSubmitButton = false
                  }
                  this.isDisabledSubmitButton = false
               },
               fail(res) {
                  console.log(res, 'res2')
                  uni.$u.toast('提交失败!')
                  this.isDisabledSubmitButton = false
               },
            })
            // uni.uploadFile({
            //    url: this.$baseUrl + '/DeviceManager/RepairScanDeviceSave',
            //    files: [...this.fileList, ...this.fileList2].length === 0 ? [{
            //       "uri": "/"
            //    }] : [...this.fileList, ...this.fileList2],
            //    name: 'files',
            //    header: header,
            //    formData: formData,
            //    success: (res) => {
            //       console.log(res, 'res')
            //       let result = JSON.parse(res.data)
            //       if (res.statusCode == 200 && result.code == '200') {
            //          uni.$u.toast('提交成功!')
            //          this.topContent = this.topContent.filter(i => i.docu_code !== this.radioValue)
            //          this.radioValue = this.topContent.length === 0 ? '' : this.topContent[0]
            //             .docu_code
            //          this.descMessage = ''
            //          this.imgPreviewSrcs = []
            //          this.fileList = []
            //          this.isStop = 'Y'
            //          this.descMessage2 = ''
            //          this.descMessage3 = ''
            //          this.fileList2 = []
            //          this.imgPreviewSrcs2 = []
            //       } else {
            //          uni.$u.toast(result.Message)
            //       }
            //       this.isDisabledSubmitButton = false
            //    },
            //    fail(res) {
            //       console.log(res, 'res2')
            //       uni.$u.toast('提交失败!')
            //       this.isDisabledSubmitButton = false
            //    },
            // })
         },
      }