调整
This commit is contained in:
@@ -116,10 +116,19 @@
|
||||
customFooter
|
||||
@close="handleClose">
|
||||
<el-form class="ai-form" :model="form" label-width="160px" ref="form">
|
||||
<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 multiple style="width: 380px" 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">
|
||||
@@ -264,6 +273,15 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
siteList: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
mallList () {
|
||||
const filteredData = this.$store.state.mallList.filter(item => {
|
||||
return item.isSemiManagedMall == this.form.isSemi
|
||||
})
|
||||
|
||||
return filteredData
|
||||
}
|
||||
},
|
||||
|
||||
created () {
|
||||
this.getList()
|
||||
@@ -297,21 +315,6 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
}
|
||||
})
|
||||
},
|
||||
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
|
||||
}
|
||||
},
|
||||
remove () {
|
||||
if (this.ids.length <= 0) {
|
||||
alert('请选择要删除的商品');
|
||||
@@ -522,76 +525,82 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
addToDraft() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.ids.map((id, index) => {
|
||||
let product = this.tableData.filter((item) => {
|
||||
return item.id == id
|
||||
})
|
||||
let content = JSON.parse(product[0].content)
|
||||
let category = null
|
||||
if (this.form.isSameCategory) {
|
||||
let i = 1
|
||||
while(true) {
|
||||
if (!content['cat'+i+'Id']) {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
category = content['cat'+(i-1)+'Id']
|
||||
} else {
|
||||
category = this.form.targetCatId[this.form.targetCatId.length - 1]
|
||||
}
|
||||
let data = {catId: category}
|
||||
if (this.form.isSemi) {
|
||||
data.productSemiManagedReq = {
|
||||
bindSiteIds: this.form.siteId
|
||||
}
|
||||
}
|
||||
content.personalizationSwitch = content.personalizationSwitch || 0
|
||||
setTimeout(() => {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/add',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
data: data}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
let draftId = res.result.productDraftId
|
||||
if (!this.form.isSameCategory) {
|
||||
let i = 0
|
||||
for (; i < this.form.targetCatId.length; i++) {
|
||||
content['cat' + (i+1) + 'Id'] = this.form.targetCatId[i]
|
||||
}
|
||||
for (; i < 10; i++) {
|
||||
content['cat' + (i+1) + 'Id'] = ''
|
||||
}
|
||||
}
|
||||
content.productDraftId = draftId
|
||||
if (this.form.isSemi) {
|
||||
content.productSemiManagedReq = {
|
||||
bindSiteIds: this.form.siteId
|
||||
}
|
||||
}
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/save',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
data: {
|
||||
...content
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
Message.success("商品【" + product[0].productName + "】成功添加到草稿箱")
|
||||
} else {
|
||||
Message.error(res.errorMsg)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Message.error("【拼多多】" + res.errorMsg)
|
||||
}
|
||||
})
|
||||
}, 1000*index)
|
||||
})
|
||||
this.beginAddToDraft()
|
||||
|
||||
this.mallDlgShow = false
|
||||
}
|
||||
})
|
||||
},
|
||||
async beginAddToDraft() {
|
||||
for (let xx = 0 ; xx < this.ids.length; xx++) {
|
||||
let id = this.ids[xx]
|
||||
let product = this.tableData.filter((item) => {
|
||||
return item.id == id
|
||||
})
|
||||
let content = JSON.parse(product[0].content)
|
||||
let category = null
|
||||
if (this.form.isSameCategory) {
|
||||
let i = 1
|
||||
while(true) {
|
||||
if (!content['cat'+i+'Id']) {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
category = content['cat'+(i-1)+'Id']
|
||||
} else {
|
||||
category = this.form.targetCatId[this.form.targetCatId.length - 1]
|
||||
}
|
||||
let data = {catId: category}
|
||||
if (this.form.isSemi) {
|
||||
data.productSemiManagedReq = {
|
||||
bindSiteIds: this.form.siteId
|
||||
}
|
||||
}
|
||||
content.personalizationSwitch = content.personalizationSwitch || 0
|
||||
|
||||
for (let kk = 0; kk < this.form.targetMallId.length; kk++) {
|
||||
let res = await sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/add',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId[kk],
|
||||
data: data})
|
||||
if (res.errorCode == 1000000) {
|
||||
let draftId = res.result.productDraftId
|
||||
if (!this.form.isSameCategory) {
|
||||
let i = 0
|
||||
for (; i < this.form.targetCatId.length; i++) {
|
||||
content['cat' + (i+1) + 'Id'] = this.form.targetCatId[i]
|
||||
}
|
||||
for (; i < 10; i++) {
|
||||
content['cat' + (i+1) + 'Id'] = ''
|
||||
}
|
||||
}
|
||||
content.productDraftId = draftId
|
||||
if (this.form.isSemi) {
|
||||
content.productSemiManagedReq = {
|
||||
bindSiteIds: this.form.siteId
|
||||
}
|
||||
}
|
||||
let res1 = await sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/save',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId[kk],
|
||||
data: {
|
||||
...content
|
||||
}})
|
||||
if (res1.errorCode == 1000000) {
|
||||
Message.success("商品【" + product[0].productName + "】成功添加到草稿箱")
|
||||
} else {
|
||||
Message.error(res1.errorMsg)
|
||||
}
|
||||
} else {
|
||||
Message.error("【拼多多】" + res.errorMsg)
|
||||
}
|
||||
|
||||
await this.$sleepSync(500)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user