shj
2022-08-01 8b33982f891ba4ef96365d9e6ab75bf007ea60ec
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
    <el-dialog v-model="dialogVisible" :fullscreen="full" :title="titles" width="50%" draggable>
        <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button>
        <el-form :model="form" :disabled="disabled" label-width="120px">
            <el-row>
                <el-col :span="11">
                    <el-form-item label="是否为设备内容" size="default">
                        <el-select v-model="form.isContent" placeholder="请选择" style="width: 100%">
                            <el-option label="是" value="1" />
                            <el-option label="否" value="2" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="11" :offset="2">
                    <el-form-item label="父级编号" size="default">
                        <el-tree-select check-strictly="true" v-model="form.parentId" :data="data" :props="propst" class="w100" placeholder="请选择" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="11">
                    <el-form-item label="类别名称" size="default">
                        <el-input v-model="form.typeName" />
                    </el-form-item>
                </el-col>
                <el-col :span="11" :offset="2">
                    <el-form-item label="排列序列" size="default">
                        <el-input v-model="form.sortNum" />
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="resetForm">关闭</el-button>
                <el-button type="primary" @click="submitForm">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { FullScreen } from '@element-plus/icons-vue';
import { facilityManagementApi } from '/@/api/facilityManagement';
import { ElMessage } from 'element-plus';
export default defineComponent({
    setup(prpos, { emit }) {
        const dialogVisible = ref(false);
        const form = ref({
            isContent: '', ////是否为设备内容  1:是 2:否
            typeName: '', ////类别名称
            parentId: 0, ////父级ID,如果没有父级,为0
            isCheck: 0, ////是否检测  1:是 2:否
            isVisit: 0, ////是否巡检 1:是 2:否
            sortNum: '', //排列序列
            id: '', //设备类型ID ,更新时必填
        });
        const titles = ref();
        const disabled = ref(false);
        const openDailog = (title: string, id: number) => {
            listApi();
            dialogVisible.value = true;
            titles.value = `${title}设备设施类型管理`;
            if (title == '查看') {
                disabled.value = true;
                detail(id);
            } else if (title == '修改') {
                detail(id);
            } else if (title == '添加') {
                // detail(id);
            }
        };
        const detail = (id: number) => {
            facilityManagementApi()
                .getequipmentTypeMngDetail(id)
                .then((res) => {
                    if (res.data.code == 200) {
                        form.value = res.data.data;
                    } else {
                        ElMessage({
                            showClose: true,
                            message: res.data.msg,
                            type: 'error',
                        });
                    }
                });
        };
        // 列表
        const listApi = () => {
            facilityManagementApi()
                .getequipmentTypeMngTreeData()
                .then((res) => {
                    if (res.data.code == 200) {
                        data.value = res.data.data;
                    } else {
                        ElMessage({
                            showClose: true,
                            message: res.data.msg,
                            type: 'error',
                        });
                    }
                });
        };
        const data = ref([]);
        const propst = {
            value: 'id',
            lable: 'typeName',
            children: 'childList',
        };
        const submitForm = () => {
            facilityManagementApi()
                .getequipmentTypeMngAddOrUpdate(form.value)
                .then((res) => {
                    if (res.data.code == 200) {
                        dialogVisible.value = false;
                        ElMessage({
                            showClose: true,
                            message: res.data.msg,
                            type: 'success',
                        });
                        emit('onAdd');
                    } else {
                        ElMessage({
                            showClose: true,
                            message: res.data.msg,
                            type: 'error',
                        });
                    }
                });
            form.value = {
                isContent: '', ////是否为设备内容  1:是 2:否
                typeName: '', ////类别名称
                parentId: 0, ////父级ID,如果没有父级,为0
                isCheck: 0, ////是否检测  1:是 2:否
                isVisit: 0, ////是否巡检 1:是 2:否
                sortNum: '', //排列序列
                id: '', //设备类型ID ,更新时必填
            };
        };
        const resetForm = () => {
            form.value = {
                isContent: '', ////是否为设备内容  1:是 2:否
                typeName: '', ////类别名称
                parentId: 0, ////父级ID,如果没有父级,为0
                isCheck: 0, ////是否检测  1:是 2:否
                isVisit: 0, ////是否巡检 1:是 2:否
                sortNum: '', //排列序列
                id: '', //设备类型ID ,更新时必填
            };
        };
        //全屏
        const full = ref(false);
        const toggleFullscreen = () => {
            if (full.value == false) {
                full.value = true;
            } else {
                full.value = false;
            }
        };
        return {
            detail,
            listApi,
            propst,
            submitForm,
            resetForm,
            data,
            disabled,
            dialogVisible,
            form,
            titles,
            openDailog,
            full,
            toggleFullscreen,
            FullScreen,
        };
    },
});
</script>
<style scoped>
.el-row {
    padding: 0 0 20px 0;
}
</style>