<template>
|
<el-dialog
|
:visible.sync="dialog.showDialog"
|
:title="dialog.title"
|
width="40%"
|
append-to-body
|
:submit-icon="dialog.submitIcon"
|
:submit-txt="dialog.submitTxt"
|
:loading="dialog.loading"
|
@cancel="cancleDialog"
|
@submit="submitDialog"
|
>
|
<!--动态模板-->
|
<d-from
|
:form-data="formData"
|
:form-prop="ruleForm"
|
ref="referDialogFormRef"
|
></d-from>
|
</el-dialog>
|
</template>
|
<script>
|
import DFrom from "@/views/test/referDemo/DynamicsFrom";
|
import {deferFormTemplate} from "@/views/test/referDemo/referDemo";
|
import { handlerObj } from "@/util/platformUtils";
|
export default {
|
name: "referDemoDialog",
|
components:{DFrom},
|
data() {
|
return {
|
dialog: {
|
showDialog: false,
|
title: "",
|
submitTxt: "",
|
submitIcon: "",
|
loading: false,
|
type: "add",
|
},
|
formData: deferFormTemplate,
|
ruleForm: {},
|
};
|
},
|
methods: {
|
// 打开对话框
|
openDialog(event) {
|
console.log(event)
|
this.dialog.type = event.type;
|
if (event.type === "add") {
|
this.dialog.title = "新增";
|
this.dialog.submitTxt = "新增";
|
this.dialog.submitIcon = "el-icon-plus";
|
this.formData = deferFormTemplate;
|
this.ruleForm = this.formData
|
|
} else if (event.type === "edit") {
|
this.dialog.title = "修改";
|
this.dialog.submitTxt = "修改";
|
this.dialog.submitIcon = "el-icon-edit";
|
// 处理修改逻辑
|
this.handleEditForm(event.row);
|
}
|
this.dialog.showDialog = true;
|
},
|
// 确认提交
|
submitDialog() {
|
this.$refs.referDialogFormRef.validate((valid, form) => {
|
console.log("referDialogFormRef");
|
console.log(form);
|
});
|
},
|
// 取消
|
cancleDialog() {
|
this.dialog.loading = false;
|
this.dialog.showDialog = false;
|
this.formData = deferFormTemplate;
|
this.ruleForm = {};
|
this.$refs.referDialogFormRef.reset();
|
},
|
},
|
};
|
</script>
|