zhouwenxuan
2023-11-29 88d7869b422a1070a0ea8efd22613997e9dbe2fe
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
<template>
    <div class="notice">
        <el-dialog
            v-model="dialogVisible"
            :title="title"
            width="500px"
            :before-close="handleClose"
        >
            <el-form :model="state.form" size="default" ref="busRef" :rules="state.formRules" label-width="110px" >
                <el-form-item label="业务范围:" prop="business">
                    <el-input v-model.trim="state.form.business"></el-input>
                </el-form-item>
            </el-form>
            <template #footer>
                    <span class="dialog-footer">
                        <el-button @click="handleClose" size="default">取 消</el-button>
                        <el-button type="primary"  @click="onSubmit" size="default">确认</el-button>
                    </span>
            </template>
        </el-dialog>
    </div>
</template>
<script setup>
import {reactive, ref, toRefs} from 'vue'
import Editor from "@/components/Editor/index.vue";
import {ElMessage} from "element-plus";
 
const dialogVisible = ref(false);
const title = ref("");
const busRef = ref();
const state = reactive({
    form: {
        business: ''
    },
    formRules:{
        business: [{ required: true, message: '请输入业务范围', trigger: 'blur' }],
    },
 
})
 
const openDialog = (type, value) => {
    title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ;
    if(type === 'edit') {
        state.form = value;
    }
    dialogVisible.value = true;
}
 
const onSubmit = async () => {
    const valid = await busRef.value.validate();
    if(valid){
        busRef.value.clearValidate();
        reset();
        dialogVisible.value = false;
 
    }
}
 
const handleClose = () => {
    busRef.value.clearValidate();
    reset();
    dialogVisible.value = false;
 
}
const reset = () => {
    state.form = {
        business: ""
    }
}
defineExpose({
    openDialog
});
 
</script>
 
<style scoped lang="scss">
.notice{
    :deep(.el-form .el-form-item__label) {
        font-size: 15px;
    }
    .file {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
}
</style>