fix(分数显示): 修复分数显示逻辑,支持0分显示并处理空值情况
修改多个组件中分数显示的条件判断,避免0分被隐藏 在首页视图添加总分显示的空值处理逻辑 更新分数映射处理逻辑,保留0分并清除不存在的分数映射
Showing
4 changed files
with
31 additions
and
9 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-30 11:34:19 | 2 | * @Date: 2022-08-30 11:34:19 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-11-24 17:53:08 | 4 | + * @LastEditTime: 2025-11-25 16:14:32 |
| 5 | * @FilePath: /data-table/src/components/CheckboxField/index.vue | 5 | * @FilePath: /data-table/src/components/CheckboxField/index.vue |
| 6 | * @Description: 多项选择控件 | 6 | * @Description: 多项选择控件 |
| 7 | --> | 7 | --> |
| ... | @@ -14,7 +14,11 @@ | ... | @@ -14,7 +14,11 @@ |
| 14 | <span v-if="item.component_props.max" style="color: gray"> | 14 | <span v-if="item.component_props.max" style="color: gray"> |
| 15 | (最多可选数: {{ item.component_props.max }}) | 15 | (最多可选数: {{ item.component_props.max }}) |
| 16 | </span> | 16 | </span> |
| 17 | - <span v-if="item.component_props.x_score" style="margin-left: 0.5rem; color: red;">( {{ item.component_props.x_score }} 分 )</span> | 17 | + <!-- TAG:显示分数时保留0分,仅在有值(非空字符串/非空/非undefined)时展示 --> |
| 18 | + <span | ||
| 19 | + v-if="item.component_props.x_score !== undefined && item.component_props.x_score !== null && item.component_props.x_score !== ''" | ||
| 20 | + style="margin-left: 0.5rem; color: red;" | ||
| 21 | + >( {{ item.component_props.x_score }} 分 )</span> | ||
| 18 | </div> | 22 | </div> |
| 19 | <div v-if="item.component_props.note" class="note" v-html="item.component_props.note" /> | 23 | <div v-if="item.component_props.note" class="note" v-html="item.component_props.note" /> |
| 20 | <van-field v-if="!item.component_props.readonly" :rules="item.rules" :border="false"> | 24 | <van-field v-if="!item.component_props.readonly" :rules="item.rules" :border="false"> | ... | ... |
| ... | @@ -11,7 +11,11 @@ | ... | @@ -11,7 +11,11 @@ |
| 11 | <span v-if="item.component_props.disabled_show"><van-icon name="https://cdn.ipadbiz.cn/custom_form/icon/closed-eye1.png" /></span> | 11 | <span v-if="item.component_props.disabled_show"><van-icon name="https://cdn.ipadbiz.cn/custom_form/icon/closed-eye1.png" /></span> |
| 12 | <span v-if="item.component_props.required" style="color: red"> *</span> | 12 | <span v-if="item.component_props.required" style="color: red"> *</span> |
| 13 | <span :class="[ReadonlyShow ? 'readonly-show' : '']">{{ item.component_props.label }}</span> | 13 | <span :class="[ReadonlyShow ? 'readonly-show' : '']">{{ item.component_props.label }}</span> |
| 14 | - <span v-if="item.component_props.x_score" style="margin-left: 0.5rem; color: red;">( {{ item.component_props.x_score }} 分 )</span> | 14 | + <!-- TAG:显示分数时保留0分,仅在有值(非空字符串/非空/非undefined)时展示 --> |
| 15 | + <span | ||
| 16 | + v-if="item.component_props.x_score !== undefined && item.component_props.x_score !== null && item.component_props.x_score !== ''" | ||
| 17 | + style="margin-left: 0.5rem; color: red;" | ||
| 18 | + >( {{ item.component_props.x_score }} 分 )</span> | ||
| 15 | </div> | 19 | </div> |
| 16 | <van-field :name="item.name" :rules="item.rules" style="padding: 0;"> | 20 | <van-field :name="item.name" :rules="item.rules" style="padding: 0;"> |
| 17 | <template #input> | 21 | <template #input> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-30 11:34:19 | 2 | * @Date: 2022-08-30 11:34:19 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-11-24 17:54:22 | 4 | + * @LastEditTime: 2025-11-25 16:16:39 |
| 5 | * @FilePath: /data-table/src/components/RadioField/index.vue | 5 | * @FilePath: /data-table/src/components/RadioField/index.vue |
| 6 | * @Description: 单项选择控件 | 6 | * @Description: 单项选择控件 |
| 7 | --> | 7 | --> |
| ... | @@ -11,7 +11,11 @@ | ... | @@ -11,7 +11,11 @@ |
| 11 | <span v-if="item.component_props.disabled_show"><van-icon name="https://cdn.ipadbiz.cn/custom_form/icon/closed-eye1.png" /></span> | 11 | <span v-if="item.component_props.disabled_show"><van-icon name="https://cdn.ipadbiz.cn/custom_form/icon/closed-eye1.png" /></span> |
| 12 | <span v-if="item.component_props.required" style="color: red"> *</span> | 12 | <span v-if="item.component_props.required" style="color: red"> *</span> |
| 13 | <span :class="[ReadonlyShow ? 'readonly-show' : '']">{{ item.component_props.label }}</span> | 13 | <span :class="[ReadonlyShow ? 'readonly-show' : '']">{{ item.component_props.label }}</span> |
| 14 | - <span v-if="item.component_props.x_score" style="margin-left: 0.5rem; color: red;">( {{ item.component_props.x_score }} 分 )</span> | 14 | + <!-- TAG:显示分数时保留0分,仅在有值(非空字符串/非空/非undefined)时展示 --> |
| 15 | + <span | ||
| 16 | + v-if="item.component_props.x_score !== undefined && item.component_props.x_score !== null && item.component_props.x_score !== ''" | ||
| 17 | + style="margin-left: 0.5rem; color: red;" | ||
| 18 | + >( {{ item.component_props.x_score }} 分 )</span> | ||
| 15 | </div> | 19 | </div> |
| 16 | <div v-if="item.component_props.note" class="note" v-html="item.component_props.note" /> | 20 | <div v-if="item.component_props.note" class="note" v-html="item.component_props.note" /> |
| 17 | <van-field v-if="!item.component_props.readonly" :rules="item.rules"> | 21 | <van-field v-if="!item.component_props.readonly" :rules="item.rules"> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-07-18 10:22:22 | 2 | * @Date: 2022-07-18 10:22:22 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-11-24 17:52:07 | 4 | + * @LastEditTime: 2025-11-25 16:20:30 |
| 5 | * @FilePath: /data-table/src/views/index.vue | 5 | * @FilePath: /data-table/src/views/index.vue |
| 6 | * @Description: 首页 | 6 | * @Description: 首页 |
| 7 | --> | 7 | --> |
| ... | @@ -20,7 +20,11 @@ | ... | @@ -20,7 +20,11 @@ |
| 20 | <div v-if="PHeader.type === 'text'" class="PHeader-Text" v-html="PHeader.banner" /> | 20 | <div v-if="PHeader.type === 'text'" class="PHeader-Text" v-html="PHeader.banner" /> |
| 21 | </template> | 21 | </template> |
| 22 | <div v-if="PHeader.label" class="table-title" v-html="PHeader.label" /> | 22 | <div v-if="PHeader.label" class="table-title" v-html="PHeader.label" /> |
| 23 | - <div v-if="PHeader.x_total_score" style="font-weight: bold; color: red; text-align: center; font-size: 0.9rem;">总分: {{ PHeader.x_total_score }}</div> | 23 | + <!-- TAG:总分支持0分显示,避免因真假值判断被隐藏 --> |
| 24 | + <div | ||
| 25 | + v-if="PHeader.x_total_score !== undefined && PHeader.x_total_score !== null && PHeader.x_total_score !== ''" | ||
| 26 | + style="font-weight: bold; color: red; text-align: center; font-size: 0.9rem;" | ||
| 27 | + >总分: {{ PHeader.x_total_score }}</div> | ||
| 24 | <div v-if="PHeader.flow_node_name" style="text-align: center;">({{ PHeader.flow_node_name }})</div> | 28 | <div v-if="PHeader.flow_node_name" style="text-align: center;">({{ PHeader.flow_node_name }})</div> |
| 25 | <div v-if="PHeader.description" class="table-desc" v-html="PHeader.description" /> | 29 | <div v-if="PHeader.description" class="table-desc" v-html="PHeader.description" /> |
| 26 | <van-config-provider :theme-vars="themeVars"> | 30 | <van-config-provider :theme-vars="themeVars"> |
| ... | @@ -520,9 +524,15 @@ onMounted(async () => { | ... | @@ -520,9 +524,15 @@ onMounted(async () => { |
| 520 | } | 524 | } |
| 521 | // 处理分页表单结果数据 | 525 | // 处理分页表单结果数据 |
| 522 | if (object.x_score_map) { | 526 | if (object.x_score_map) { |
| 527 | + // TAG:分数映射存在时才处理分页成绩(保留0分) | ||
| 523 | const score_map = object.x_score_map; | 528 | const score_map = object.x_score_map; |
| 524 | - item.component_props.x_score = score_map[item.key] || ''; | 529 | + // 这里使用空值合并运算符,避免0分被当作假值 |
| 525 | - PHeader.value.x_total_score = score_map.x_total_score || ''; | 530 | + item.component_props.x_score = (score_map[item.key] ?? ''); |
| 531 | + PHeader.value.x_total_score = (score_map.x_total_score ?? ''); | ||
| 532 | + } else { | ||
| 533 | + // TAG:分数映射不存在时清空分页成绩,避免残留展示 | ||
| 534 | + item.component_props.x_score = undefined; | ||
| 535 | + PHeader.value.x_total_score = undefined; | ||
| 526 | } | 536 | } |
| 527 | } | 537 | } |
| 528 | }); | 538 | }); | ... | ... |
-
Please register or login to post a comment