surprise
2023-12-29 18377dc5d61caf3a6a0835e17015ac2601f8709d
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
<template>
  <Popup
    ref="pop"
    :title="title"
    width="390px"
    showBtn="true"
    @yes="addData"
    @cancel="close()"
  >
    <el-form ref="form" :model="data" :rules="rules" label-width="105px">
      <el-form-item label="名称:" prop="name">
        <el-input v-model="data.name"></el-input>
      </el-form-item>
    </el-form>
  </Popup>
</template>
 
<script>
import Popup from "@tools/Popup";
export default {
  name: "SaveScene",
  components: {
    Popup,
  },
  data() {
    return {
      title: "保存工程",
      data: {
        name: "工程名称",
      },
      // 表单验证规则
      rules: {
        name: [{ required: true, message: "请输入名称", trigger: "blur" }],
      },
    };
  },
  computed: {},
  mounted() {},
  methods: {
    // 关闭弹窗
    close() {
      // 重置data值
      Object.assign(this.$data, this.$options.data());
      this.$refs.pop.close();
    },
    // 打开弹窗
    open() {
      this.$refs.pop.open();
    },
    // 添加数据
    addData() {
      this.$refs.form.validate((valid) => {
        // 验证通过
        if (valid) {
          this.$emit("success", this.data);
 
          this.close();
        }
      });
    },
  },
};
</script>
 
<style scoped lang="less">
.el-form {
  margin-top: 20px;
  margin-right: 10px;
  width: 380px;
 
  /deep/ .el-form-item__label {
    color: #fff;
    font-size: 18px;
  }
}
</style>