Commit d7563cea by chenwq

refactor(teamWork): 优化团队列表列值的样式统一处理逻辑

- 为日报、月报状态映射新增fontSize配置项
- 重构getColValueColor方法为getColValueStyle,支持返回完整样式对象
- 更新模板绑定以使用新的样式计算方法
- 补充样式注释说明默认样式会被动态覆盖
1 parent ceae4250
...@@ -34,15 +34,15 @@ export const COMPLETION_STATUS_MAP = { ...@@ -34,15 +34,15 @@ export const COMPLETION_STATUS_MAP = {
// 日报状态映射 // 日报状态映射
export const DAILY_STATUS_MAP = { export const DAILY_STATUS_MAP = {
0: { text: '未提交', color: '#F24724' }, 0: { text: '未提交', color: '#F24724', fontSize: '14px' },
1: { text: '在岗', color: '#35C376' }, 1: { text: '在岗', color: '#35C376', fontSize: '14px' },
2: { text: '调休', color: '#FF9D0A' } 2: { text: '调休', color: '#FF9D0A', fontSize: '14px' }
} }
// 月报状态映射 // 月报状态映射
export const MONTH_STATUS_MAP = { export const MONTH_STATUS_MAP = {
0: { text: '未提交', color: '#F24724' }, 0: { text: '未提交', color: '#F24724', fontSize: '14px' },
1: { text: '已提交', color: '#35C376' } 1: { text: '已提交', color: '#35C376', fontSize: '14px' }
} }
// 任务状态映射 (兼容其他可能用到的状态) // 任务状态映射 (兼容其他可能用到的状态)
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<div class="item-grid" :class="'cols-' + getGridCols()"> <div class="item-grid" :class="'cols-' + getGridCols()">
<div class="grid-col" v-for="(col, cIndex) in getGridConfig()" :key="cIndex"> <div class="grid-col" v-for="(col, cIndex) in getGridConfig()" :key="cIndex">
<div class="col-label">{{ col.label }}</div> <div class="col-label">{{ col.label }}</div>
<div class="col-value" :style="{ color: getColValueColor(item, col) }">{{ getColValue(item, col) }}</div> <div class="col-value" :style="getColValueStyle(item, col)">{{ getColValue(item, col) }}</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -153,20 +153,25 @@ export default { ...@@ -153,20 +153,25 @@ export default {
const map = this[`${col.type}Map`] const map = this[`${col.type}Map`]
return map?.[val]?.text ?? val return map?.[val]?.text ?? val
}, },
// 根据字段类型和值,动态计算其展示颜色,实现进度预警 // 动态获取列表项对应字段的显示样式
getColValueColor(item, col) { getColValueStyle(item, col) {
const val = item[col.key] const val = item[col.key]
if (val == null) return '#333333' if (val == null) return { color: '#000000E5' }
// 从字典中获取配置好的颜色
const map = this[`${col.type}Map`] const map = this[`${col.type}Map`]
if (map) return map[val]?.color || '#333333' if (map && map[val]) {
return {
color: map[val].color || '#000000E5',
fontSize: map[val].fontSize || '20px',
fontWeight: map[val].fontSize ? '600' : '500'
}
}
// 针对进度类(如 3/20)和比率类(如 30%)进行动态计算 let color = '#000000E5'
if (col.type === 'progress') return this.getProgressColor(val) if (col.type === 'progress') color = this.getProgressColor(val)
if (col.type === 'rate') return this.getRateColor(val) else if (col.type === 'rate') color = this.getRateColor(val)
return '#333333' return { color, fontSize: '20px', fontWeight: '500' }
}, },
// 进度预警:如果完成数小于总数,则标红;否则默认黑色(专项督办模式下达标显示绿色) // 进度预警:如果完成数小于总数,则标红;否则默认黑色(专项督办模式下达标显示绿色)
getProgressColor(val, isSpecial = false) { getProgressColor(val, isSpecial = false) {
...@@ -450,6 +455,7 @@ export default { ...@@ -450,6 +455,7 @@ export default {
white-space: nowrap; white-space: nowrap;
} }
.col-value { .col-value {
/* 默认的 fontSize 和 fontWeight 会被 getColValueStyle 动态覆盖 */
color: #000000e5; color: #000000e5;
font-size: 20px; font-size: 20px;
font-family: 'numberNor'; font-family: 'numberNor';
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!