Browse Source

添加按照厂区筛选档位的列表功能

master
DU 1 week ago
parent
commit
3a32240b1b
  1. 6
      src/api/points/rule.js
  2. 16
      src/views/hazard/audit/components/AuditActionForm.vue

6
src/api/points/rule.js

@ -20,9 +20,9 @@ export function getPointsRule(id) { @@ -20,9 +20,9 @@ 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 } })
// 根据隐患等级编码(general/major/critical)查询该等级下的根规则与子档位列表;可传 deptId 指定厂区
export function getRulesByLevel(params) {
return request({ url: '/business/points/rule/rulesByLevel', method: 'get', params })
}
// 积分试算:按厂区 + 隐患等级编码 + 档位模拟计算积分,返回 calculatedPoints

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

@ -414,10 +414,13 @@ export default { @@ -414,10 +414,13 @@ export default {
if (!level) {
console.warn('[积分档位] level 为空,跳过查询,tierOptions 清空')
this.tierOptions = []
this.applyTierFallback()
return
}
this.tierLoading = true
getRulesByLevel(level).then(res => {
const params = { hazardLevel: level }
if (this.report.factoryDeptId) params.deptId = this.report.factoryDeptId
getRulesByLevel(params).then(res => {
console.log('[积分档位] getRulesByLevel 原始返回 =', JSON.stringify(res))
const data = (res && res.data) || res || {}
console.log('[积分档位] 解析后的 data =', JSON.stringify(data))
@ -429,15 +432,26 @@ export default { @@ -429,15 +432,26 @@ export default {
label: String(item.hazardCategory || item.ruleName || '').toUpperCase()
}))
console.log('[积分档位] 最终 tierOptions =', JSON.stringify(this.tierOptions))
this.applyTierFallback()
// 档位列表到达后补一次试算,兼容只有 finalFlowLevelId、没有档位文本的历史数据。
this.loadEstimatedPoints()
}).catch((err) => {
console.error('[积分档位] getRulesByLevel 请求失败 =', err)
this.tierOptions = []
this.applyTierFallback()
}).finally(() => {
this.tierLoading = false
})
},
applyTierFallback() {
// 后端按厂区查不到档位列表时,用详情已存的档位兜底,避免下拉显示裸规则ID
if (this.tierOptions.length) return
if (!this.form.finalFlowLevelId) return
this.tierOptions = [{
id: this.form.finalFlowLevelId,
label: String(this.form.finalFlowLevel || this.form.finalFlowLevelId)
}]
},
handleTierChange(value) {
const item = this.tierOptions.find(option => String(option.id) === String(value))
this.$set(this.form, 'finalFlowLevel', item ? item.label : '')

Loading…
Cancel
Save