Browse Source

调整和修改部分代码

master
DU 2 weeks ago
parent
commit
116de4a789
  1. 10
      src/api/points/rule.js
  2. 2
      src/utils/request.js
  3. 120
      src/views/hazard/audit/components/AuditActionForm.vue
  4. 26
      src/views/hazard/audit/components/FlowSyncPanel.vue
  5. 8
      src/views/hazard/audit/index.vue

10
src/api/points/rule.js

@ -28,6 +28,16 @@ export function getPointsRule(id) { @@ -28,6 +28,16 @@ export function getPointsRule(id) {
return request({ url: '/business/points/rule/info', method: 'get', params: { id }})
}
// 根据隐患等级编码(general/major/critical)查询该等级下的根规则与子档位列表
export function getRulesByLevel(hazardLevel) {
return request({ url: '/business/points/rule/rulesByLevel', method: 'get', params: { hazardLevel } })
}
// 积分试算:按厂区 + 隐患等级编码 + 档位模拟计算积分,返回 calculatedPoints
export function trialCalculatePoints(params) {
return request({ url: '/business/points/rule/trialCalculate', method: 'get', params })
}
export function addPointsRule(data) {
return request({ url: '/business/points/rule/add', method: 'post', data })
}

2
src/utils/request.js

@ -17,7 +17,7 @@ const service = axios.create({ @@ -17,7 +17,7 @@ const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL: MyConfig.BASE_API,
// 超时
timeout: 10000
timeout: 80000
})
// request拦截器

120
src/views/hazard/audit/components/AuditActionForm.vue

@ -54,6 +54,17 @@ @@ -54,6 +54,17 @@
<dict-select v-model="form.hazardCategory" :options="dict.type.hazard_category" placeholder="请选择隐患分类" @change="syncDictName('hazardCategory', 'hazardCategoryName', 'hazard_category')" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="积分档位">
<el-select v-model="form.finalFlowLevelId" placeholder="请选择积分档位" style="width:100%" :loading="tierLoading" @change="handleTierChange">
<el-option v-for="item in tierOptions" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
<div v-if="estimatedPoints !== null" class="tier-points-tip">
预计积分:<strong>{{ estimatedPoints > 0 ? '+' : '' }}{{ estimatedPoints }}</strong>
<span v-if="pointsLoading" class="tier-points-loading">计算中…</span>
</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="隐患名称" prop="hazardName">
<el-input v-model.trim="form.hazardName" placeholder="请输入隐患名称" maxlength="200" show-word-limit />
@ -177,7 +188,7 @@ @@ -177,7 +188,7 @@
<el-dialog title="通过审核" :visible.sync="passVisible" width="460px" append-to-body>
<div class="confirm-content">
<i class="el-icon-warning-outline" />
<p>确认先保存平台补录信息,再通过当前审批任务?积分、员工通知和平台同步均以后端处理结果为准。</p>
<p>确认先保存平台补录信息,再通过当前审批任务?积分、员工通知和平台同步均以后端处理结果为准。<span v-if="estimatedPoints !== null">本次档位预计积分:<strong>{{ estimatedPoints > 0 ? '+' : '' }}{{ estimatedPoints }}</strong>。</span></p>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="passVisible = false">取消</el-button>
@ -228,6 +239,7 @@ @@ -228,6 +239,7 @@
<script>
/* global MyConfig */
import SelectTree from '@/components/SelectTree'
import { getRulesByLevel, trialCalculatePoints } from '@/api/points/rule'
const DictSelect = {
functional: true,
@ -263,6 +275,7 @@ export default { @@ -263,6 +275,7 @@ export default {
dicts: ['tree_dept', 'tree_person', 'hazard_major', 'hazard_category', 'hazard_management_level', 'hazard_source', 'hazard_type', 'hazard_governance_type', 'hazard_funds_source'],
props: {
report: { type: Object, required: true },
reportId: { type: String, default: '' },
attachments: { type: Array, default: () => [] },
taskId: { type: String, default: '' },
submitting: Boolean
@ -270,6 +283,10 @@ export default { @@ -270,6 +283,10 @@ export default {
data() {
return {
form: {},
tierOptions: [],
tierLoading: false,
estimatedPoints: null,
pointsLoading: false,
auditComment: '',
uploadedAttachments: [],
uploading: false,
@ -320,15 +337,29 @@ export default { @@ -320,15 +337,29 @@ export default {
return this.uploadedImageAttachments.map(item => this.attachmentUrl(item)).filter(Boolean)
},
pointsSuffix() {
if (this.report.pointsAwarded === undefined || this.report.pointsAwarded === null || this.report.pointsAwarded === '') return ''
const points = Number(this.report.pointsAwarded)
return ` · ${points > 0 ? '+' : ''}${this.report.pointsAwarded} 积分`
// 审核阶段按当前档位实时试算,优先展示预计积分;无档位时回退到后端已发放积分。
const value = this.estimatedPoints !== null ? this.estimatedPoints : this.report.pointsAwarded
if (value === undefined || value === null || value === '') return ''
const points = Number(value)
if (!points) return ''
return ` · ${points > 0 ? '+' : ''}${value} 积分`
},
normalizedCurrentLevel() {
const value = this.report.currentFlowLevel || this.report.hazardCategory || ''
const nameMap = { 一般: 'general', 一般隐患: 'general', 较大: 'major', 较大隐患: 'major', 重大: 'critical', 重大隐患: 'critical' }
return nameMap[value] || value
},
tierFilterLevel() {
return this.report.hazardCategory || this.report.currentFlowLevel || ''
},
pointsQueryKey() {
return [
this.report.factoryDeptId || '',
this.normalizedCurrentLevel || '',
this.form.finalFlowLevelId || '',
this.form.finalFlowLevel || ''
].join('|')
},
currentLevelName() {
const item = this.levelOptions.find(option => option.value === this.normalizedCurrentLevel)
return (item && item.label) || this.normalizedCurrentLevel || '—'
@ -343,6 +374,22 @@ export default { @@ -343,6 +374,22 @@ export default {
this.auditComment = this.form.auditRemark || ''
this.uploadedAttachments = []
}
},
tierFilterLevel: {
immediate: true,
handler(level) {
this.loadTierOptions(level)
}
},
pointsQueryKey: {
immediate: true,
handler() {
this.loadEstimatedPoints()
}
},
estimatedPoints(value) {
// 试算结果供父级同步给「流转与同步」面板。
this.$emit('estimated-points', value)
}
},
methods: {
@ -362,6 +409,66 @@ export default { @@ -362,6 +409,66 @@ export default {
const item = (this.dict.type[dictType] || []).find(option => String(option.value) === String(this.form[valueField]))
this.$set(this.form, nameField, item ? item.label : '')
},
loadTierOptions(level) {
console.log('[积分档位] loadTierOptions 入参 level =', level, '| report.hazardCategory =', this.report.hazardCategory, '| report.currentFlowLevel =', this.report.currentFlowLevel, '| report.hazardCategoryName =', this.report.hazardCategoryName)
if (!level) {
console.warn('[积分档位] level 为空,跳过查询,tierOptions 清空')
this.tierOptions = []
return
}
this.tierLoading = true
getRulesByLevel(level).then(res => {
console.log('[积分档位] getRulesByLevel 原始返回 =', JSON.stringify(res))
const data = (res && res.data) || res || {}
console.log('[积分档位] 解析后的 data =', JSON.stringify(data))
const children = Array.isArray(data.children) ? data.children : []
const nodes = children.length ? children : (data.root ? [data.root] : [])
console.log('[积分档位] children =', JSON.stringify(children), '| nodes =', JSON.stringify(nodes))
this.tierOptions = nodes.map(item => ({
id: item.id,
label: String(item.hazardCategory || item.ruleName || '').toUpperCase()
}))
console.log('[积分档位] 最终 tierOptions =', JSON.stringify(this.tierOptions))
// 档位列表到达后补一次试算,兼容只有 finalFlowLevelId、没有档位文本的历史数据。
this.loadEstimatedPoints()
}).catch((err) => {
console.error('[积分档位] getRulesByLevel 请求失败 =', err)
this.tierOptions = []
}).finally(() => {
this.tierLoading = false
})
},
handleTierChange(value) {
const item = this.tierOptions.find(option => String(option.id) === String(value))
this.$set(this.form, 'finalFlowLevel', item ? item.label : '')
},
resolveTierCategory() {
const direct = String(this.form.finalFlowLevel || '').trim()
if (direct) return direct.toUpperCase()
const matched = this.tierOptions.find(item => String(item.id) === String(this.form.finalFlowLevelId))
return matched ? String(matched.label || '').toUpperCase() : ''
},
loadEstimatedPoints() {
const hazardLevel = this.normalizedCurrentLevel
const hazardCategory = this.resolveTierCategory()
if (!hazardLevel || !hazardCategory) {
this.estimatedPoints = null
return
}
this.pointsLoading = true
const params = { hazardLevel, hazardCategory }
if (this.report.factoryDeptId) params.deptId = this.report.factoryDeptId
trialCalculatePoints(params).then(res => {
const data = (res && res.data) || res || {}
this.estimatedPoints = data.calculatedPoints === undefined || data.calculatedPoints === null
? null
: Number(data.calculatedPoints)
}).catch(() => {
this.estimatedPoints = null
}).finally(() => {
this.pointsLoading = false
})
},
beforeUpload(file) {
if (this.attachmentCount >= 8) {
this.$modal.msgError('附件数量不能超过 8 个')
@ -432,6 +539,7 @@ export default { @@ -432,6 +539,7 @@ export default {
completeData: {
taskId: this.taskId,
instanceId: this.report.flowInstanceId,
zyxkid: String(this.reportId || this.report.id || ''),
comment: this.auditComment || '同意',
result: '1'
}
@ -447,6 +555,7 @@ export default { @@ -447,6 +555,7 @@ export default {
completeData: {
taskId: this.taskId,
instanceId: this.report.flowInstanceId,
zyxkid: String(this.reportId || this.report.id || ''),
comment,
result: '2'
}
@ -481,6 +590,9 @@ export default { @@ -481,6 +590,9 @@ export default {
.uploaded-remove { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: #c0c4cc; font-size: 13px; cursor: pointer; z-index: 1; }
.uploaded-remove:hover { color: #f56c6c; }
.security-tip, .disabled-tip { margin-top: 6px; color: #f56c6c; font-size: 11px; line-height: 1.6; }
.tier-points-tip { margin-top: 4px; color: #606266; font-size: 12px; line-height: 18px; }
.tier-points-tip strong { color: #f56c6c; font-weight: 600; }
.tier-points-loading { margin-left: 6px; color: #909399; }
.action-buttons { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 8px; }
.reject-options { display: flex; flex-direction: column; gap: 12px; }
.confirm-content { display: flex; gap: 12px; color: #606266; line-height: 1.7; }

26
src/views/hazard/audit/components/FlowSyncPanel.vue

@ -14,10 +14,10 @@ @@ -14,10 +14,10 @@
<span>流程状态</span>
<el-tag size="mini" :type="flowTagType">{{ flowStatusText }}</el-tag>
</div>
<div class="flow-row">
<!-- <div class="flow-row">
<span>平台同步状态</span>
<el-tag size="mini" :type="pushTagType">{{ report.pushStatusName || report.pushStatus || '待同步' }}</el-tag>
</div>
</div> -->
<div v-if="report.pushTime" class="flow-row">
<span>同步时间</span>
<strong>{{ formatTime(report.pushTime) }}</strong>
@ -26,12 +26,12 @@ @@ -26,12 +26,12 @@
<span>同步结果</span>
<strong>{{ report.pushResponse }}</strong>
</div>
<div class="flow-row">
<!-- <div class="flow-row">
<span>相似隐患提示</span>
<el-tag size="mini" type="info">暂无接口数据</el-tag>
</div>
</div> -->
<div class="flow-row">
<span>预计/已发积分</span>
<span>{{ pointsLabel }}</span>
<strong class="points">{{ pointsText }}</strong>
</div>
<div v-if="report.pointsStatusName || report.pointsStatus" class="flow-row">
@ -55,6 +55,11 @@ export default { @@ -55,6 +55,11 @@ export default {
report: {
type: Object,
default: () => ({})
},
// 审核页按当前档位试算的预计积分,未选档位时为 null。
estimatedPoints: {
type: Number,
default: null
}
},
computed: {
@ -71,7 +76,18 @@ export default { @@ -71,7 +76,18 @@ export default {
if (/失败/i.test(text)) return 'danger'
return 'warning'
},
pointsLabel() {
return this.hasEstimatedPoints ? '预计积分' : '已发积分'
},
hasEstimatedPoints() {
return this.estimatedPoints !== null && this.estimatedPoints !== undefined
},
pointsText() {
// 审核阶段优先展示按当前档位试算的预计积分,未选档位时回退到后端已发放积分。
if (this.hasEstimatedPoints) {
const points = Number(this.estimatedPoints)
return `${points > 0 ? '+' : ''}${this.estimatedPoints}`
}
if (this.report.pointsAwarded === undefined || this.report.pointsAwarded === null || this.report.pointsAwarded === '') return '以后端规则结果为准'
const points = Number(this.report.pointsAwarded)
return `${points > 0 ? '+' : ''}${this.report.pointsAwarded}`

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

@ -36,14 +36,16 @@ @@ -36,14 +36,16 @@
<hazard-report-panel :report="report" :attachments="attachments" />
<audit-action-form
:report="report"
:report-id="reportId"
:attachments="attachments"
:task-id="taskId"
:submitting="submitting"
@upload="handleAttachmentUpload"
@submit="handleAuditSubmit"
@switch-level="handleSwitchLevel"
@estimated-points="estimatedPoints = $event"
/>
<flow-sync-panel :report="report" />
<flow-sync-panel :report="report" :estimated-points="estimatedPoints" />
</template>
</div>
</div>
@ -74,7 +76,8 @@ export default { @@ -74,7 +76,8 @@ export default {
loadError: '',
report: {},
taskId: '',
attachments: []
attachments: [],
estimatedPoints: null
}
},
computed: {
@ -107,6 +110,7 @@ export default { @@ -107,6 +110,7 @@ export default {
this.report = {}
this.taskId = ''
this.attachments = []
this.estimatedPoints = null
},
async loadPage() {
this.loading = true

Loading…
Cancel
Save