46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
export interface StandardModelWhiteBgView {
|
|
key: StandardModelWhiteBgKey
|
|
label: string
|
|
fieldName: string
|
|
}
|
|
|
|
export type StandardModelWhiteBgKey =
|
|
| 'leftTop'
|
|
| 'rightTop'
|
|
| 'front'
|
|
| 'left'
|
|
| 'right'
|
|
| 'back'
|
|
|
|
export const STANDARD_MODEL_WHITE_BG_VIEWS: StandardModelWhiteBgView[] = [
|
|
{ key: 'leftTop', label: '左侧俯视', fieldName: 'whiteBgLeftTop' },
|
|
{ key: 'rightTop', label: '右侧俯视', fieldName: 'whiteBgRightTop' },
|
|
{ key: 'front', label: '正视图', fieldName: 'whiteBgFront' },
|
|
{ key: 'left', label: '左视图', fieldName: 'whiteBgLeft' },
|
|
{ key: 'right', label: '右视图', fieldName: 'whiteBgRight' },
|
|
{ key: 'back', label: '后视图', fieldName: 'whiteBgBack' },
|
|
]
|
|
|
|
export function getWhiteBackgroundFieldName(key: StandardModelWhiteBgKey): string {
|
|
const target = STANDARD_MODEL_WHITE_BG_VIEWS.find((item) => item.key === key)
|
|
return target ? target.fieldName : `whiteBg${key}`
|
|
}
|
|
|
|
export function getMissingWhiteBackgroundViews(
|
|
files: Partial<Record<StandardModelWhiteBgKey, File | null>>,
|
|
): StandardModelWhiteBgKey[] {
|
|
return STANDARD_MODEL_WHITE_BG_VIEWS
|
|
.map((item) => item.key)
|
|
.filter((key) => !files[key])
|
|
}
|
|
|
|
export function hasCompleteWhiteBackgroundSet(
|
|
files: Partial<Record<StandardModelWhiteBgKey, File | null>>,
|
|
): boolean {
|
|
return getMissingWhiteBackgroundViews(files).length === 0
|
|
}
|
|
|
|
export function hasReachedStandardModelSkuLimit(existingSkuCount: number): boolean {
|
|
return existingSkuCount >= 1
|
|
}
|