版本迭代
This commit is contained in:
260
src/view/CopyProduct.vue
Normal file
260
src/view/CopyProduct.vue
Normal file
@@ -0,0 +1,260 @@
|
||||
<template>
|
||||
<div>
|
||||
<ai-list class="list">
|
||||
<ai-title
|
||||
slot="title"
|
||||
title="商品模板"
|
||||
tips="请先在当前浏览器登录“拼多多跨境卖家中心”,期间保持登录状态"
|
||||
isShowBottomBorder>
|
||||
</ai-title>
|
||||
<template slot="content">
|
||||
<div class="content">
|
||||
<ai-search-bar>
|
||||
<template #left>
|
||||
<el-button type="button" :icon="'el-icon-delete'" :class="'el-button el-button--primary'" @click="remove()">删除</el-button>
|
||||
<el-button v-if="$store.state.mallName" type="button" :class="'el-button el-button--primary'" @click="toAddTemplate()">从“{{$store.state.mallName}}”添加商品模板</el-button>
|
||||
<el-button v-if="$store.state.mallName" type="button" :class="'el-button el-button--primary'" @click="addToDraft()">将商品模板添加到“{{$store.state.mallName}}”草稿箱</el-button>
|
||||
</template>
|
||||
<template #right>
|
||||
<el-button size="small" circle icon="el-icon-refresh-right" @click="getList()"></el-button>
|
||||
</template>
|
||||
</ai-search-bar>
|
||||
<ai-table
|
||||
:tableData="tableData"
|
||||
:col-configs="colConfigs"
|
||||
:total="total"
|
||||
style="margin-top: 8px;"
|
||||
:current.sync="search.current" :size.sync="search.size"
|
||||
@selection-change="handleSelectionChange"
|
||||
@getList="getList">
|
||||
</ai-table>
|
||||
</div>
|
||||
</template>
|
||||
</ai-list>
|
||||
|
||||
<el-dialog
|
||||
title="商品列表"
|
||||
:visible.sync="dlgShow"
|
||||
:close-on-click-modal="false"
|
||||
width="70%"
|
||||
:before-close="handleClose">
|
||||
<ai-table
|
||||
:tableData="productTableData"
|
||||
:col-configs="productColConfigs"
|
||||
:total="productPage.total"
|
||||
:current.sync="productPage.page" :size.sync="productPage.pageSize"
|
||||
style="margin-top: 8px;"
|
||||
@selection-change="productHandleSelectionChange"
|
||||
@getList="getProductList">
|
||||
</ai-table>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dlgShow = false">取 消</el-button>
|
||||
<el-button type="primary" @click="saveProduct">添加到模板</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {sendChromeAPIMessage} from '@/api/chromeApi'
|
||||
import {timestampToTime} from '@/utils/date'
|
||||
import {transform} from '@/utils/product'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
export default {
|
||||
name: 'List',
|
||||
|
||||
data () {
|
||||
return {
|
||||
search: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
productName: '',
|
||||
mallName: '',
|
||||
startDate: '',
|
||||
endDate: ''
|
||||
},
|
||||
colConfigs: [
|
||||
{ type: "selection", width: '70px', align: 'left', fixed: 'left'},
|
||||
{ prop: 'productSpu', label: 'SPU', align: 'left' },
|
||||
{ prop: 'productName', label: '商品名称', align: 'left' },
|
||||
{ prop: 'mallName', label: '来源店铺', align: 'left'},
|
||||
{ prop: 'createTime', label: '添加时间', width: '180px', fixed: 'right'}
|
||||
],
|
||||
tableData: [],
|
||||
total: 0,
|
||||
ids: [],
|
||||
|
||||
dlgShow: false,
|
||||
productTableData: [],
|
||||
productPage: {page: 1, pageSize: 10, total: 0},
|
||||
productColConfigs: [
|
||||
{ type: "selection", width: '70px', align: 'left', fixed: 'left'},
|
||||
{ prop: 'productSpu', label: 'SPU ID', align: 'left' },
|
||||
{ prop: 'productSkc', label: 'SKC ID', align: 'left' },
|
||||
{ prop: 'productName', label: '商品名称', align: 'left' },
|
||||
{ prop: 'createTime', label: '创建时间', align: 'left' }
|
||||
],
|
||||
productIds: [],
|
||||
}
|
||||
},
|
||||
|
||||
created () {
|
||||
this.getList()
|
||||
},
|
||||
|
||||
methods: {
|
||||
getList () {
|
||||
this.$http.post('/api/product/myPage',null,{
|
||||
params: {
|
||||
...this.search
|
||||
}
|
||||
}).then(res => {
|
||||
this.tableData = res.data.records
|
||||
this.total = res.data.total
|
||||
})
|
||||
},
|
||||
remove () {
|
||||
if (this.ids.length <= 0) {
|
||||
alert('请选择要删除的商品');
|
||||
return;
|
||||
}
|
||||
this.$confirm('确定要删除?', '温馨提示', {
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$http.post('/api/product/delByIds',this.ids
|
||||
).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success('删除成功!')
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
this.ids = [];
|
||||
val.forEach(e => {
|
||||
this.ids.push(e.id);
|
||||
});
|
||||
},
|
||||
|
||||
// 添加模板
|
||||
handleClose() {
|
||||
this.productTableData = []
|
||||
this.productPage = {page: 1, pageSize: 10, total: 0}
|
||||
this.dlgShow = false
|
||||
},
|
||||
toAddTemplate() {
|
||||
this.$http.post('/api/malluser/info').then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$store.commit('setUserInfo', res.data)
|
||||
if (res.data.flag != 1) {
|
||||
Message.error('您的账号未激活或已失效,请激活后使用')
|
||||
this.$store.commit('setActiveDlgShow', true)
|
||||
return;
|
||||
}
|
||||
this.dlgShow = true
|
||||
this.getProductList()
|
||||
}
|
||||
})
|
||||
},
|
||||
getProductList() {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/skc/pageQuery',
|
||||
needMallId: true,
|
||||
data: {
|
||||
...this.productPage
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
this.productPage.total = res.result.total
|
||||
this.productTableData = res.result.pageItems.map((item) => {
|
||||
console.log(item.createdAt)
|
||||
return {
|
||||
productSpu: item.productId,
|
||||
productSkc: item.productSkcId,
|
||||
productName: item.productName,
|
||||
createTime: timestampToTime(item.createdAt)
|
||||
};
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
productHandleSelectionChange(val) {
|
||||
this.productIds = [];
|
||||
val.forEach(e => {
|
||||
this.productIds.push(e.productSpu);
|
||||
});
|
||||
},
|
||||
saveProduct() {
|
||||
if (this.productIds.length <= 0) {
|
||||
alert('请选择商品');
|
||||
return;
|
||||
}
|
||||
this.productIds.map((productSpu, index) => {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/query',
|
||||
needMallId: true,
|
||||
data: {
|
||||
productEditTaskUid: '',
|
||||
productId: productSpu
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
let content = transform(res.result)
|
||||
this.$http.post('/api/product/add', {
|
||||
mallName: this.$store.state.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()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
addToDraft() {
|
||||
if (this.ids.length <= 0) {
|
||||
alert('请选择商品模板');
|
||||
return;
|
||||
}
|
||||
this.ids.map((id, index) => {
|
||||
let product = this.tableData.filter((item) => {
|
||||
return item.id == id
|
||||
})
|
||||
setTimeout(() => {
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/add',
|
||||
needMallId: true,
|
||||
data: {
|
||||
catId: 26117
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
let draftId = res.result.productDraftId
|
||||
let content = JSON.parse(product[0].content)
|
||||
content.productDraftId = draftId
|
||||
sendChromeAPIMessage({
|
||||
url: 'bg-visage-mms/product/draft/save',
|
||||
needMallId: true,
|
||||
data: {
|
||||
...content
|
||||
}}).then((res) => {
|
||||
if (res.errorCode == 1000000) {
|
||||
Message.success("商品【" + product[0].productName + "】成功添加到草稿箱")
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 1000*index)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
Reference in New Issue
Block a user