el-upload 图片回显

 <el-table @row-click="handleEditdeli"  :data="listData" >
     <el-table-column align="center" label="操作" width="200">
       <template slot-scope="scope">
         <el-button
           size="mini"
           plain
           type="primary"
           @click.stop="handleEdit(scope.$index, scope.row)"
         >修改</el-button>
       </template>
     </el-table-column>
   </el-table>
 methods: {
	  //显示编辑界面
    handleEdit: function (index, row) {
      let that = this;
       if ( row.HeatUserRecord.CardIdImg == null || row.HeatUserRecord.CardIdImg == "") {
         that.editForm.CardIdImg = "";
       } else {
         that.editForm.CardIdImg = "xxx" + row.HeatUserRecord.CardIdImg;
         let obj = new Object();
         obj.url = that.editForm.CardIdImg;
         that.form1.push(obj);
       }
       if ( row.HeatUserRecord.HouseCardImg == null || row.HeatUserRecord.HouseCardImg == "" ) {
         that.editForm.HouseCardImg = "";
       } else {
         that.editForm.HouseCardImg ="xxx" + row.HeatUserRecord.HouseCardImg;
         let obj1 = new Object();
         obj1.url = that.editForm.HouseCardImg;
         that.form.push(obj1);
       }
     }uploadFile(editData) { //保存修改
      // this.$refs.upload.submit();
      let that = this;
      that.$refs[editData].validate((valid) => {
        if (valid) {
			 var formData;
            formData = new FormData();
            //判断有无文件修改
            if (that.changeUpload == true) {
              if (that.form.length > 0) {
                for (let i in that.form) {
                  formData.append("HouseCardImg", that.form[i]);
                  formData.append("HouseCardImg", "HouseCardImg");
                }
              } else {
                formData.append("HouseCardImg", "删除");
              }
            } else {
              formData.append("HouseCardImg", "HouseCardImg");
            }
            if (that.changeUpload1 == true) {
              if (that.form1.length > 0) {
                for (let i in that.form1) {
                  formData.append("CardIdImg", that.form1[i]);
                  formData.append("CardIdImg", "CardIdImg");
                }
              } else {
                formData.append("CardIdImg", "");
              }
            } else {
              formData.append("CardIdImg", "CardIdImg");
            }
            UpdateRecord(formData)
              .then((res) => {
                if (res.Data == true) {
                  that.$message({
                    type: "success",
                    message: res.Message,
                  });
                  that.Init();
                } else {
                  that.$message({
                    type: "info",
                    message: res.Message,
                  });
                }
              })
              .catch((err) => {});
         }
        }
        }

你可能感兴趣的:(el-upload 图片回显)