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