fix(recycle): recycle photo for rule list
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
>
|
||||
<div class="filters glass">
|
||||
<t-input
|
||||
v-model.trim="keyword"
|
||||
v-model="keyword"
|
||||
class="keyword"
|
||||
type="search"
|
||||
borderless
|
||||
@@ -53,7 +53,14 @@
|
||||
@click="toEdit(item)"
|
||||
>
|
||||
<template #left-icon>
|
||||
<div class="avatar fallback" v-text="(getRecycleItemName(item) || '模').slice(0, 1)" />
|
||||
<t-image
|
||||
v-if="coverId(item)"
|
||||
class="avatar"
|
||||
:src="getAttachmentReadURL(coverId(item), 96)"
|
||||
:alt="getRecycleItemName(item)"
|
||||
fit="cover"
|
||||
/>
|
||||
<div v-else class="avatar fallback" v-text="(getRecycleItemName(item) || '模').slice(0, 1)" />
|
||||
</template>
|
||||
<template #title>
|
||||
<span class="clip-text" v-text="getRecycleItemName(item) || '未命名回收物'" />
|
||||
@@ -115,6 +122,7 @@ import RecycleRuleDetail from "@/pages/recycle/RecycleRuleDetail.vue";
|
||||
import RecycleRuleEdit from "@/pages/recycle/RecycleRuleEdit.vue";
|
||||
import type { NavbarAction } from "@/types/NavbarAction";
|
||||
import type { RecycleExchangeRule, RecycleRuleItem } from "@/types/Recycle";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
@@ -157,6 +165,10 @@ function getRecycleItemName(rule: RecycleExchangeRule): string {
|
||||
return rule.recycleName || "";
|
||||
}
|
||||
|
||||
function coverId(rule: RecycleExchangeRule): string {
|
||||
return rule.recycleItemAttachments?.find(attachment => attachment.id && attachment.mimeType?.startsWith("image/"))?.id || "";
|
||||
}
|
||||
|
||||
function getRuleItemList(rule: RecycleExchangeRule): RecycleRuleItem[] {
|
||||
return rule.itemList || [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user