Admin
2022-09-02 0d69019484ae3654579577d06871075b8a389159
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<template>
    <div class="home-container">
        <div style="height: 100%">
            <el-row class="homeCard">
                <el-col :span="6" style="display:flex;align-items: center">
                    <span style="white-space: nowrap">作业证编号:</span>
                    <div class="grid-content topInfo">
                        <el-input v-model="searchWord"></el-input>
                    </div>
                </el-col>
                <el-col :span="6" style="display:flex;align-items: center">
                    <span style="white-space: nowrap">作业类型:</span>
                    <div class="grid-content topInfo">
                        <el-select v-model="searchType" placeholder="请选择作业类型">
                            <el-option
                                    v-for="item in workTypeList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                            />
                        </el-select>
                    </div>
                </el-col>
                <el-col :span="6" style="display:flex;align-items: center">
                    <span style="white-space: nowrap">预警类型:</span>
                    <div class="grid-content topInfo">
                        <el-select v-model="searchAlert" placeholder="请选择预警类型">
                            <el-option
                                    v-for="item in alertTypeList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                            />
                        </el-select>
                    </div>
                </el-col>
                <el-button type="primary" @click="searchRecord">查询</el-button>
                <el-button plain @click="clearSearch">重置</el-button>
            </el-row>
            <div class="homeCard">
                <div class="main-card">
<!--                    <el-row class="cardTop">-->
<!--                        <el-col :span="12" class="mainCardBtn">-->
<!--                            <el-button type="primary" :icon="Plus" size="default" @click="dialogAddRecord = true">新建</el-button>-->
<!--                        </el-col>-->
<!--                        <el-button type="primary" :icon="Refresh" size="default"/>-->
<!--                    </el-row>-->
                    <el-table
                            ref="multipleTableRef"
                            :data="tableData"
                            style="width: 100%"
                            height="calc(100% - 48px)"
                            :header-cell-style="{background: '#fafafa'}"
                    >
                        <el-table-column type="index" label="序号" width="200"/>
                        <el-table-column property="id" label="作业证编号" width="200"/>
                        <el-table-column property="workType" label="作业类型" width="200"/>
                        <el-table-column property="alertInfo" label="预警信息"/>
                        <el-table-column property="alertType" label="预警类型"/>
                        <el-table-column property="desc" label="描述" width="200"/>
                        <el-table-column property="name" label="上报人"/>
                        <el-table-column property="updateTime" label="上报时间"/>
                        <el-table-column fixed="right" label="操作" align="center" width="250">
                            <template #default="scope">
                                <el-button link type="primary" size="small" :icon="View" @click="viewRecord(scope.row)">查看</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="pageBtn">
                        <el-pagination
                                v-model:currentPage="currentPage"
                                v-model:page-size="pageSize"
                                :page-sizes="[10, 15]"
                                small=false
                                background
                                layout="total, sizes, prev, pager, next, jumper"
                                :total="100"
                                @size-change="handleSizeChange"
                                @current-change="handleCurrentChange"
                        />
                    </div>
                </div>
            </div>
        </div>
        <el-dialog v-model="dialogDetails" title="作业预警记录">
            <el-form :model="details" label-width="120px">
                <el-form-item label="作业证编号">
                    <el-input v-model="details.id" readonly/>
                </el-form-item>
                <el-form-item label="作业类型">
                    <el-input v-model="details.workType" readonly/>
                </el-form-item>
                <el-form-item label="预警信息">
                    <el-input v-model="details.alertInfo" readonly/>
                </el-form-item>
                <el-form-item label="预警类型">
                    <el-input v-model="details.alertType" readonly/>
                </el-form-item>
                <el-form-item label="描述">
                    <el-input v-model="details.desc" type="textarea" readonly/>
                </el-form-item>
                <el-form-item label="上报人">
                    <el-input v-model="details.name" readonly/>
                </el-form-item>
                <el-form-item label="上报时间">
                    <el-input v-model="details.updateTime" readonly/>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="dialogDetails = false" size="default">确认</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>
 
<script lang="ts">
    import { toRefs, reactive, ref, onMounted } from 'vue';
    import { storeToRefs } from 'pinia';
    import { initBackEndControlRoutes } from '/@/router/backEnd';
    import { useUserInfo } from '/@/stores/userInfo';
    import { Session } from '/@/utils/storage';
    import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue';
    import { ElTable } from 'element-plus';
    import { FormInstance, FormRules, ElMessage } from 'element-plus';
    import { teamManageApi } from '/@/api/systemManage/basicDateManage/personShiftManage/teamManage';
 
    // 定义接口来定义对象的类型
    interface stateType {
        tableData: Array<any>;
        departmentList: Array<any>;
        department:string;
        workerList: Array<string>;
        casProps: {};
        multipleSelection: Array<any>;
        deleteArr: Array<any>;
        dialogDetails: boolean;
        dialogAddRecord: boolean;
        deleteDialog: boolean;
        deleteSetDialog: boolean;
        pageIndex: number;
        pageSize: number;
        chosenIndex: null | number;
        deleteId: null | number;
        searchWord: string;
        searchType: number | null;
        searchAlert: number | null;
        totalSize: number;
        addRecord: {
 
        };
        details: {
 
        };
        workTypeList: Array<any>;
        alertTypeList: Array<any>
    }
 
    export default {
        name: 'alertRecord',
        components: {},
        setup() {
            const userInfo = useUserInfo();
            const { userInfos } = storeToRefs(userInfo);
 
            const state = reactive<stateType>({
                pageIndex: 1,
                pageSize: 10,
                totalSize: 0,
                chosenIndex: null,
                searchWord: '',
                searchType: null,
                searchAlert: null,
                tableData: [
                    {
                        id: 'GTXH-0000001',
                        workType: '动火作业',
                        alertInfo: '可燃气检查超标',
                        alertType: '气体分析',
                        desc: 'A车间动火作业过程检查',
                        name: '李羽飞',
                        updateTime: '2022-08-31 12:00:00'
                    },
                    {
                        id: 'GTXH-0000002',
                        workType: '动火作业',
                        alertInfo: '作业现场检查异常',
                        alertType: '作业检查',
                        desc: 'B车间动火作业过程气体检查',
                        name: '李羽飞',
                        updateTime: '2022-08-31 16:31:44'
                    },
                    {
                        id: 'GTXH-0000003',
                        workType: '动火作业',
                        alertInfo: '可燃气检查超标',
                        alertType: '气体分析',
                        desc: '',
                        name: '李羽飞',
                        updateTime: '2022-08-31 17:05:20'
                    }
                ],
                departmentList: [],
                department: '',
                workerList: [],
                casProps: {
                    expandTrigger: 'hover',
                    emitPath: false,
                    value: 'depId',
                    label: 'depName'
                },
                multipleSelection: [],
                dialogDetails: false,
                dialogAddRecord: false,
                deleteDialog: false,
                deleteSetDialog: false,
                addRecord: {
 
                },
                details: {
 
                },
                deleteId: null,
                deleteArr: [],
                workTypeList: [
                    { id: 1, name: '动火作业' },
                    { id: 2, name: '受限空间作业' },
                    { id: 3, name: '吊装作业' },
                    { id: 4, name: '动土作业' },
                    { id: 5, name: '断路作业' },
                    { id: 6, name: '高处作业' },
                    { id: 7, name: '临时用电作业' },
                    { id: 8, name: '盲板抽堵作业' }
                ],
                alertTypeList: [
                    { id: 1, name: '气体分析' },
                    { id: 2, name: '作业检查' }
                ]
            });
 
            // 页面载入时执行方法
            onMounted(() => {
                // getListByPage();
                // getAllDepartment();
            });
 
            // 分页获取班组管理列表
            const getListByPage = async () => {
                const data = { pageSize: state.pageSize, pageIndex: state.pageIndex, searchParams: { groupName: state.searchWord, containGroupMemberEnable: true } };
                let res = await teamManageApi().getRecordPage(data);
                if (res.data.code === '200') {
                    state.tableData = res.data.data.map((item) => {
                        if (!item.groupMembers || item.groupMembers == null) {
                            item.groupMembers = [];
                        } else {
                            item.groupMembers = Array.from(item.groupMembers, ({ username }) => username);
                        }
                        return item;
                    });
                    state.totalSize = res.data.total;
                } else {
                    ElMessage({
                        type: 'warning',
                        message: res.data.msg
                    });
                }
            };
 
            // 获取部门列表
            const getAllDepartment = async () => {
                let res = await teamManageApi().getAllDepartment();
                if (res.data.code === '200') {
                    state.departmentList = res.data.data;
                } else {
                    ElMessage({
                        type: 'warning',
                        message: res.data.msg
                    });
                }
            };
 
            const handleChange = async (value) => {
                state.addRecord.depId = value;
                console.log(state.addRecord.department, 'de');
                let res = await teamManageApi().getAllMember(value);
                if (res.data.code === '200') {
                    state.workerList = res.data.data;
                } else {
                    ElMessage({
                        type: 'warning',
                        message: res.data.msg
                    });
                }
            };
 
            // 关键词查询记录
            const searchRecord = async () => {
                if (state.searchWord == '') {
                    ElMessage({
                        type: 'warning',
                        message: '请输入查询关键词'
                    });
                } else {
                    getListByPage();
                }
            };
 
            const clearSearch = async () => {
                state.searchWord = '';
                getListByPage();
            };
 
            const handleSizeChange = (val: number) => {
                state.pageSize = val;
                getListByPage();
            };
 
            const handleCurrentChange = (val: number) => {
                state.pageIndex = val;
                getListByPage();
            };
 
            // 查看记录
            const viewRecord = (row) => {
                state.details = JSON.parse(JSON.stringify(row));
                state.dialogDetails = true;
            };
 
            // 刷新
            const reLoadData = async () => {
                getListByPage();
            };
 
            // 折线图
            const renderMenu = async (value: string) => {
                Session.set('projectId', value);
                userInfos.value.projectId = value;
                await initBackEndControlRoutes();
            };
 
            return {
                View,
                Edit,
                Delete,
                Refresh,
                Plus,
                handleChange,
                searchRecord,
                clearSearch,
                viewRecord,
                getListByPage,
                reLoadData,
                handleSizeChange,
                handleCurrentChange,
                ...toRefs(state)
            };
        }
    };
</script>
 
<style scoped lang="scss">
    $homeNavLengh: 8;
    .home-container {
        height: calc(100vh - 144px);
        box-sizing: border-box;
        overflow: hidden;
        .homeCard {
            width: 100%;
            padding: 20px;
            box-sizing: border-box;
            background: #fff;
            border-radius: 4px;
 
            .main-card {
                width: 100%;
                height: 100%;
                .cardTop {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    margin-bottom: 20px;
                    .mainCardBtn {
                        margin: 0;
                    }
                }
                .pageBtn {
                    height: 60px;
                    display: flex;
                    align-items: center;
                    justify-content: right;
 
                    .demo-pagination-block + .demo-pagination-block {
                        margin-top: 10px;
                    }
                    .demo-pagination-block .demonstration {
                        margin-bottom: 16px;
                    }
                }
            }
            &:last-of-type {
                height: calc(100% - 100px);
            }
        }
        .el-row {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            &:last-child {
                margin-bottom: 0;
            }
            .grid-content {
                align-items: center;
                min-height: 36px;
            }
 
            .topInfo {
                width: 100%;
                display: flex;
                align-items: center;
                font-size: 16px;
                font-weight: bold;
 
                & > div {
                    white-space: nowrap;
                    margin-right: 20px;
                }
            }
        }
    }
    .el-input{
        width: 100% !important;
    }
    .el-date-editor::v-deep{
        width: 100%;
    }
    .el-select{
        width: 100%;
    }
</style>