董国庆
昨天 b72204f082f6762b528716aadfd93b63a026852a
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
  <div>
    <el-dialog
      title="新增工艺时间"
      :visible.sync="dialogVisible"
      width="40%"
      @close="handleClose"
    >
      <el-form
        :model="form"
        ref="form"
        :rules="rules"
        label-width="100px"
        class="center-form"
        label-position="top"
      >
        <el-form-item label="工艺时间" prop="processTime">
          <el-input
            v-model="form.processTime"
            placeholder="请输入工艺时间"
            style="width: 300px;"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer select-member-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleSubmit">确认新增</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      dialogVisible: false,
      form: {
        processTime: "",
      },
      rules: {
        processTime: [
          { required: true, message: "请输入工艺时间", trigger: "blur" },
        ],
      },
    };
  },
  watch: {
    show: {
      immediate: true,
      handler(val) {
        this.dialogVisible = val;
      },
    },
  },
  methods: {
    handleClose() {
      this.resetForm();
      this.$emit("update:show", false);
    },
    resetForm() {
      if (this.$refs.form) {
        this.$refs.form.resetFields();
      }
      this.form.processTime = "";
    },
    handleSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$emit("confirm", this.form.processTime);
          this.handleClose();
        }
      });
    },
  },
};
</script>
 
<style lang="less" scoped>
.dialog-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
}
 
.center-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  
  :deep(.el-form-item__label) {
    text-align: left;
    width: 100%;
  }
}
</style>