spring
2025-02-27 66b3c4c129b05b634d37ac7eac63eff0f0b9f426
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
<template>
  <div style="padding: 10px">
    <div class="header">
      <span></span>
      <div style="min-width: 200px">
        <el-button type="primary" size="small" @click="addFun">新 增</el-button>
        <el-button type="primary" size="small" @click="approvalFun">审 批</el-button>
        <el-button type="primary" size="small" @click="approveFun">批 准</el-button>
        <el-upload style="display: inline-block; padding: 0 6px" :headers="uploadHeader" :action="action"
          :on-error="onError" :show-file-list="false" :on-success="onSuccess">
          <el-button size="small" type="primary">导 入</el-button>
        </el-upload>
        <el-button size="small" @click="openDownloadDia">导出</el-button>
      </div>
    </div>
    <el-table :data="tableData" style="width: 100%" height="calc(100vh - 18em)" key="table1">
      <el-table-column type="index" label="序号" width="120">
        <template v-slot="scope">
          <span>{{ (page.current - 1) * page.size + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="venue" label="地点/活动" min-width="180"></el-table-column>
      <el-table-column prop="hazard" label="危险因素" width="testDate" min-width="180"></el-table-column>
      <el-table-column prop="accidents" label="可能导致的事故" min-width="180"></el-table-column>
      <el-table-column prop="injury" label="对人可能造成的危害" min-width="180"></el-table-column>
      <el-table-column label="风险评价" align="center" min-width="180">
        <template>
          <el-table-column prop="riskL" label="L" min-width="80"></el-table-column>
          <el-table-column prop="riskE" label="E" min-width="80"></el-table-column>
          <el-table-column prop="riskC" label="C" min-width="80"></el-table-column>
          <el-table-column prop="riskD" label="D" min-width="80"></el-table-column>
        </template>
      </el-table-column>
      <el-table-column prop="level" label="风险等级" min-width="180"></el-table-column>
      <el-table-column prop="measures" label="控制措施" min-width="180"></el-table-column>
      <el-table-column prop="editorName" label="编制人姓名" min-width="180"></el-table-column>
      <el-table-column prop="editorDate" label="编制日期" min-width="180"></el-table-column>
      <el-table-column prop="approvalName" label="审批人姓名" min-width="180"></el-table-column>
      <el-table-column prop="approvalDate" label="审批日期" min-width="180"></el-table-column>
      <el-table-column prop="approvalStatus" label="审批状态" min-width="180">
        <template #default="{ row }">
          {{ row.approvalStatus === 1 ? '通过' : row.approvalStatus === 2 ? '不通过' : '' }}
        </template>
      </el-table-column>
      <el-table-column prop="approveName" label="批准人姓名" min-width="180"></el-table-column>
      <el-table-column prop="approveStatus" label="批准状态" min-width="180">
        <template #default="{ row }">
          {{ row.approveStatus === 1 ? '通过' : row.approveStatus === 2 ? '不通过' : '' }}
        </template>
      </el-table-column>
      <el-table-column prop="approveDate" label="批准日期" min-width="180"></el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template v-slot="scope">
          <el-button type="text" size="small" @click="editClick(scope.row)">编辑</el-button>
          <el-button @click="deleteClick(scope.row)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="1" :page-size="page.size" :page-sizes="[10, 20, 30, 50, 100]" :total="page.total"
      layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
      @current-change="handleCurrentChange">
    </el-pagination>
    <el-dialog title="提示" :visible.sync="dialogVisible" width="50%">
      <el-form ref="form" :model="form" label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="地点/活动">
              <el-input v-model="form.venue" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="危险因素">
              <el-input v-model="form.hazard" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="可能导致的事故">
              <el-input v-model="form.accidents" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="对人可能造成的危害" label-width="140px">
              <el-input v-model="form.injury" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风险评价/L">
              <el-input v-model="form.riskL" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风险评价/E">
              <el-input v-model="form.riskE" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风险评价/C">
              <el-input v-model="form.riskC" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风险评价/D">
              <el-input v-model="form.riskD" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风险等级">
              <el-input v-model="form.level" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="控制措施">
              <el-input v-model="form.measures" size="small"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addApi" :loading="loading">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { getToken } from "@/utils/auth";
import {
  getPageResults,
  dangerousRiskApproval,
  hazardIdentificationAndRiskApproval,
  removeRiskFactors,
  addNewRiskFactors,
  exportHazardFactorIdentification,
} from '@/api/cnas/systemManagement/measuresDealRisks.js'
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      dialogVisible: false,
      form: {},
      page: {
        total: 0,
        size: 10,
        current: 1,
      },
      tableData: [],
      loading: false
    }
  },
  computed: {
    action() {
      return this.javaApi + '/manageRiskAssessmentResults/riskAssessmentImport'
    },
    ...mapGetters(["userId"]),
  },
  methods: {
    handleSizeChange(val) {
      this.page.size = val;
      this.initData();
    },
    handleCurrentChange(val) {
      this.page.current = val;
      this.initData();
    },
    // 分页表格初始化
    initData() {
      this.tableData = []
      getPageResults(this.page).then(res => {
        if (res.code === 201) return;
        this.tableData = res.data.records;
        this.page.total = res.data.total;
      });
    },
    // 审批
    approvalFun() {
      this.$confirm('是否审批通过?', '提示', {
        confirmButtonText: '通过',
        cancelButtonText: '不通过',
        type: 'warning',
        closeOnClickModal: false, // 禁止点击遮罩层关闭
        distinguishCancelAndClose: true,
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            this.approvalApi(this.userId, 1)
            done();
          } else if (action === 'cancel') {
            this.approvalApi(this.userId, 2)
            done();
          } else if (action === 'close') {
            // 点击“×”按钮,不允许关闭
            done();
          }
        }
      })
    },
    // 审批接口
    approvalApi(userId, status) {
      dangerousRiskApproval({ approval: userId, status: status }).then(res => {
        if (res.code === 201) return;
        this.initData()
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
      });
    },
    // 批准
    approveFun() {
      this.$confirm('是否批准通过?', '提示', {
        confirmButtonText: '通过',
        cancelButtonText: '不通过',
        type: 'warning',
        closeOnClickModal: false, // 禁止点击遮罩层关闭
        distinguishCancelAndClose: true,
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            this.approveApi(this.userId, 1)
            done();
          } else if (action === 'cancel') {
            this.approveApi(this.userId, 2)
            done();
          } else if (action === 'close') {
            // 点击“×”按钮,不允许关闭
            done();
          }
        }
      })
    },
    // 批准接口
    approveApi(userId, status) {
      hazardIdentificationAndRiskApproval({ approve: userId, status: status }).then(res => {
        if (res.code === 201) return;
        this.initData()
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
      });
    },
    // 文件上传失败
    onError() {
      this.$message({
        type: 'error',
        message: '操作失败!'
      });
    },
    // 文件上传成功
    onSuccess(response) {
      if (response.code == 201) {
        this.$message({
          type: 'error',
          message: response.message,
        });
        return
      }
      this.initData()
      this.$message({
        type: 'success',
        message: '操作成功!'
      });
    },
    addFun() {
      this.form = {}
      this.dialogVisible = true
    },
    // 删除
    deleteClick(row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        removeRiskFactors({ id: row.id }).then(res => {
          if (res.code === 201) return;
          this.initData()
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    addApi() {
      this.loading = true
      addNewRiskFactors(this.form).then(res => {
        if (res.code === 201) return;
        this.dialogVisible = false
        this.loading = false
        this.initData()
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
      }).catch(err => {
        this.loading = false
      });
    },
    // 编辑
    editClick(row) {
      this.form = { ...row }
      this.dialogVisible = true
    },
    // 导出
    openDownloadDia() {
      exportHazardFactorIdentification().then(res => {
        this.outLoading = false
        this.$message.success('导出成功')
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, '危险因素辨识与风险评价结果一览' + '.docx');
      })
    },
  },
  mounted() {
    this.initData()
  },
}
</script>
 
<style scoped>
.header {
  height: 3em;
  width: 100%;
  display: flex;
  justify-content: space-between;
}
</style>