调整
This commit is contained in:
@@ -9,10 +9,19 @@
|
||||
<el-form-item v-if="!isMultiCopy" label="商品地址:" style="width: 100%;" prop="url" :rules="[{ required: true, message: '请输入商品地址', trigger: 'blur' }]">
|
||||
<el-input type="textarea" :rows="5" v-model="form.url"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
prop="isSemi"
|
||||
label="是否半托管:"
|
||||
:rules="[{ required: true, message: '请选择是否半托管', trigger: 'blur' }]">
|
||||
<el-radio-group v-model="form.isSemi" size="medium">
|
||||
<el-radio :label="false">否</el-radio>
|
||||
<el-radio :label="true">是</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="店铺:" style="width: 100%;" prop="targetMallId" :rules="[{ required: true, message: '请选择店铺', trigger: 'blur' }]">
|
||||
<el-select style="width: 380px" v-model="form.targetMallId" @change="onMallChange" placeholder="请选择">
|
||||
<el-select style="width: 380px" multiple v-model="form.targetMallId" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in $store.state.mallList"
|
||||
v-for="item in mallList"
|
||||
:key="item.mallId"
|
||||
:label="item.mallName"
|
||||
:value="item.mallId">
|
||||
@@ -136,6 +145,15 @@ export default {
|
||||
siteList: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
mallList () {
|
||||
const filteredData = this.$store.state.mallList.filter(item => {
|
||||
return item.isSemiManagedMall == this.form.isSemi
|
||||
})
|
||||
|
||||
return filteredData
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.getSiteList()
|
||||
if (this.params?.url) {
|
||||
@@ -143,21 +161,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onMallChange() {
|
||||
if (!this.form.targetMallId) {
|
||||
Message.error("请先选择店铺")
|
||||
return
|
||||
}
|
||||
let tempMall = this.$store.state.mallList.filter(item => {
|
||||
return item.mallId == this.form.targetMallId
|
||||
})
|
||||
if (null == tempMall || tempMall.length == 0) {
|
||||
Message.error("请先选择店铺")
|
||||
return
|
||||
} else {
|
||||
this.form.isSemi = tempMall[0].isSemiManagedMall
|
||||
}
|
||||
},
|
||||
getSiteList() {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/config/common/site/query',
|
||||
@@ -250,7 +253,7 @@ export default {
|
||||
})
|
||||
})
|
||||
|
||||
Promise.all(specIds.map(item => this.getSpecIdNew(item).then(res => {
|
||||
/*Promise.all(specIds.map(item => this.getSpecIdNew(item).then(res => {
|
||||
this.sku.forEach(item1 => {
|
||||
item1.specs.forEach(item2 => {
|
||||
if (item2.spec_value == item.spec_value) {
|
||||
@@ -265,7 +268,8 @@ export default {
|
||||
this.createDraft(res.data)
|
||||
}
|
||||
})
|
||||
})
|
||||
})*/
|
||||
this.toCreateDraftNew(specIds)
|
||||
})
|
||||
},
|
||||
async addToDraft() {
|
||||
@@ -319,7 +323,7 @@ export default {
|
||||
})
|
||||
})
|
||||
|
||||
Promise.all(specIds.map(item => this.getSpecId(item).then(res => {
|
||||
/*Promise.all(specIds.map(item => this.getSpecId(item).then(res => {
|
||||
this.sku.forEach(item1 => {
|
||||
item1.specs.forEach(item2 => {
|
||||
if (item2.specValue == item.specValue) {
|
||||
@@ -334,9 +338,9 @@ export default {
|
||||
this.createDraft(res.data)
|
||||
}
|
||||
})
|
||||
})
|
||||
})*/
|
||||
this.toCreateDraft(specIds)
|
||||
} else if (this.form.type == '2') {
|
||||
console.log(1)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -344,7 +348,45 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
async createDraft(data) {
|
||||
async toCreateDraft(specIds) {
|
||||
for (let kk = 0; kk < this.form.targetMallId.length; kk++) {
|
||||
await Promise.all(specIds.map(item => this.getSpecId(item, this.form.targetMallId[kk]).then(res => {
|
||||
this.sku.forEach(item1 => {
|
||||
item1.specs.forEach(item2 => {
|
||||
if (item2.specValue == item.specValue) {
|
||||
item2.specValueId = res.result.specId
|
||||
}
|
||||
})
|
||||
})
|
||||
return 0
|
||||
})))
|
||||
let res = await this.$http.post('/api/copyProduct/translate',{type: 1, goods: this.goods, sku: this.sku, productDetail: this.productDetail})
|
||||
if (res.code == 0) {
|
||||
await this.createDraft(res.data, this.form.targetMallId[kk])
|
||||
}
|
||||
await this.$sleepSync(500)
|
||||
}
|
||||
},
|
||||
async toCreateDraftNew(specIds) {
|
||||
for (let kk = 0; kk < this.form.targetMallId.length; kk++) {
|
||||
await Promise.all(specIds.map(item => this.getSpecIdNew(item, this.form.targetMallId[kk]).then(res => {
|
||||
this.sku.forEach(item1 => {
|
||||
item1.specs.forEach(item2 => {
|
||||
if (item2.spec_value == item.spec_value) {
|
||||
item2.spec_value_id = res.result.specId
|
||||
}
|
||||
})
|
||||
})
|
||||
return 0
|
||||
})))
|
||||
let res = await this.$http.post('/api/copyProduct/translateNew',{type: 1, goods: this.goods, sku: this.sku, productDetail: this.productDetail})
|
||||
if (res.code == 0) {
|
||||
await this.createDraft(res.data, this.form.targetMallId[kk])
|
||||
}
|
||||
await this.$sleepSync(500)
|
||||
}
|
||||
},
|
||||
async createDraft(data, mallId) {
|
||||
let reqData = {}
|
||||
let catId = null;
|
||||
if (this.form.isSameCategory) {
|
||||
@@ -360,7 +402,7 @@ export default {
|
||||
let res = await sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/add',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
mallId: mallId,
|
||||
data: reqData})
|
||||
|
||||
if (res.errorCode == 1000000) {
|
||||
@@ -384,7 +426,7 @@ export default {
|
||||
let res3 = await sendChromeAPIMessage({
|
||||
url: 'bg-anniston-mms/category/template/query',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
mallId: mallId,
|
||||
data: {
|
||||
catId: reqData.catId,
|
||||
productCreateTime: null,
|
||||
@@ -436,50 +478,44 @@ export default {
|
||||
content.personalizationSwitch = 0
|
||||
content.productDraftId = draftId
|
||||
|
||||
this.createProduct(content)
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.createDraft(data)
|
||||
}, 500)
|
||||
await this.createProduct(content, mallId)
|
||||
}
|
||||
},
|
||||
createProduct(content) {
|
||||
async createProduct(content, mallId) {
|
||||
if (this.form.isSemi) {
|
||||
content.productSemiManagedReq = {
|
||||
bindSiteIds: this.form.siteId
|
||||
}
|
||||
}
|
||||
sendChromeAPIMessage({
|
||||
let res = await sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/save',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
mallId: mallId,
|
||||
data: {
|
||||
...content
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
this.successList.push(this.currentUrl)
|
||||
this.saveInfo()
|
||||
if (this.isMultiCopy) {
|
||||
this.currentIndex ++
|
||||
if (this.currentIndex == this.params.urlList.length) {
|
||||
this.isCopying = false
|
||||
this.$emit('onSuccess')
|
||||
MessageBox.alert(`成功添加${this.successList.length}个商品进入草稿箱`)
|
||||
} else {
|
||||
this.currentUrl = this.params.urlList[this.currentIndex]
|
||||
this.execAddToDraft()
|
||||
}
|
||||
} else {
|
||||
}})
|
||||
if (res.errorCode == 1000000) {
|
||||
this.successList.push(this.currentUrl)
|
||||
this.saveInfo(mallId)
|
||||
if (this.isMultiCopy) {
|
||||
this.currentIndex ++
|
||||
if (this.currentIndex == this.params.urlList.length) {
|
||||
this.isCopying = false
|
||||
Message.success("成功添加到草稿箱")
|
||||
this.$emit('onSuccess')
|
||||
MessageBox.alert(`成功添加${this.successList.length}个商品进入草稿箱`)
|
||||
} else {
|
||||
this.currentUrl = this.params.urlList[this.currentIndex]
|
||||
this.execAddToDraft()
|
||||
}
|
||||
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.createProduct(content)
|
||||
}, 500)
|
||||
this.isCopying = false
|
||||
Message.success("成功添加到草稿箱")
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
await this.$sleepSync(1000)
|
||||
this.createProduct(content)
|
||||
}
|
||||
},
|
||||
getSpecIdNew(data) {
|
||||
return sendChromeAPIMessage({
|
||||
@@ -497,11 +533,11 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
getSpecId(data) {
|
||||
getSpecId(data, mallId) {
|
||||
return sendChromeAPIMessage({
|
||||
url: 'bg-anniston-mms/sku/spec/byName/queryOrAdd',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
mallId: mallId,
|
||||
data: {
|
||||
parentSpecId: data.specKeyId,
|
||||
specName: data.specValue
|
||||
@@ -509,13 +545,13 @@ export default {
|
||||
if (res.errorCode == 1000000) {
|
||||
return res
|
||||
} else {
|
||||
this.getSpecId(data)
|
||||
this.getSpecId(data, mallId)
|
||||
}
|
||||
})
|
||||
},
|
||||
saveInfo() {
|
||||
saveInfo(mallId) {
|
||||
let mallInfo = this.$store.state.mallList.filter(item => {
|
||||
return item.mallId == this.form.targetMallId
|
||||
return item.mallId == mallId
|
||||
})
|
||||
this.$http.post('/api/copyProduct/add', {
|
||||
mallId: mallInfo[0].mallId,
|
||||
|
||||
Reference in New Issue
Block a user