当页面对话框只需要修改少量字段,很多字段展示即可时,可以不使用表单修改样式,改为<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就行
2370

被折叠的 条评论
为什么被折叠?



