新增商品详情md转html
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
@batchMove="openMove"
|
||||
@import="openImport"
|
||||
@imageImport="openImageImport"
|
||||
@detailImport="openDetailImport"
|
||||
@convertContent="convertSelectedContent"
|
||||
@export="handleExport"
|
||||
/>
|
||||
</template>
|
||||
@@ -91,6 +93,11 @@
|
||||
v-model:visible="showImageImport"
|
||||
@done="reload"
|
||||
/>
|
||||
|
||||
<ShopGoodsDetailImport
|
||||
v-model:visible="showDetailImport"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
@@ -114,7 +121,15 @@
|
||||
import Extra from '@/views/shop/shopGoods/components/extra.vue';
|
||||
import ShopGoodsImport from './components/shop-goods-import.vue';
|
||||
import ShopGoodsImageImport from './components/shop-goods-image-import.vue';
|
||||
import { listShopGoods, pageShopGoods, removeShopGoods, removeBatchShopGoods, updateShopGoods } from '@/api/shop/shopGoods';
|
||||
import ShopGoodsDetailImport from './components/shop-goods-detail-import.vue';
|
||||
import {
|
||||
convertMarkdownImagesToHtml,
|
||||
listShopGoods,
|
||||
pageShopGoods,
|
||||
removeShopGoods,
|
||||
removeBatchShopGoods,
|
||||
updateShopGoods
|
||||
} from '@/api/shop/shopGoods';
|
||||
import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import { ShopGoodsCategory } from '@/api/shop/shopGoodsCategory/model';
|
||||
@@ -137,6 +152,8 @@
|
||||
const showImport = ref(false);
|
||||
// 是否显示图片导入弹窗
|
||||
const showImageImport = ref(false);
|
||||
// 是否显示详情导入弹窗
|
||||
const showDetailImport = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
@@ -176,12 +193,12 @@
|
||||
key: 'name',
|
||||
width: 300
|
||||
},
|
||||
// {
|
||||
// title: '编号',
|
||||
// dataIndex: 'code',
|
||||
// key: 'code',
|
||||
// align: 'center',
|
||||
// },
|
||||
{
|
||||
title: '编号',
|
||||
dataIndex: 'code',
|
||||
key: 'code',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '价格',
|
||||
dataIndex: 'price',
|
||||
@@ -273,6 +290,50 @@
|
||||
showImageImport.value = true;
|
||||
};
|
||||
|
||||
/* 打开详情导入弹窗 */
|
||||
const openDetailImport = () => {
|
||||
showDetailImport.value = true;
|
||||
};
|
||||
|
||||
/* 转换选中商品详情Markdown图片为HTML */
|
||||
const convertSelectedContent = () => {
|
||||
const goodsIds = selection.value
|
||||
.map((goods) => goods.goodsId)
|
||||
.filter((goodsId): goodsId is number => goodsId != null);
|
||||
if (!goodsIds.length) {
|
||||
message.error('请至少选择一条商品');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '转换商品详情内容',
|
||||
content: `确定要转换选中的 ${goodsIds.length} 个商品详情内容吗?`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: async () => {
|
||||
const hide = message.loading('正在转换商品详情..', 0);
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
goodsIds.map((goodsId) => convertMarkdownImagesToHtml({ goodsId }))
|
||||
);
|
||||
const total = results.reduce(
|
||||
(sum, item) => sum + (item.data?.total || 0),
|
||||
0
|
||||
);
|
||||
const success = results.reduce(
|
||||
(sum, item) => sum + (item.data?.success || 0),
|
||||
0
|
||||
);
|
||||
hide();
|
||||
message.success(`转换完成,匹配${total}个商品,成功转换${success}个`);
|
||||
reload();
|
||||
} catch (e: any) {
|
||||
hide();
|
||||
message.error(e.message || '转换失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出商品列表 */
|
||||
const handleExport = async () => {
|
||||
if (loading.value) {
|
||||
|
||||
Reference in New Issue
Block a user