fix(bug):1.帮我检查一下平台中有多少处显示部门地方这种“e10-、、、、”字样拿掉不要显示
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
2.月培训计划发布时授课时间默认空着点击【发布】时提示先维护授课时间,(不要默认年培训计划) 3.授课地点默认“年度计划”所设置的授课地点,如果年培训计划没有维护发布时也要必填 4.点击【发布】时要校验参加人员不能为空!默认为所属部门下的人员~ 认真阅读相关代码~
This commit is contained in:
1 parent
6cdcc4f221
commit
858c352991
16 files changed
+421
-89
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { cleanDeptName, cleanDeptNameText, displayDeptName, filterVisibleDepts, isSyntheticDeptName } from './deptName'
|
||||
|
||||
test('cleanDeptName strips e10-<id> tokens and trims', () => {
|
||||
assert.equal(cleanDeptName('e10-1115765553620631553'), '')
|
||||
assert.equal(cleanDeptName('研发技术课'), '研发技术课')
|
||||
assert.equal(cleanDeptName('研发组 e10-1172161210096713736'), '研发组')
|
||||
assert.equal(cleanDeptName('e10-111 e10-222 研发组'), '研发组')
|
||||
assert.equal(cleanDeptName(' E10-1172161210096713736 '), '')
|
||||
assert.equal(cleanDeptName(null), '')
|
||||
assert.equal(cleanDeptName(undefined), '')
|
||||
})
|
||||
|
||||
test('isSyntheticDeptName detects nameless synced depts', () => {
|
||||
assert.equal(isSyntheticDeptName('e10-1115765553620631553'), true)
|
||||
assert.equal(isSyntheticDeptName('模具课'), false)
|
||||
assert.equal(isSyntheticDeptName(''), true)
|
||||
assert.equal(isSyntheticDeptName(null), true)
|
||||
})
|
||||
|
||||
test('displayDeptName returns displayable text', () => {
|
||||
assert.equal(displayDeptName('e10-1172161210096713736'), '')
|
||||
assert.equal(displayDeptName('资讯组'), '资讯组')
|
||||
})
|
||||
|
||||
test('filterVisibleDepts drops synthetic-only depts', () => {
|
||||
const depts = [
|
||||
{ id: '1', name: '研发技术课' },
|
||||
{ id: '2', name: 'e10-1115765553620631553' },
|
||||
{ id: '3', name: '模具课' },
|
||||
{ id: '4', name: '' },
|
||||
]
|
||||
assert.deepEqual(filterVisibleDepts(depts), [
|
||||
{ id: '1', name: '研发技术课' },
|
||||
{ id: '3', name: '模具课' },
|
||||
])
|
||||
assert.deepEqual(filterVisibleDepts(null), [])
|
||||
})
|
||||
|
||||
test('cleanDeptNameText strips tokens inside free text without dangling separators', () => {
|
||||
assert.equal(cleanDeptNameText('e10-1115765553620631553、研发组'), '研发组')
|
||||
assert.equal(cleanDeptNameText('研发组、e10-1172161210096713736、模具课'), '研发组、模具课')
|
||||
assert.equal(cleanDeptNameText('资讯组'), '资讯组')
|
||||
assert.equal(cleanDeptNameText('e10-111,e10-222'), '')
|
||||
assert.equal(cleanDeptNameText(null), '')
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
// 部门名展示清洗(2026-11 需求):企微同步经 Casdoor 落库时,上游未映射部门名的
|
||||
// 部门以「e10-<企微部门ID>」兜底形态存入 org_depts.name / users.dept_name,
|
||||
// 平台各处(下拉/列表/导出)直出时呈现为一串「e10-1115765553620631553」字样。
|
||||
// 展示侧一律剥离该字样;整体即该形态的「无名部门」不进入部门下拉。
|
||||
|
||||
const E10_DEPT_TOKEN_RE = /e10-\d+/gi
|
||||
|
||||
/** 剥离部门名中残留的「e10-数字」字样并去首尾空白(入参为空安全)。 */
|
||||
export function cleanDeptName(name: string | null | undefined): string {
|
||||
return (name || '').replace(E10_DEPT_TOKEN_RE, '').trim()
|
||||
}
|
||||
|
||||
/** 部门名剥离后是否为空(整段就是「e10-数字」的同步残留部门,展示层视为无部门名)。 */
|
||||
export function isSyntheticDeptName(name: string | null | undefined): boolean {
|
||||
return cleanDeptName(name) === ''
|
||||
}
|
||||
|
||||
/** 部门名展示值:剥掉「e10-数字」字样,空名由调用方回退 '-' 等占位符。 */
|
||||
export function displayDeptName(name: string | null | undefined): string {
|
||||
return cleanDeptName(name)
|
||||
}
|
||||
|
||||
/** 过滤掉整段即「e10-数字」的无名部门(部门下拉/部门表数据源统一走这里)。 */
|
||||
export function filterVisibleDepts<T extends { name?: string | null }>(depts: T[] | null | undefined): T[] {
|
||||
return (depts || []).filter((d) => !isSyntheticDeptName(d.name))
|
||||
}
|
||||
|
||||
/** 自由文本(适合人员/参加人员串等)清洗:按分隔符拆开逐段剥离「e10-数字」后重组,
|
||||
* 避免段中残留后出现悬空分隔符。 */
|
||||
export function cleanDeptNameText(text: string | null | undefined): string {
|
||||
return (text || '')
|
||||
.split(/[、,,;;]/)
|
||||
.map((part) => cleanDeptName(part))
|
||||
.filter(Boolean)
|
||||
.join('、')
|
||||
}
|
||||
Reference in new issue
Block a user