马宇豪
2023-08-07 7ed4982b8f2a345bfad95a96070143c32142bc61
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
<template>
    <div class="home-container">
        <div style="height: 100%">
            <el-row class="homeCard">
                <div class="basic-line">
                    <span>风险单元编号:</span>
                    <el-input v-model="unitState.searchQuery.riskCode" clearable filterable class="input-box" placeholder="风险单元编号">
                    </el-input>
                </div>
                <div class="basic-line">
                    <span>风险单元名称:</span>
                    <el-input v-model="unitState.searchQuery.riskName" clearable filterable class="input-box" placeholder="风险单元名称">
                    </el-input>
                </div>
                <div class="basic-line">
                    <span>风险源风险类型:</span>
                    <el-select v-model="unitState.searchQuery.riskSourceType" clearable filterable class="input-box" placeholder="风险源风险类型">
                        <el-option v-for="item in unitState.riskSourceTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </div>
                <div style="padding-bottom: 10px">
                    <el-button type="primary" @click="getUnitData">查询</el-button>
                    <el-button plain @click="reset">重置</el-button>
                </div>
            </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="openUnitDialog('新增', {})">新增</el-button>
                            <!--                            <el-button type="danger" :icon="Delete" size="default" plain>删除</el-button>-->
                        </el-col>
<!--                        <el-button type="primary" :icon="Refresh" size="default" />-->
                    </el-row>
                    <el-table ref="multipleTableRef" :data="unitState.unitData" style="width: 100%" height="calc(100% - 100px)" :header-cell-style="{ background: '#fafafa' }">
                        <el-table-column prop="riskCode" label="风险单元编号" show-overflow-tooltip/>
                        <el-table-column prop="riskName" label="风险单元名称" show-overflow-tooltip/>
                        <el-table-column prop="riskSourceType" label="风险源风险类型" show-overflow-tooltip>
                            <template #default="scope">
                                <span>{{`${unitState.riskSourceTypeList.find(item =>item.id === scope.row.riskSourceType)?.name || ''}`}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="evaluateStatus" label="评价状态" show-overflow-tooltip>
                            <template #default="scope">
                                <span>{{`${unitState.evaluateStatusList.find(item =>item.id === scope.row.evaluateStatus)?.name  || ''}`}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="liabilityUserName" label="责任人" show-overflow-tooltip/>
                        <el-table-column prop="liabilityDep" label="责任部门" show-overflow-tooltip/>
                        <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="createByUserName" label="创建人" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="updateTime" label="最后修改时间" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="updateByUserName" label="最后修改人" show-overflow-tooltip></el-table-column>
                        <el-table-column label="操作" width="150">
                            <template #default="scope">
                                <el-button size="small" text type="primary" :icon="Edit" @click="openUnitDialog('修改', scope.row)">编辑</el-button>
                                <el-button size="small" text type="danger" :icon="Delete" @click="onDelUnit(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="pageBtn">
                        <el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="unitState.searchQuery.pageIndex" background v-model:page-size="unitState.searchQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="unitState.total" class="page-position"> </el-pagination>
                    </div>
                </div>
            </div>
        </div>
        <unit-dialog ref="unitDialogRef" @refresh="getUnitData"></unit-dialog>
    </div>
</template>
 
<script setup lang="ts">
import {defineAsyncComponent, onMounted, reactive, ref} from "vue";
import {unitApi} from "/@/api/basic/unit";
import {ElMessage, ElMessageBox} from "element-plus";
import { Edit, View, Plus, Delete } from '@element-plus/icons-vue';
import {roomApi} from "/@/api/basic/room";
import {equipmentApi} from "/@/api/basic/equipement";
import {personApi} from "/@/api/basic/person";
 
const UnitDialog = defineAsyncComponent(() => import('./components/unitDialog.vue'));
 
const unitDialogRef = ref();
 
const unitState = reactive<UnitStateType>({
    unitData: [],
    searchQuery: {
        pageIndex: 1,
        pageSize: 10,
        riskCode: '',
        riskName: '',
        riskSourceType: null,
    },
    total: 0,
    riskSourceTypeList: [
        {id: 1, name: '区域、实验场所'},
        {id:2, name: '设施设备'},
        {id:3, name: '固定工艺节点'},
    ],
    evaluateStatusList: [
        {id: 1, name: '未评价'},
        {id:2, name: '已评价'},
    ],
    allRoomList: [],
    allEquipmentList: [],
    allPersonList: [],
})
 
const getUnitData = async () => {
    let res = await unitApi().getUnitByList(unitState.searchQuery);
    if(res.data.code === 100){
        unitState.unitData = res.data.data;
    }else{
        ElMessage({
            type: 'warning',
            message: res.data.msg
        });
    }
};
 
const getRoomData = async () => {
    let res = await roomApi().getAllRoom();
    if(res.data.code === 100){
        unitState.allRoomList = JSON.parse(JSON.stringify(res.data.data));
    }else{
        ElMessage({
            type: 'warning',
            message: res.data.msg
        });
    }
};
 
const getAllEquipmentList = async () => {
    let res = await equipmentApi().getAllEquipment();
    if(res.data.code === 100){
        unitState.allEquipmentList = JSON.parse(JSON.stringify(res.data.data));
    }else{
        ElMessage({
            type: 'warning',
            message: res.data.msg
        })
    }
};
 
const getAllPersonList = async () => {
    let res = await personApi().getAllPerson();
    if(res.data.code === 100){
        unitState.allPersonList = JSON.parse(JSON.stringify(res.data.data));
    }else{
        ElMessage({
            type: 'warning',
            message: res.data.msg
        })
    }
};
 
const openUnitDialog = (title: string, value: UnitType) => {
    unitDialogRef.value.showUnitDialog(title, value, unitState.allEquipmentList, unitState.allRoomList, unitState.allPersonList);
};
 
const onDelUnit = (val: UnitType) => {
    ElMessageBox.confirm(`此操作将永久删除该单元:“${val.riskName}”,是否继续?`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
    })
        .then(async () => {
            let res = await unitApi().deleteUnitById({ id: val.id });
            if (res.data.code === 100) {
                ElMessage({
                    type: 'success',
                    duration: 2000,
                    message: '删除成功'
                });
                await getUnitData();
            } else {
                ElMessage({
                    type: 'warning',
                    message: res.data.msg
                });
            }
        })
        .catch((error) => {
        });
}
 
const onHandleSizeChange = (val: number) => {
    unitState.searchQuery.pageSize = val;
    getUnitData();
};
 
const onHandleCurrentChange = (val: number) => {
    unitState.searchQuery.pageIndex = val;
    getUnitData();
};
 
const reset = () => {
    unitState.searchQuery = {
        pageIndex: 1,
        pageSize: 10,
        riskCode: '',
        riskName: '',
        riskSourceType: null,
    }
};
 
onMounted(() => {
    getUnitData();
    getRoomData();
    getAllEquipmentList();
    getAllPersonList();
})
 
</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 {
            display: flex;
            align-items: center;
            font-size: 16px;
            font-weight: bold;
 
            & > div {
                white-space: nowrap;
                margin-right: 20px;
            }
        }
    }
}
.stepItem {
    width: 100%;
    display: flex;
    align-items: flex-start;
    margin-bottom: 30px;
    margin-left: 30px;
    padding-bottom: 30px;
    border-left: 2px solid #ccc;
    &:first-of-type {
        margin-top: 30px;
    }
    &:last-of-type {
        margin-bottom: 0;
        border-left: none;
    }
    .stepNum {
        width: 30px;
        height: 30px;
        border-radius: 15px;
        box-sizing: border-box;
        color: #333;
        border: 1px solid #999;
        line-height: 28px;
        text-align: center;
        margin-right: 10px;
        margin-left: -16px;
        margin-top: -30px;
    }
    .stepCard {
        width: 100%;
        margin-top: -30px;
 
        .box-card {
            width: 100%;
            &:deep(.el-card__header) {
                padding: 10px 15px;
            }
            .card-header {
                width: 100%;
                display: flex;
                justify-content: space-between;
                align-items: center;
                & > div:first-of-type {
                    margin-right: 80px;
                    font-size: 18px;
                    font-weight: bold;
                }
            }
        }
    }
    &:hover .card-header {
        color: #0098f5;
    }
    &:hover .stepNum {
        border: 2px solid #0098f5;
        color: #0098f5;
    }
}
 
:deep(.el-date-editor) {
    width: 100%;
}
.el-select {
    width: 100%;
}
:deep(.el-textarea.is-disabled .el-textarea__inner) {
    background-color: var(--el-card-bg-color);
    color: var(--el-input-text-color, var(--el-text-color-regular));
}
:deep(.el-input.is-disabled .el-input__inner) {
    color: var(--el-input-text-color, var(--el-text-color-regular));
}
:deep(.el-input.is-disabled .el-input__wrapper) {
    background-color: var(--el-card-bg-color);
}
</style>