From 3754154e2f47f73f810bd2e77803ac9652bd13b7 Mon Sep 17 00:00:00 2001 From: lihaoyuan <18278596806@163.com> Date: Fri, 18 Jul 2025 15:12:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=80=E7=9B=B4=E8=BD=AC=E5=9C=88=E5=9C=88?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=EF=BC=9A=E4=B8=8B=E8=BD=BD=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=92=8C=E5=AF=BC=E5=87=BA=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E6=94=BE=E5=9C=A8=E5=90=8C=E4=B8=80=E4=B8=AA=E5=9C=B0=E6=96=B9?= =?UTF-8?q?=EF=BC=8C=E6=8A=8A=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E9=A1=B9?= =?UTF-8?q?=E7=9A=84"=E4=B8=8B=E8=BD=BD=E6=A8=A1=E6=9D=BF"=E5=92=8C?= =?UTF-8?q?=E2=80=9C=E5=BA=97=E9=93=BA=E5=95=86=E5=93=81=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E2=80=9D=E5=8A=9F=E8=83=BD=E6=8C=89=E9=92=AE=E7=A7=BB=E5=88=B0?= =?UTF-8?q?=E4=BA=86=E4=B8=8A=E6=96=B9=E5=8A=9F=E8=83=BD=E6=A0=8F=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E8=81=94=E8=B0=83=E2=80=9D=E5=90=8C=E6=AD=A5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E2=80=9C=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=9A=84=E2=80=9C=E6=96=B0=E5=A2=9E=E2=80=9D=E5=92=8C?= =?UTF-8?q?=E2=80=9C=E4=BF=AE=E6=94=B9=E2=80=9D=E8=A1=A8=E5=8D=95=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/goodsTool.js | 29 +- src/utils/routes.js | 2 +- .../goodsTool/BatchProductOperation.vue | 119 ++ src/views/product/goodsTool/GoodsItem.vue | 42 +- src/views/product/goodsTool/index.vue | 1581 +---------------- src/views/store/storeConf/DbConfigForm.vue | 21 +- src/views/store/storeConf/index.vue | 4 +- 7 files changed, 212 insertions(+), 1586 deletions(-) create mode 100644 src/views/product/goodsTool/BatchProductOperation.vue diff --git a/src/api/goodsTool.js b/src/api/goodsTool.js index 31116aa..b96a987 100644 --- a/src/api/goodsTool.js +++ b/src/api/goodsTool.js @@ -38,11 +38,11 @@ export async function deleteGoods(data) { }) } -export async function downloadTempGoods(data) { - data = stringify(data) +export async function downloadTempGoods() { return request({ - url: `/admin/shop/shop-sync-productMapper/template?${data}`, + url: '/admin/shop/shop-sync-productMapper/template', method: 'get', + responseType: 'blob', }) } @@ -58,15 +58,18 @@ export async function batchCreateGoods(data) { } export async function batchExportGoods(data) { + const formData = new URLSearchParams(); + data.forEach(id => formData.append('ids', id)); return request({ url: '/admin/shop/shop-sync-productMapper/exportSelected', method: 'post', headers: { - 'Content-Type': 'application/json', - }, - data, - }) -} + 'Content-Type': 'application/x-www-form-urlencoded', + }, + data: formData.toString(), + responseType: 'blob' + }); +} export async function getProductMapping(data) { return request({ @@ -91,20 +94,26 @@ export async function downloadErrorReport(data) { }) } -export async function syncProductMaping() { +export async function syncProductMaping(storeId) { return request({ url: `/admin/shop/shop-sync-productMapper/syncProductMaping`, method: 'put', headers: { 'Content-Type': 'application/json', }, + params:{ + storeId + } }) } export async function importGoodsData(data) { return request({ - url: `/admin/shop/shop-sync-productMapper/importData`, + url: '/admin/shop/shop-sync-productMapper/importData', method: 'post', + headers: { + 'Content-Type': 'multipart/form-data', + }, data, }) } diff --git a/src/utils/routes.js b/src/utils/routes.js index 45ab076..6834801 100644 --- a/src/utils/routes.js +++ b/src/utils/routes.js @@ -33,7 +33,7 @@ export function convertRouter(asyncRoutes) { if (route.meta.title == '店铺' && route.name == 'Vab330') { const obj = { - path: '/goodsTool', + path: '/storeConf', component: '@/views/store/storeConf/index', name: 'Vab88001', redirect: null, diff --git a/src/views/product/goodsTool/BatchProductOperation.vue b/src/views/product/goodsTool/BatchProductOperation.vue new file mode 100644 index 0000000..62ed6ad --- /dev/null +++ b/src/views/product/goodsTool/BatchProductOperation.vue @@ -0,0 +1,119 @@ + + + + diff --git a/src/views/product/goodsTool/GoodsItem.vue b/src/views/product/goodsTool/GoodsItem.vue index 212a51f..8e5ff41 100644 --- a/src/views/product/goodsTool/GoodsItem.vue +++ b/src/views/product/goodsTool/GoodsItem.vue @@ -319,25 +319,33 @@ return } - let res = null - if (this.mode == 'add') { - res = await GoodsToolApi.batchCreateGoods(submitData) - } else { - res = await GoodsToolApi.updateGoods({ - ...submitData?.[0], - id: this.batchForm.items?.[0].id, - }) - } - - if (res.status == 200) { - this.$message.success('操作成功') - } else { - this.loading = false - } + try { + let res = null; + if (this.mode === 'add') { + res = await GoodsToolApi.batchCreateGoods(submitData); } else { - this.$message.error('请完善表单信息') - return false + res = await GoodsToolApi.updateGoods({ + ...submitData[0], + id: this.batchForm.items[0].id, + }); } + + if (res.status === 200) { + this.$message.success('操作成功'); + this.drawerVisible = false; // 关闭抽屉 + } else { + this.$message.error('操作失败: ' + res.msg); + } + } catch (error) { + console.error('提交错误:', error); + this.$message.error('提交时发生错误'); + } finally { + this.loading = false; // 确保无论成功或失败都重置 loading + } + } else { + this.$message.error('请完善表单信息'); + return false; + } }) }, }, diff --git a/src/views/product/goodsTool/index.vue b/src/views/product/goodsTool/index.vue index ffddc1f..94e13d1 100644 --- a/src/views/product/goodsTool/index.vue +++ b/src/views/product/goodsTool/index.vue @@ -38,7 +38,14 @@ > 导出数据 - + + 下载模板 + 导入数据 - 同步数据 - - - 商品图库匹配 - + @@ -149,16 +147,19 @@ :shop-list-data="shopList" @success="handleSuccess" /> + +