马宇豪
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
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<template>
    <div class="home-container">
        <div style="height: 100%">
            <el-row class="homeCard">
                <div class="basic-line">
                    <span>评估计划名称:</span>
                    <el-input v-model="planState.searchQuery.assessPlanName" clearable filterable class="input-box" placeholder="评估计划名称">
                    </el-input>
                </div>
                <div class="basic-line">
                    <span>风险单元名称:</span>
                    <el-input v-model="planState.searchQuery.riskUnitName" clearable filterable class="input-box" placeholder="风险单元名称">
                    </el-input>
                </div>
                <div style="padding-bottom: 10px">
                    <el-button type="primary" @click="getPlanData">查询</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="openPlanDialog('新增', {})">新增</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="planState.planData" style="width: 100%" height="calc(100% - 100px)" :header-cell-style="{ background: '#fafafa' }">
                        <el-table-column prop="assessPlanName" label="评估计划名称"/>
                        <el-table-column prop="riskUnitName" label="风险单元名称" />
                        <el-table-column prop="planUserName" label="计划制定人" />
                        <el-table-column prop="assessStartTime" label="评估开始时间">
                          <template #default="scope">
                            <span>{{scope.row.assessStartTime?scope.row.assessStartTime.substring(0,16):'--'}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="assessEndTime" label="评估结束时间">
                          <template #default="scope">
                            <span>{{scope.row.assessEndTime?scope.row.assessEndTime.substring(0,16):'--'}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="identificationUser" label="辨识专家" />
                        <el-table-column prop="evaluateUser" label="评价专家" />
<!--                        <el-table-column prop="sceneUser" label="现场专家" />-->
                        <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 prop="planSellStatus" label="是否派发" show-overflow-tooltip>
                            <template #default="scope">
                                <div>
                                    <div v-if="scope.row.planSellStatus === 1">
                                        <el-tag :type="'info'">
                                            {{ '未派发' }}
                                        </el-tag>
                                    </div>
                                    <div v-if="scope.row.planSellStatus === 2">
                                        <el-tag :type="'success'">
                                            {{ '已派发' }}
                                        </el-tag>
                                    </div>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" width="250">
                            <template #default="scope">
                                <el-button size="small" text type="primary" v-if="scope.row.planSellStatus === 1" @click="accessPlan(scope.row)">派发</el-button>
                                <el-button size="small" text type="primary" :icon="View" @click="openPlanDialog('查看', scope.row)">查看</el-button>
                                <el-button v-if="scope.row.planSellStatus === 1" size="small" text type="primary" :icon="Edit" @click="openPlanDialog('修改', scope.row)">编辑</el-button>
                                <el-button v-if="scope.row.identityUsers?.find(i=>i.identificationUserId == planState.user)" size="small" text type="primary" :icon="Edit" @click="refuseIdentify(scope.row)">拒绝辨识</el-button>
                                <el-button v-if="scope.row.evaluateUsers?.find(i=>i.evaluateUserId== planState.user)" size="small" text type="primary" :icon="Edit" @click="refuseEvaluate(scope.row)">拒绝评价</el-button>
<!--                                <el-button v-if="scope.row.sceneUserId == planState.user" size="small" text type="primary" :icon="Edit" @click="refuseScene(scope.row)">拒绝现场</el-button>-->
                                <el-button v-if="!scope.row.identityUsers" size="small" text type="primary" :icon="Edit" @click="reSendJob(scope.row,1)">重新指派辨识</el-button>
                                <el-button v-if="!scope.row.evaluateUsers" size="small" text type="primary" :icon="Edit" @click="reSendJob(scope.row,2)">重新指派评价</el-button>
                                <el-button v-if="scope.row.planSellStatus === 1" size="small" text type="danger" :icon="Delete" @click="onDelPlan(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="planState.searchQuery.pageIndex" background v-model:page-size="planState.searchQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="planState.total" class="page-position"> </el-pagination>
                    </div>
                </div>
            </div>
        </div>
        <plan-dialog ref="planDialogRef" @refresh="getPlanData"></plan-dialog>
 
        <el-dialog class="chooseExpert" :title="planState.reSendTitle" v-model="planState.reSendDialogVisible" width="50%">
          <el-form ref="ruleFormRef" :rules="planState.rules" :model="planState.reSendForm" label-width="120px">
            <el-form-item v-if="planState.reSendTitle == '指派辨识专家'" label="选择辨识专家" prop="identificationUserId" class="valueSelect">
              <el-select v-model="planState.reSendForm.userIds" multiple style="width:100%" :teleported="false" placeholder="辨识专家" clearable>
                <el-option v-for="item in planState.bsExperts" :key="item.id" :label="item.realName" :value="item.id">
                  <div class="valueTable">
                    <div><div>姓名:</div><span>{{item.realName}}</span></div>
                    <div><div>专业:</div><span>{{item.userIdentities?.map(i=>i.userIdentity).join(',')}}</span></div>
                  </div>
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="planState.reSendTitle == '指派评价专家'" label="选择评价专家" prop="evaluateUserId" class="valueSelect">
              <el-select v-model="planState.reSendForm.userIds" multiple style="width:100%" :teleported="false" placeholder="评价专家" clearable>
                <el-option v-for="item in planState.pjExperts" :key="item.id" :label="item.realName" :value="item.id">
                  <div class="valueTable">
                    <div><div>姓名:</div><span>{{item.realName}}</span></div>
                    <div><div>专业:</div><span>{{item.userIdentities?.map(i=>i.userIdentity).join(',')}}</span></div>
                  </div>
                </el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <template #footer>
                <span class="dialog-footer" style="padding-top:10px;text-align: center !important;">
                  <el-button @click="planState.reSendDialogVisible = !planState.reSendDialogVisible" size="default">取 消</el-button>
                  <el-button type="primary" @click="onSubmitReSend(ruleFormRef)" size="default">确认指派</el-button>
                </span>
          </template>
        </el-dialog>
 
    </div>
</template>
 
<script setup lang="ts">
import {defineAsyncComponent, onMounted, reactive, ref} from "vue";
import {planApi} from "/@/api/analyse/plan";
import {ElMessage, ElMessageBox, FormInstance} from "element-plus";
import { Edit, View, Plus, Delete } from '@element-plus/icons-vue';
import {riskUnitApi} from "/@/api/analyse/riskUnit";
import {personApi} from "/@/api/basic/person";
import {useUserInfo} from "/@/stores/userInfo";
import { storeToRefs } from 'pinia';
import {userApi} from "/@/api/systemManage/user";
import {assessApplyApi} from "/@/api/analyse/assessApply";
 
 
const PlanDialog = defineAsyncComponent(() => import('./components/planDialog.vue'));
const planDialogRef = ref();
const userInfo = useUserInfo();
const { userInfos } = storeToRefs(userInfo);
const ruleFormRef = ref<FormInstance>()
const planState = reactive<PlanStateType>({
    planData: [],
    user: null,
    searchQuery: {
        pageIndex: 1,
        pageSize: 10,
        assessPlanName: '',
        riskUnitName: '',
    },
    total: 0,
    riskUnitList: [
    ],
    personList: [],
    bsExperts: [],
    pjExperts: [],
    identificationMethodList: [
        {id:1, name: 'PHA'},
        {id:2, name: 'JHA'},
        {id:3, name: 'SCL'},
        {id:4, name: 'HAZOP'},
        {id:5, name: '类比法'},
    ],
        evaluateMethodList: [
        {id:1, name: 'LEC'},
        {id:2, name: 'LS'},
        {id:3, name: 'MES'},
        {id:4, name: 'RS'},
    ],
    reSendTitle:'',
    reSendDialogVisible: false,
    reSendForm: {
      riskAssessPlanId: null,
      userIds: [],
      userType: null
    },
    rules: {
      userIds: [{ required: true, message: '请选择专家', trigger: 'blur' }]
    }
    // deviceUnitList: [
    //     {id:1, name: '台'},
    //     {id:2, name: '个'},
    //     {id:3, name: '件'}
    // ]
})
 
const getPlanData = async () => {
    let res = await planApi().getPlanByList(planState.searchQuery);
    if(res.data.code === 100){
        planState.planData = res.data.data;
        planState.total = res.data.total;
    }else{
        ElMessage({
            type: 'warning',
            message: res.data.msg
        });
    }
};
 
const getAllRiskUnitList = async () => {
    let res = await riskUnitApi().getAllRiskUnit();
    if(res.data.code === 100){
        planState.riskUnitList = JSON.parse(JSON.stringify(res.data.data));
    }else{
        ElMessage({
            type: 'warning',
            message: res.data.msg
        });
    }
};
 
const getPersonList = async () => {
    let res = await userApi().getUserList({
        pageIndex: 1,
        pageSize: 99999,
        searchParams:{
          roleId: null,
          name: '',
          realName: ''
        }
    });
    if(res.data.code === 100){
        planState.personList = JSON.parse(JSON.stringify(res.data.data));
    }else{
        ElMessage({
            type: 'warning',
            message: res.data.msg
        })
    }
};
 
const getAllExperts = async () => {
  let res = await userApi().getExpertsList({
    pageIndex: 1,
    pageSize: 99999,
    searchParams:{
      userIndentityId: null
    }
  });
  if (res.data.code === 100) {
    const expertsList = res.data.data;
    for(let i of expertsList){
      if(i.roles?.find(obj=>obj.roleId == 2)){
        planState.bsExperts.push(i)
      }
      if(i.roles?.find(obj=>obj.roleId == 3)){
        planState.pjExperts.push(i)
      }
    }
  } else {
    ElMessage({
      type: 'warning',
      message: res.data.msg
    });
  }
};
 
const openPlanDialog = (title: string, value: PlanType) => {
    planDialogRef.value.showPlanDialog(title, value, planState.riskUnitList, planState.personList,planState.bsExperts,planState.pjExperts);
};
 
const refuseIdentify = async(val: PlanType)=>{
  ElMessageBox.confirm(`此操作将拒绝作为该计划:“${val.assessPlanName}”的辨识专家,是否继续?`, '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning'
  })
      .then(async () => {
        let res = await planApi().refuseIdentify({ id: val.id });
        if (res.data.code === 100) {
          ElMessage({
            type: 'success',
            duration: 2000,
            message: '拒绝成功'
          });
          await getPlanData();
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      })
      .catch((error) => {
      });
}
 
const reSendJob= async(val: PlanType,type:number | null)=>{
  planState.reSendForm = {
    riskAssessPlanId: val.id,
    userIds: [],
    userType: type
  }
  if(type==1){
    planState.reSendTitle = '指派辨识专家'
  }else{
    planState.reSendTitle = '指派评价专家'
  }
  planState.reSendDialogVisible = true
}
 
const onSubmitReSend = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate(async(valid, fields) => {
    if (valid) {
      let res = await planApi().reSendJob(planState.reSendForm);
      if(res.data.code === 100){
        ElMessage({
          type: 'success',
          message: '重新指派成功'
        });
      }else{
        ElMessage({
          type: 'warning',
          message: res.data.msg
        });
      }
 
      planState.reSendForm = {
        riskAssessPlanId: null,
        userIds: [],
        userType: null
      },
      planState.reSendDialogVisible = false
      getPlanData()
    } else {
      console.log('error submit!', fields)
    }
  })
}
 
const refuseEvaluate = async(val: PlanType)=>{
  ElMessageBox.confirm(`此操作将拒绝作为该计划:“${val.assessPlanName}”的评价专家,是否继续?`, '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning'
  })
      .then(async () => {
        let res = await planApi().refuseEvaluate({ id: val.id });
        if (res.data.code === 100) {
          ElMessage({
            type: 'success',
            duration: 2000,
            message: '拒绝成功'
          });
          await getPlanData();
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      })
      .catch((error) => {
      });
}
 
// const refuseScene = async(val: PlanType)=>{
//   let res = await planApi().refuseScene({ id: val.id });
//   if (res.data.code === 100) {
//     ElMessage({
//       type: 'success',
//       duration: 2000,
//       message: '拒绝成功'
//     });
//     await getPlanData();
//   } else {
//     ElMessage({
//       type: 'warning',
//       message: res.data.msg
//     });
//   }
// }
 
const onDelPlan = (val: PlanType) => {
    ElMessageBox.confirm(`此操作将永久删除该计划:“${val.assessPlanName}”,是否继续?`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
    })
        .then(async () => {
            let res = await planApi().deletePlanById({ id: val.id });
            if (res.data.code === 100) {
                ElMessage({
                    type: 'success',
                    duration: 2000,
                    message: '删除成功'
                });
                await getPlanData();
            } else {
                ElMessage({
                    type: 'warning',
                    message: res.data.msg
                });
            }
        })
        .catch((error) => {
        });
};
 
const accessPlan = (val: PlanType) => {
    ElMessageBox.confirm(`此操作将派发该计划:“${val.assessPlanName}”,是否继续?`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
    })
        .then(async () => {
            let res = await planApi().sellAssessPlan({ id: val.id });
            if (res.data.code === 100) {
                ElMessage({
                    type: 'success',
                    duration: 2000,
                    message: '派发成功'
                });
                await getPlanData();
            } else {
                ElMessage({
                    type: 'warning',
                    message: res.data.msg
                });
            }
        })
        .catch((error) => {
        });
};
 
const onHandleSizeChange = (val: number) => {
    planState.searchQuery.pageSize = val;
    getPlanData();
};
 
const onHandleCurrentChange = (val: number) => {
    planState.searchQuery.pageIndex = val;
    getPlanData();
};
 
const reset = () => {
    planState.searchQuery = {
        pageIndex: 1,
        pageSize: 10,
        riskUnitName: '',
        assessPlanName: '',
    }
};
 
onMounted(() => {
    getPlanData();
    getAllRiskUnitList();
    getAllExperts();
    getPersonList();
    planState.user = Number(userInfos.value.uid)
})
 
</script>
 
<style scoped lang="scss">
$homeNavLengh: 8;
::v-deep(.el-dialog){
  .el-dialog__body{
    overflow-y: visible !important;
    overflow-x: visible !important;
  }
}
 
.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;
            }
        }
    }
}
 
.valueSelect{
  ::v-deep(.el-popper){
    .el-select-dropdown__item{
      width: 100%;
      height: auto;
      white-space: normal;
      word-break: break-all;
      word-wrap: break-word;
      overflow: auto;
      padding: 10px 25px;
      border-bottom: 1px solid #ccc;
 
      .valueTable{
        &>div{
          line-height: 1.5;
          margin-bottom: 6px;
          display: flex;
          align-items: center;
 
          div{
            color: #999;
          }
 
          span{
            font-weight: bolder;
          }
 
          &:last-of-type{
            margin-bottom: 0;
          }
        }
      }
    }
  }
}
: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);
}
:deep(.el-range-editor.is-disabled input){
    background-color: var(--el-card-bg-color);
    color: var(--el-input-text-color, var(--el-text-color-regular));
}
</style>