更新
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
<template #left>
|
||||
<div class="search-item">
|
||||
<label style="width:90px">店铺:</label>
|
||||
<el-select v-model="productPage.mallId" @change="productTableData = [], productPage.total = 0, productPage.page =1, getProductList()" placeholder="请选择">
|
||||
<el-select v-model="productPage.mallId" @change="productTableData = [], productPage.total = 0, productPage.page =1, getProductOrDraftList()" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in $store.state.mallList"
|
||||
:key="item.mallId"
|
||||
@@ -54,6 +54,21 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label style="width:90px">模板来源:</label>
|
||||
<el-select v-model="productPage.from" @change="productTableData = [], productPage.total = 0, productPage.page =1, getProductOrDraftList()" placeholder="请选择">
|
||||
<el-option
|
||||
key="0"
|
||||
label="商品列表"
|
||||
value="0">
|
||||
</el-option>
|
||||
<el-option
|
||||
key="1"
|
||||
label="草稿箱列表"
|
||||
value="1">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label style="width:90px">SKC:</label>
|
||||
<el-input size="small" placeholder="请输入SKC,多个用,隔开" v-model="productPage.productSkcIds" @keyup.enter.native="productPage.page =1, getProductList()"></el-input>
|
||||
@@ -67,10 +82,11 @@
|
||||
<el-button @click="productPage= {
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
from: '0',
|
||||
productName: '',
|
||||
productSkcIds: ''
|
||||
}, getProductList()">重置</el-button>
|
||||
<el-button type="primary" @click="productPage.page =1, getProductList()">查询</el-button>
|
||||
}, getProductOrDraftList()">重置</el-button>
|
||||
<el-button type="primary" @click="productPage.page =1, getProductOrDraftList()">查询</el-button>
|
||||
</template>
|
||||
</ai-search-bar>
|
||||
<ai-table
|
||||
@@ -80,7 +96,7 @@
|
||||
:current.sync="productPage.page" :size.sync="productPage.pageSize"
|
||||
style="margin-top: 8px;"
|
||||
@selection-change="productHandleSelectionChange"
|
||||
@getList="getProductList">
|
||||
@getList="getProductOrDraftList">
|
||||
</ai-table>
|
||||
</div>
|
||||
</template>
|
||||
@@ -98,7 +114,7 @@
|
||||
width="790px"
|
||||
customFooter
|
||||
@close="handleClose">
|
||||
<el-form class="ai-form" :model="form" label-width="120px" ref="form">
|
||||
<el-form class="ai-form" :model="form" label-width="160px" 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="请选择">
|
||||
<el-option
|
||||
@@ -109,7 +125,16 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" style="width: 100%;" prop="targetCatId" :rules="[{ required: true, message: '请选择商品分类', trigger: 'blur' }]">
|
||||
<el-form-item
|
||||
prop="isSameCategory"
|
||||
label="是否保持相同类目:"
|
||||
:rules="[{ required: true, message: '请选择是否保持相同类目', trigger: 'blur' }]">
|
||||
<el-radio-group v-model="form.isSameCategory" size="medium">
|
||||
<el-radio :label="false">否</el-radio>
|
||||
<el-radio :label="true">是</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!form.isSameCategory" label="商品分类" style="width: 100%;" prop="targetCatId" :rules="[{ required: true, message: '请选择商品分类', trigger: 'blur' }]">
|
||||
<ai-lazy-cascader
|
||||
style="width: 380px"
|
||||
v-model="form.targetCatId"
|
||||
@@ -207,7 +232,7 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
|
||||
dlgShow: false,
|
||||
productTableData: [],
|
||||
productPage: {page: 1, pageSize: 10, mallId: '', productName: '', productSkcIds: '', total: 0},
|
||||
productPage: {page: 1, pageSize: 10, mallId: '', from: '0', productName: '', productSkcIds: '', total: 0},
|
||||
productColConfigs: [
|
||||
{ type: "selection", width: '70px', align: 'left', fixed: 'left'},
|
||||
{ prop: 'productSpu', label: 'SPU ID', align: 'left' },
|
||||
@@ -220,7 +245,8 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
productIds: [],
|
||||
form: {
|
||||
targetMallId: '',
|
||||
targetCatId: []
|
||||
targetCatId: [],
|
||||
isSameCategory: true
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -270,7 +296,7 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
// 添加模板
|
||||
handleClose() {
|
||||
this.productTableData = []
|
||||
this.productPage = {page: 1, pageSize: 10, total: 0}
|
||||
this.productPage = {page: 1, pageSize: 10, from: '0', total: 0}
|
||||
this.dlgShow = false
|
||||
},
|
||||
toAddTemplate() {
|
||||
@@ -283,10 +309,46 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
return;
|
||||
}
|
||||
this.dlgShow = true
|
||||
this.getProductList()
|
||||
this.getProductOrDraftList()
|
||||
}
|
||||
})
|
||||
},
|
||||
getProductOrDraftList() {
|
||||
if (this.productPage.from == '0') {
|
||||
this.getProductList()
|
||||
} else {
|
||||
this.getDraftList()
|
||||
}
|
||||
},
|
||||
getDraftList() {
|
||||
let params = {};
|
||||
params.page = this.productPage.page;
|
||||
params.pageSize = this.productPage.pageSize;
|
||||
if (this.productPage.productName) {
|
||||
params.productName = this.productPage.productName
|
||||
}
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/pageQuery',
|
||||
needMallId: true,
|
||||
mallId: this.productPage.mallId,
|
||||
data: {
|
||||
...params
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
this.productPage.total = res.result.total
|
||||
this.productTableData = res.result.pageItems.map((item) => {
|
||||
return {
|
||||
productSpu: item.productDraftId,
|
||||
productSkc: '',
|
||||
productName: item.productName,
|
||||
createTime: timestampToTime(item.updatedAt)
|
||||
};
|
||||
})
|
||||
} else {
|
||||
this.getDraftList()
|
||||
}
|
||||
});
|
||||
},
|
||||
getProductList() {
|
||||
let params = {};
|
||||
params.page = this.productPage.page;
|
||||
@@ -332,11 +394,15 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
}
|
||||
this.productIds.map((productSpu, index) => {
|
||||
setTimeout(() => {
|
||||
this.saveTemplate(productSpu, index)
|
||||
if (this.productPage.from == '0') {
|
||||
this.saveProductTemplate(productSpu, index)
|
||||
} else {
|
||||
this.saveDraftTemplate(productSpu, index)
|
||||
}
|
||||
}, 200 * index)
|
||||
})
|
||||
},
|
||||
saveTemplate(spu, index) {
|
||||
saveProductTemplate(spu, index) {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/query',
|
||||
needMallId: true,
|
||||
@@ -365,7 +431,39 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.saveTemplate(spu, index)
|
||||
this.saveProductTemplate(spu, index)
|
||||
}
|
||||
})
|
||||
},
|
||||
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,
|
||||
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)
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -383,23 +481,38 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
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]
|
||||
}
|
||||
setTimeout(() => {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/add',
|
||||
needMallId: true,
|
||||
mallId: this.form.targetMallId,
|
||||
data: {
|
||||
catId: this.form.targetCatId[this.form.targetCatId.length - 1]
|
||||
catId: category
|
||||
}}).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'] = ''
|
||||
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
|
||||
sendChromeAPIMessage({
|
||||
@@ -411,6 +524,8 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
Message.success("商品【" + product[0].productName + "】成功添加到草稿箱")
|
||||
} else {
|
||||
Message.error(res.errorMsg)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user