111
jihongshun
8 天以前 0c741cdda7ef9935a20d3090dfea97e1ce8ae754
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
<template>
  <el-dialog :title="formData.id?'编辑':'添加'" :visible.sync="modelShow">
    <el-form ref="imgGroupForm" :model="formData" label-width="120px" :rules="formRules">
      <el-form-item label="分组名" prop="groupName">
        <el-input v-model="formData.groupName"/>
      </el-form-item>
      <el-form-item>
        <el-button @click="modelShow = false">取 消</el-button>
        <el-button type="primary" @click="submitForm()">确 定</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
 
<script>
import {saveOrUpdateApi} from "@/api/ImgGroupApi";
 
export default {
  name: "ImgGroupForm",
  data() {
    return {
      formData:{},
      modelShow:false,
      formRules:{
        groupName: [
          { required: true, message: '请输入分组名', trigger: 'blur' },
          { min: 2, max: 90, message: '长度在 3 到 90 个字符', trigger: 'blur' }
        ]
      }
    }
  },
  methods:{
    opened(isEdit,row){
      this.formData = isEdit ? row:{};
      this.modelShow = true;
    },
    submitForm(){
      this.$refs['imgGroupForm'].validate((valid) => {
        if (valid) {
          saveOrUpdateApi(this.formData).then(() => {
            this.modelShow = false
            this.$emit('refreshTable');
          })
        }
      })
    },
  }
}
</script>
 
<style scoped>
 
</style>