elementUI对话框

当页面对话框只需要修改少量字段,很多字段展示即可时,可以不使用表单修改样式,改为<span>类型展示

<el-dialog :title="title" :visible.sync="open1" width="500px">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="待作废项目名称:" prop="projectName">
        <span>{{ form.projectName }}</span>
        </el-form-item>
        <el-form-item style="width: 100%" label="作废申请原因: ">
          <el-input type="textarea" placeholder="请输入" v-model="form.deleteReason" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancelDelete()">取 消</el-button>
        <el-button type="primary" @click="submitDelete()">确 定</el-button>
      </span>
    </el-dialog>


    // 项目作废对话框提交
    submitDelete() {
      if(this.form.deleteReason == '') {
        this.$message({
          type: "error",
          message: "请填写作废原因!",
        });
      } else {
        let param = {"id":this.form.id,"deleteReason":this.form.deleteReason}
        makeDeleteTraffic(param).then(response => {
          this.$modal.msgSuccess("作废申请提交");
          this.open1 = false;
          this.getList();
        });
      }
    },

看起来更加简短

想要传递对话框的某个字段,就将该字段写入给后端传递的表单结构中,双向绑定,例如,写成form.deleteReason,然后在调取更新接口时,将form表单一整个塞给更新接口,makeDeleteTraffic(this.form).then(response)

需要页面跳转的话就传id,不要的话直接传form就行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值