Your Name
2023-02-24 5a72942254d0a4cae77c2980b014a5cf55a52cf9
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
<template>
    <div class="system-menu-dialog-container">
        <el-dialog :title="identifyQueryState.title" v-model="identifyQueryState.identifyQueryVisible" :close-on-click-modal="false" width="800px">
            <el-form ref="identifyFormRef" :rules="identifyQueryState.identifyFormRules" :model="identifyQueryState.identifyQueryForm" size="default" label-width="100px">
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="评估计划" prop="id">
                            <el-select class="input-length" :disabled="true" v-model="identifyQueryState.identifyQueryForm.id" style="width:100%" placeholder="评估计划" clearable>
                                <el-option v-for="item in identifyQueryState.planList" :key="item.id" :label="item.assessPlanName" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="辨识方法" prop="identificationMethod">
                            <el-select class="input-length" :disabled="identifyQueryState.disabled" v-model="identifyQueryState.identifyQueryForm.identificationMethod" style="width:100%" placeholder="辨识方法" clearable>
                                <el-option v-for="item in identifyQueryState.identificationMethodList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div class="checkUnit-point">
                <el-tabs class="active" v-model="identifyQueryState.activeName">
                    <el-tab-pane label="辨识信息" name="identify">
                        <div style="padding-bottom: 10px" v-if="identifyQueryState.identifyForm.planExecStatus === 2">
                            <el-button size="default"  type="primary"  @click="openIdentifyDialog('新增', '')">
                                <el-icon>
                                    <ele-FolderAdd />
                                </el-icon>
                                新增
                            </el-button>
                        </div>
 
                        <el-table :data="identifyQueryState.list" border fit highlight-current-row style="width: 100%">
                            <el-table-column type="index" label="序号" width="80" />
                            <el-table-column prop="technologyMeasure" label="技术措施" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column prop="manageMeasure" label="管理措施" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column prop="educationMeasure" label="教育措施" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column prop="personalProtectionMeasure" label="防护措施" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column label="操作" width="150" align="center">
                                <template #default="scope">
                                    <el-button size="default" text  type="primary"  @click="openIdentifyDialog('查看', scope.row)">查看</el-button>
                                    <el-button size="default" text  type="primary" v-if="identifyQueryState.identifyForm.planExecStatus === 2"  @click="openIdentifyDialog('编辑', scope.row)">编辑</el-button>
                                    <el-button size="default" text type="danger" v-if="identifyQueryState.identifyForm.planExecStatus === 2" @click="onDelIdentifyQuery(scope.$index, scope.row)">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-tab-pane>
                </el-tabs>
            </div>
            <template #footer>
                <span class="Query-footer">
                    <el-button @click="identifyQueryState.identifyQueryVisible = !identifyQueryState.identifyQueryVisible" size="default">取 消</el-button>
                    <el-button v-if="identifyQueryState.identifyForm.planExecStatus === 2" type="primary" @click="identifyQueryState.identifyQueryVisible = !identifyQueryState.identifyQueryVisible" size="default">确定</el-button>
                </span>
            </template>
        </el-dialog>
        <identify-dialog ref="identifyDialogRef" @refresh="refreshList"></identify-dialog>
    </div>
</template>
 
<script setup lang="ts">
import {defineAsyncComponent, reactive, ref} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {identifyApi} from "/@/api/analyse/identify";
import {isValidKey} from "/@/utils/methods";
 
const identifyDialogRef = ref()
const IdentifyDialog = defineAsyncComponent(() => import('./identifyDialog.vue'))
 
const identifyQueryState = reactive<IdentifyQueryType>({
    title: '',
    activeName: 'identify',
    list: [],
    identifyQueryVisible: false,
    identifyQueryForm: {
        id: null,
        identificationMethod: null,
    },
    identifyForm: {},
    identificationMethodList: [
        {id:1, name: 'PHA'},
        {id:2, name: 'JHA'},
        {id:3, name: 'SCL'},
        {id:4, name: 'HAZOP'},
        {id:5, name: '类比法'},
    ],
    planList: [],
})
 
const showIdentifyQuery = (title: string, value: IdentifyType, planList: PlanType [], personList: SystemPersonType []) => {
    identifyQueryState.identifyQueryVisible = true;
    identifyQueryState.identifyForm = value;
    identifyQueryState.planList = planList;
    identifyQueryState.list = value.factorQueryDTOList;
    for(let i in identifyQueryState.identifyQueryForm){
        if(isValidKey(i, identifyQueryState.identifyQueryForm)){
            identifyQueryState.identifyQueryForm[i] = value[i]
        }
    }
    if(title === '编辑'){
        identifyQueryState.title = '编辑';
    }else {
        identifyQueryState.title = '查看';
    }
};
 
const openIdentifyDialog = (title: string, value: IdentifyType) => {
    identifyDialogRef.value.showIdentifyDialog(title, identifyQueryState.identifyForm, value);
};
 
const refreshList = (type: number, data: IdentifyType) => {
    if(type === 1){
        identifyQueryState.list?.push(data)
    }else{
        (<Array<IdentifyType>>identifyQueryState.list)[identifyQueryState.list?.findIndex(item => item.id === data.id) as number] = data
    }
};
 
const onDelIdentifyQuery = (index: number, val: IdentifyType) => {
    ElMessageBox.confirm(`此操作将永久删除该辨识,是否继续?`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
    })
        .then(async () => {
            let data = { id: val.id, analogyId: val.analogyId, hazopId: val.hazopId, jhaId: val.jhaId, phaId: val.phaId, sclId: val.sclId, }
            let res = await identifyApi().deleteIdentifyById(data);
            if (res.data.code === 100) {
                (<Array<IdentifyType>>identifyQueryState.list).splice(index, 1)
                ElMessage({
                    type: 'success',
                    duration: 2000,
                    message: '删除成功'
                });
            } else {
                ElMessage({
                    type: 'warning',
                    message: res.data.msg
                });
            }
        })
        .catch((error) => {
            console.log(error);
        });
};
 
const emit = defineEmits(['refresh'])
 
defineExpose({
    showIdentifyQuery
})
</script>
 
<style scoped>
 
</style>