refactor(ecom-dmb): 商品卡片编辑体验全面优化

- 卡片内编辑改为 Ant Design Input/TextArea 组件,尺寸/字体/换行行为和非编辑态完全一致
- 规格描述→规格名称,成本字段均可编辑
- 商品图片支持点击更换(参考 ProductFormModal 上传逻辑)
- 类目支持 TreeSelect 下拉选择
- 添加/删除规格功能(新增规格保存时由后端创建)
- 进入/退出编辑、增删规格时调用 waterfall.renderer() 触发瀑布流重排
- 解决 contenteditable 光标跳走问题
- 暗色模式全部适配
This commit is contained in:
小蟑螂
2026-04-26 17:36:23 +08:00
parent c1a182093d
commit 066680f054
2 changed files with 1059 additions and 203 deletions
File diff suppressed because it is too large Load Diff
@@ -2,7 +2,7 @@
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
import type { PageQueryDTO } from '#/types/common';
import { onMounted, onUnmounted, ref, watch } from 'vue';
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { Waterfall } from 'vue-waterfall-plugin-next';
import 'vue-waterfall-plugin-next/dist/style.css';
@@ -34,7 +34,6 @@ const props = defineProps<{
}>();
const emit = defineEmits<{
(e: 'edit', product: ProductVO.Info): void;
(e: 'delete', product: ProductVO.Info): void;
(e: 'update:searchForm', value: typeof props.searchForm): void;
}>();
@@ -47,6 +46,7 @@ const current = ref(1);
const pageSize = ref(24); // 无限滚动默认每页24个
const hasMore = ref(true); // 是否还有更多数据
const scrollContainerRef = ref<HTMLElement | null>(null);
const waterfallRef = ref();
// 本地搜索表单副本(用于 v-model)
const localSearchForm = ref({
@@ -169,14 +169,20 @@ const handleScroll = () => {
};
// 事件处理
const handleEdit = (product: ProductVO.Info) => {
emit('edit', product);
};
const handleDelete = (product: ProductVO.Info) => {
emit('delete', product);
};
const handleEditingChange = async () => {
// 等待卡片高度动画完成后再触发瀑布流重排
await nextTick();
// 等待下一个 tick 确保 DOM 已更新
await nextTick();
if (waterfallRef.value) {
waterfallRef.value.renderer();
}
};
// 刷新列表
function refreshTable() {
handleSearch();
@@ -282,6 +288,7 @@ onUnmounted(() => {
<!-- 瀑布流 -->
<Waterfall
v-else-if="productList.length > 0"
ref="waterfallRef"
:list="productList"
row-key="id"
:width="560"
@@ -299,8 +306,9 @@ onUnmounted(() => {
<div class="w-full">
<ProductCard
:product="item"
@edit="handleEdit"
@updated="refreshTable"
@delete="handleDelete"
@editing-change="handleEditingChange"
/>
</div>
</template>