hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
<template>
  <el-dialog
  title="新增分类"
  :visible="value"
  width="30%"
  :modal='false'
  :show-close="false"
  :before-close="onCancel">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="分类名称" prop="name">
        <el-input v-model="ruleForm.name"></el-input>
      </el-form-item>
      <el-form-item label="备注">
        <el-input type="textarea" v-model="ruleForm.remarks" maxlength="30" show-word-limit></el-input>
      </el-form-item>
      <el-form-item label="权重" prop="weight">
        <el-input v-model="ruleForm.weight"></el-input>
      </el-form-item>
    </el-form>
 
    <span slot="footer" class="dialog-footer">
      <el-button @click="onCancel">取 消</el-button>
      <el-button type="primary" @click="onOk('ruleForm')" >确 定</el-button>
    </span>
</el-dialog>
</template>
 
<script>
export default {
  props: {
    value: {type: Boolean},
  },
 
  data() {
    return {
      ruleForm: {
        name:"" , //分类名称
        weight:"",
        remarks:"",
        okLoading: false
      },
       rules: {
        name: [
          { required: true, message: '请输入分类名称', trigger: 'blur' },
          { min: 1, max: 10, message: '长度在10个字符', trigger: 'blur' }
        ],
        weight: [
          { required: true, message: '请输入权重', trigger: 'blur' },
        ],
       }  
    }
  },
 
  methods: {
    /** 上传图标 */
    onUpload(e){
      this.icon = e
    },
 
    /** 取消 */
    onCancel () {
      this.$emit('change', false);
    },
 
    /** 确认 */
    onOk(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
      // let parmas = {
    
      // };
      
      // this.okLoading = true;
      // this.$api.post("dyn/type/edit", parmas, 
      //   e => {
      //     demo.toast("编辑成功");
      //     this.$emit('success');
      //     this.onCancel();
      //   },
      //   err=> {
      //     demo.toast(err.msg)
      //   }
      // )
      // this.okLoading = false;
    }
 
  }
 
}
</script>
 
<style>
 
</style>