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 @@ > 导出数据 - + + 下载模板 + 导入数据 - 同步数据 - - - 商品图库匹配 - + @@ -72,10 +77,11 @@ - - - 自动计算并上架商品 - + 同步数据 + + 批量商品上架 删除配置 - - 下载模板 - - 店铺商品映射 - + --> @@ -149,16 +147,19 @@ :shop-list-data="shopList" @success="handleSuccess" /> + +