feat: 作品页支持模块化编排与自定义内容模块
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<div
|
||||
class="cell previewable"
|
||||
:class="{ dragging: dragIndex === i, over: overIndex === i }"
|
||||
draggable="true"
|
||||
:draggable="!disabled"
|
||||
@click="preview(i)"
|
||||
@dragstart="onDragStart(i)"
|
||||
@dragover.prevent="onDragOver(i)"
|
||||
@@ -16,12 +16,13 @@
|
||||
<img v-else class="thumb" :src="mediaSrc(m)" :alt="m.name" loading="lazy" />
|
||||
<div v-if="isVideo(m)" class="play"><n-icon :component="PlayCircleOutline" :size="26" /></div>
|
||||
<div class="order">{{ i + 1 }}</div>
|
||||
<button class="del" type="button" :title="t('common.action.delete')" @click.stop="remove(i)">×</button>
|
||||
<button v-if="!disabled" class="del" type="button" :title="t('common.action.delete')" @click.stop="remove(i)">×</button>
|
||||
</div>
|
||||
<n-input
|
||||
v-if="captionable"
|
||||
size="small"
|
||||
:value="m.name"
|
||||
:disabled="disabled"
|
||||
:placeholder="t('pages.artwork.imageCaption')"
|
||||
class="caption-input"
|
||||
@update:value="(v) => updateCaption(i, v)"
|
||||
@@ -32,7 +33,7 @@
|
||||
<div class="cell uploading"><n-spin size="small" /></div>
|
||||
</div>
|
||||
|
||||
<label v-if="list.length + uploading.length < max" class="item">
|
||||
<label v-if="!disabled && list.length + uploading.length < max" class="item">
|
||||
<span class="cell add">
|
||||
<input ref="inputRef" type="file" accept="image/*,video/*" multiple hidden @change="onPick" />
|
||||
<n-icon :component="AddOutline" :size="22" />
|
||||
@@ -62,8 +63,8 @@ interface MediaItem {
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ modelValue: MediaItem[]; max?: number; captionable?: boolean }>(),
|
||||
{ max: 12, captionable: false },
|
||||
defineProps<{ modelValue: MediaItem[]; max?: number; captionable?: boolean; disabled?: boolean }>(),
|
||||
{ max: 12, captionable: false, disabled: false },
|
||||
);
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: MediaItem[]): void }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -0,0 +1,473 @@
|
||||
<template>
|
||||
<div class="trace-module-editor">
|
||||
<div class="module-toolbar">
|
||||
<div>
|
||||
<div class="module-toolbar-title">{{ t('pages.traceModules.title') }}</div>
|
||||
<div class="module-toolbar-hint">{{ t('pages.traceModules.hint') }}</div>
|
||||
</div>
|
||||
<n-dropdown
|
||||
v-if="!disabled"
|
||||
trigger="click"
|
||||
:options="addOptions"
|
||||
@select="addModule"
|
||||
>
|
||||
<n-button type="primary" size="small" :disabled="modules.length >= MAX_TRACE_MODULES">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.traceModules.add') }}
|
||||
</n-button>
|
||||
</n-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="module-list">
|
||||
<section
|
||||
v-for="(module, index) in modules"
|
||||
:key="module.id"
|
||||
class="module-card"
|
||||
:class="{ hidden: !module.visible, over: overIndex === index, collapsed: !isExpanded(module) }"
|
||||
@dragover.prevent="overIndex = index"
|
||||
@drop="onDrop(index)"
|
||||
>
|
||||
<header class="module-head">
|
||||
<button
|
||||
v-if="!disabled"
|
||||
type="button"
|
||||
class="drag-handle"
|
||||
draggable="true"
|
||||
:title="t('pages.traceModules.drag')"
|
||||
:aria-label="t('pages.traceModules.drag')"
|
||||
@dragstart="dragIndex = index"
|
||||
@dragend="onDragEnd"
|
||||
>
|
||||
⋮⋮
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="expand-toggle"
|
||||
:class="{ open: isExpanded(module) }"
|
||||
:title="isExpanded(module) ? t('pages.traceModules.collapse') : t('pages.traceModules.expand')"
|
||||
:aria-label="isExpanded(module) ? t('pages.traceModules.collapse') : t('pages.traceModules.expand')"
|
||||
@click="toggleExpand(module.id)"
|
||||
>
|
||||
<n-icon :component="ChevronDownOutline" :size="18" />
|
||||
</button>
|
||||
<span class="module-order">{{ index + 1 }}</span>
|
||||
<n-tag size="small" :bordered="false">{{ moduleTypeName(module.type) }}</n-tag>
|
||||
<n-input
|
||||
v-if="module.type !== 'HERO_CAROUSEL'"
|
||||
class="module-title-input"
|
||||
size="small"
|
||||
clearable
|
||||
:disabled="disabled"
|
||||
:maxlength="120"
|
||||
:value="module.title"
|
||||
:placeholder="t('pages.traceModules.defaultTitle', { title: moduleTypeName(module.type) })"
|
||||
@update:value="(value) => patchModule(index, { title: value })"
|
||||
/>
|
||||
<div v-else class="module-title-spacer" />
|
||||
<span class="visible-label">{{ t('pages.traceModules.visible') }}</span>
|
||||
<n-switch
|
||||
size="small"
|
||||
:disabled="disabled"
|
||||
:value="module.visible"
|
||||
@update:value="(value) => patchModule(index, { visible: value })"
|
||||
/>
|
||||
<div v-if="!disabled" class="module-actions">
|
||||
<n-button quaternary circle size="small" :disabled="index === 0" @click="move(index, -1)">
|
||||
<template #icon><n-icon :component="ArrowUpOutline" /></template>
|
||||
</n-button>
|
||||
<n-button
|
||||
quaternary
|
||||
circle
|
||||
size="small"
|
||||
:disabled="index === modules.length - 1"
|
||||
@click="move(index, 1)"
|
||||
>
|
||||
<template #icon><n-icon :component="ArrowDownOutline" /></template>
|
||||
</n-button>
|
||||
<n-button
|
||||
v-if="isCustom(module.type)"
|
||||
quaternary
|
||||
circle
|
||||
size="small"
|
||||
:disabled="modules.length >= MAX_TRACE_MODULES"
|
||||
:title="t('common.action.copy')"
|
||||
@click="copyModule(index)"
|
||||
>
|
||||
<template #icon><n-icon :component="CopyOutline" /></template>
|
||||
</n-button>
|
||||
<n-button
|
||||
v-if="isCustom(module.type)"
|
||||
quaternary
|
||||
circle
|
||||
size="small"
|
||||
type="error"
|
||||
:title="t('common.action.delete')"
|
||||
@click="removeModule(index)"
|
||||
>
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div v-show="isExpanded(module)" class="module-body">
|
||||
<template v-if="module.type === 'IMAGE_TEXT'">
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.traceModules.imagePosition')">
|
||||
<n-select
|
||||
:disabled="disabled"
|
||||
:value="imageTextConfig(module).imagePosition || 'TOP'"
|
||||
:options="imagePositionOptions"
|
||||
@update:value="(value) => patchConfig(index, { imagePosition: value })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<template v-if="!templateMode">
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.traceModules.innerHeading')">
|
||||
<n-input
|
||||
:disabled="disabled"
|
||||
:maxlength="120"
|
||||
:value="imageTextConfig(module).heading"
|
||||
@update:value="(value) => patchConfig(index, { heading: value })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2" :label="t('pages.traceModules.body')">
|
||||
<n-input
|
||||
type="textarea"
|
||||
:disabled="disabled"
|
||||
:maxlength="5000"
|
||||
:autosize="{ minRows: 3, maxRows: 10 }"
|
||||
:value="imageTextConfig(module).body"
|
||||
@update:value="(value) => patchConfig(index, { body: value })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2" :label="t('pages.traceModules.image')">
|
||||
<media-upload
|
||||
:model-value="imageTextMedia(module)"
|
||||
type="image"
|
||||
:max="1"
|
||||
:disabled="disabled"
|
||||
@update:model-value="(items) => patchConfig(index, { image: items[0] })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
</template>
|
||||
</n-grid>
|
||||
<n-alert v-if="templateMode" type="info" :show-icon="false">
|
||||
{{ t('pages.traceModules.templateContentHint') }}
|
||||
</n-alert>
|
||||
</template>
|
||||
|
||||
<template v-else-if="module.type === 'HORIZONTAL_GALLERY'">
|
||||
<artwork-showcase-editor
|
||||
v-if="!templateMode"
|
||||
:model-value="galleryItems(module)"
|
||||
:max="30"
|
||||
:disabled="disabled"
|
||||
@update:model-value="(items) => patchConfig(index, { items })"
|
||||
/>
|
||||
<n-alert v-else type="info" :show-icon="false">
|
||||
{{ t('pages.traceModules.templateContentHint') }}
|
||||
</n-alert>
|
||||
</template>
|
||||
|
||||
<slot
|
||||
v-else-if="!templateMode"
|
||||
name="system"
|
||||
:module="module"
|
||||
:index="index"
|
||||
>
|
||||
<n-empty size="small" :description="t('pages.traceModules.systemDataHint')" />
|
||||
</slot>
|
||||
|
||||
<n-alert v-else type="default" :show-icon="false">
|
||||
{{ t('pages.traceModules.systemDataHint') }}
|
||||
</n-alert>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ArrowDownOutline,
|
||||
ArrowUpOutline,
|
||||
AddOutline,
|
||||
ChevronDownOutline,
|
||||
CopyOutline,
|
||||
TrashOutline,
|
||||
} from '@vicons/ionicons5';
|
||||
import {
|
||||
cloneTraceLayout,
|
||||
createDefaultTraceLayout,
|
||||
MAX_TRACE_MODULES,
|
||||
type TraceHorizontalGalleryConfig,
|
||||
type TraceImageTextConfig,
|
||||
type TraceLayout,
|
||||
type TraceModule,
|
||||
type TraceModuleType,
|
||||
} from '@artveris/shared';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import ArtworkShowcaseEditor from '@/components/ArtworkShowcaseEditor.vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue?: TraceLayout;
|
||||
disabled?: boolean;
|
||||
templateMode?: boolean;
|
||||
}>(),
|
||||
{ disabled: false, templateMode: false },
|
||||
);
|
||||
const emit = defineEmits<{ (event: 'update:modelValue', value: TraceLayout): void }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const modules = computed(() => props.modelValue?.modules ?? createDefaultTraceLayout().modules);
|
||||
const dragIndex = ref<number | null>(null);
|
||||
const overIndex = ref<number | null>(null);
|
||||
// 卡片折叠是纯编辑态 UI,不写入布局 JSON;默认收起便于总览排序,新增/复制的模块自动展开
|
||||
const expandedIds = ref<Set<string>>(new Set());
|
||||
let customSequence = 0;
|
||||
|
||||
function isExpanded(module: TraceModule) {
|
||||
return expandedIds.value.has(module.id);
|
||||
}
|
||||
|
||||
function toggleExpand(id: string) {
|
||||
const next = new Set(expandedIds.value);
|
||||
next.has(id) ? next.delete(id) : next.add(id);
|
||||
expandedIds.value = next;
|
||||
}
|
||||
|
||||
function expandModule(id: string) {
|
||||
expandedIds.value = new Set(expandedIds.value).add(id);
|
||||
}
|
||||
|
||||
const addOptions = computed(() => [
|
||||
{ label: t('pages.traceModules.types.IMAGE_TEXT'), key: 'IMAGE_TEXT' },
|
||||
{ label: t('pages.traceModules.types.HORIZONTAL_GALLERY'), key: 'HORIZONTAL_GALLERY' },
|
||||
]);
|
||||
const imagePositionOptions = computed(() => [
|
||||
{ label: t('pages.traceModules.positions.TOP'), value: 'TOP' },
|
||||
{ label: t('pages.traceModules.positions.BOTTOM'), value: 'BOTTOM' },
|
||||
{ label: t('pages.traceModules.positions.LEFT'), value: 'LEFT' },
|
||||
{ label: t('pages.traceModules.positions.RIGHT'), value: 'RIGHT' },
|
||||
]);
|
||||
|
||||
function moduleTypeName(type: TraceModuleType) {
|
||||
return t(`pages.traceModules.types.${type}`);
|
||||
}
|
||||
|
||||
function isCustom(type: TraceModuleType) {
|
||||
return type === 'IMAGE_TEXT' || type === 'HORIZONTAL_GALLERY';
|
||||
}
|
||||
|
||||
function commit(nextModules: TraceModule[]) {
|
||||
emit('update:modelValue', { version: 1, modules: nextModules });
|
||||
}
|
||||
|
||||
function patchModule(index: number, patch: Partial<TraceModule>) {
|
||||
commit(modules.value.map((module, itemIndex) => (itemIndex === index ? { ...module, ...patch } : module)));
|
||||
}
|
||||
|
||||
function patchConfig(index: number, patch: Record<string, unknown>) {
|
||||
const module = modules.value[index];
|
||||
if (!module) return;
|
||||
patchModule(index, { config: { ...(module.config ?? {}), ...patch } });
|
||||
}
|
||||
|
||||
function move(index: number, offset: -1 | 1) {
|
||||
const target = index + offset;
|
||||
if (target < 0 || target >= modules.value.length) return;
|
||||
const next = [...modules.value];
|
||||
const [module] = next.splice(index, 1);
|
||||
next.splice(target, 0, module);
|
||||
commit(next);
|
||||
}
|
||||
|
||||
function customId(type: TraceModuleType) {
|
||||
customSequence += 1;
|
||||
const random =
|
||||
typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
||||
? crypto.randomUUID().replace(/-/g, '').slice(0, 12)
|
||||
: `${Date.now()}${customSequence}`;
|
||||
return `custom_${type.toLowerCase()}_${random}`;
|
||||
}
|
||||
|
||||
function addModule(type: TraceModuleType) {
|
||||
if (modules.value.length >= MAX_TRACE_MODULES) return;
|
||||
const module: TraceModule = {
|
||||
id: customId(type),
|
||||
type,
|
||||
visible: true,
|
||||
config: type === 'IMAGE_TEXT' ? { imagePosition: 'TOP' } : { items: [] },
|
||||
};
|
||||
commit([...modules.value, module]);
|
||||
expandModule(module.id);
|
||||
}
|
||||
|
||||
function copyModule(index: number) {
|
||||
if (modules.value.length >= MAX_TRACE_MODULES) return;
|
||||
const current = modules.value[index];
|
||||
if (!current || !isCustom(current.type)) return;
|
||||
const copied = cloneTraceLayout({ version: 1, modules: [current] }).modules[0];
|
||||
copied.id = customId(copied.type);
|
||||
commit([...modules.value.slice(0, index + 1), copied, ...modules.value.slice(index + 1)]);
|
||||
expandModule(copied.id);
|
||||
}
|
||||
|
||||
function removeModule(index: number) {
|
||||
commit(modules.value.filter((_, itemIndex) => itemIndex !== index));
|
||||
}
|
||||
|
||||
function imageTextConfig(module: TraceModule): TraceImageTextConfig {
|
||||
return (module.config ?? {}) as TraceImageTextConfig;
|
||||
}
|
||||
|
||||
function imageTextMedia(module: TraceModule) {
|
||||
const image = imageTextConfig(module).image;
|
||||
return image ? [image] : [];
|
||||
}
|
||||
|
||||
function galleryItems(module: TraceModule) {
|
||||
return ((module.config ?? {}) as TraceHorizontalGalleryConfig).items ?? [];
|
||||
}
|
||||
|
||||
function onDrop(target: number) {
|
||||
const source = dragIndex.value;
|
||||
if (source === null || source === target) return onDragEnd();
|
||||
const next = [...modules.value];
|
||||
const [module] = next.splice(source, 1);
|
||||
next.splice(target, 0, module);
|
||||
commit(next);
|
||||
onDragEnd();
|
||||
}
|
||||
|
||||
function onDragEnd() {
|
||||
dragIndex.value = null;
|
||||
overIndex.value = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.trace-module-editor {
|
||||
width: 100%;
|
||||
}
|
||||
.module-toolbar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.module-toolbar-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
.module-toolbar-hint {
|
||||
margin-top: 4px;
|
||||
color: #98a2b3;
|
||||
font-size: 12px;
|
||||
}
|
||||
.module-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.module-card {
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--n-border-color, #e0e0e6);
|
||||
border-radius: 10px;
|
||||
background: var(--n-color, #fff);
|
||||
transition: border-color 0.15s ease, opacity 0.15s ease;
|
||||
}
|
||||
.module-card.over {
|
||||
border-color: var(--brand, #138a72);
|
||||
}
|
||||
.module-card.hidden {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.module-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 52px;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid var(--n-border-color, #e0e0e6);
|
||||
background: rgba(19, 138, 114, 0.035);
|
||||
}
|
||||
.module-card.collapsed .module-head {
|
||||
border-bottom: none;
|
||||
}
|
||||
.expand-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: #667085;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.18s ease;
|
||||
}
|
||||
.expand-toggle:hover {
|
||||
background: rgba(19, 138, 114, 0.08);
|
||||
}
|
||||
.expand-toggle.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.drag-handle {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: #8b95a5;
|
||||
cursor: grab;
|
||||
}
|
||||
.drag-handle:hover {
|
||||
background: rgba(19, 138, 114, 0.08);
|
||||
}
|
||||
.module-order {
|
||||
width: 22px;
|
||||
color: #98a2b3;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.module-title-input {
|
||||
min-width: 160px;
|
||||
flex: 1;
|
||||
}
|
||||
.module-title-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.visible-label {
|
||||
color: #667085;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.module-actions {
|
||||
display: inline-flex;
|
||||
gap: 2px;
|
||||
}
|
||||
.module-body {
|
||||
padding: 14px;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.module-head {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.module-title-input,
|
||||
.module-title-spacer {
|
||||
order: 2;
|
||||
width: 100%;
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.module-actions {
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -280,7 +280,8 @@
|
||||
"disableConfirmContent": "Disable \"{name}\"? It will no longer be available when creating new artwork files.",
|
||||
"namePlaceholder": "Enter template name",
|
||||
"fieldKeyTip": "Unique English key",
|
||||
"sortHint": "Field order = display order on consumer page; use arrows to reorder",
|
||||
"sortHint": "Field order = display order inside the artwork introduction module; use arrows to reorder",
|
||||
"defaultTraceLayout": "Default Consumer Page Layout",
|
||||
"defaultFields": {
|
||||
"craft": "Craft",
|
||||
"year": "Creation Era / Release Time",
|
||||
@@ -290,6 +291,42 @@
|
||||
"dataOwner": "Data Ownership"
|
||||
}
|
||||
},
|
||||
"traceModules": {
|
||||
"title": "Page Modules",
|
||||
"clientLayout": "Consumer Page Composer",
|
||||
"hint": "Module order matches the consumer page. Configure visibility and titles, or add custom content modules.",
|
||||
"add": "Add Module",
|
||||
"drag": "Drag to reorder modules",
|
||||
"expand": "Expand module content",
|
||||
"collapse": "Collapse module content",
|
||||
"visible": "Visible",
|
||||
"defaultTitle": "Leave empty for default: {title}",
|
||||
"imagePosition": "Image Position",
|
||||
"innerHeading": "Content Heading",
|
||||
"body": "Body",
|
||||
"image": "Image",
|
||||
"templateContentHint": "Templates only save module structure and presentation. Add artwork-specific content after creating the artwork.",
|
||||
"systemDataHint": "This module reads existing artwork data. The template only controls order, visibility and title.",
|
||||
"authenticityHint": "Authenticity status is generated from each consumer query. These options only control presentation and never disable activation, counting or query logs.",
|
||||
"blockchainHint": "This module reads each trace code's on-chain status and transaction details. These options only control presentation.",
|
||||
"types": {
|
||||
"HERO_CAROUSEL": "Hero Carousel",
|
||||
"AUTHENTICITY_STATUS": "Authenticity Status",
|
||||
"PRODUCT_INTRO": "Artwork Introduction",
|
||||
"SHOWCASE": "Artwork Showcase",
|
||||
"CERTIFICATES": "Copyright Certificates",
|
||||
"TIMELINE": "Trace Timeline",
|
||||
"BLOCKCHAIN": "Digital Identity & Blockchain",
|
||||
"IMAGE_TEXT": "Image & Text",
|
||||
"HORIZONTAL_GALLERY": "Horizontal Gallery"
|
||||
},
|
||||
"positions": {
|
||||
"TOP": "Image above",
|
||||
"BOTTOM": "Image below",
|
||||
"LEFT": "Image left (stacked on mobile)",
|
||||
"RIGHT": "Image right (stacked on mobile)"
|
||||
}
|
||||
},
|
||||
"audit": {
|
||||
"status": "Audit Status",
|
||||
"approve": "Approve",
|
||||
|
||||
@@ -280,7 +280,8 @@
|
||||
"disableConfirmContent": "确认停用“{name}”?停用后新建档案时将不能选择该模板。",
|
||||
"namePlaceholder": "请输入模板名称",
|
||||
"fieldKeyTip": "英文唯一标识",
|
||||
"sortHint": "字段顺序即客户端展示顺序,可用上下箭头调整",
|
||||
"sortHint": "字段顺序即作品介绍模块内的展示顺序,可用上下箭头调整",
|
||||
"defaultTraceLayout": "客户端默认页面布局",
|
||||
"defaultFields": {
|
||||
"craft": "工艺",
|
||||
"year": "创作年代 / 出品时间",
|
||||
@@ -290,6 +291,42 @@
|
||||
"dataOwner": "数据权属"
|
||||
}
|
||||
},
|
||||
"traceModules": {
|
||||
"title": "页面模块",
|
||||
"clientLayout": "客户端页面编排",
|
||||
"hint": "模块顺序即客户端展示顺序;可调整显隐、标题并添加自定义内容模块。",
|
||||
"add": "添加模块",
|
||||
"drag": "拖拽调整模块顺序",
|
||||
"expand": "展开模块内容",
|
||||
"collapse": "收起模块内容",
|
||||
"visible": "显示",
|
||||
"defaultTitle": "留空使用默认标题:{title}",
|
||||
"imagePosition": "图文位置",
|
||||
"innerHeading": "内容标题",
|
||||
"body": "正文",
|
||||
"image": "图片",
|
||||
"templateContentHint": "模板仅保存模块结构和展示方式,具体作品内容请在建档后填写。",
|
||||
"systemDataHint": "该模块读取作品现有业务数据,模板只设置顺序、显隐和标题。",
|
||||
"authenticityHint": "防伪状态由消费者每次查询结果自动生成;此处只调整显示位置、显隐和标题,不影响激活、计数与查询日志。",
|
||||
"blockchainHint": "区块链模块自动读取每个追溯码的上链状态和交易信息;此处只调整显示位置、显隐和标题。",
|
||||
"types": {
|
||||
"HERO_CAROUSEL": "顶部作品轮播",
|
||||
"AUTHENTICITY_STATUS": "防伪状态",
|
||||
"PRODUCT_INTRO": "作品介绍",
|
||||
"SHOWCASE": "作品展示",
|
||||
"CERTIFICATES": "版权证书",
|
||||
"TIMELINE": "溯源时间轴",
|
||||
"BLOCKCHAIN": "数字身份与区块链存证",
|
||||
"IMAGE_TEXT": "图文模块",
|
||||
"HORIZONTAL_GALLERY": "横向滚动图区"
|
||||
},
|
||||
"positions": {
|
||||
"TOP": "图片在上",
|
||||
"BOTTOM": "图片在下",
|
||||
"LEFT": "图片在左(移动端转为纵向)",
|
||||
"RIGHT": "图片在右(移动端转为纵向)"
|
||||
}
|
||||
},
|
||||
"audit": {
|
||||
"status": "审核状态",
|
||||
"approve": "通过",
|
||||
|
||||
@@ -78,175 +78,210 @@
|
||||
<n-select
|
||||
v-model:value="form.templateId"
|
||||
:options="templateOptions"
|
||||
:disabled="!isNew"
|
||||
:disabled="!isNew || !auth.canWrite"
|
||||
@update:value="onTemplateChange"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2 m:1" path="title" :label="t('pages.artwork.title')">
|
||||
<n-input v-model:value="form.title" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.artwork.artist')">
|
||||
<n-input v-model:value="form.artist" />
|
||||
<n-input v-model:value="form.title" :disabled="!auth.canWrite" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi v-if="!isNew" span="2 m:1" :label="t('common.label.status')">
|
||||
<n-select v-model:value="form.status" :options="statusOptions" />
|
||||
<n-select v-model:value="form.status" :options="statusOptions" :disabled="!auth.canWrite" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.dynamicFields') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi
|
||||
v-for="f in currentFields"
|
||||
:key="f.fieldKey"
|
||||
span="2 m:1"
|
||||
:label="f.required ? `${f.label} *` : f.label"
|
||||
>
|
||||
<n-date-picker
|
||||
v-if="f.type === 'DATE'"
|
||||
v-model:formatted-value="form.dynamicFields[f.fieldKey]"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="date"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
v-else-if="f.type === 'TEXTAREA'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
/>
|
||||
<n-input-number
|
||||
v-else-if="f.type === 'NUMBER'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
v-else-if="f.type === 'LINK'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
placeholder="https://"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'IMAGE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="image"
|
||||
:max="1"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'FILE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="file"
|
||||
:max="1"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<n-input v-else v-model:value="form.dynamicFields[f.fieldKey]" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.coverMedia') }}</n-divider>
|
||||
<media-sorter v-model="form.images" :max="12" />
|
||||
</n-form>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
|
||||
<!-- 作品展示 -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.showcase')" :bordered="false">
|
||||
<artwork-showcase-editor
|
||||
v-model="form.showcaseImages"
|
||||
:max="30"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.traceModules.clientLayout')" :bordered="false">
|
||||
<trace-module-editor
|
||||
v-model="form.traceLayout"
|
||||
:disabled="!auth.canWrite"
|
||||
>
|
||||
<template #system="{ module }">
|
||||
<media-sorter
|
||||
v-if="module.type === 'HERO_CAROUSEL'"
|
||||
v-model="form.images"
|
||||
:max="12"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
|
||||
<!-- 溯源时间轴 -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.nodes')" :bordered="false">
|
||||
<template #header-extra>
|
||||
<n-space align="center">
|
||||
<n-checkbox v-model:checked="form.showOutboundTimeline" :disabled="!auth.canWrite">
|
||||
{{ t('pages.artwork.showOutboundTimeline') }}
|
||||
</n-checkbox>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openNode()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addNode') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
<n-empty v-if="!nodes.length" :description="t('common.msg.noData')" />
|
||||
<n-timeline v-else>
|
||||
<n-timeline-item v-for="n in nodes" :key="n.id ?? n.localId" type="info" :title="n.title">
|
||||
<template #header>
|
||||
<div class="node-head">
|
||||
<span>{{ t(`common.nodeType.${n.nodeType}`) }} · {{ n.title }}</span>
|
||||
<span v-if="auth.canWrite" class="node-ops">
|
||||
<n-button text size="tiny" @click="openNode(n)">{{ t('common.action.edit') }}</n-button>
|
||||
<n-button text size="tiny" type="error" @click="removeNode(n)">{{ t('common.action.delete') }}</n-button>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
||||
<div>{{ n.description }}</div>
|
||||
<div class="node-media">
|
||||
<template v-for="m in n.media" :key="m.url || m.key">
|
||||
<video
|
||||
v-if="isVideoMedia(m)"
|
||||
:src="mediaUrl(m)"
|
||||
controls
|
||||
preload="metadata"
|
||||
style="max-height: 90px; border-radius: 6px; background: #000"
|
||||
<n-alert
|
||||
v-else-if="module.type === 'AUTHENTICITY_STATUS'"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
>
|
||||
{{ t('pages.traceModules.authenticityHint') }}
|
||||
</n-alert>
|
||||
|
||||
<n-form
|
||||
v-else-if="module.type === 'PRODUCT_INTRO'"
|
||||
label-placement="top"
|
||||
>
|
||||
<n-form-item :label="t('pages.artwork.artist')">
|
||||
<n-input v-model:value="form.artist" :disabled="!auth.canWrite" />
|
||||
</n-form-item>
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.dynamicFields') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi
|
||||
v-for="f in currentFields"
|
||||
:key="f.fieldKey"
|
||||
span="2 m:1"
|
||||
:label="f.required ? `${f.label} *` : f.label"
|
||||
>
|
||||
<n-date-picker
|
||||
v-if="f.type === 'DATE'"
|
||||
v-model:formatted-value="form.dynamicFields[f.fieldKey]"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="date"
|
||||
clearable
|
||||
:disabled="!auth.canWrite"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<img
|
||||
<n-input
|
||||
v-else-if="f.type === 'TEXTAREA'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
<n-input-number
|
||||
v-else-if="f.type === 'NUMBER'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
:disabled="!auth.canWrite"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
v-else-if="f.type === 'LINK'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
:disabled="!auth.canWrite"
|
||||
placeholder="https://"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'IMAGE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="image"
|
||||
:max="1"
|
||||
:disabled="!auth.canWrite"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'FILE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="file"
|
||||
:max="1"
|
||||
:disabled="!auth.canWrite"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<n-input
|
||||
v-else
|
||||
class="node-media-image"
|
||||
:src="mediaUrl(m)"
|
||||
:alt="m.name || n.title"
|
||||
loading="lazy"
|
||||
@click="previewNodeImage(n.media, m)"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</n-timeline-item>
|
||||
</n-timeline>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
</n-form>
|
||||
|
||||
<!-- 版权证书 -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.certificates')" :bordered="false">
|
||||
<template #header-extra>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openCert()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addCert') }}
|
||||
</n-button>
|
||||
<artwork-showcase-editor
|
||||
v-else-if="module.type === 'SHOWCASE'"
|
||||
v-model="form.showcaseImages"
|
||||
:max="30"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
|
||||
<template v-else-if="module.type === 'TIMELINE'">
|
||||
<div class="module-content-toolbar">
|
||||
<n-checkbox v-model:checked="form.showOutboundTimeline" :disabled="!auth.canWrite">
|
||||
{{ t('pages.artwork.showOutboundTimeline') }}
|
||||
</n-checkbox>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openNode()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addNode') }}
|
||||
</n-button>
|
||||
</div>
|
||||
<n-empty v-if="!nodes.length" :description="t('common.msg.noData')" />
|
||||
<n-timeline v-else>
|
||||
<n-timeline-item v-for="n in nodes" :key="n.id ?? n.localId" type="info" :title="n.title">
|
||||
<template #header>
|
||||
<div class="node-head">
|
||||
<span>{{ t(`common.nodeType.${n.nodeType}`) }} · {{ n.title }}</span>
|
||||
<span v-if="auth.canWrite" class="node-ops">
|
||||
<n-button text size="tiny" @click="openNode(n)">{{ t('common.action.edit') }}</n-button>
|
||||
<n-button text size="tiny" type="error" @click="removeNode(n)">{{ t('common.action.delete') }}</n-button>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
||||
<div>{{ n.description }}</div>
|
||||
<div class="node-media">
|
||||
<template v-for="m in n.media" :key="m.url || m.key">
|
||||
<video
|
||||
v-if="isVideoMedia(m)"
|
||||
:src="mediaUrl(m)"
|
||||
controls
|
||||
preload="metadata"
|
||||
style="max-height: 90px; border-radius: 6px; background: #000"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
class="node-media-image"
|
||||
:src="mediaUrl(m)"
|
||||
:alt="m.name || n.title"
|
||||
loading="lazy"
|
||||
@click="previewNodeImage(n.media, m)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</n-timeline-item>
|
||||
</n-timeline>
|
||||
</template>
|
||||
|
||||
<template v-else-if="module.type === 'CERTIFICATES'">
|
||||
<div class="module-content-toolbar">
|
||||
<div />
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openCert()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addCert') }}
|
||||
</n-button>
|
||||
</div>
|
||||
<n-empty v-if="!certs.length" :description="t('common.msg.noData')" />
|
||||
<n-grid v-else :cols="4" :x-gap="12" :y-gap="12" item-responsive responsive="screen">
|
||||
<n-grid-item v-for="c in certs" :key="c.id ?? c.localId" span="2 m:1">
|
||||
<n-card size="small" :title="c.name">
|
||||
<template #cover>
|
||||
<img
|
||||
v-if="c.watermarkUrl || c.originUrl"
|
||||
class="cert-preview-image"
|
||||
:src="certUrl(c)"
|
||||
:alt="c.name"
|
||||
loading="lazy"
|
||||
@click="previewCert(c)"
|
||||
/>
|
||||
<div v-else class="cert-pending">{{ t('pages.artwork.watermarkPending') }}</div>
|
||||
</template>
|
||||
<div class="cert-meta">{{ c.issuer || '-' }}</div>
|
||||
<template #footer>
|
||||
<n-button v-if="auth.canWrite" text size="tiny" type="error" @click="removeCert(c)">
|
||||
{{ t('common.action.delete') }}
|
||||
</n-button>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
</template>
|
||||
|
||||
<n-alert
|
||||
v-else-if="module.type === 'BLOCKCHAIN'"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
>
|
||||
{{ t('pages.traceModules.blockchainHint') }}
|
||||
</n-alert>
|
||||
</template>
|
||||
<n-empty v-if="!certs.length" :description="t('common.msg.noData')" />
|
||||
<n-grid v-else :cols="4" :x-gap="12" :y-gap="12" item-responsive responsive="screen">
|
||||
<n-grid-item v-for="c in certs" :key="c.id ?? c.localId" span="2 m:1">
|
||||
<n-card size="small" :title="c.name">
|
||||
<template #cover>
|
||||
<img
|
||||
v-if="c.watermarkUrl || c.originUrl"
|
||||
class="cert-preview-image"
|
||||
:src="certUrl(c)"
|
||||
:alt="c.name"
|
||||
loading="lazy"
|
||||
@click="previewCert(c)"
|
||||
/>
|
||||
<div v-else class="cert-pending">{{ t('pages.artwork.watermarkPending') }}</div>
|
||||
</template>
|
||||
<div class="cert-meta">{{ c.issuer || '-' }}</div>
|
||||
<template #footer>
|
||||
<n-button v-if="auth.canWrite" text size="tiny" type="error" @click="removeCert(c)">
|
||||
{{ t('common.action.delete') }}
|
||||
</n-button>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</trace-module-editor>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
|
||||
<n-grid-item v-if="!isNew">
|
||||
<n-card :title="t('pages.artwork.changeRecords')" :bordered="false">
|
||||
@@ -349,12 +384,23 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NTag, type DataTableColumns, type FormInst, type FormRules } from 'naive-ui';
|
||||
import { ArrowBackOutline, AddOutline } from '@vicons/ionicons5';
|
||||
import { ArtworkStatus, CertType, NodeType } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkStatus,
|
||||
CertType,
|
||||
cloneTraceLayout,
|
||||
createDefaultTraceLayout,
|
||||
NodeType,
|
||||
parseTraceLayout,
|
||||
resolveTraceLayout,
|
||||
type TraceLayout,
|
||||
type TraceModule,
|
||||
} from '@artveris/shared';
|
||||
import { artworkApi, templateApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import MediaSorter from '@/components/MediaSorter.vue';
|
||||
import ArtworkShowcaseEditor from '@/components/ArtworkShowcaseEditor.vue';
|
||||
import TraceModuleEditor from '@/components/TraceModuleEditor.vue';
|
||||
import { openMediaViewer } from '@/composables/openMediaViewer';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmtDate, fmtSecond } from '@/utils/format';
|
||||
@@ -377,6 +423,7 @@ const form = reactive<any>({
|
||||
dynamicFields: {},
|
||||
images: [],
|
||||
showcaseImages: [],
|
||||
traceLayout: createDefaultTraceLayout(),
|
||||
showOutboundTimeline: false,
|
||||
});
|
||||
const submitReviewForm = reactive({ title: '', reason: '' });
|
||||
@@ -436,8 +483,11 @@ function defaultTraceNodes() {
|
||||
];
|
||||
}
|
||||
|
||||
function onTemplateChange() {
|
||||
function onTemplateChange(templateId?: number | null) {
|
||||
if (templateId !== undefined) form.templateId = templateId;
|
||||
form.dynamicFields = {};
|
||||
const template = templates.value.find((item) => item.id === form.templateId);
|
||||
form.traceLayout = cloneTraceLayout(resolveTraceLayout(template?.defaultTraceLayout));
|
||||
}
|
||||
|
||||
// 动态字段 IMAGE/FILE 适配:dynamicFields 存 url 字符串,MediaUpload 需要 MediaItem[]
|
||||
@@ -515,6 +565,7 @@ function applyArtworkToForm(a: any) {
|
||||
type: 'image',
|
||||
description: m.description || '',
|
||||
}));
|
||||
form.traceLayout = traceLayoutForForm(a.traceLayout);
|
||||
}
|
||||
|
||||
function applySnapshotToForm(snapshot: any) {
|
||||
@@ -526,6 +577,7 @@ function applySnapshotToForm(snapshot: any) {
|
||||
status: snapshot.artwork.status,
|
||||
showOutboundTimeline: snapshot.artwork.showOutboundTimeline ?? false,
|
||||
showcaseImages: snapshot.artwork.showcaseImages ?? [],
|
||||
traceLayout: snapshot.artwork.traceLayout,
|
||||
dynamicFields: snapshot.artwork.dynamicFields,
|
||||
images: snapshot.artwork.images,
|
||||
});
|
||||
@@ -594,6 +646,58 @@ function buildCertPayload() {
|
||||
}));
|
||||
}
|
||||
|
||||
function traceLayoutForForm(value: any): TraceLayout {
|
||||
if (value?.version === 1 && Array.isArray(value.modules)) {
|
||||
return JSON.parse(JSON.stringify(value)) as TraceLayout;
|
||||
}
|
||||
return createDefaultTraceLayout();
|
||||
}
|
||||
|
||||
function traceMediaPayload(item?: any) {
|
||||
if (!item?.key) return undefined;
|
||||
return {
|
||||
key: item.key,
|
||||
name: item.name || undefined,
|
||||
type: 'image' as const,
|
||||
description: item.description || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function buildTraceLayoutPayload(): TraceLayout {
|
||||
const modules = (form.traceLayout?.modules || []).map((module: TraceModule) => {
|
||||
const base: TraceModule = {
|
||||
id: module.id,
|
||||
type: module.type,
|
||||
visible: module.visible === true,
|
||||
...(module.title?.trim() ? { title: module.title.trim() } : {}),
|
||||
};
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config: any = module.config || {};
|
||||
const image = traceMediaPayload(config.image);
|
||||
return {
|
||||
...base,
|
||||
config: {
|
||||
imagePosition: config.imagePosition || 'TOP',
|
||||
...(config.heading?.trim() ? { heading: config.heading.trim() } : {}),
|
||||
...(config.body?.trim() ? { body: config.body.trim() } : {}),
|
||||
...(image ? { image } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config: any = module.config || {};
|
||||
return {
|
||||
...base,
|
||||
config: {
|
||||
items: (config.items || []).map(traceMediaPayload).filter(Boolean),
|
||||
},
|
||||
};
|
||||
}
|
||||
return base;
|
||||
});
|
||||
return parseTraceLayout({ version: 1, modules });
|
||||
}
|
||||
|
||||
async function saveArtwork(asDraft: boolean) {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
@@ -625,6 +729,7 @@ async function saveArtwork(asDraft: boolean) {
|
||||
description: m.description,
|
||||
type: 'image',
|
||||
})),
|
||||
traceLayout: buildTraceLayoutPayload(),
|
||||
revisionTitle: submitReviewForm.title || undefined,
|
||||
revisionReason: submitReviewForm.reason || undefined,
|
||||
traceNodes: buildNodePayload(),
|
||||
@@ -659,6 +764,7 @@ function buildComparableSnapshot() {
|
||||
dynamicFields: normalizeJson(form.dynamicFields || {}),
|
||||
images: normalizeMedia(form.images),
|
||||
showcaseImages: normalizeMedia(form.showcaseImages),
|
||||
traceLayout: buildTraceLayoutPayload(),
|
||||
},
|
||||
traceNodes: nodes.value.map((node, index) => ({
|
||||
nodeType: node.nodeType,
|
||||
@@ -877,6 +983,13 @@ onMounted(async () => {
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
.module-content-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.node-ops {
|
||||
display: inline-flex;
|
||||
gap: 8px;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
v-model:show="showModal"
|
||||
preset="card"
|
||||
:title="editing ? t('pages.template.edit') : t('pages.template.create')"
|
||||
style="width: 720px; max-width: 94vw"
|
||||
style="width: 960px; max-width: 94vw"
|
||||
>
|
||||
<n-form ref="formRef" :model="form" :rules="rules">
|
||||
<n-form-item path="name" :label="t('pages.template.name')">
|
||||
@@ -81,6 +81,12 @@
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-divider>{{ t('pages.template.defaultTraceLayout') }}</n-divider>
|
||||
<trace-module-editor
|
||||
v-model="form.defaultTraceLayout"
|
||||
template-mode
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<div style="text-align: right">
|
||||
@@ -105,7 +111,15 @@ import {
|
||||
ArrowDownOutline,
|
||||
PowerOutline,
|
||||
} from '@vicons/ionicons5';
|
||||
import { FieldType, TemplateStatus } from '@artveris/shared';
|
||||
import {
|
||||
cloneTraceLayout,
|
||||
createDefaultTraceLayout,
|
||||
FieldType,
|
||||
resolveTraceLayout,
|
||||
templateTraceLayout,
|
||||
TemplateStatus,
|
||||
type TraceLayout,
|
||||
} from '@artveris/shared';
|
||||
import { templateApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
@@ -113,6 +127,7 @@ import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
import TraceModuleEditor from '@/components/TraceModuleEditor.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
@@ -130,7 +145,19 @@ const showModal = ref(false);
|
||||
const editing = ref<number | null>(null);
|
||||
const saving = ref(false);
|
||||
const formRef = ref<FormInst | null>(null);
|
||||
const form = reactive<{ name: string; remark: string; status: string; fields: any[] }>({ name: '', remark: '', status: 'ENABLED', fields: [] });
|
||||
const form = reactive<{
|
||||
name: string;
|
||||
remark: string;
|
||||
status: string;
|
||||
fields: any[];
|
||||
defaultTraceLayout: TraceLayout;
|
||||
}>({
|
||||
name: '',
|
||||
remark: '',
|
||||
status: 'ENABLED',
|
||||
fields: [],
|
||||
defaultTraceLayout: createDefaultTraceLayout(),
|
||||
});
|
||||
const rules: FormRules = { name: { required: true, message: () => t('pages.template.namePlaceholder'), trigger: 'blur' } };
|
||||
|
||||
function createDefaultTemplateFields() {
|
||||
@@ -271,6 +298,7 @@ function openCreate() {
|
||||
form.remark = '';
|
||||
form.status = 'ENABLED';
|
||||
form.fields = createDefaultTemplateFields();
|
||||
form.defaultTraceLayout = createDefaultTraceLayout();
|
||||
showModal.value = true;
|
||||
}
|
||||
function openEdit(r: any) {
|
||||
@@ -279,6 +307,7 @@ function openEdit(r: any) {
|
||||
form.remark = r.remark || '';
|
||||
form.status = r.status || 'ENABLED';
|
||||
form.fields = (r.fields || []).map((f: any) => ({ ...f }));
|
||||
form.defaultTraceLayout = cloneTraceLayout(resolveTraceLayout(r.defaultTraceLayout));
|
||||
showModal.value = true;
|
||||
}
|
||||
async function save() {
|
||||
@@ -295,7 +324,12 @@ async function save() {
|
||||
try {
|
||||
// 排序:按当前顺序写 sortOrder
|
||||
const fields = form.fields.map((f, i) => ({ ...f, sortOrder: i }));
|
||||
const payload: any = { name: form.name, remark: form.remark, fields };
|
||||
const payload: any = {
|
||||
name: form.name,
|
||||
remark: form.remark,
|
||||
fields,
|
||||
defaultTraceLayout: templateTraceLayout(form.defaultTraceLayout),
|
||||
};
|
||||
if (editing.value) payload.status = form.status;
|
||||
if (editing.value) {
|
||||
await templateApi.update(editing.value, payload);
|
||||
|
||||
Reference in New Issue
Block a user