element upload上传图标隐藏和修改回显图片

上传代码

        <el-form-item label="上传照片" prop="image">
          <el-upload
            accept="image/*"
            :class="{ uploadImg: fileList.length }"
            :action="upload1.url"
            list-type="picture-card"
            :headers="upload1.headers"
            :on-remove="handleRemove"
            :on-preview="handlePictureCardPreview"
            :on-success="onSuccess"
            :limit="1"
            :file-list="fileList"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
          <el-dialog :visible.sync="dialogVisible" :modal="false">
            <img width="100%" :src="dialogImageUrl" alt=""/>
          </el-dialog>
        </el-form-item>
    //  上传
    handleRemove(file, fileList) {
      this.fileList = []
      this.form.workPhoto = ''
      this.dialogImageUrl = ''
    },
    handlePictureCardPreview(file, fileList) {
      console.log(file)
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    onSuccess(file, fileList) {
      console.log(file)
      this.dialogImageUrl = file.data
      this.form.workPhoto = file.data
      this.fileList.push({ url: this.imgUrl + this.dialogImageUrl })
    },
      // 上传
      upload1: {
        url: this.Url + '/oss/upload',
        headers: {
          Authorization: 'Bearer ' + getToken(),
          'User-Type': 'PC_MARKET'
        }
        // data: {
        //   fileType: "reservation",
        // },
      },
      fileList: [], //图片详情回显
      isNum: false, //控制是新增还是修改
      dialogImageUrl: '',
      dialogVisible: false, //控制弹窗显示

点击修改

          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['loader:Trade']"
          >修改
          </el-button>
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id
      this.disablePhone = true
      getStevedoreInfo(id).then((response) => {
        // 回显上传的图片
        this.fileList = [{ url: this.imgUrl + response.data.workPhoto }]
        this.isNum = true
        this.form = response.data
        // 返回数据不同回显显示不对,转换为相同类型
        this.form.areaId = Number(response.data.areaId)
        this.open = true
        this.title = '修改'
      })
    },

取消时把 fileList 置空即可

// 取消按钮
cancel() {
  this.open = false
  this.reset()
  this.fileList = []
  this.disablePhone = false
},

动态隐藏上传的图标样式

<style scoped lang="scss">
::v-deep .uploadImg .el-upload--picture-card {
  display: none !important; /* 上传按钮隐藏 */
}
</style>

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值