zhouwenxuan
2023-08-11 1c328d7233aaa6ea48fbdfb73b415eb9837956a6
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
<template>
    <div class="system-add-gas-container">
        <el-dialog
            :title="state.title"
            v-model="state.isShowUserDialog"
            width="550px"
        >
            <el-form :model="state.setForm" size="default" ref="gasRef" :rules="state.setFormRules" label-width="150px">
                <el-form-item label="预警名称:" prop="name">
                    <span>{{state.setForm.name}}</span>
                </el-form-item>
                <el-form-item label="连续超过阈值点数:" prop="points">
                    <el-input v-model.trim="state.setForm.points" :disabled="state.disabled"></el-input>
                </el-form-item>
            </el-form>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="handleClose" size="default" v-if="!state.disabled">取 消</el-button>
                    <el-button type="primary"  @click="onSubmit" size="default">确 定</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>
 
<script setup lang="ts">
import {reactive, ref} from "vue";
import {SetState} from "/@/types/warning";
 
const gasRef = ref();
const emit = defineEmits(["getSetData"]);
const state = reactive<SetState>({
    title: '',
    isShowUserDialog: false,
    disabled: false,
    setForm: {
        name: '',
        points: 0
    },
    setFormRules:{
        points: [{ required: true, message: '请填写连续超过阈值点数', trigger: 'blur' }],
    }
});
const openDialog = (type: string, value: any) => {
    state.isShowUserDialog = true;
    if (type === '查看') {
        state.disabled = true;
        state.title = '查看';
        state.setForm = JSON.parse(JSON.stringify(value));
    } else {
        state.disabled = false;
        state.title = '修改';
        state.setForm = JSON.parse(JSON.stringify(value));
    }
};
const onSubmit = () => {
    gasRef.value.clearValidate();
    state.isShowUserDialog = false;
    emit('getSetData');
};
 
const handleClose = () => {
    gasRef.value.clearValidate();
    state.isShowUserDialog = false;
    emit('getSetData');
}
 
defineExpose({
    openDialog
});
</script>
<style scoped lang="scss">
 
</style>