fix(web-admin): 项目业务类型下拉去掉中试服务可选 (#162) #163
No files matched your search
@@ -1,5 +1,23 @@
|
||||
import type { BizType, ProjectRecord } from '@/api/project-management'
|
||||
|
||||
/**
|
||||
* 项目新建/编辑弹窗「业务类型」选项。
|
||||
* 中试服务已下线:默认不可选;若旧项目已含 pilot_service 则保留展示。
|
||||
*/
|
||||
export function projectBizTypeSelectLabels(
|
||||
allLabels: Record<string, string>,
|
||||
selectedBizTypes?: string[] | null
|
||||
): Record<string, string> {
|
||||
const selected = new Set((selectedBizTypes || []).filter(Boolean))
|
||||
return Object.fromEntries(
|
||||
Object.entries(allLabels).filter(([key]) => {
|
||||
if (key === 'presign') return false
|
||||
if (key === 'pilot_service') return selected.has('pilot_service')
|
||||
return true
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/** Drill-down uses the last successful statistics query, never unsaved filter edits. */
|
||||
export function buildDrillFilters(
|
||||
applied: ProjectRecord,
|
||||
|
||||
@@ -260,7 +260,11 @@
|
||||
>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { joinChildNames, managementPayload } from '@/utils/project-management'
|
||||
import {
|
||||
joinChildNames,
|
||||
managementPayload,
|
||||
projectBizTypeSelectLabels
|
||||
} from '@/utils/project-management'
|
||||
import { useMenuPerm } from '@/hooks/core/useMenuPerm'
|
||||
import {
|
||||
Plus,
|
||||
@@ -281,9 +285,6 @@
|
||||
fetchProjectReferences,
|
||||
type ProjectRecord
|
||||
} from '@/api/project-management'
|
||||
const projectBizLabels = Object.fromEntries(
|
||||
Object.entries(bizLabels).filter(([key]) => key !== 'presign')
|
||||
)
|
||||
const props = defineProps<{ kind: 'teams' | 'projects' }>()
|
||||
const isTeam = computed(() => props.kind === 'teams')
|
||||
const { hasMenuPerm } = useMenuPerm()
|
||||
@@ -323,6 +324,10 @@
|
||||
memberIds = ref<string[]>([]),
|
||||
regionIds = ref<string[]>([]),
|
||||
hospitalIds = ref<string[]>([])
|
||||
/** 默认不含中试;旧项目已选中试时保留该选项以展示 */
|
||||
const projectBizLabels = computed(() =>
|
||||
projectBizTypeSelectLabels(bizLabels, form.value.bizTypes as string[] | undefined)
|
||||
)
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
|
||||
@@ -3,7 +3,8 @@ import test from 'node:test'
|
||||
import {
|
||||
buildDrillFilters,
|
||||
assignmentSnapshot,
|
||||
joinChildNames
|
||||
joinChildNames,
|
||||
projectBizTypeSelectLabels
|
||||
} from '../src/utils/project-management'
|
||||
|
||||
test('drill preserves applied dates and selected project when a team is opened', () => {
|
||||
@@ -83,3 +84,22 @@ test('filter options use visible historical scope; create and reassignment remai
|
||||
})
|
||||
assert.deepEqual(projectOptionsParams('cell_storage', false), { bizType: 'cell_storage' })
|
||||
})
|
||||
|
||||
test('project biz type select hides pilot by default but keeps it when already selected', () => {
|
||||
const labels = {
|
||||
presign: '预签约',
|
||||
cell_storage: '细胞存储',
|
||||
research_donation: '科研捐赠',
|
||||
pilot_service: '中试服务',
|
||||
basic_experiment: '临床科研'
|
||||
}
|
||||
const fresh = projectBizTypeSelectLabels(labels, [])
|
||||
assert.equal(fresh.pilot_service, undefined)
|
||||
assert.equal(fresh.presign, undefined)
|
||||
assert.equal(fresh.cell_storage, '细胞存储')
|
||||
assert.equal(fresh.basic_experiment, '临床科研')
|
||||
|
||||
const legacy = projectBizTypeSelectLabels(labels, ['cell_storage', 'pilot_service'])
|
||||
assert.equal(legacy.pilot_service, '中试服务')
|
||||
assert.equal(legacy.cell_storage, '细胞存储')
|
||||
})
|
||||
Reference in new issue
Block a user