This commit is contained in:
liushiwei
2024-05-25 10:12:50 +08:00
parent 10c5bce468
commit 9253427bcc
5 changed files with 525 additions and 3 deletions

View File

@@ -85,6 +85,11 @@ const router = new VueRouter({
name: 'copyProduct', name: 'copyProduct',
component: () => import('../view/product/CopyProduct.vue') component: () => import('../view/product/CopyProduct.vue')
}, },
{
path: 'draft',
name: 'draft',
component: () => import('../view/product/Draft.vue')
},
{ {
path: 'copyProductShein', path: 'copyProductShein',
name: 'copyProductShein', name: 'copyProductShein',

View File

@@ -139,6 +139,175 @@ export function transform(leftData) {
return JSON.stringify(rightData); return JSON.stringify(rightData);
} }
export function transformSubmitForHalf(leftData, config, draftId) {
let rightData = {};
// 分类
let leftCategory = leftData.categories;
rightData.cat1Id = leftCategory.cat1.catId;
rightData.cat2Id = leftCategory.cat2.catId;
rightData.cat3Id = leftCategory.cat3.catId;
rightData.cat4Id = leftCategory.cat4.catId;
rightData.cat5Id = leftCategory.cat5.catId;
rightData.cat6Id = leftCategory.cat6.catId;
rightData.cat7Id = leftCategory.cat7.catId;
rightData.cat8Id = leftCategory.cat8.catId;
rightData.cat9Id = leftCategory.cat9.catId;
rightData.cat10Id = leftCategory.cat10.catId;
// 普通属性
rightData.productName = leftData.productName;
rightData.materialMultiLanguages = leftData.productLocalExtAttr.materialMultiLanguages;
rightData.productI18nReqs = leftData.productI18nList;
rightData.productPropertyReqs = [];
for (let i = 0; i < leftData.productPropertyList.length; i++) {
rightData.productPropertyReqs.push({
valueUnit: leftData.productPropertyList[i].valueUnit,
propValue: leftData.productPropertyList[i].propValue,
propName: leftData.productPropertyList[i].propName,
refPid: leftData.productPropertyList[i].refPid,
vid: leftData.productPropertyList[i].vid,
controlType: 1,
pid: leftData.productPropertyList[i].pid,
templatePid: leftData.productPropertyList[i].templatePid,
valueExtendInfo: leftData.productPropertyList[i].valueExtendInfo
});
}
// SKC
let rightSkc = [];
let leftSkc = leftData.productSkcList;
let productSpecPropertyReqs = [];
for(let i = 0; i < leftSkc.length; i++) {
let rightSkcItem = {};
rightSkcItem.previewImgUrls = leftSkc[i].previewImgUrls;
rightSkcItem.productSkcCarouselImageI18nReqs = leftSkc[i].productSkcCarouselImageI18nVOList;
rightSkcItem.extCode = leftSkc[i].extCode;
rightSkcItem.mainProductSkuSpecReqs = [
{
"parentSpecId": 0,
"parentSpecName": "",
"specId": 0,
"specName": ""
}
];
rightSkcItem.productSkuReqs = [];
for(let j = 0; j < leftSkc[i].productSkuList.length; j++) {
let leftSkuItem = leftSkc[i].productSkuList[j];
let rightSkuItem = {};
rightSkuItem.thumbUrl = leftSkuItem.thumbUrl;
rightSkuItem.productSkuThumbUrlI18nReqs = leftSkuItem.productSkuThumbUrlI18nVOList;
rightSkuItem.extCode = leftSkuItem.extCode;
rightSkuItem.supplierPrice = leftSkuItem.supplierPrice;
rightSkuItem.currencyType = leftSkuItem.currencyType;
rightSkuItem.productSkuSpecReqs = leftSkuItem.productSkuSpecList;
productSpecPropertyReqs.push({
"parentSpecId": leftSkuItem.productSkuSpecList[0].parentSpecId,
"parentSpecName": leftSkuItem.productSkuSpecList[0].parentSpecName,
"specId": leftSkuItem.productSkuSpecList[0].specId,
"specName": leftSkuItem.productSkuSpecList[0].specName,
"refPid": 0,
"pid": 0,
"templatePid": 0,
"propName": leftSkuItem.productSkuSpecList[0].specName,
"vid": 0,
"propValue": leftSkuItem.productSkuSpecList[0].specName,
"valueUnit": "",
"valueGroupId": 0,
"valueGroupName": "",
"valueExtendInfo": ""
});
rightSkuItem.productSkuId = 0;
rightSkuItem.productSkuWhExtAttrReq = {
"productSkuVolumeReq": leftSkuItem.productSkuWhExtAttr.productSkuVolume,
"productSkuWeightReq": leftSkuItem.productSkuWhExtAttr.productSkuWeight,
"productSkuBarCodeReqs": leftSkuItem.productSkuWhExtAttr.productSkuBarCodes,
"productSkuSensitiveAttrReq": {
"isSensitive": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveAttr.isSensitive,
"sensitiveList": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveAttr.sensitiveList},
"productSkuSensitiveLimitReq": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveLimit,
};
let warehouseStockQuantityReqs = []
for (let k = 0; k < config.wareHouseList.length; k++) {
warehouseStockQuantityReqs.push({
warehouseId: config.wareHouseList[k],
targetStockAvailable: config.stockNumber
})
}
let productSkuStockQuantityReq = {
warehouseStockQuantityReqs: warehouseStockQuantityReqs
}
rightSkuItem.productSkuStockQuantityReq = productSkuStockQuantityReq
rightSkuItem.currencyType = leftSkuItem.currencyType;
rightSkcItem.productSkuReqs.push(rightSkuItem);
}
rightSkcItem.productSkcId = 0;
rightSkc.push(rightSkcItem);
}
rightData.productSkcReqs = rightSkc;
// Spec
rightData.productSpecPropertyReqs = productSpecPropertyReqs;
rightData.carouselImageUrls = leftData.carouselImageUrls;
rightData.carouselImageI18nReqs = leftData.carouselImageI18nVOList;
rightData.materialImgUrl = leftData.materialImgUrl;
rightData.goodsLayerDecorationReqs = leftData.goodsLayerDecorationVOList;
rightData.sizeTemplateIds = !leftData.sizeTemplateIds ? []: leftData.sizeTemplateIds;
rightData.showSizeTemplateIds = !leftData.showSizeTemplateIds ? []: leftData.showSizeTemplateIds;
rightData.goodsModelReqs = !leftData.goodsModelList ? []: leftData.goodsModelList;
rightData.productWhExtAttrReq = {
outerGoodsUrl: leftData.productWhExtAttr.outerGoodsUrl,
productOrigin: {
countryShortName: leftData.productWhExtAttr.productOrigin ? leftData.productWhExtAttr.productOrigin.countryShortName: 'CN'
}
};
rightData.productCarouseVideoReqList = leftData.carouseVideoVOList;
rightData.goodsAdvantageLabelTypes = leftData.goodsAdvantageLabelVOList;
rightData.productDetailVideoReqList = leftData.detailVideoVOList;
rightData.productOuterPackageImageReqs = [];
for (let i = 0;i < leftData.outerPackageImages.length; i++) {
rightData.productOuterPackageImageReqs.push({
imageUrl: leftData.outerPackageImages[i].imageUrl
})
}
if (leftData.productGuideFileI18nList) {
rightData.productGuideFileI18nReqs = leftData.productGuideFileI18nList.map(item => {
return {fileName: item.fileName,
fileUrl: item.fileUrl,
language: item.language,
languages: item.languages}
});
} else {
rightData.productGuideFileI18nReqs = []
}
rightData.productOuterPackageReq = leftData.productWhExtAttr.productOuterPackage;
rightData.sensitiveTransNormalFileReqs = leftData.productWhExtAttr.sensitiveTransNormalFiles;
rightData.productSaleExtAttrReq = {};
rightData.productShipmentReq = {
freightTemplateId: config.freightTemplateId,
shipmentLimitSecond: config.sendGoodsSecond
}
rightData.productSemiManagedReq = {
bindSiteIds: config.siteList
}
let targetRouteList = []
for (let m = 0; m < config.wareHouseList.length; m++) {
targetRouteList.push({
warehouseId: config.wareHouseList[m],
siteIdList: config.siteList
})
}
rightData.productWarehouseRouteReq = {
targetRouteList: targetRouteList
}
rightData.productDraftId = draftId;
return rightData;
}
export function transformAliExpress(content) { export function transformAliExpress(content) {
let template = { let template = {
cat1Id: 0, cat1Id: 0,

View File

@@ -70,6 +70,7 @@
</template> </template>
<el-menu-item index="/productList">商品列表</el-menu-item> <el-menu-item index="/productList">商品列表</el-menu-item>
<el-menu-item index="/copyProduct">商品复制</el-menu-item> <el-menu-item index="/copyProduct">商品复制</el-menu-item>
<el-menu-item index="/draft">草稿箱管理</el-menu-item>
<el-menu-item index="/copyProductShein">商品复制(希音)</el-menu-item> <el-menu-item index="/copyProductShein">商品复制(希音)</el-menu-item>
<!--<el-menu-item index="/copyProductAliExpress">商品复制(速卖通)</el-menu-item>--> <!--<el-menu-item index="/copyProductAliExpress">商品复制(速卖通)</el-menu-item>-->
</el-submenu> </el-submenu>

347
src/view/product/Draft.vue Normal file
View File

@@ -0,0 +1,347 @@
<template>
<div>
<ai-list class="list" v-loading="isLoading" :element-loading-text="loadingText">
<ai-title
slot="title"
title="草稿箱管理"
tips="请先在当前浏览器登录“拼多多跨境卖家中心”,期间保持登录状态"
isShowBottomBorder>
<template #rightBtn>
<div class="title-right">
<div>
<label style="width:90px">店铺</label>
<el-select v-model="mallId" placeholder="请选择" size="small">
<el-option
v-for="item in $store.state.mallList"
:key="item.mallId"
:label="item.mallName"
:value="item.mallId">
</el-option>
</el-select>
</div>
</div>
</template>
</ai-title>
<template slot="content">
<div class="content">
<ai-search-bar>
<template #left>
<el-button v-if="$store.state.mallName" type="button" :class="'el-button el-button--primary'" @click="batchSubmitConfig()">批量提交</el-button>
</template>
<template #right>
<label style="width:120px">商品名称</label>
<el-input clearable size="small" style="display: inline" placeholder="请输入商品名称" v-model="search.productName"></el-input>
<el-button type="primary" @click="toLoad">查询</el-button>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
style="margin-top: 8px;"
@selection-change="handleSelectionChange"
:isShowPagination="false">
</ai-table>
</div>
</template>
</ai-list>
<ai-dialog
title="配置参数"
:visible.sync="dlgShow"
:close-on-click-modal="false"
width="790px"
customFooter
@close="handleClose">
<el-form class="ai-form" :model="configForm" label-width="160px" ref="configForm">
<el-form-item label="运费模板" style="width: 100%;" prop="freightTemplateId" :rules="[{ required: true, message: '请选择运费模板', trigger: 'blur' }]">
<el-select style="width: 380px" v-model="configForm.freightTemplateId" placeholder="请选择运费模板">
<el-option
v-for="item in freightTmplList"
:key="item.freightTemplateId"
:label="item.templateName"
:value="item.freightTemplateId">
</el-option>
</el-select>
</el-form-item>
<el-form-item
prop="stockNumber"
label="库存数量:"
:rules="[{ required: true, message: '请输入库存数量', trigger: 'blur' }]">
<el-input size="small" placeholder="请输入库存数量" type="number" v-model="configForm.stockNumber"></el-input>
</el-form-item>
<el-form-item label="发货仓" style="width: 100%;" prop="wareHouseList" :rules="[{ required: true, message: '请选择发货仓', trigger: 'blur' }]">
<el-select style="width: 380px" multiple v-model="configForm.wareHouseList" placeholder="请选择发货仓">
<el-option
v-for="item in wareHouseList"
:key="item.warehouseId"
:label="item.warehouseName"
:value="item.warehouseId">
</el-option>
</el-select>
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="dlgShow = false"> </el-button>
<el-button type="primary" @click="toBtachSubmit">确定</el-button>
</div>
</ai-dialog>
</div>
</template>
<script>
import {sendChromeAPIMessage} from '@/api/chromeApi'
import {timestampToTime} from '@/utils/date'
import {transform, transformSubmitForHalf} from '@/utils/product'
import { Message } from 'element-ui'
export default {
name: 'CopyProduct',
data () {
return {
mallId: '',
search: {
productName: ''
},
colConfigs: [
{ type: "selection", width: '70px', align: 'left', fixed: 'left'},
{ prop: 'spuId', label: 'SPU ID', width: '100px', align: 'left' },
{ prop: 'productName', label: '商品名称', align: 'left' },
{ prop: 'category', label: '商品分类', align: 'left'},
{ prop: 'bindSites', label: '经营站点', width: '120px', align: 'left'},
{ prop: 'updatedAt', label: '修改时间', width: '180px', fixed: 'right'}
],
isLoading: false,
page: 1,
pageSize: 100,
tableData: [],
total: 0,
dlgShow: false,
configForm: {
sendGoodsSecond: 172800,
freightTemplateId: '',
stockNumber: 5,
siteList: [],
wareHouseList: []
},
wareHouseList: [],
freightTmplList: [],
ids: [],
sites: [],
loadingText: '拼命加载中……'
}
},
created () {
// this.getDraftList()
},
methods: {
toLoad() {
if (!this.mallId) {
Message.error("请选择店铺")
return
}
this.isLoading = true
this.loadingText = '拼命加载中……'
this.getDraftList()
},
async getDraftList () {
let res = await sendChromeAPIMessage({
url: 'bg-visage-mms/product/draft/pageQuery',
needMallId: true,
mallId: this.mallId,
data: {
page: this.page,
pageSize: this.pageSize,
...this.search
}})
if (res.success && res.errorCode == 1000000) {
res.result.pageItems.map(item => {
let category = ''
for (let i = 1; i < 11; i++) {
if (item.categories['cat'+i].catName) {
category += '->' + item.categories['cat'+i].catName
} else {
break
}
}
category = category.substring(2)
let site = []
let siteId = []
item.copyFromFullyToSemiInfo.bindSites.map(item1 => {
site.push(item1.siteName)
siteId.push(item1.siteId)
})
this.tableData.push({
spuId: item.productDraftId,
productName: item.productName,
category: category,
bindSites: site.join(','),
bindSiteIds: siteId.join(','),
updatedAt: timestampToTime(item.updatedAt)
})
})
if (this.page == 1 && res.result.pageItems.length == 0) {
this.isLoading = false
}
else if (res.result.pageItems.length == this.pageSize) {
this.page ++
this.getDraftList()
} else {
this.isLoading = false
}
}
},
async batchSubmitConfig() {
if (this.ids.length <= 0) {
Message.error('请选择要提交的商品');
return;
}
let id = this.ids[0]
this.sites = []
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].spuId == id) {
this.sites = this.tableData[i].bindSiteIds.split(',')
}
}
this.configForm.siteList = this.sites
await this.getFreightTmplList(this.sites)
await this.getWareahouseList(this.sites)
this.dlgShow = true
},
async toBtachSubmit() {
this.$refs.configForm.validate((valid) => {
if (valid) {
this.isLoading = true
this.dlgShow = false
for(let i = 0; i < this.ids.length; i++) {
this.loadingText = '正在提交第' + (i+1) + '/' + this.ids.length + '个商品'
this.submitSpu(this.ids[i])
}
this.isLoading = false
}
})
},
async submitSpu(spuId) {
let res = await sendChromeAPIMessage({
url: 'bg-visage-mms/product/draft/query',
needMallId: true,
mallId: this.mallId,
data: {
productDraftId: spuId
}})
if (res.success && res.errorCode == 1000000) {
let content = transformSubmitForHalf(res.result, this.configForm, spuId)
let res1 = await sendChromeAPIMessage({
url: 'bg-visage-mms/product/add',
needMallId: true,
mallId: this.mallId,
data: content})
console.log(res1)
}
},
async getFreightTmplList(siteId) {
let res = await sendChromeAPIMessage({
url: 'bg-visage-mms/freight/template/list',
needMallId: true,
mallId: this.mallId,
data: {
siteIds: siteId
}})
if (res.success && res.errorCode == 1000000) {
res.result.freightTmplSimpleList.map(item => {
this.freightTmplList.push({
freightTemplateId: item.freightTemplateId,
templateName: item.templateName
})
})
}
},
async getWareahouseList(siteId) {
let res = await sendChromeAPIMessage({
url: 'marvel-mms/cn/api/kiana/starlaod/btg/sales/stock/querySiteCanSelectWarehouseList',
needMallId: true,
mallId: this.mallId,
data: {
siteIdList: siteId
}})
if (res.success && res.errorCode == 1000000) {
res.result.warehouseDTOList.map(item => {
item.validWarehouseList.map(item1 => {
this.wareHouseList.push({
warehouseId: item1.warehouseId,
warehouseName: item1.warehouseName
})
})
})
}
},
handleSelectionChange(val) {
this.ids = [];
val.forEach(e => {
this.ids.push(e.spuId);
});
},
saveDraftTemplate(spu, index) {
sendChromeAPIMessage({
url: 'bg-visage-mms/product/draft/query',
needMallId: true,
mallId: this.productPage.mallId,
data: {
productDraftId: spu
}}).then((res) => {
if (res.errorCode == 1000000) {
let content = transform(res.result)
let mallInfo = this.$store.state.mallList.filter(item => {
return item.mallId == this.productPage.mallId
})
this.$http.post('/api/product/add', {
mallId: mallInfo[0].mallId,
mallName: mallInfo[0].mallName,
productSpu: spu,
productName: res.result.productName,
type: 0,
content: content
}).then(res1 => {
if (res1.code == 0) {
Message.success("商品【" + res.result.productName + "】成功添加为商品模板")
if (index == this.productIds.length - 1) {
this.getList()
}
}
})
} else {
this.saveDraftTemplate(spu, index)
}
})
},
async getSiteList() {
let res = await sendChromeAPIMessage({
url: 'bg-visage-mms/config/common/site/query',
needMallId: true,
mallId: this.$store.state.mallList[0].mallId,
data: {}})
if (res.success && res.errorCode == 1000000) {
this.siteList = res.result.siteBaseList.filter(item => {
return item.matchSemiManaged
})
}
},
}
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -19,7 +19,7 @@
<!--<el-button type="primary" :disabled="isBegin" @click="isShow = true">添加备货单</el-button> <!--<el-button type="primary" :disabled="isBegin" @click="isShow = true">添加备货单</el-button>
<el-button type="primary" :disabled="isBegin" @click="loadAll">一键加载全部</el-button>--> <el-button type="primary" :disabled="isBegin" @click="loadAll">一键加载全部</el-button>-->
</el-dropdown> </el-dropdown>
<el-button v-if="!isBegin" type="button" :class="'el-button el-button--primary'" @click="beginCreateConfirm">开始创建</el-button> <el-button v-if="!isBegin" type="button" :class="'el-button el-button--primary'" @click="beginCreate">开始创建</el-button>
<el-button v-else type="button" :icon="isBegin? 'el-icon-loading': ''" :class="isBegin ? 'el-button el-button--danger': 'el-button el-button--primary'" @click="beginCreate()">{{ `结束创建(${choosedList.length}/${createTotal})` }}</el-button> <el-button v-else type="button" :icon="isBegin? 'el-icon-loading': ''" :class="isBegin ? 'el-button el-button--danger': 'el-button el-button--primary'" @click="beginCreate()">{{ `结束创建(${choosedList.length}/${createTotal})` }}</el-button>
</template> </template>
@@ -68,7 +68,7 @@
<el-table-column slot="options" label="操作" width="80px" v-if="!isBegin" show-overflow-tooltip align="center" fixed="right"> <el-table-column slot="options" label="操作" width="80px" v-if="!isBegin" show-overflow-tooltip align="center" fixed="right">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<div class="table-options"> <div class="table-options">
<el-button type="text" @click="remove(row.subPurchaseOrderBasicVO.subPurchaseOrderSn)">移除</el-button> <el-button type="text" @click="remove(row.subPurchaseOrderSn)">移除</el-button>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@@ -344,7 +344,7 @@
this.isBegin = true; this.isBegin = true;
this.choosedList.map((data, index) => { this.choosedList.map((data, index) => {
let deliverOrderDetailInfos = data.orderDetailVOList.map(item => { let deliverOrderDetailInfos = data.skuQuantityDetailList.map(item => {
if (this.robForm.isModifyMaxNum) { if (this.robForm.isModifyMaxNum) {
return { return {
productSkuId: item.productSkuId, productSkuId: item.productSkuId,