This commit is contained in:
liushiwei
2024-10-25 18:33:21 +08:00
17 changed files with 113528 additions and 1276 deletions

View File

@@ -297,8 +297,6 @@ export default {
},
created() {
window.eval = () => {
}
const devVersion = require('../manifest.development.json').version
const prodVersion = require('../manifest.production.json').version
this.version = process.env.NODE_ENV === 'production' ? prodVersion : devVersion
@@ -399,7 +397,7 @@ export default {
}
await detalAction(res);
console.log("--fileList--", fileList)
},
},
gotoKefu() {
window.open('https://work.weixin.qq.com/kfid/kfcaa4208f661131eba', '_blank')
},

View File

@@ -1,13 +1,15 @@
<template>
<AiDetail class="add-label">
<template #title>
<ai-title title="添加标签" isShowBack :isShowBottomBorder="true" @onBackClick="cancel">
<ai-title title="添加模板" isShowBack :isShowBottomBorder="true" @onBackClick="cancel">
<template #rightBtn>
<label>模板名称</label>
<el-input placeholder="请输入模板名称" size="small" v-model="name" style="width: 200px; margin-right: 300px;"></el-input>
<el-button @click="preview" size="small" type="danger">预览</el-button>
<el-button @click="savePdf" size="small" type="primary">下载pdf</el-button>
<el-button @click="saveTemplate" size="small" type="primary">保存</el-button>
<el-button @click="print" size="small">打印</el-button>
<el-button @click="clearPaper" size="small" type="danger">清空纸张</el-button>
<el-button @click="saveTemplate" size="small" type="primary">保存</el-button>
</template>
</ai-title>
</template>
@@ -15,7 +17,7 @@
<ai-card title="标签模板" class="card" :hideTitle="true">
<template #content>
<div class="add-label__wrapper">
<Print ref="printRef" :labels="labels"></Print>
<Print ref="printRef" :template="template" :isPrint="false"></Print>
</div>
</template>
</ai-card>
@@ -25,6 +27,7 @@
<script>
import Print from '@/components/print/Print'
import template from '@/components/print/template'
export default {
components: {
@@ -33,7 +36,8 @@
data () {
return {
labels: []
name: '',
template: template
}
},
@@ -55,6 +59,10 @@
},
saveTemplate () {
if (!this.name) {
return this.$message.error('模板名称不能为空')
}
const json = this.$refs.printRef.exportJson()
console.log(json)
},

View File

@@ -2,45 +2,98 @@
<ai-list class="Learning">
<ai-title
slot="title"
title="新手园地"
title="标签打印"
isShowBottomBorder>
</ai-title>
<template slot="content">
<ai-search-bar>
<template #left>
<el-radio-group v-model="search.categoryId" @change="onChange">
<el-radio-button label="">全部</el-radio-button>
<el-radio-button label="isFavorite">我的收藏</el-radio-button>
<el-radio-button :label="item.id" :key="item.id" v-for="item in cateList">{{ item.name }}</el-radio-button>
</el-radio-group>
</template>
<template #right>
</template>
</ai-search-bar>
<div class="search-item__wrapper">
<div class="left">
<div class="search-item">
<label>添加方式</label>
<el-radio-group v-model="type" size="small" @change="onSearchRest">
<el-radio-button label="1">按备货单打印</el-radio-button>
<el-radio-button label="2">按SKC打印</el-radio-button>
<el-radio-button label="3">按SKU打印</el-radio-button>
</el-radio-group>
</div>
<div class="search-item">
<label>店铺</label>
<el-select v-model="search.mallId" placeholder="请选择店铺" size="small">
<el-option
v-for="item in $store.state.mallList"
:key="item.mallId"
:label="item.mallName"
:value="item.mallId">
</el-option>
</el-select>
</div>
</div>
<div class="right"></div>
</div>
<div class="search-item__wrapper">
<div class="left">
<div class="search-item" v-show="addType === '1'">
<label>备货单</label>
<el-button style="margin-left: 10px;" @click="onCateChange" size="small" :disabled="!search.mallId" :loading="isLoading">查询</el-button>
</div>
<div class="search-item" v-show="addType === '2'">
<label>SKC</label>
<el-input
v-model="search.SKC"
style="width: 250px"
size="small"
placeholder="多个查询请用户逗号分割"
clearable
suffix-icon="iconfont iconSearch">
</el-input>
<el-button style="margin-left: 10px;" @click="getSkuList" size="small" :disabled="!search.mallId" :loading="isLoading">查询</el-button>
</div>
<div class="search-item" v-show="addType === '3'">
<label>SKU</label>
<el-input
v-if="addType === '3'"
v-model="search.SKU"
style="width: 250px"
size="small"
clearable
placeholder="多个查询请用户逗号分割"
suffix-icon="iconfont iconSearch">
</el-input>
<el-button style="margin-left: 10px;" @click="getSkuList" size="small" :disabled="!search.mallId" :loading="isLoading">查询</el-button>
</div>
</div>
</div>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
:current.sync="search.current"
:size.sync="search.size"
style="margin-top: 8px;"
:isShowPagination="false"
@getList="getList">
<el-table-column slot="options" label="操作" align="center" fixed="right" width="140px">
<template v-slot="{ row }">
<div class="table-options">
<el-button type="text" @click="collection(row.id, row.isFavorite)">{{ row.isFavorite === '0' ? '收藏' : '取消收藏' }}</el-button>
<el-button type="text">打印</el-button>
<el-button type="text" @click="toDetail(row.url)">详情</el-button>
</div>
</template>
</el-table-column>
</ai-table>
<Print ref="printRef" :isPrint="true"></Print>
</template>
</ai-list>
</template>
<script>
import Print from '@/components/print/Print'
export default {
name: 'Learning',
name: 'PrintPage',
components: {
Print
},
data () {
return {
@@ -49,83 +102,27 @@
{ prop: 'createTime', label: '发布时间', align: 'center' },
],
tableData: [],
total: 0,
search: {
current: 1,
size: 10,
categoryId: ''
mallId: '',
SKC: '',
SKU: ''
},
cateList: [],
isFavorite: 0
type: '1',
isLoading: false
}
},
created () {
this.$store.dispatch('getUserInfo').then(e => {
console.log(e)
})
this.getCateList()
this.getList()
},
methods: {
toDetail (url) {
window.open(url)
},
onChange (e) {
if (e === 'isFavorite') {
this.$http.post('/api/learning/favoritePage', null, {
params: {
...this.search
}
}).then(res => {
if (res.code === 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
} else {
this.search.current = 1
this.getList()
}
},
collection (id, isFavorite) {
this.$confirm(isFavorite === '0' ? '确定收藏该文章?' : '确定取消收藏?', '温馨提示', {
confirmButtonText: '确定',
callback: action => {
if (action === 'confirm') {
this.$http.post(isFavorite === '0' ? `/api/learning/addFavorite?id=${id}` : `/api/learning/delFavorite?id=${id}`).then(res => {
if (res.code === 0) {
this.$message.success(isFavorite === '0' ? '收藏成功' : '取消成功')
this.getList()
}
})
}
}
})
},
getCateList () {
this.$http.post('/api/learningCategory/page?size=50').then(res => {
if (res.code === 0) {
this.cateList = res.data.records
}
})
toPrint (template, printData) {
this.$refs.printData.print(template, printData)
},
getList () {
this.$http.post('/api/learning/pluginPage', null, {
params: {
...this.search
}
}).then(res => {
if (res.code === 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
}
}
}

View File

@@ -10,19 +10,22 @@
<template slot="content">
<ai-search-bar>
<template #left>
<el-button type="primary" size="small" @click="isShow = true">添加</el-button>
<el-button type="primary" size="small" @click="chooseSkuList = [], isShow = true">添加</el-button>
<el-button type="warning" size="small" @click="toAdd(row.url)">导入</el-button>
<el-button type="danger" size="small" @click="toAdd(row.url)">导出</el-button>
</template>
<template #right>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:tableData="skuList"
:col-configs="colConfigs"
:total="total"
:current.sync="search.current"
:size.sync="search.size"
style="margin-top: 8px;"
@getList="getList">
@getList="getList"
@selection-change="handleSelectionChange">
<el-table-column slot="productName" width="300px" :show-overflow-tooltip='true' label="商品名称" fixed="left">
<template slot-scope="scope">
<div>
@@ -31,7 +34,7 @@
</div>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" align="center" fixed="right" width="140px">
<el-table-column slot="options" label="操作" align="center" fixed="right" width="240px">
<template v-slot="{ row }">
<div class="table-options">
<el-button type="text" @click="toAdd(row.url)">编辑</el-button>
@@ -45,31 +48,90 @@
title="添加SKU"
width="1400px"
@confirm="onConfirm">
<ai-search-bar>
<template #left>
<el-select v-model="skuSearch.mallId" placeholder="请选择店铺" size="small" @change="onMallChange">
<el-option
v-for="item in $store.state.mallList"
:key="item.mallId"
:label="item.mallName"
:value="item.mallId">
</el-option>
</el-select>
</template>
<template #right>
</template>
</ai-search-bar>
<div class="search-item__wrapper">
<div class="left">
<div class="search-item">
<label>添加方式</label>
<el-radio-group v-model="addType" size="small" @change="onSearchRest">
<el-radio-button label="1">按类目添加</el-radio-button>
<el-radio-button label="2">按SKC添加</el-radio-button>
<el-radio-button label="3">按SKU添加</el-radio-button>
</el-radio-group>
</div>
<div class="search-item">
<label>店铺</label>
<el-select v-model="lableSearch.mallId" placeholder="请选择店铺" size="small">
<el-option
v-for="item in $store.state.mallList"
:key="item.mallId"
:label="item.mallName"
:value="item.mallId">
</el-option>
</el-select>
</div>
</div>
<div class="right"></div>
</div>
<div class="search-item__wrapper">
<div class="left">
<div class="search-item" v-show="addType === '1'">
<label>商品分类</label>
<el-cascader
style="width: 280px;"
v-model="targetCatId"
:props="props"
size="small"
filterable
:show-all-levels="false"
collapse-tags
clearable>
</el-cascader>
<el-button style="margin-left: 10px;" @click="onCateChange" size="small" :disabled="!lableSearch.mallId" :loading="isLoading">查询</el-button>
</div>
<div class="search-item" v-show="addType === '2'">
<label>SKC</label>
<el-input
v-model="skuReqParams.SKC"
style="width: 250px"
size="small"
v-throttle="() => {getSkuList()}"
placeholder="多个查询请用户逗号分割"
clearable
@clear="getSkuList()"
suffix-icon="iconfont iconSearch">
</el-input>
<el-button style="margin-left: 10px;" @click="getSkuList" size="small" :disabled="!lableSearch.mallId" :loading="isLoading">查询</el-button>
</div>
<div class="search-item" v-show="addType === '3'">
<label>SKU</label>
<el-input
v-if="addType === '3'"
v-model="skuReqParams.SKU"
style="width: 250px"
size="small"
v-throttle="() => {getSkuList()}"
placeholder="多个查询请用户逗号分割"
clearable
@clear="getSkuList()"
suffix-icon="iconfont iconSearch">
</el-input>
<el-button style="margin-left: 10px;" @click="getSkuList" size="small" :disabled="!lableSearch.mallId" :loading="isLoading">查询</el-button>
</div>
</div>
</div>
<ai-table
height="400"
:tableData="skuList"
height="370"
:tableData="lableList"
:col-configs="colConfigs"
:total="skuTotal"
:current.sync="skuSearch.current"
:size.sync="skuSearch.size"
:total="lableTotal"
:current.sync="lableSearch.current"
:size.sync="lableSearch.size"
style="margin-top: 8px;"
@getList="getSkuList"
:pageSizes="[10, 20, 50, 100, 500, 1000]"
v-loading="isLoading">
v-loading="isLoading"
:isShowPagination="false"
@getList="() => {}"
@selection-change="handleSelectionChange">
<el-table-column slot="productName" width="300px" :show-overflow-tooltip="true" label="商品名称" fixed="left">
<template slot-scope="scope">
<div>
@@ -87,11 +149,12 @@
<script>
import { sendChromeAPIMessage } from '@/api/chromeApi'
export default {
name: 'Template',
name: 'SkuManage',
data () {
return {
colConfigs: [
{ type: 'selection' },
// { slot: 'productName', label: '商品名称', width: '300px', align: 'left', fixed: 'left' },
// { prop: 'category', label: '分类', width: '140px', align: 'left', fixed: 'left' },
{ prop: 'mallName', label: '店铺名称', align: 'left' },
@@ -102,25 +165,55 @@
{ prop: 'skuExtCode', label: 'SKU货号', align: 'center' },
{ prop: 'skuSpecName', label: '次销售属性', align: 'center' }
],
tableData: [],
total: 0,
search: {
current: 1,
size: 100
},
skuSearch: {
lableSearch: {
current: 1,
size: 100,
mallId: ''
},
skuTotal: 0,
skuList: [],
lableTotal: 0,
lableList: [],
isShow: false,
skuReqParams: {
page: 1,
pageSize: 100
pageSize: 100,
SKC: '',
SKU: ''
},
isLoading: false
isLoading: false,
addType: '1',
props: {
value: 'catId',
label: 'catName',
multiple: true,
checkStrictly: true,
lazy: true,
lazyLoad (value, resolve) {
sendChromeAPIMessage({
url: 'bg-anniston-mms/category/children/list',
needMallId: true,
data: {
parentCatId: value.level === 0 ? '' : value.value
}
}).then(res => {
if (res.errorCode === 1000000) {
resolve(res.result.categoryNodeVOS.map(v => {
return {
...v,
leaf: v.isLeaf
}
}))
}
})
}
},
targetCatId: [],
skuList: [],
chooseSkuList: []
}
},
@@ -130,7 +223,7 @@
return {}
}
return this.$store.state.mallList.filter(v => v.mallId === this.skuSearch.mallId)[0]
return this.$store.state.mallList.filter(v => v.mallId === this.lableSearch.mallId)[0]
}
},
@@ -143,20 +236,92 @@
this.$router.push('/addLabelsTemplate')
},
requestSKUList () {
sendChromeAPIMessage({
onSearchRest() {
this.skuReqParams.SKC = ''
this.skuReqParams.SKU = ''
},
handleSelectionChange(e) {
console.log(e)
this.chooseSkuList = e
},
getSKCList(catIds, page) {
return new Promise(resolve => {
sendChromeAPIMessage({
url: 'bg-visage-mms/product/skc/pageQuery',
needMallId: true,
mallId: this.lableSearch.mallId,
anti: true,
data: {
page: 1,
pageSize: 200,
catIds: catIds
}
}).then(res => {
if (res.errorCode == 1000000) {
resolve({
list: res.result.pageItems.map(v => v.productSkcId),
isHasNext: page * 200 < res.result.total
})
} else {
resolve({ list: [], isHasNext: false })
}
}).catch(() => {
resolve({ list: [], isHasNext: false })
})
})
},
async onCateChange() {
this.$userCheck(this.lableSearch.mallId).then(async () => {
let page = 1
let list = []
let isHasNext = true
this.lableList = []
this.isLoading = true
while (isHasNext) {
const result = await this.getSKCList([].concat(this.targetCatId.flat()), page)
page = page + 1
isHasNext = result.isHasNext ? true : false
list.push(...result.list)
await this.$sleepSync(5000)
}
const skcList = [...new Set(list)]
const len = Math.ceil(skcList.length / 100)
for (let i = 0; i < len; i++) {
this.skuReqParams.page = 1
this.skuReqParams.SKC = [...new Set(list)].slice(i * 100, i * 100 + 100).join(',')
await this.requestSKUList(true)
await this.$sleepSync(2000)
}
console.log(111)
this.isLoading = false
}).catch(() => {
this.lableSearch.mallId = ''
})
},
requestSKUList(flag) {
return sendChromeAPIMessage({
url: 'bg-visage-mms/labelcode/pageQuery',
needMallId: true,
mallId: this.skuSearch.mallId,
mallId: this.lableSearch.mallId,
anti: true,
data: {
page: this.skuSearch.size > 100 ? this.skuReqParams.page : this.skuSearch.current,
pageSize: this.skuSearch.size > 100 ? 100 : this.skuSearch.size
page: this.skuReqParams.page,
pageSize: 200,
productSkcIdList: (['2', '1'].includes(this.addType)) ? this.skuReqParams.SKC.split(',') : [],
productSkuIdList: this.addType === '3' ? this.skuReqParams.SKU.split(',') : []
}
}).then(async (res) => {
if (res.errorCode == 1000000) {
const list = res.result.pageItems.map(v => {
return {
mallId: this.lableSearch.mallId,
mallName: this.currMall.mallName,
productName: v.productName,
productSkuId: v.labelCodeVO.productSkuId,
@@ -167,50 +332,32 @@
}).join(',')
}
})
this.skuTotal = res.result.total
this.skuList.push(...list)
this.lableTotal = res.result.total
this.lableList.push(...list)
if (this.skuSearch.size > 100 && (res.result.total > this.skuList.length)) {
if (res.result.total > this.lableList.length) {
this.skuReqParams.page++
await this.$sleepSync(5000)
this.requestSKUList()
await this.requestSKUList()
} else {
this.isLoading = false
!flag && (this.isLoading = false)
}
}
})
},
onMallChange (e) {
if (!e) {
this.skuList = []
return false
}
this.$userCheck(this.skuSearch.mallId).then(() => {
this.skuList = []
this.skuReqParams.page = 1
this.isLoading = true
this.requestSKUList()
}).catch(() => {
this.skuSearch.mallId = ''
})
},
getSkuList () {
if (!this.skuSearch.mallId) {
if (!this.lableSearch.mallId) {
return this.$message.error('请选择店铺')
}
this.$userCheck(this.skuSearch.mallId).then(() => {
this.skuList = []
this.$userCheck(this.lableSearch.mallId).then(() => {
this.lableList = []
this.skuReqParams.page = 1
this.isLoading = true
this.requestSKUList()
}).catch(() => {
this.skuSearch.mallId = ''
this.lableSearch.mallId = ''
})
},
@@ -228,11 +375,24 @@
},
onConfirm () {
this.skuList = this.chooseSkuList
this.isShow = false
}
}
}
</script>
<style scoped lang="scss">
.Template {
.search-item__wrapper {
display: flex;
align-items: center;
justify-content: space-between;
&>div {
display: flex;
align-items: center;
}
}
}
</style>