商品复制
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
@close="handleClose">
|
||||
<el-form class="ai-form" :model="form" label-width="120px" ref="form">
|
||||
<el-form-item label="店铺" style="width: 100%;" prop="targetMallId" :rules="[{ required: true, message: '请选择店铺', trigger: 'blur' }]">
|
||||
<el-select style="width: 380px" v-model="form.targetMallId" placeholder="请选择" @change="getCateList">
|
||||
<el-select style="width: 380px" v-model="form.targetMallId" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in $store.state.mallList"
|
||||
:key="item.mallId"
|
||||
@@ -109,8 +109,8 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" style="width: 100%;" prop="targetMallId" :rules="[{ required: true, message: '请选择店铺', trigger: 'blur' }]">
|
||||
<el-cascader style="width: 380px" :props="props"></el-cascader>
|
||||
<el-form-item label="商品分类" style="width: 100%;" prop="targetCatId" :rules="[{ required: true, message: '请选择商品分类', trigger: 'blur' }]">
|
||||
<el-cascader style="width: 380px" v-model="form.targetCatId" :props="props"></el-cascader>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer" slot="footer">
|
||||
@@ -188,7 +188,8 @@ import { Message } from 'element-ui'
|
||||
mallDlgShow: false,
|
||||
productIds: [],
|
||||
form: {
|
||||
targetMallId: ''
|
||||
targetMallId: '',
|
||||
targetCatId: []
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -299,35 +300,37 @@ import { Message } from 'element-ui'
|
||||
return;
|
||||
}
|
||||
this.productIds.map((productSpu, index) => {
|
||||
setTimeout(sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/query',
|
||||
needMallId: true,
|
||||
mallId: this.productPage.mallId,
|
||||
data: {
|
||||
productEditTaskUid: '',
|
||||
productId: productSpu
|
||||
}}).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: res.result.productId,
|
||||
productName: res.result.productName,
|
||||
content: content
|
||||
}).then(res1 => {
|
||||
if (res1.code == 0) {
|
||||
Message.success("商品【" + res.result.productName + "】成功添加为商品模板")
|
||||
if (index == this.productIds.length - 1) {
|
||||
this.getList()
|
||||
setTimeout(() => {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/query',
|
||||
needMallId: true,
|
||||
mallId: this.productPage.mallId,
|
||||
data: {
|
||||
productEditTaskUid: '',
|
||||
productId: productSpu
|
||||
}}).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: res.result.productId,
|
||||
productName: res.result.productName,
|
||||
content: content
|
||||
}).then(res1 => {
|
||||
if (res1.code == 0) {
|
||||
Message.success("商品【" + res.result.productName + "】成功添加为商品模板")
|
||||
if (index == this.productIds.length - 1) {
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}), 200 * index)
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 200 * index)
|
||||
})
|
||||
},
|
||||
beforeAddToDraft() {
|
||||
@@ -350,11 +353,18 @@ import { Message } from 'element-ui'
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
data: {
|
||||
catId: 26117
|
||||
catId: this.form.targetCatId[this.form.targetCatId.length - 1]
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
let draftId = res.result.productDraftId
|
||||
let content = JSON.parse(product[0].content)
|
||||
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
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/save',
|
||||
@@ -367,6 +377,8 @@ import { Message } from 'element-ui'
|
||||
Message.success("商品【" + product[0].productName + "】成功添加到草稿箱")
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Message.error("【拼多多】" + res.errorMsg)
|
||||
}
|
||||
})
|
||||
}, 1000*index)
|
||||
|
||||
Reference in New Issue
Block a user