ludc
2025-01-10 a3910f64e8a6170d1d8f611b6f7af635a3b7a27f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<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>