马宇豪
2025-03-12 de5e674a5655cd5c8d5457d1be8182519625d265
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
<template>
    <div class="system-menu-dialog-container">
        <el-dialog :title="identifyQueryState.title" v-model="identifyQueryState.identifyQueryVisible" :close-on-click-modal="false" width="800px" @close="resetData()">
            <el-form ref="identifyFormRef" :model="identifyQueryState.identifyQueryForm" size="default" label-width="160px">
                <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="评价类型">-->
<!--                        <el-input v-model="identifyQueryState.identifyQueryForm.assessType" readonly></el-input>-->
<!--                      </el-form-item>-->
<!--                    </el-col>-->
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                      <el-form-item label="计划开始评价时间">
                        <el-input v-model="identifyQueryState.identifyQueryForm.assessStartTime" readonly></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                      <el-form-item label="评价风险分析单元">
                        <el-input v-model="identifyQueryState.identifyQueryForm.riskUnitName" readonly placeholder="暂无风险分析单元"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col style="display: flex;align-items: center" :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="辨识方法" prop="identificationMethod">
                            <el-select class="input-length" 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-button size="default" v-if="identifyQueryState.identifyForm.planExecStatus == 2" type="primary" @click="openChangeMethod()">修改辨识方法</el-button>
                    </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 v-if="identifyQueryState.identifyForm.identificationMethod == 1" prop="phaCheckItem" label="检查项目" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 1" prop="phaRiskFactor" label="存在风险因素" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 1" prop="phaResult" label="可能存在后果" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 2" prop="jhaCheckItem" label="作业步骤" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 2" prop="jhaRiskFactor" label="存在风险因素" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 2" prop="jhaResult" label="可能存在后果" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 3" prop="sclCheckItem" label="检查项目" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 3" prop="sclCheckStandard" label="检查标准" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 3" prop="sclCheckUnstandard" label="不符合标准情况" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 3" prop="sclCheckResult" label="主要后果" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopNode" label="节点" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopParam" label="参数" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopParamDesc" label="参数描述" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopNode" label="节点" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopGuide" label="引导词" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopDeviation" label="偏差" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopPossibleCauses" label="可能原因" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 4" prop="hazopResult" label="可能存在后果" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 5" prop="analogyCheckItem" label="检查项目" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 5" prop="analogyReference" label="类比参照" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 5" prop="analogyRiskFactor" label="存在风险因素" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column v-if="identifyQueryState.identifyForm.identificationMethod == 5" prop="analogyResult" label="可能存在后果" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column prop="result" label="辨识结果" show-overflow-tooltip align="center">
                                <template #default="scope">
                                    <span>{{scope.row.result == 1?'有风险':scope.row.result == 2?'无风险':'--'}}</span>
                                </template>
                            </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>
        <el-dialog title="修改辨识方法" v-model="identifyQueryState.identifyMethodVisible" width="30%">
          <el-select class="input-length" v-model="identifyQueryState.currentMethod" 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>
          <template #footer>
            <span class="Query-footer">
              <el-button @click="identifyQueryState.identifyMethodVisible = false" size="default">取 消</el-button>
              <el-button type="primary" @click="conFirmChange()" size="default">确定</el-button>
            </span>
          </template>
        </el-dialog>
        <identify-dialog ref="identifyDialogRef" @refresh="getIdentifyData"></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";
import {userApi} from "/@/api/systemManage/user";
 
const identifyDialogRef = ref()
const IdentifyDialog = defineAsyncComponent(() => import('./identifyDialog.vue'))
 
const identifyQueryState = reactive<IdentifyQueryType>({
    title: '',
    activeName: 'identify',
    list: [],
    identifyQueryVisible: false,
    identifyMethodVisible: false,
    currentMethod: null,
    identifyQueryForm: {
        id: null,
        identificationMethod: null,
        assessType: null,
        assessStartTime: '',
        riskUnitName: ''
    },
    identifyForm: {},
    identificationMethodList: [
        {id:1, name: 'PHA'},
        {id:2, name: 'JHA'},
        {id:3, name: 'SCL'},
        {id:4, name: 'HAZOP'},
        {id:5, name: '类比法'},
    ],
    planList: [],
    personList: []
})
 
// const getAssessInfo =(value: number|null)=>{
//   const data = identifyQueryState.planList.find(item => item.id === value) as PlanType
// }
 
const showIdentifyQuery = (title: string, value: IdentifyType, planList: PlanType [], personList: AllPersonListType []) => {
    identifyQueryState.identifyQueryVisible = true;
    identifyQueryState.identifyForm = value;
    identifyQueryState.planList = planList;
    identifyQueryState.personList = personList
    identifyQueryState.list = value.factorQueryDTOList
    // getAssessInfo(identifyQueryState.identifyQueryForm.id);
    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, value, identifyQueryState.identifyQueryForm,identifyQueryState.identifyForm, identifyQueryState.personList);
};
 
const openChangeMethod = ()=>{
  identifyQueryState.currentMethod = identifyQueryState.identifyQueryForm.identificationMethod
  identifyQueryState.identifyMethodVisible = true
}
 
const conFirmChange = async () =>{
  let res = await identifyApi().UpdateIdentifyMethod({
    id: identifyQueryState.identifyQueryForm.id,
    identificationMethodId: identifyQueryState.currentMethod
  });
  if(res.data.code === 100){
    ElMessage({
      type: 'success',
      message: '辨识方法修改成功'
    })
    identifyQueryState.identifyQueryForm.identificationMethod = identifyQueryState.currentMethod,
    identifyQueryState.currentMethod = identifyQueryState.currentMethod,
    emit('refresh')
    getIdentifyData()
  }else{
    ElMessage({
      type: 'warning',
      message: res.data.msg
    })
  }
  identifyQueryState.identifyMethodVisible = false
}
 
const resetData = ()=>{
  emit('refresh')
}
 
// 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 getIdentifyData = async () => {
  let res = await identifyApi().getIdentifyByList(
{
        pageIndex: 1,
        pageSize: 10,
        assessPlanName: '',
        experimentName: '',
        tag: 1,
        assessPlanId: identifyQueryState.identifyForm.id
      }
    );
  if(res.data.code === 100){
    identifyQueryState.list = res.data.data[0].factorQueryDTOList
  }else{
    ElMessage({
      type: 'warning',
      message: res.data.msg
    });
  }
};
 
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>