2023-08-06 16:50:17 +08:00
|
|
|
|
<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>
|
2023-08-08 02:01:34 +08:00
|
|
|
|
<el-button v-if="$store.state.mallName" type="button" :class="'el-button el-button--primary'" @click="toAddTemplate()">添加商品模板</el-button>
|
|
|
|
|
|
<el-button v-if="$store.state.mallName" type="button" :class="'el-button el-button--primary'" @click="beforeAddToDraft">添加到草稿箱</el-button>
|
2023-08-06 16:50:17 +08:00
|
|
|
|
</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"
|
2024-07-18 14:48:44 +08:00
|
|
|
|
height="700"
|
2023-08-06 16:50:17 +08:00
|
|
|
|
@getList="getList">
|
|
|
|
|
|
</ai-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</ai-list>
|
|
|
|
|
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
|
|
title="商品列表"
|
|
|
|
|
|
:visible.sync="dlgShow"
|
|
|
|
|
|
:close-on-click-modal="false"
|
2023-08-08 02:01:34 +08:00
|
|
|
|
width="80%"
|
2023-08-06 16:50:17 +08:00
|
|
|
|
:before-close="handleClose">
|
2023-08-08 02:01:34 +08:00
|
|
|
|
<ai-list class="list">
|
|
|
|
|
|
<template slot="content">
|
|
|
|
|
|
<div class="content">
|
|
|
|
|
|
<ai-search-bar>
|
|
|
|
|
|
<template #left>
|
|
|
|
|
|
<div class="search-item">
|
|
|
|
|
|
<label style="width:90px">店铺:</label>
|
2023-11-24 01:04:54 +08:00
|
|
|
|
<el-select v-model="productPage.mallId" @change="productTableData = [], productPage.total = 0, productPage.page =1, getProductOrDraftList()" placeholder="请选择">
|
2023-08-08 02:01:34 +08:00
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in $store.state.mallList"
|
|
|
|
|
|
:key="item.mallId"
|
|
|
|
|
|
:label="item.mallName"
|
|
|
|
|
|
:value="item.mallId">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
2023-11-24 01:04:54 +08:00
|
|
|
|
<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>
|
2023-08-08 02:01:34 +08:00
|
|
|
|
<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>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="search-item">
|
|
|
|
|
|
<label style="width:90px">商品名称:</label>
|
|
|
|
|
|
<el-input size="small" placeholder="请输入商品名称" v-model="productPage.productName" @keyup.enter.native="productPage.page =1, getProductList()"></el-input>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #right>
|
|
|
|
|
|
<el-button @click="productPage= {
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
pageSize: 10,
|
2023-11-24 01:04:54 +08:00
|
|
|
|
from: '0',
|
2023-08-08 02:01:34 +08:00
|
|
|
|
productName: '',
|
|
|
|
|
|
productSkcIds: ''
|
2023-11-24 01:04:54 +08:00
|
|
|
|
}, getProductOrDraftList()">重置</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="productPage.page =1, getProductOrDraftList()">查询</el-button>
|
2023-08-08 02:01:34 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</ai-search-bar>
|
|
|
|
|
|
<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"
|
2023-11-24 01:04:54 +08:00
|
|
|
|
@getList="getProductOrDraftList">
|
2023-08-08 02:01:34 +08:00
|
|
|
|
</ai-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</ai-list>
|
2023-08-06 16:50:17 +08:00
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
|
|
<el-button @click="dlgShow = false">取 消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="saveProduct">添加到模板</el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-dialog>
|
2023-08-08 02:01:34 +08:00
|
|
|
|
|
2023-08-13 21:35:09 +08:00
|
|
|
|
<ai-dialog
|
2023-08-08 02:01:34 +08:00
|
|
|
|
title="请选择店铺"
|
|
|
|
|
|
:visible.sync="mallDlgShow"
|
|
|
|
|
|
:close-on-click-modal="false"
|
2023-08-13 21:21:27 +08:00
|
|
|
|
width="790px"
|
2023-08-13 21:35:09 +08:00
|
|
|
|
customFooter
|
|
|
|
|
|
@close="handleClose">
|
2023-11-24 01:04:54 +08:00
|
|
|
|
<el-form class="ai-form" :model="form" label-width="160px" ref="form">
|
2023-08-08 02:01:34 +08:00
|
|
|
|
<el-form-item label="店铺" style="width: 100%;" prop="targetMallId" :rules="[{ required: true, message: '请选择店铺', trigger: 'blur' }]">
|
2024-02-23 10:29:39 +08:00
|
|
|
|
<el-select style="width: 380px" v-model="form.targetMallId" @change="onMallChange" placeholder="请选择">
|
2023-08-08 02:01:34 +08:00
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in $store.state.mallList"
|
|
|
|
|
|
:key="item.mallId"
|
|
|
|
|
|
:label="item.mallName"
|
|
|
|
|
|
:value="item.mallId">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2024-02-23 10:29:39 +08:00
|
|
|
|
<el-form-item v-if="form.isSemi" label="经营站点" style="width: 100%;" prop="siteId" :rules="[{ required: true, message: '请选择经营站点', trigger: 'blur' }]">
|
|
|
|
|
|
<el-select style="width: 380px" multiple v-model="form.siteId" placeholder="请选择">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in siteList"
|
|
|
|
|
|
:key="item.siteId"
|
|
|
|
|
|
:label="item.siteName"
|
|
|
|
|
|
:value="item.siteId">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2023-11-24 01:04:54 +08:00
|
|
|
|
<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' }]">
|
2023-10-25 12:20:10 +08:00
|
|
|
|
<ai-lazy-cascader
|
|
|
|
|
|
style="width: 380px"
|
|
|
|
|
|
v-model="form.targetCatId"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
:props="props"></ai-lazy-cascader>
|
2023-08-13 21:21:27 +08:00
|
|
|
|
</el-form-item>
|
2023-08-08 02:01:34 +08:00
|
|
|
|
</el-form>
|
2023-08-13 21:35:09 +08:00
|
|
|
|
<div class="dialog-footer" slot="footer">
|
2023-08-08 02:01:34 +08:00
|
|
|
|
<el-button @click="mallDlgShow = false">取 消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="addToDraft">确定</el-button>
|
2023-08-13 21:35:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</ai-dialog>
|
2023-08-06 16:50:17 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import {sendChromeAPIMessage} from '@/api/chromeApi'
|
|
|
|
|
|
import {timestampToTime} from '@/utils/date'
|
|
|
|
|
|
import {transform} from '@/utils/product'
|
|
|
|
|
|
import { Message } from 'element-ui'
|
2023-10-25 12:20:10 +08:00
|
|
|
|
import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
2023-08-06 16:50:17 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
2023-08-22 20:16:59 +08:00
|
|
|
|
name: 'CopyProduct',
|
2023-10-25 12:20:10 +08:00
|
|
|
|
components: {AiLazyCascader},
|
2023-08-06 16:50:17 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
search: {
|
|
|
|
|
|
current: 1,
|
|
|
|
|
|
size: 10,
|
|
|
|
|
|
productName: '',
|
|
|
|
|
|
mallName: '',
|
|
|
|
|
|
startDate: '',
|
|
|
|
|
|
endDate: ''
|
|
|
|
|
|
},
|
2023-08-13 21:21:27 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
value: 'catId',
|
|
|
|
|
|
label: 'catName',
|
|
|
|
|
|
lazy: true,
|
2023-10-25 12:20:10 +08:00
|
|
|
|
lazyLoad (value, resolve) {
|
2023-08-13 21:21:27 +08:00
|
|
|
|
sendChromeAPIMessage({
|
|
|
|
|
|
url: 'bg-anniston-mms/category/children/list',
|
|
|
|
|
|
needMallId: true,
|
|
|
|
|
|
data: {
|
2023-10-25 12:20:10 +08:00
|
|
|
|
parentCatId: value || ''
|
2023-08-13 21:21:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res.errorCode === 1000000) {
|
|
|
|
|
|
resolve(res.result.categoryNodeVOS.map(v => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
...v,
|
|
|
|
|
|
leaf: v.isLeaf
|
|
|
|
|
|
}
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-10-25 12:20:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
lazySearch(queryString, resolve) {
|
|
|
|
|
|
sendChromeAPIMessage({
|
|
|
|
|
|
url: 'bg-anniston-mms/category/search',
|
|
|
|
|
|
needMallId: true,
|
|
|
|
|
|
data: {
|
|
|
|
|
|
searchText: queryString || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res.errorCode === 1000000) {
|
|
|
|
|
|
resolve(res.result.categoryPaths.map(v => {
|
|
|
|
|
|
let value = []
|
|
|
|
|
|
let label = []
|
|
|
|
|
|
for (let i = 1; i <= 10; i++ ) {
|
|
|
|
|
|
if (v['cat'+i+'NodeVO']) {
|
|
|
|
|
|
value.push(v['cat'+i+'NodeVO'].catId)
|
|
|
|
|
|
label.push(v['cat'+i+'NodeVO'].catName)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
catId: value,
|
|
|
|
|
|
catName: label
|
|
|
|
|
|
}
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-08-13 21:21:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2023-08-06 16:50:17 +08:00
|
|
|
|
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: [],
|
2023-11-24 01:04:54 +08:00
|
|
|
|
productPage: {page: 1, pageSize: 10, mallId: '', from: '0', productName: '', productSkcIds: '', total: 0},
|
2023-08-06 16:50:17 +08:00
|
|
|
|
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' }
|
|
|
|
|
|
],
|
2023-08-08 02:01:34 +08:00
|
|
|
|
|
|
|
|
|
|
mallDlgShow: false,
|
2023-08-06 16:50:17 +08:00
|
|
|
|
productIds: [],
|
2023-08-08 02:01:34 +08:00
|
|
|
|
form: {
|
2023-08-13 22:18:42 +08:00
|
|
|
|
targetMallId: '',
|
2023-11-24 01:04:54 +08:00
|
|
|
|
targetCatId: [],
|
2024-02-23 10:29:39 +08:00
|
|
|
|
isSemi: false,
|
|
|
|
|
|
isSameCategory: true,
|
|
|
|
|
|
siteId: []
|
|
|
|
|
|
},
|
|
|
|
|
|
siteList: []
|
2023-08-06 16:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
created () {
|
|
|
|
|
|
this.getList()
|
2024-02-23 10:29:39 +08:00
|
|
|
|
this.getSiteList()
|
2023-08-08 02:01:34 +08:00
|
|
|
|
if (this.$store.state.mallList.length > 0) {
|
|
|
|
|
|
this.productPage.mallId = this.$store.state.mallList[0].mallId
|
|
|
|
|
|
}
|
2023-08-06 16:50:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
getList () {
|
2024-05-18 16:06:44 +08:00
|
|
|
|
this.$http.post('/api/product/myPage?type=0',null,{
|
2023-08-06 16:50:17 +08:00
|
|
|
|
params: {
|
|
|
|
|
|
...this.search
|
|
|
|
|
|
}
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
this.tableData = res.data.records
|
|
|
|
|
|
this.total = res.data.total
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-02-23 10:29:39 +08:00
|
|
|
|
getSiteList() {
|
|
|
|
|
|
sendChromeAPIMessage({
|
|
|
|
|
|
url: 'bg-visage-mms/config/common/site/query',
|
|
|
|
|
|
needMallId: true,
|
2024-02-27 15:38:08 +08:00
|
|
|
|
mallId: this.$store.state.mallList[0].mallId,
|
2024-02-23 10:29:39 +08:00
|
|
|
|
data: {}}).then((res) => {
|
|
|
|
|
|
if (res.success) {
|
|
|
|
|
|
this.siteList = res.result.siteBaseList.filter(item => {
|
|
|
|
|
|
return item.matchSemiManaged
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2023-08-06 16:50:17 +08:00
|
|
|
|
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 = []
|
2023-11-24 01:04:54 +08:00
|
|
|
|
this.productPage = {page: 1, pageSize: 10, from: '0', total: 0}
|
2023-08-06 16:50:17 +08:00
|
|
|
|
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
|
2023-11-24 01:04:54 +08:00
|
|
|
|
this.getProductOrDraftList()
|
2023-08-06 16:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-11-24 01:04:54 +08:00
|
|
|
|
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()
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2023-08-06 16:50:17 +08:00
|
|
|
|
getProductList() {
|
2023-08-08 02:01:34 +08:00
|
|
|
|
let params = {};
|
|
|
|
|
|
params.page = this.productPage.page;
|
|
|
|
|
|
params.pageSize = this.productPage.pageSize;
|
|
|
|
|
|
if (this.productPage.productName) {
|
|
|
|
|
|
params.productName = this.productPage.productName
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.productPage.productSkcIds) {
|
|
|
|
|
|
params.productSkcIds = this.productPage.productSkcIds.split(',')
|
|
|
|
|
|
}
|
2023-08-06 16:50:17 +08:00
|
|
|
|
sendChromeAPIMessage({
|
|
|
|
|
|
url: 'bg-visage-mms/product/skc/pageQuery',
|
|
|
|
|
|
needMallId: true,
|
2023-08-08 02:01:34 +08:00
|
|
|
|
mallId: this.productPage.mallId,
|
2023-08-06 16:50:17 +08:00
|
|
|
|
data: {
|
2023-08-08 02:01:34 +08:00
|
|
|
|
...params
|
2023-08-06 16:50:17 +08:00
|
|
|
|
}}).then((res) => {
|
|
|
|
|
|
if (res.errorCode == 1000000) {
|
|
|
|
|
|
this.productPage.total = res.result.total
|
|
|
|
|
|
this.productTableData = res.result.pageItems.map((item) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
productSpu: item.productId,
|
|
|
|
|
|
productSkc: item.productSkcId,
|
|
|
|
|
|
productName: item.productName,
|
|
|
|
|
|
createTime: timestampToTime(item.createdAt)
|
|
|
|
|
|
};
|
|
|
|
|
|
})
|
2023-08-09 02:32:02 +08:00
|
|
|
|
} else {
|
2023-09-25 10:13:54 +08:00
|
|
|
|
this.getProductList()
|
2023-08-06 16:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
productHandleSelectionChange(val) {
|
|
|
|
|
|
this.productIds = [];
|
|
|
|
|
|
val.forEach(e => {
|
|
|
|
|
|
this.productIds.push(e.productSpu);
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
saveProduct() {
|
|
|
|
|
|
if (this.productIds.length <= 0) {
|
2023-08-08 02:01:34 +08:00
|
|
|
|
Message.error('请选择商品');
|
2023-08-06 16:50:17 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.productIds.map((productSpu, index) => {
|
2023-09-25 10:13:54 +08:00
|
|
|
|
setTimeout(() => {
|
2023-11-24 01:04:54 +08:00
|
|
|
|
if (this.productPage.from == '0') {
|
|
|
|
|
|
this.saveProductTemplate(productSpu, index)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.saveDraftTemplate(productSpu, index)
|
|
|
|
|
|
}
|
2023-09-25 10:13:54 +08:00
|
|
|
|
}, 200 * index)
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-11-24 01:04:54 +08:00
|
|
|
|
saveProductTemplate(spu, index) {
|
2023-09-25 10:13:54 +08:00
|
|
|
|
sendChromeAPIMessage({
|
|
|
|
|
|
url: 'bg-visage-mms/product/query',
|
|
|
|
|
|
needMallId: true,
|
|
|
|
|
|
mallId: this.productPage.mallId,
|
|
|
|
|
|
data: {
|
|
|
|
|
|
productEditTaskUid: '',
|
|
|
|
|
|
productId: 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: res.result.productId,
|
|
|
|
|
|
productName: res.result.productName,
|
2024-05-18 16:06:44 +08:00
|
|
|
|
type: 0,
|
2023-09-25 10:13:54 +08:00
|
|
|
|
content: content
|
|
|
|
|
|
}).then(res1 => {
|
|
|
|
|
|
if (res1.code == 0) {
|
|
|
|
|
|
Message.success("商品【" + res.result.productName + "】成功添加为商品模板")
|
|
|
|
|
|
if (index == this.productIds.length - 1) {
|
|
|
|
|
|
this.getList()
|
|
|
|
|
|
}
|
2023-08-13 22:18:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-09-25 10:13:54 +08:00
|
|
|
|
} else {
|
2023-11-24 01:04:54 +08:00
|
|
|
|
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,
|
2024-05-18 16:06:44 +08:00
|
|
|
|
type: 0,
|
2023-11-24 01:04:54 +08:00
|
|
|
|
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)
|
2023-09-25 10:13:54 +08:00
|
|
|
|
}
|
2023-08-06 16:50:17 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-08-08 02:01:34 +08:00
|
|
|
|
beforeAddToDraft() {
|
2023-08-06 16:50:17 +08:00
|
|
|
|
if (this.ids.length <= 0) {
|
2023-08-08 02:01:34 +08:00
|
|
|
|
Message.error('请选择商品模板');
|
2023-08-06 16:50:17 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-08-08 02:01:34 +08:00
|
|
|
|
this.mallDlgShow = true
|
|
|
|
|
|
},
|
|
|
|
|
|
addToDraft() {
|
|
|
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
this.ids.map((id, index) => {
|
|
|
|
|
|
let product = this.tableData.filter((item) => {
|
|
|
|
|
|
return item.id == id
|
|
|
|
|
|
})
|
2023-11-24 01:04:54 +08:00
|
|
|
|
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]
|
|
|
|
|
|
}
|
2024-02-23 10:29:39 +08:00
|
|
|
|
let data = {catId: category}
|
|
|
|
|
|
if (this.form.isSemi) {
|
|
|
|
|
|
data.productSemiManagedReq = {
|
|
|
|
|
|
bindSiteIds: this.form.siteId
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-18 14:48:44 +08:00
|
|
|
|
content.personalizationSwitch = content.personalizationSwitch || 0
|
2023-08-08 02:01:34 +08:00
|
|
|
|
setTimeout(() => {
|
2023-08-06 16:50:17 +08:00
|
|
|
|
sendChromeAPIMessage({
|
2023-08-08 02:01:34 +08:00
|
|
|
|
url: 'bg-visage-mms/product/draft/add',
|
2023-08-06 16:50:17 +08:00
|
|
|
|
needMallId: true,
|
2023-08-08 02:01:34 +08:00
|
|
|
|
mallId: this.form.targetMallId,
|
2024-02-23 10:29:39 +08:00
|
|
|
|
data: data}).then((res) => {
|
2023-08-06 16:50:17 +08:00
|
|
|
|
if (res.errorCode == 1000000) {
|
2023-08-08 02:01:34 +08:00
|
|
|
|
let draftId = res.result.productDraftId
|
2023-11-24 01:04:54 +08:00
|
|
|
|
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'] = ''
|
|
|
|
|
|
}
|
2023-08-13 22:18:42 +08:00
|
|
|
|
}
|
2023-08-08 02:01:34 +08:00
|
|
|
|
content.productDraftId = draftId
|
2024-02-23 10:29:39 +08:00
|
|
|
|
if (this.form.isSemi) {
|
|
|
|
|
|
content.productSemiManagedReq = {
|
|
|
|
|
|
bindSiteIds: this.form.siteId
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-08-08 02:01:34 +08:00
|
|
|
|
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 + "】成功添加到草稿箱")
|
2023-11-24 01:04:54 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
Message.error(res.errorMsg)
|
2023-08-08 02:01:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-08-13 22:18:42 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
Message.error("【拼多多】" + res.errorMsg)
|
2023-08-06 16:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-08-08 02:01:34 +08:00
|
|
|
|
}, 1000*index)
|
2023-08-06 16:50:17 +08:00
|
|
|
|
})
|
2023-08-08 02:01:34 +08:00
|
|
|
|
this.mallDlgShow = false
|
|
|
|
|
|
}
|
2023-08-06 16:50:17 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
</style>
|