k94314517
2024-10-16 17efddc6a667670dca682bf36b51a43e99615e6d
h5/pages/staff/snapshot.vue
@@ -19,7 +19,7 @@
      <view class="line">
        <view class="label">
          <text>*</text>
          <text>接受人</text>
          <text>接收人</text>
        </view>
        <view class="value" @click="selMember">
          <text
@@ -48,22 +48,31 @@
      <view class="upload_line">
        <view class="name">现场情况</view>
        <view class="wrap">
          <view class="adduser_list_item_ipt1_upload" @click="showUpload = true"
            ><u-icon name="plus" color="rgb(153, 153, 153)" size="28"></u-icon
          ></view>
          <view
            class="adduser_list_item_ipt1_upload"
            @click="showUpload = true"
          >
            <u-icon name="plus" color="rgb(153, 153, 153)" size="20"></u-icon>
            <view class="mt6">图片/视频</view>
          </view>
          <view
            class="adduser_list_item_ipt1_upload"
            v-for="(item, i) in submitFileList"
            :key="i"
            ><image
          >
            <u-icon
              class="close"
              size="20"
              name="close-circle-fill"
              color="red"
              @click="fileDel(i)"
            ></u-icon>
            <image
              v-if="item.type == 0"
              :src="item.fileurlFull"
              mode="widthFix"
            ></image
            ><video
              v-if="item.type == 1"
              :src="item.fileurlFull"
            ></video
            ><video v-if="item.type == 1" :src="item.fileurlFull"></video
          ></view>
        </view>
      </view>
@@ -215,11 +224,19 @@
        icon: 'none'
      })
      if (!param.applyCheckUserId) return uni.showToast({
        title: '请选择接受人',
        title: '请选择接收人',
        icon: 'none'
      })
      if (!param.categoryName) return uni.showToast({
        title: '请选择隐患类型',
        icon: 'none'
      })
      if (!param.content) return uni.showToast({
        title: '请输入情况说明',
        icon: 'none'
      })
      if (param.content.length < 10) return uni.showToast({
        title: '情况说明不得小于10个字',
        icon: 'none'
      })
@@ -237,6 +254,15 @@
      this.$set(this.param, 'areaId', item.id)
      this.$set(this.param, 'areaName', item.name)
      console.log(item)
      if (item.memberIds && item.memberIds.indexOf(',') === -1) {
        this.$set(this.param, 'checkUserId', item.memberIds)
        this.$set(this.param, 'applyCheckUserId', item.memberIds)
        this.$set(this.param, 'checkorName', item.memberNames)
      } else {
        this.$set(this.param, 'checkUserId', '')
        this.$set(this.param, 'applyCheckUserId', '')
        this.$set(this.param, 'checkorName', '')
      }
      this.isShowArea = false
    },
    seletedType(e) {
@@ -262,67 +288,94 @@
      })
    },
    selMember() {
      uni.navigateTo({
        url: '/pages/staff/memberSel'
      if (!this.param.areaId) return uni.showToast({
        title: '请先选择隐患区域',
        icon: 'none'
      })
      uni.navigateTo({
        url: '/pages/staff/memberSel?areaId=' + this.param.areaId
      })
    },
    fileDel(i) {
      this.submitFileList.splice(i, 1)
    },
    uploadImage() {
      this.showUpload = false
      let token = uni.getStorageSync('token') || ''
      uni.chooseImage({
        count: 1,
        count: 4,
        success: (chooseImageRes) => {
          console.log('chooseImageRes.tempFilePaths', chooseImageRes.tempFilePaths)
          uni.showLoading({ title: '上传中', mask: true })
          for (let i = 0; i < chooseImageRes.tempFilePaths.length; i++) {
            uni.uploadFile({
              url: `${uploadUrl}`,
              filePath: chooseImageRes.tempFilePaths[i],
          const tempFilePaths = chooseImageRes.tempFilePaths
          let imgs = tempFilePaths.map((value, index) => {
            return {
              name: 'file',
              formData: {
                folderCode: 'HIDDEN_DANGER_FILE'
              },
              success: (uploadFileRes) => {
                let res = JSON.parse(uploadFileRes.data)
                console.log('res', res)
                let obj = {
                  type: '0'
                }
                obj.fileurl = res.data.halfPath
                obj.fileurlFull = res.data.addr
                this.submitFileList.push(obj)
              },
              complete() {
                if (i === chooseImageRes.tempFilePaths.length - 1) {
                  uni.hideLoading()
                }
              uri: value
            }
          })
          uni.uploadFile({
            url: `${uploadUrl}`,
            files: imgs,
            name: 'file',
            formData: {
              folder: 'HIDDEN_DANGER_FILE'
            },
            header: {
              Dm_user_token: token
            },
            success: (uploadFileRes) => {
              let res = JSON.parse(uploadFileRes.data)
              console.log('res', res.data)
              if (res.data && res.data.length > 0) {
                res.data.forEach(i => {
                  i.type = 0
                  i.fileurl = i.imgaddr
                  i.fileurlFull = i.url
                  this.submitFileList.push(i)
                })
              }
            })
          }
            },
            fail(err) {
              console.log('err', err)
            },
            complete() {
              uni.hideLoading()
              // if (i === chooseImageRes.tempFilePaths.length - 1) {
              //   uni.hideLoading()
              // }
            }
          })
          // }
        }
      })
    },
    uploadVideo() {
      this.showUpload = false
      let that = this
      let token = uni.getStorageSync('token') || ''
      uni.chooseVideo({
        success: (chooseImageRes) => {
          uni.showLoading({ title: '上传中', mask: true })
          uni.uploadFile({
            url: `${uploadUrl}`,
            filePath: chooseImageRes.tempFilePath,
            header: {
              Dm_user_token: token
            },
            name: 'file',
            formData: {
              folderCode: 'HIDDEN_DANGER_FILE'
              folder: 'HIDDEN_DANGER_FILE'
            },
            success: (uploadFileRes) => {
              let res = JSON.parse(uploadFileRes.data)
              console.log('res', res)
              let obj = {
                type: '1'
              if (res.data && res.data.length > 0) {
                res.data.forEach(i => {
                  i.type = 1
                  i.fileurl = i.imgaddr
                  i.fileurlFull = i.url
                  this.submitFileList.push(i)
                })
              }
              obj.fileurl = res.data.halfPath
              obj.fileurlFull = res.data.addr
              this.submitFileList.push(obj)
            },
            complete() {
              uni.hideLoading()
@@ -339,6 +392,7 @@
<style lang="scss">
.main_wrap {
  padding-bottom: 200rpx;
  .line {
    display: flex;
    justify-content: space-between;
@@ -388,15 +442,23 @@
      color: #666666;
      font-size: 22rpx;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      position: relative;
      .close {
        position: absolute;
        right: -20rpx;
        top: -20rpx;
        z-index: 9999;
      }
      image {
        width: 100%;
        height: 100%;
      }
      video {
        width: 100%;
        max-height: 120rpx;
      }
    }
  }