马宇豪
2023-04-12 8d14fec97344df49d58db115852c03b466482bc6
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
<template>
    <div class="system-menu-dialog-container">
        <el-dialog title="管理实验现实风险" v-model="assessApplyDialogState.assessApplyDialogVisible" width="60%">
          <div>
            <el-button @click="addUnit()" type="primary" style="margin-bottom: 20px" size="default">增加风险分析单元</el-button>
          </div>
          <el-table ref="multipleTableRef" :data="assessApplyDialogState.riskUnitData" style="width: 100%" :header-cell-style="{ background: '#fafafa' }">
            <el-table-column prop="riskCode" label="风险单元编号"/>
            <el-table-column prop="riskName" label="风险单元名称"/>
            <el-table-column prop="riskType" label="风险类型">
              <template #default="scope">
                <span>{{`${assessApplyDialogState.riskList.find(item =>item.id === scope.row.riskType)?.name || ''}`}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="riskUnitType" label="风险单元类型"/>
            <el-table-column prop="riskUnitType" label="负责人">
              <template #default="scope">
                <span>{{`${assessApplyDialogState.allPersonList.find(item =>item.id === scope.row.liabilityUserId)?.personName || ''}`}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="evaluateStatus" label="是否评价">
              <template #default="scope">
                <span>{{scope.row.evaluateStatus == 1?'未评价':scope.row.evaluateStatus == 2?'已评价':'--'}}</span>
              </template>
            </el-table-column>
          </el-table>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="assessApplyDialogState.assessApplyDialogVisible = !assessApplyDialogState.assessApplyDialogVisible" type="primary" size="default">确定</el-button>
            </span>
          </template>
          <risk-unit-dialog ref="riskUnitDialogRef" @refresh="getRiskData"></risk-unit-dialog>
        </el-dialog>
    </div>
</template>
 
<script setup lang="ts">
import {defineAsyncComponent, onMounted, reactive, ref} from "vue";
import {ElMessage} from "element-plus";
import {projectApi} from "/@/api/experiment/project";
import {personApi} from "/@/api/basic/person";
import {riskUnitApi} from "/@/api/analyse/riskUnit";
import {unitApi} from "/@/api/basic/unit";
const RiskUnitDialog = defineAsyncComponent(() => import('./riskUnitDialog.vue'));
 
const assessApplyDialogState = reactive<AssessApplyDialogStateType>({
    title: '',
    riskUnitData: [],
    assessApplyDialogVisible: false,
    id: null,
    liabilityUserId: null,
    riskList: [
      {id: 1, name: '固有风险'},
      {id:2, name: '实验风险'}
    ],
    basicUnitList: [],
    allPersonList: [],
    allRiskTypeList: []
})
 
const riskUnitDialogRef = ref()
 
const showRiskDialog = (value: ProjectType) => {
    assessApplyDialogState.assessApplyDialogVisible = true;
    assessApplyDialogState.id = <number>value.id
    assessApplyDialogState.liabilityUserId = <number>value.liabilityUserId
    getRiskData(<number>value.id)
};
 
const addUnit = (id: number, value: RiskUnitType) => {
  riskUnitDialogRef.value.showRiskUnitDialog(assessApplyDialogState.id, assessApplyDialogState.liabilityUserId, assessApplyDialogState.basicUnitList, assessApplyDialogState.allPersonList, assessApplyDialogState.allRiskTypeList);
};
 
const getRiskData = async (id: number|null) => {
  let res = await riskUnitApi().getRiskUnitByList({pageIndex: 1,pageSize: 9999,riskCode: '',riskName: '',experimentId: id});
  if(res.data.code === 100){
    assessApplyDialogState.riskUnitData = JSON.parse(JSON.stringify(res.data.data));
  }else{
    ElMessage({
      type: 'warning',
      message: res.data.msg
    })
  }
};
 
const getAllBasicUnitList = async () => {
  let res = await unitApi().getAllUnit();
  if(res.data.code === 100){
    assessApplyDialogState.basicUnitList = 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){
    assessApplyDialogState.allPersonList = JSON.parse(JSON.stringify(res.data.data));
  }else{
    ElMessage({
      type: 'warning',
      message: res.data.msg
    })
  }
};
 
const getAllTypeList = async () =>{
  let res = await unitApi().getAllUnitType()
  if(res.data.code === 100){
    assessApplyDialogState.allRiskTypeList = JSON.parse(JSON.stringify(res.data.data));
  }else{
    ElMessage({
      type: 'warning',
      message: res.data.msg
    })
  }
}
 
const emit = defineEmits(['refresh'])
 
defineExpose({
    showRiskDialog
})
 
onMounted(() => {
  getAllBasicUnitList()
  getAllPersonList()
  getAllTypeList()
})
</script>
 
<style scoped>
 
</style>