v1.2.54:修复请假附件区被隐藏——根因:旧套学校 enableAttach 恒为 0,不能作为显示/放行条件——① 实测复现:陈莎莎(ysdwl 昆明文理学院)名下 6 个请假类型,queryLeaveTypeCfg 全部返回 enableAttach=0、attachmentNumberLimit=4(学校实际允许传 4 张,app 内亦显示为可选附件),而 v1.2.53 前端显示条件为 enableAttach===1,导致所有旧套学校附件区被隐藏;多校只读采样(马鞍山/兰州财经/安徽师大/芜湖职大/蚌埠医科/新疆师大/矿大)确认旧套 enableAttach 全为 0、limit 全为 4,属该字段在旧套链路的语义问题而非个例;② 判定修正:可传附件 = enableAttach===1 或 attachmentNumberLimit>0(前端新增 applyAttachVisible;旧套服务端校验同步改为「两者都表明不可用才拒绝」);上限仍取 min(4, 学校值);③ 新套侧补漏:leaveNewToLeaveTypes 在 isVisibledEvidenceFile=false 时不再带出 evidenceFileCountMax(否则前端按「上限>0」会误显示上传入口),仅可见时带出;④ 新增回归测试 TestLeaveNewToLeaveTypesAttachGating(可见/不可见类型分别断言开关与上限);go build、go vet、go test -count=1 ./...、vue-tsc --noEmit、npm run build 全过;⑤ 全流程只读实测(未调用任何提交接口),真实提交由用户自测
ci/woodpecker/tag/build Pipeline was successful
ci/woodpecker/tag/build Pipeline was successful
This commit is contained in:
@@ -371,8 +371,10 @@ func ExecuteLeaveApply(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// 附件复核:类型开关 + 数量上限(学校配置为准,产品上限 4 张)
|
||||
// 注意:实测多所旧套学校 enableAttach 恒为 0(该字段在旧套不代表"可传附件"),
|
||||
// 是否允许以 attachmentNumberLimit>0 为准;仅当两者都表明不可用时才拒绝。
|
||||
if len(imageURLs) > 0 {
|
||||
if cfg.EnableAttach != 1 {
|
||||
if cfg.EnableAttach != 1 && cfg.AttachmentNumberLimit <= 0 {
|
||||
errMsg := "该请假类型不支持上传附件"
|
||||
saveLog(false, errMsg)
|
||||
sendEvent("task_error", map[string]interface{}{"status": "error", "message": errMsg})
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package handler
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
cpd "cpdaily-new/internal/service/cpdaily"
|
||||
)
|
||||
|
||||
// TestMergeApplyImageURLs 附件合并:多图字段 + 旧前端兼容单图字段,
|
||||
// 保序去重、剔除空串与首尾空白(避免旧缓存包附件被静默丢弃或重复提交)。
|
||||
@@ -68,3 +72,26 @@ func TestMergeApplyImageURLs(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestLeaveNewToLeaveTypesAttachGating 新套类型翻译:材料区不可见时不得带出数量上限,
|
||||
// 否则前端按「上限>0」的条件会误显示上传入口(旧套学校 enableAttach 恒为 0 的同类问题)。
|
||||
func TestLeaveNewToLeaveTypesAttachGating(t *testing.T) {
|
||||
types := []cpd.LeaveNewType{
|
||||
{TypeWid: 1, TypeName: "可见类型"},
|
||||
{TypeWid: 2, TypeName: "不可见类型"},
|
||||
}
|
||||
details := map[int]*cpd.LeaveNewFormDetail{
|
||||
1: {TypeName: "可见类型", IsVisibledEvidenceFile: true, EvidenceFileCountMax: 4},
|
||||
2: {TypeName: "不可见类型", IsVisibledEvidenceFile: false, EvidenceFileCountMax: 10},
|
||||
}
|
||||
out := leaveNewToLeaveTypes(types, func(wid int) *cpd.LeaveNewFormDetail { return details[wid] })
|
||||
if len(out) != 2 {
|
||||
t.Fatalf("期望 2 个类型, got %d", len(out))
|
||||
}
|
||||
if out[0].EnableAttach != 1 || out[0].AttachmentNumberLimit != 4 {
|
||||
t.Errorf("可见类型应带出开关与上限: %+v", out[0])
|
||||
}
|
||||
if out[1].EnableAttach != 0 || out[1].AttachmentNumberLimit != 0 {
|
||||
t.Errorf("不可见类型不应带出上限(否则前端误显示): %+v", out[1])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,12 @@ func leaveNewToLeaveTypes(list []cpd.LeaveNewType, detailOf func(typeWid int) *c
|
||||
item.NeedApproval = 1
|
||||
if d.IsVisibledEvidenceFile {
|
||||
item.EnableAttach = 1
|
||||
item.AttachmentNumberLimit = d.EvidenceFileCountMax
|
||||
} else {
|
||||
// 材料区不可见时不得带出上限,否则前端按「上限>0」会误显示上传入口
|
||||
item.AttachmentNumberLimit = 0
|
||||
}
|
||||
item.ReasonWordLimit = d.LeaveReasonWordsMini
|
||||
item.AttachmentNumberLimit = d.EvidenceFileCountMax
|
||||
item.DisableTime = 0
|
||||
item.LimitDay = 0
|
||||
} else {
|
||||
|
||||
@@ -468,8 +468,8 @@
|
||||
<p v-if="applyGpsError" class="text-[10px] text-amber-500 mt-1">{{ applyGpsError }}</p>
|
||||
</div>
|
||||
|
||||
<!-- 附件(enableAttach=1 时显示;多图,最多 4 张且不超学校配置) -->
|
||||
<div v-if="currentType?.enableAttach === 1">
|
||||
<!-- 附件(enableAttach=1 或 attachmentNumberLimit>0 时显示;多图,最多 4 张且不超学校配置) -->
|
||||
<div v-if="applyAttachVisible">
|
||||
<label class="text-xs text-gray-500 mb-1 block">
|
||||
附件(可选,最多 {{ applyAttachLimit }} 张<template v-if="applyForm.imageUrls.length">,已传 {{ applyForm.imageUrls.length }}/{{ applyAttachLimit }}</template>)
|
||||
</label>
|
||||
@@ -994,9 +994,17 @@ function currentTypeOf(): LeaveType | null {
|
||||
}
|
||||
const currentType = ref<LeaveType | null>(null)
|
||||
|
||||
// 附件数量上限:产品上限 4 张,学校配置更小时取学校值(未配置/超 4 均按 4)
|
||||
// 附件数量上限:产品上限 4 张,学校配置更小时取学校值(未配置/超 4 均按 4)。
|
||||
// 显示与否同时看 enableAttach 与 attachmentNumberLimit:实测旧套学校 enableAttach 恒为 0,
|
||||
// 但 attachmentNumberLimit>0 表示可传附件(app 内亦显示),故二者取“或”。
|
||||
const applyAttachVisible = computed(() => {
|
||||
const t = currentType.value
|
||||
if (!t) return false
|
||||
return t.enableAttach === 1 || (t.attachmentNumberLimit || 0) > 0
|
||||
})
|
||||
|
||||
const applyAttachLimit = computed(() => {
|
||||
if (currentType.value?.enableAttach !== 1) return 0
|
||||
if (!applyAttachVisible.value) return 0
|
||||
const schoolLimit = currentType.value?.attachmentNumberLimit || 0
|
||||
return schoolLimit > 0 && schoolLimit < 4 ? schoolLimit : 4
|
||||
})
|
||||
@@ -1066,7 +1074,7 @@ function onApplyTypeChange() {
|
||||
applyForm.value.detailAddress = ''
|
||||
}
|
||||
// 附件随类型收敛:不支持附件则清空,支持但上限变小则截断(避免提交超出学校限制)
|
||||
if (t?.enableAttach !== 1) {
|
||||
if (!applyAttachVisible.value) {
|
||||
applyForm.value.imageUrls = []
|
||||
} else if (applyForm.value.imageUrls.length > applyAttachLimit.value) {
|
||||
applyForm.value.imageUrls = applyForm.value.imageUrls.slice(0, applyAttachLimit.value)
|
||||
@@ -1301,7 +1309,7 @@ async function submitApply() {
|
||||
return
|
||||
}
|
||||
// 附件:上限复核(学校开关与数量由后端再次校验)
|
||||
if (f.imageUrls.length > 0 && t?.enableAttach !== 1) {
|
||||
if (f.imageUrls.length > 0 && !applyAttachVisible.value) {
|
||||
message.warning('该请假类型不支持上传附件')
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user