diff --git a/src/api/mall/product/management/spu.ts b/src/api/mall/product/management/spu.ts index 007963bb..2aa83e7a 100644 --- a/src/api/mall/product/management/spu.ts +++ b/src/api/mall/product/management/spu.ts @@ -5,6 +5,10 @@ import type { SpuType } from './type/spuType' export const getSpuList = (params: any) => { return request.get({ url: '/product/spu/page', params }) } +// 获得spu列表tabsCount +export const getTabsCount = () => { + return request.get({ url: '/product/spu/tabsCount' }) +} // 创建商品spu export const createSpu = (data: SpuType) => { return request.post({ url: '/product/spu/create', data }) @@ -13,7 +17,15 @@ export const createSpu = (data: SpuType) => { export const updateSpu = (data: SpuType) => { return request.put({ url: '/product/spu/update', data }) } +// 更新商品spu status +export const updateStatus = (data: { id: number; status: number }) => { + return request.put({ url: '/product/spu/updateStatus', data }) +} // 获得商品spu export const getSpu = (id: number) => { return request.get({ url: `/product/spu/get-detail?id=${id}` }) } +// 删除商品Spu +export const deleteSpu = (id: number) => { + return request.delete({ url: `/product/spu/delete?id=${id}` }) +} diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 5cda391f..597064ee 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -220,3 +220,20 @@ export const PayRefundStatusEnum = { name: '退款关闭' } } +/** + * 商品SPU枚举类 + */ +export const ProductSpuStatusEnum = { + RECYCLE: { + status: -1, + name: '回收站' + }, + DISABLE: { + status: 0, + name: '下架' + }, + ENABLE: { + status: 1, + name: '上架' + } +} diff --git a/src/views/mall/product/management/addForm.vue b/src/views/mall/product/management/addForm.vue index 27f8a8ae..7f31871f 100644 --- a/src/views/mall/product/management/addForm.vue +++ b/src/views/mall/product/management/addForm.vue @@ -144,7 +144,7 @@ const getDetail = async () => { const submitForm = async () => { // 提交请求 formLoading.value = true - const newSkus = [...formData.value.skus] //复制一份skus保存失败时使用 + const newSkus = JSON.parse(JSON.stringify(formData.value.skus)) //深拷贝一份skus保存失败时使用 // TODO 三个表单逐一校验,如果有一个表单校验不通过则切换到对应表单,如果有两个及以上的情况则切换到最前面的一个并弹出提示消息 // 校验各表单 try { @@ -184,9 +184,12 @@ const submitForm = async () => { await managementApi.updateSpu(data) message.success(t('common.updateSuccess')) } + close() } catch (e) { - console.log(e) - console.log(newSkus) + // 如果是后端校验失败,恢复skus数据 + if (typeof e === 'string') { + formData.value.skus = newSkus + } } finally { formLoading.value = false } diff --git a/src/views/mall/product/management/components/OtherSettingsForm.vue b/src/views/mall/product/management/components/OtherSettingsForm.vue index 4469962d..bd0ca26d 100644 --- a/src/views/mall/product/management/components/OtherSettingsForm.vue +++ b/src/views/mall/product/management/components/OtherSettingsForm.vue @@ -117,6 +117,7 @@ watch( (data) => { if (!data) return copyValueToTarget(formData.value, data) + // TODO 如果先修改其他设置的值,再改变商品详情或是商品信息会重置其他设置页面中的相关值 下一个版本修复 checkboxGroup.value = [] formData.value.recommendHot ? checkboxGroup.value.push('recommendHot') : '' formData.value.recommendBenefit ? checkboxGroup.value.push('recommendBenefit') : '' diff --git a/src/views/mall/product/management/components/SkuList.vue b/src/views/mall/product/management/components/SkuList.vue index 2a7441cc..3311202a 100644 --- a/src/views/mall/product/management/components/SkuList.vue +++ b/src/views/mall/product/management/components/SkuList.vue @@ -206,9 +206,6 @@ const generateTableData = (data: any[]) => { } const buildList = build(propertiesItemList) // 如果构建后的组合数跟sku数量一样的话则不用处理,添加新属性没有属性值也不做处理 (解决编辑表单时或查看详情时数据回显问题) - console.log( - buildList.length === formData.value.skus.length || data.some((item) => item.values.length === 0) - ) if ( buildList.length === formData.value.skus.length || data.some((item) => item.values.length === 0) diff --git a/src/views/mall/product/management/index.vue b/src/views/mall/product/management/index.vue index f2e480f5..7b5fb0c1 100644 --- a/src/views/mall/product/management/index.vue +++ b/src/views/mall/product/management/index.vue @@ -57,39 +57,38 @@ - + - - - + + + + + + + + + + + + + + + + @@ -108,9 +107,9 @@