Browse Source

Web 隐患审核页新增审批流转记录、台账详情新增审核流程

master
DU 1 month ago committed by trae-solo-agent
parent
commit
94fed0218c
  1. 99
      src/views/hazard/audit/index.vue
  2. 47
      src/views/hazard/ledger/index.vue

99
src/views/hazard/audit/index.vue

@ -31,21 +31,47 @@
:closable="false" :closable="false"
show-icon show-icon
class="route-alert" class="route-alert"
style="grid-column: 1 / -1;"
/> />
<hazard-report-panel :report="report" :attachments="attachments" /> <div class="audit-grid">
<audit-action-form <hazard-report-panel :report="report" :attachments="attachments" />
:report="report" <audit-action-form
:report-id="reportId" :report="report"
:attachments="attachments" :report-id="reportId"
:task-id="taskId" :attachments="attachments"
:submitting="submitting" :task-id="taskId"
@upload="handleAttachmentUpload" :submitting="submitting"
@submit="handleAuditSubmit" @upload="handleAttachmentUpload"
@switch-level="handleSwitchLevel" @submit="handleAuditSubmit"
@estimated-points="estimatedPoints = $event" @switch-level="handleSwitchLevel"
/> @estimated-points="estimatedPoints = $event"
<flow-sync-panel :report="report" :estimated-points="estimatedPoints" /> />
<div class="audit-side">
<flow-sync-panel :report="report" :estimated-points="estimatedPoints" />
<el-card class="audit-card flow-record-card" shadow="never">
<div slot="header" class="card-header">审批流转记录</div>
<div v-if="flowRecordLoading" class="flow-record-empty">加载中…</div>
<el-timeline v-else-if="flowRecordList.length">
<el-timeline-item
v-for="(item, index) in flowRecordList"
:key="index"
:icon="item.finishTime ? 'el-icon-check' : 'el-icon-more'"
:color="item.finishTime ? '#67c23a' : '#e6a23c'"
>
<p class="flow-node">{{ item.taskName || '—' }}</p>
<div class="flow-meta">
<span v-if="item.assigneeName">办理人:{{ item.assigneeName }}</span>
<span v-else-if="item.candidate">候选办理:{{ item.candidate }}</span>
<span>接收时间:{{ formatTime(item.createTime) }}</span>
<span v-if="item.finishTime">处理时间:{{ formatTime(item.finishTime) }}</span>
<span v-if="item.duration">耗时:{{ item.duration }}</span>
</div>
<div v-if="item.comment && item.comment.comment" class="flow-comment">处理意见:{{ item.comment.comment }}</div>
</el-timeline-item>
</el-timeline>
<div v-else class="flow-record-empty">暂无流转记录</div>
</el-card>
</div>
</div>
</template> </template>
</div> </div>
</div> </div>
@ -64,6 +90,7 @@ import {
updateHazardReport, updateHazardReport,
uploadHazardAttachment uploadHazardAttachment
} from '@/api/hazard/audit' } from '@/api/hazard/audit'
import { flowRecord } from '@/api/flowable/finished'
export default { export default {
name: 'HazardAudit', name: 'HazardAudit',
@ -77,7 +104,9 @@ export default {
report: {}, report: {},
taskId: '', taskId: '',
attachments: [], attachments: [],
estimatedPoints: null estimatedPoints: null,
flowRecordList: [],
flowRecordLoading: false
} }
}, },
computed: { computed: {
@ -111,6 +140,8 @@ export default {
this.taskId = '' this.taskId = ''
this.attachments = [] this.attachments = []
this.estimatedPoints = null this.estimatedPoints = null
this.flowRecordList = []
this.flowRecordLoading = false
}, },
async loadPage() { async loadPage() {
this.loading = true this.loading = true
@ -129,6 +160,7 @@ export default {
this.$set(this.report, 'canApprove', true) this.$set(this.report, 'canApprove', true)
} }
await this.resolveCurrentTask() await this.resolveCurrentTask()
this.loadFlowRecord()
this.loaded = true this.loaded = true
} catch (error) { } catch (error) {
this.loadError = '隐患详情或附件加载失败,请稍后重试。' this.loadError = '隐患详情或附件加载失败,请稍后重试。'
@ -172,6 +204,26 @@ export default {
visit(data) visit(data)
return tasks return tasks
}, },
loadFlowRecord() {
const procInsId = this.report.flowInstanceId
if (!procInsId) {
this.flowRecordList = []
return
}
this.flowRecordLoading = true
// 仅传流程实例 ID:携带 deployId 时后端会因“未配置流程表单”返回 500。
flowRecord({ procInsId }).then(response => {
const data = response.data || {}
this.flowRecordList = Array.isArray(data.flowList) ? data.flowList : []
}).catch(() => {
this.flowRecordList = []
}).finally(() => {
this.flowRecordLoading = false
})
},
formatTime(value) {
return value ? String(value).replace('T', ' ').slice(0, 19) : '—'
},
handleAttachmentUpload(payload) { handleAttachmentUpload(payload) {
uploadHazardAttachment(payload.file, payload.attachmentType).then(response => { uploadHazardAttachment(payload.file, payload.attachmentType).then(response => {
const data = response.data const data = response.data
@ -241,16 +293,23 @@ export default {
.hazard-audit-page { min-height: calc(100vh - 52px); padding: 16px 20px 40px; background: #f0f2f5; } .hazard-audit-page { min-height: calc(100vh - 52px); padding: 16px 20px 40px; background: #f0f2f5; }
.page-header { margin-bottom: 14px; padding: 14px 18px; border-radius: 8px; background: #fff; } .page-header { margin-bottom: 14px; padding: 14px 18px; border-radius: 8px; background: #fff; }
.route-alert { margin-bottom: 14px; } .route-alert { margin-bottom: 14px; }
.audit-content { display: grid; grid-template-columns: minmax(330px, 1.05fr) minmax(540px, 1.9fr) minmax(280px, .9fr); align-items: start; gap: 14px; min-height: 280px; } .audit-content { min-height: 280px; }
.audit-grid { display: grid; grid-template-columns: minmax(330px, 1.05fr) minmax(540px, 1.9fr) minmax(280px, .9fr); align-items: start; gap: 14px; }
.audit-side { display: flex; flex-direction: column; gap: 14px; }
.card-header { font-weight: 600; }
.flow-node { margin: 0 0 6px; font-weight: 600; color: #303133; }
.flow-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; color: #909399; }
.flow-comment { margin-top: 6px; font-size: 12px; color: #606266; word-break: break-word; }
.flow-record-empty { font-size: 12px; color: #909399; }
::v-deep .audit-card { margin: 0; border: 0; border-radius: 8px; } ::v-deep .audit-card { margin: 0; border: 0; border-radius: 8px; }
::v-deep .audit-card > .el-card__header { padding: 16px; border-bottom-color: #ebeef5; } ::v-deep .audit-card > .el-card__header { padding: 16px; border-bottom-color: #ebeef5; }
::v-deep .audit-card > .el-card__body { padding: 16px; } ::v-deep .audit-card > .el-card__body { padding: 16px; }
@media (max-width: 1450px) { @media (max-width: 1450px) {
.audit-content { grid-template-columns: minmax(300px, 1fr) minmax(500px, 1.6fr); } .audit-grid { grid-template-columns: minmax(300px, 1fr) minmax(500px, 1.6fr); }
.audit-content > :last-child { grid-column: 1 / -1; } .audit-grid > :last-child { grid-column: 1 / -1; }
} }
@media (max-width: 980px) { @media (max-width: 980px) {
.audit-content { grid-template-columns: 1fr; } .audit-grid { grid-template-columns: 1fr; }
.audit-content > :last-child { grid-column: auto; } .audit-grid > :last-child { grid-column: auto; }
} }
</style> </style>

47
src/views/hazard/ledger/index.vue

@ -174,6 +174,24 @@
</div> </div>
<span v-else class="muted">暂无附件</span> <span v-else class="muted">暂无附件</span>
</div> </div>
<div class="flow-section">
<div class="section-title">审核流程</div>
<div v-loading="flowLoading" class="flow-steps">
<el-steps v-if="flowNodes.length" :active="flowActiveIndex" align-center finish-status="success">
<el-step v-for="(node, index) in flowNodes" :key="index">
<template slot="title">{{ node.taskName || '—' }}</template>
<template slot="description">
<div class="step-desc">
<span v-if="node.assigneeName">办理人:{{ node.assigneeName }}</span>
<span v-else-if="node.candidate">待办理</span>
<span>{{ formatTime(node.createTime) }}</span>
</div>
</template>
</el-step>
</el-steps>
<span v-else class="muted">暂无流程信息</span>
</div>
</div>
</template> </template>
<el-empty v-else-if="!detailLoading" description="暂无详情数据" /> <el-empty v-else-if="!detailLoading" description="暂无详情数据" />
</div> </div>
@ -232,24 +250,27 @@
/* global MyConfig */ /* global MyConfig */
import { getMyFactoryDepartment, listFactoryDepartments } from '@/api/system/dept' import { getMyFactoryDepartment, listFactoryDepartments } from '@/api/system/dept'
import { listHazardLedger, getHazardLedgerDetail, listHazardLedgerAttachments, retryHazardSync, getHazardImportAction, downloadHazardImportTemplate } from '@/api/hazard/ledger' import { listHazardLedger, getHazardLedgerDetail, listHazardLedgerAttachments, retryHazardSync, getHazardImportAction, downloadHazardImportTemplate } from '@/api/hazard/ledger'
import { flowRecord } from '@/api/flowable/finished'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
export default { export default {
name: 'HazardLedger', name: 'HazardLedger',
data() { return { loading: false, detailLoading: false, detailVisible: false, ledgerList: [], total: 0, unitOptions: [], currentFactory: null, attachments: [], detail: null, importUpload: { open: false, mode: 'excel', isUploading: false, headers: { Authorization: 'Bearer ' + getToken() }, action: getHazardImportAction('excel') }, queryParams: { pageNum: 1, pageSize: 10, status: undefined, unitId: undefined, hazardName: undefined }, statusOptions: [{ label: '待提交', value: 'draft' }, { label: '审核中', value: 'reviewing' }, { label: '整改中', value: 'rectifying' }, { label: '已通过', value: 'approved' }, { label: '已驳回', value: 'rejected' }], basicFields: [{ label: '单位', key: 'unitName' }, { label: '所属部门', key: 'departmentName', fallback: 'factoryDeptName' }, { label: '上报人', key: 'reporterName' }, { label: '隐患分类', key: 'hazardCategoryName', fallback: 'hazardCategory' }, { label: '隐患类型', key: 'hazardTypeName', fallback: 'hazardType' }, { label: '隐患来源', key: 'sourceTypeName', fallback: 'sourceType' }, { label: '专业', key: 'majorName', fallback: 'major' }, { label: '风险分析单元', key: 'riskUnit' }, { label: '风险分析对象', key: 'riskTarget' }, { label: '发现时间', key: 'discoverTime', time: true }, { label: '创建时间', key: 'createTime', time: true }, { label: '更新人', key: 'updateBy' }], flowFields: [{ label: '治理类型', key: 'governanceTypeName', fallback: 'governanceType' }, { label: '整改负责人', key: 'chargePersonName' }, { label: '限定完成时间', key: 'limitedCompleteTime', time: true }, { label: '实际完成时间', key: 'actualCompleteTime', time: true }, { label: '奖励积分', key: 'pointsAwarded', suffix: ' 分' }, { label: '积分状态', key: 'pointsStatusName', fallback: 'pointsStatus' }, { label: '平台同步', key: 'pushStatusName', fallback: 'pushStatus' }, { label: '同步时间', key: 'pushTime', time: true }, { label: '第三方记录', key: 'thirdPartyId' }, { label: '流程状态', key: 'flowStatus' }, { label: '审核人', key: 'auditUserNameName', fallback: 'auditUserName' }, { label: '审核时间', key: 'auditTime', time: true }], textFields: [{ label: '隐患描述', key: 'description' }, { label: '原因分析', key: 'causeAnalysis' }, { label: '整改方案', key: 'rectificationPlan' }, { label: '防范措施', key: 'preventiveMeasures' }, { label: '审核意见', key: 'auditRemark' }, { label: '备注', key: 'remark' }] } }, data() { return { loading: false, detailLoading: false, detailVisible: false, ledgerList: [], total: 0, unitOptions: [], currentFactory: null, attachments: [], detail: null, flowNodes: [], flowLoading: false, importUpload: { open: false, mode: 'excel', isUploading: false, headers: { Authorization: 'Bearer ' + getToken() }, action: getHazardImportAction('excel') }, queryParams: { pageNum: 1, pageSize: 10, status: undefined, unitId: undefined, hazardName: undefined }, statusOptions: [{ label: '待提交', value: 'draft' }, { label: '审核中', value: 'reviewing' }, { label: '整改中', value: 'rectifying' }, { label: '已通过', value: 'approved' }, { label: '已驳回', value: 'rejected' }], basicFields: [{ label: '单位', key: 'unitName' }, { label: '所属部门', key: 'departmentName', fallback: 'factoryDeptName' }, { label: '上报人', key: 'reporterName' }, { label: '隐患分类', key: 'hazardCategoryName', fallback: 'hazardCategory' }, { label: '隐患类型', key: 'hazardTypeName', fallback: 'hazardType' }, { label: '隐患来源', key: 'sourceTypeName', fallback: 'sourceType' }, { label: '专业', key: 'majorName', fallback: 'major' }, { label: '风险分析单元', key: 'riskUnit' }, { label: '风险分析对象', key: 'riskTarget' }, { label: '发现时间', key: 'discoverTime', time: true }, { label: '创建时间', key: 'createTime', time: true }, { label: '更新人', key: 'updateBy' }], flowFields: [{ label: '治理类型', key: 'governanceTypeName', fallback: 'governanceType' }, { label: '整改负责人', key: 'chargePersonName' }, { label: '限定完成时间', key: 'limitedCompleteTime', time: true }, { label: '实际完成时间', key: 'actualCompleteTime', time: true }, { label: '奖励积分', key: 'pointsAwarded', suffix: ' 分' }, { label: '积分状态', key: 'pointsStatusName', fallback: 'pointsStatus' }, { label: '平台同步', key: 'pushStatusName', fallback: 'pushStatus' }, { label: '同步时间', key: 'pushTime', time: true }, { label: '第三方记录', key: 'thirdPartyId' }, { label: '流程状态', key: 'flowStatus' }, { label: '审核人', key: 'auditUserNameName', fallback: 'auditUserName' }, { label: '审核时间', key: 'auditTime', time: true }], textFields: [{ label: '隐患描述', key: 'description' }, { label: '原因分析', key: 'causeAnalysis' }, { label: '整改方案', key: 'rectificationPlan' }, { label: '防范措施', key: 'preventiveMeasures' }, { label: '审核意见', key: 'auditRemark' }, { label: '备注', key: 'remark' }] } },
computed: { computed: {
isSuperAdmin() { return (this.$store.getters.roles || []).indexOf('admin') !== -1 }, isSuperAdmin() { return (this.$store.getters.roles || []).indexOf('admin') !== -1 },
summary() { return this.ledgerList.reduce((result, row) => { const status = this.statusKey(row); if (status === 'draft') result.draft++; else if (status === 'reviewing') result.reviewing++; else if (status === 'rectifying') result.rectifying++; else if (status === 'approved') result.approved++; else if (status === 'rejected') result.rejected++; return result }, { draft: 0, reviewing: 0, rectifying: 0, approved: 0, rejected: 0 }) }, summary() { return this.ledgerList.reduce((result, row) => { const status = this.statusKey(row); if (status === 'draft') result.draft++; else if (status === 'reviewing') result.reviewing++; else if (status === 'rectifying') result.rectifying++; else if (status === 'approved') result.approved++; else if (status === 'rejected') result.rejected++; return result }, { draft: 0, reviewing: 0, rectifying: 0, approved: 0, rejected: 0 }) },
imageAttachments() { return this.attachments.filter(item => this.isImageAttachment(item)) }, imageAttachments() { return this.attachments.filter(item => this.isImageAttachment(item)) },
otherAttachments() { return this.attachments.filter(item => !this.isImageAttachment(item)) }, otherAttachments() { return this.attachments.filter(item => !this.isImageAttachment(item)) },
previewUrls() { return this.imageAttachments.map(item => this.attachmentUrl(item)).filter(Boolean) } previewUrls() { return this.imageAttachments.map(item => this.attachmentUrl(item)).filter(Boolean) },
flowActiveIndex() { return this.flowNodes.filter(node => node.finishTime).length }
}, },
created() { this.getUnits().finally(() => this.getList()) }, created() { this.getUnits().finally(() => this.getList()) },
methods: { methods: {
getList() { this.loading = true; listHazardLedger(this.queryParams).then(response => { const page = response.data || response; this.ledgerList = page.list || page.rows || []; this.total = Number(page.total || page.totalCount || this.ledgerList.length) }).catch(() => { this.ledgerList = []; this.total = 0; this.$modal.msgError('隐患台账加载失败,请检查后端服务和登录状态') }).finally(() => { this.loading = false }) }, getList() { this.loading = true; listHazardLedger(this.queryParams).then(response => { const page = response.data || response; this.ledgerList = page.list || page.rows || []; this.total = Number(page.total || page.totalCount || this.ledgerList.length) }).catch(() => { this.ledgerList = []; this.total = 0; this.$modal.msgError('隐患台账加载失败,请检查后端服务和登录状态') }).finally(() => { this.loading = false }) },
getUnits() { const request = this.isSuperAdmin ? listFactoryDepartments() : getMyFactoryDepartment(); return request.then(response => { const data = response.data || response; if (this.isSuperAdmin) { this.unitOptions = Array.isArray(data) ? data : (data && (data.list || data.rows)) || []; return } this.currentFactory = data || null; if (this.currentFactory) { this.queryParams.unitId = this.factoryId(this.currentFactory) } }).catch(() => { this.unitOptions = []; this.currentFactory = null }) }, factoryId(item) { const value = item && (item.deptId !== undefined ? item.deptId : item.id); return value === undefined || value === null ? '' : String(value) }, factoryName(item) { return (item && (item.deptName || item.label || item.name)) || '' }, getUnits() { const request = this.isSuperAdmin ? listFactoryDepartments() : getMyFactoryDepartment(); return request.then(response => { const data = response.data || response; if (this.isSuperAdmin) { this.unitOptions = Array.isArray(data) ? data : (data && (data.list || data.rows)) || []; return } this.currentFactory = data || null; if (this.currentFactory) { this.queryParams.unitId = this.factoryId(this.currentFactory) } }).catch(() => { this.unitOptions = []; this.currentFactory = null }) }, factoryId(item) { const value = item && (item.deptId !== undefined ? item.deptId : item.id); return value === undefined || value === null ? '' : String(value) }, factoryName(item) { return (item && (item.deptName || item.label || item.name)) || '' },
handleQuery() { this.queryParams.pageNum = 1; this.getList() }, resetQuery() { this.$refs.queryForm.resetFields(); this.queryParams.pageNum = 1; this.getList() }, handleQuery() { this.queryParams.pageNum = 1; this.getList() }, resetQuery() { this.$refs.queryForm.resetFields(); this.queryParams.pageNum = 1; this.getList() },
openDetail(row) { this.detailVisible = true; this.detail = null; this.attachments = []; this.detailLoading = true; Promise.all([getHazardLedgerDetail(row.id), listHazardLedgerAttachments(row.id)]).then(results => { this.detail = results[0].data || results[0]; const data = results[1].data || results[1]; this.attachments = Array.isArray(data) ? data : [] }).catch(() => { this.$modal.msgError('隐患详情加载失败') }).finally(() => { this.detailLoading = false }) }, openDetail(row) { this.detailVisible = true; this.detail = null; this.attachments = []; this.flowNodes = []; this.detailLoading = true; this.loadFlowNodes(row.flowInstanceId); Promise.all([getHazardLedgerDetail(row.id), listHazardLedgerAttachments(row.id)]).then(results => { this.detail = results[0].data || results[0]; const data = results[1].data || results[1]; this.attachments = Array.isArray(data) ? data : [] }).catch(() => { this.$modal.msgError('隐患详情加载失败') }).finally(() => { this.detailLoading = false }) },
loadFlowNodes(procInsId) { if (!procInsId) { this.flowNodes = []; return } this.flowLoading = true; flowRecord({ procInsId: String(procInsId) }).then(response => { const data = response.data || {}; this.flowNodes = Array.isArray(data.flowList) ? data.flowList : [] }).catch(() => { this.flowNodes = [] }).finally(() => { this.flowLoading = false }) },
goAudit(row) { const query = { id: String(row.id) }; if (row.canApprove === true || String(row.canApprove) === 'true') query.canApprove = '1'; if (row.flowInstanceId) query.flowInstanceId = String(row.flowInstanceId); this.detailVisible = false; this.$router.push({ path: '/hazard/audit/detail', query }) }, goAudit(row) { const query = { id: String(row.id) }; if (row.canApprove === true || String(row.canApprove) === 'true') query.canApprove = '1'; if (row.flowInstanceId) query.flowInstanceId = String(row.flowInstanceId); this.detailVisible = false; this.$router.push({ path: '/hazard/audit/detail', query }) },
handleRetrySync(row) { this.$confirm('确认重试将该隐患同步到生产运营平台吗?', '重试同步', { type: 'warning' }).then(() => retryHazardSync(row.id)).then(() => { this.$modal.msgSuccess('同步重试成功'); this.getList() }).catch(error => { if (error !== 'cancel') this.$modal.msgError(error.message || '同步重试失败') }) }, handleRetrySync(row) { this.$confirm('确认重试将该隐患同步到生产运营平台吗?', '重试同步', { type: 'warning' }).then(() => retryHazardSync(row.id)).then(() => { this.$modal.msgSuccess('同步重试成功'); this.getList() }).catch(error => { if (error !== 'cancel') this.$modal.msgError(error.message || '同步重试失败') }) },
handleImport() { this.importUpload.mode = 'excel'; this.importUpload.action = getHazardImportAction('excel'); this.importUpload.isUploading = false; this.importUpload.open = true }, handleImport() { this.importUpload.mode = 'excel'; this.importUpload.action = getHazardImportAction('excel'); this.importUpload.isUploading = false; this.importUpload.open = true },
@ -381,10 +402,28 @@ export default {
.detail-section, .detail-section,
.text-section, .text-section,
.attachment-section { .attachment-section,
.flow-section {
margin-top: 16px; margin-top: 16px;
} }
.flow-steps {
min-height: 44px;
padding: 6px 4px;
border: 1px solid #ebeef5;
border-radius: 6px;
background: #fbfbfd;
}
.flow-steps .step-desc {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 12px;
color: #909399;
line-height: 1.5;
}
.section-title { .section-title {
margin-bottom: 8px; margin-bottom: 8px;
color: #5a5a72; color: #5a5a72;

Loading…
Cancel
Save