fix(web-admin): treat empty allowedProductIds as restricted mode
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9b8848ea8c
commit
8777173fb7
2 files changed
+14
-4
No files matched your search
@@ -513,7 +513,11 @@
|
||||
const productSelectorVisible = ref(false)
|
||||
/** 当前装货合同明细中的 CRM productId(非内部客户限制选品) */
|
||||
const loadContractProductIds = ref<string[]>([])
|
||||
const productSelectorAllowedIds = computed(() => {
|
||||
/**
|
||||
* 内部客户:undefined → ProductSelector 全量目录
|
||||
* 非内部:始终传 string[](合同无明细时为 [])→ 受限模式,勿与「未传」混淆
|
||||
*/
|
||||
const productSelectorAllowedIds = computed((): string[] | undefined => {
|
||||
if (isPlInternalCustomerName(loadForm.value.customerName)) return undefined
|
||||
return loadContractProductIds.value
|
||||
})
|
||||
|
||||
@@ -264,7 +264,10 @@
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
supplierId?: string | number
|
||||
/** 非空时仅展示这些产品(按 id 拉详情,避免分页漏选) */
|
||||
/**
|
||||
* 传入数组(含空数组)→ 受限模式:仅按 id 拉详情 / 空列表+警告,隐藏「新增」
|
||||
* undefined / 未传 → 完整 CRM 目录模式
|
||||
*/
|
||||
allowedProductIds?: string[]
|
||||
}>()
|
||||
|
||||
@@ -282,10 +285,13 @@
|
||||
/** 限制模式下打开弹窗后「无产品」提示只打一次 */
|
||||
let emptyAllowedWarnedOnOpen = false
|
||||
|
||||
/** 是否传入数组(含 [])即为受限;勿用 length 判断,避免空合同打开全量目录 */
|
||||
const isRestrictedMode = computed(() => Array.isArray(props.allowedProductIds))
|
||||
const normalizedAllowedIds = computed(() =>
|
||||
(props.allowedProductIds || []).map((id) => String(id).trim()).filter(Boolean)
|
||||
(isRestrictedMode.value ? props.allowedProductIds || [] : [])
|
||||
.map((id) => String(id).trim())
|
||||
.filter(Boolean)
|
||||
)
|
||||
const isRestrictedMode = computed(() => normalizedAllowedIds.value.length > 0)
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
|
||||
Reference in new issue
Block a user