修复资源组
This commit is contained in:
parent
91cc67e192
commit
94d7c7529b
@ -20,6 +20,15 @@ const props = withDefaults(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const type = computed(() => props.item.detailType || props.item.type || '');
|
const type = computed(() => props.item.detailType || props.item.type || '');
|
||||||
|
const imageUrl = computed(() =>
|
||||||
|
String(
|
||||||
|
props.item.cover ||
|
||||||
|
props.item.coverUrl ||
|
||||||
|
props.item.sourceUrl ||
|
||||||
|
props.item.resourceUrl ||
|
||||||
|
'',
|
||||||
|
).trim(),
|
||||||
|
);
|
||||||
const sizeStyle = computed(() => ({
|
const sizeStyle = computed(() => ({
|
||||||
height: `${props.size}px`,
|
height: `${props.size}px`,
|
||||||
width: `${props.size}px`,
|
width: `${props.size}px`,
|
||||||
@ -61,10 +70,10 @@ const tokenClassName = computed(() => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="reward-icon" :style="sizeStyle">
|
<div class="reward-icon" :style="sizeStyle">
|
||||||
<Image
|
<Image
|
||||||
v-if="item.cover && !isCurrencyRewardType(type) && !isGameCouponType(type) && !isPropsCouponType(type) && type !== 'SPECIAL_ID'"
|
v-if="imageUrl && !isCurrencyRewardType(type) && !isGameCouponType(type) && !isPropsCouponType(type) && type !== 'SPECIAL_ID'"
|
||||||
class="reward-icon__image"
|
class="reward-icon__image"
|
||||||
:preview="{ src: item.cover }"
|
:preview="{ src: imageUrl }"
|
||||||
:src="item.cover"
|
:src="imageUrl"
|
||||||
/>
|
/>
|
||||||
<div v-else :class="tokenClassName">
|
<div v-else :class="tokenClassName">
|
||||||
{{ tokenLabel }}
|
{{ tokenLabel }}
|
||||||
|
|||||||
@ -393,7 +393,7 @@ function buildRewardItem(resource: DisplayResource): RewardGroupItem {
|
|||||||
const item: RewardGroupItem = {
|
const item: RewardGroupItem = {
|
||||||
amount: resource.amount,
|
amount: resource.amount,
|
||||||
content: resource.id,
|
content: resource.id,
|
||||||
cover: resource.cover || '',
|
cover: resource.cover || resource.sourceUrl || '',
|
||||||
detailType: resource.type,
|
detailType: resource.type,
|
||||||
name: resource.name,
|
name: resource.name,
|
||||||
quantity: getDefaultQuantity(resource),
|
quantity: getDefaultQuantity(resource),
|
||||||
@ -408,6 +408,45 @@ function buildRewardItem(resource: DisplayResource): RewardGroupItem {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyResourcePreview(item: RewardGroupItem, resource: DisplayResource) {
|
||||||
|
if (!String(item.cover || '').trim()) {
|
||||||
|
item.cover = resource.cover || resource.sourceUrl || '';
|
||||||
|
}
|
||||||
|
if (!String(item.sourceUrl || '').trim()) {
|
||||||
|
item.sourceUrl = resource.sourceUrl || '';
|
||||||
|
}
|
||||||
|
if (!String(item.name || '').trim()) {
|
||||||
|
item.name = resource.name;
|
||||||
|
}
|
||||||
|
if (!String(item.remark || '').trim()) {
|
||||||
|
item.remark = resource.remark || resource.name || '';
|
||||||
|
}
|
||||||
|
if (!String(item.typeLabel || '').trim()) {
|
||||||
|
item.typeLabel = resource.typeLabel;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(item.amount === undefined ||
|
||||||
|
item.amount === null ||
|
||||||
|
String(item.amount).trim() === '') &&
|
||||||
|
resource.amount !== undefined
|
||||||
|
) {
|
||||||
|
item.amount = resource.amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hydrateSelectedItemsFromResources(resources: DisplayResource[]) {
|
||||||
|
if (resources.length === 0 || form.rewardConfigList.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const resourceMap = new Map(resources.map((item) => [item.key, item]));
|
||||||
|
form.rewardConfigList.forEach((item) => {
|
||||||
|
const resource = resourceMap.get(getRewardKey(item));
|
||||||
|
if (resource) {
|
||||||
|
applyResourcePreview(item, resource);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function selectType(option: TypeOption) {
|
function selectType(option: TypeOption) {
|
||||||
if (selectedType.value === option.value) {
|
if (selectedType.value === option.value) {
|
||||||
return;
|
return;
|
||||||
@ -451,6 +490,7 @@ async function loadOptions(type: string) {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
store.list = uniqueResources(results.flat());
|
store.list = uniqueResources(results.flat());
|
||||||
|
hydrateSelectedItemsFromResources(store.list);
|
||||||
store.loaded = true;
|
store.loaded = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -460,6 +500,7 @@ async function loadOptions(type: string) {
|
|||||||
store.list = (rows || []).map((item) =>
|
store.list = (rows || []).map((item) =>
|
||||||
normalizeDisplayResource(item, 'gift', 'GIFT', '礼物'),
|
normalizeDisplayResource(item, 'gift', 'GIFT', '礼物'),
|
||||||
);
|
);
|
||||||
|
hydrateSelectedItemsFromResources(store.list);
|
||||||
store.loaded = true;
|
store.loaded = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -489,6 +530,7 @@ async function loadOptions(type: string) {
|
|||||||
'VIP',
|
'VIP',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
hydrateSelectedItemsFromResources(store.list);
|
||||||
store.loaded = true;
|
store.loaded = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -498,6 +540,7 @@ async function loadOptions(type: string) {
|
|||||||
store.list = (rows || []).map((item) =>
|
store.list = (rows || []).map((item) =>
|
||||||
normalizeDisplayResource(item, 'props', type, typeLabel),
|
normalizeDisplayResource(item, 'props', type, typeLabel),
|
||||||
);
|
);
|
||||||
|
hydrateSelectedItemsFromResources(store.list);
|
||||||
store.loaded = true;
|
store.loaded = true;
|
||||||
} finally {
|
} finally {
|
||||||
store.loading = false;
|
store.loading = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user