From c29ba04e3c73d5791fdaa494d04c475ce6831e3d Mon Sep 17 00:00:00 2001 From: DU Date: Fri, 30 Oct 2026 20:44:37 +0800 Subject: [PATCH] =?UTF-8?q?Web=20=E5=B7=A5=E4=BD=9C=E5=8F=B0=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E4=B8=8A=E6=8A=A5=E6=8C=89=20canApprove=20=E6=94=B6?= =?UTF-8?q?=E6=95=9B=E5=AE=A1=E6=A0=B8=E5=85=A5=E5=8F=A3=EF=BC=8C=E8=A1=A5?= =?UTF-8?q?=E9=BD=90=E9=97=AE=E9=A2=9813?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/workbench/index.vue | 40 ++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/views/workbench/index.vue b/src/views/workbench/index.vue index 32c1d6b..ea63bac 100644 --- a/src/views/workbench/index.vue +++ b/src/views/workbench/index.vue @@ -76,7 +76,7 @@ @@ -90,6 +90,7 @@ import * as echarts from 'echarts' import resize from '@/views/dashboard/mixins/resize' import { getHomeOverview, getHomeTodoWarning, getHomeTrendLatest } from '@/api/analysis/home' +import { listHazardLedger } from '@/api/hazard/ledger' export default { name: 'Workbench', @@ -101,7 +102,9 @@ export default { overview: {}, warning: {}, trendList: [], - latestReports: [] + latestReports: [], + // 最新上报接口不含 canApprove;用隐患待办列表补齐 id→canApprove。null 表示未就绪/加载失败,此时退回「仅按状态」判断 + approveMap: null } }, computed: { @@ -150,6 +153,7 @@ export default { const trend = (trendRes && trendRes.data) || {} this.trendList = Array.isArray(trend.trend7d) ? trend.trend7d : [] this.latestReports = Array.isArray(trend.latestReports) ? trend.latestReports : [] + this.loadApproveMap() this.$nextTick(this.renderChart) }) .catch(() => { @@ -157,12 +161,35 @@ export default { this.warning = {} this.trendList = [] this.latestReports = [] + this.approveMap = null this.$modal.msgError('工作台数据加载失败,请检查后端服务和登录状态') }) .finally(() => { this.loading = false }) }, + // 最新上报接口未返回 canApprove,改用隐患待办列表(与台账同一数据源,按创建时间倒序)建立 id→canApprove 映射,用于收敛「审核」入口 + loadApproveMap() { + return listHazardLedger({ pageNum: 1, pageSize: 30 }) + .then(response => { + const page = response.data || response + const rows = page.list || page.rows || page.records || [] + if (!rows.length) { + this.approveMap = null + return + } + const map = {} + rows.forEach(item => { + if (item && item.id !== undefined && item.id !== null) { + map[String(item.id)] = item.canApprove === true || String(item.canApprove) === 'true' + } + }) + this.approveMap = map + }) + .catch(() => { + this.approveMap = null + }) + }, renderChart() { const el = this.$refs.trendChart if (!el) return @@ -209,10 +236,17 @@ export default { if (row.route) this.$router.push(row.route) }, isReviewing(row) { - // 最新上报数据未含 canApprove,这里按状态收敛:仅“审核中”才显示审核入口。 + // 仅「审核中」状态 const value = String(row.status || '').toLowerCase() return value === 'reviewing' || value === '1' || /审核中|待审核/.test(row.statusName || '') }, + // 最新上报需要「审核中 且 当前用户可审批」才显示审核入口;canApprove 由 approveMap 补齐 + canAudit(row) { + if (!this.isReviewing(row)) return false + if (!this.approveMap) return true + const key = row.id === undefined || row.id === null ? '' : String(row.id) + return this.approveMap[key] === true + }, goAudit(row) { if (row.id === undefined || row.id === null) { this.$modal.msgWarning('该记录缺少主键,无法进入审核')