diff --git a/.gitignore b/.gitignore index b92657c..0607221 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules /dist /artifacts package-lock.json +/node_modules # local env files .env.local diff --git a/node_modules/vue-plugin-hiprint/dist/vue-plugin-hiprint.js b/node_modules/vue-plugin-hiprint/dist/vue-plugin-hiprint.js index c023199..5b0506a 100644 --- a/node_modules/vue-plugin-hiprint/dist/vue-plugin-hiprint.js +++ b/node_modules/vue-plugin-hiprint/dist/vue-plugin-hiprint.js @@ -7466,10 +7466,18 @@ }, t.prototype.mathroundToporleft = function (t) { var e = p.a.instance.movingDistance; return Math.round(t / e) * e +<<<<<<< HEAD }, t.prototype.appendDesignPrintElement = function (t, e, i) { e.setCurrenttemplateData(void 0); var n = e.getDesignTarget(t); n.addClass("design"), i && e.initSizeByHtml(n), t.append(n) +======= + }, t.prototype.appendDesignPrintElement = function (t, e, i, className) { + e.setCurrenttemplateData(void 0); + var n = e.getDesignTarget(t); + const isAddClass = !!e.options.field + n.addClass(`design ${isAddClass ? 'dynamicField' : ''}`), i && e.initSizeByHtml(n), t.append(n) +>>>>>>> 4b6e221369194b3387a0e3c28135acd3736c1bcd }, t.prototype.createNewPage = function (t, e) { t = new T(this.templateId, this.index, this.watermarkOptions, this.panelPageRule, this.scale, this.width, this.height, this.paperHeader, this.paperFooter, this.paperNumberLeft, this.paperNumberTop, this.paperNumberDisabled, this.paperNumberContinue, this.paperNumberFormat, t, e); return t.setFooter(this.firstPaperFooter, this.evenPaperFooter, this.oddPaperFooter, this.lastPaperFooter), t.setOffset(this.leftOffset, this.topOffset), t diff --git a/src/api/index.js b/src/api/index.js index dae2761..030265f 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -4,7 +4,7 @@ import store from '@/store' var instance = axios.create({ - baseURL: process.env.NODE_ENV === 'production' ? 'http://124.71.2.127:8888' : 'http://124.71.2.127:8888', + baseURL: process.env.NODE_ENV === 'production' ? 'http://124.71.2.127:8888' : 'http://124.71.2.127:10248', timeout: 50000, validateStatus: function (status) { return status < 500 diff --git a/src/components/LablesMember.vue b/src/components/LablesMember.vue index 83d29ba..763d536 100644 --- a/src/components/LablesMember.vue +++ b/src/components/LablesMember.vue @@ -18,13 +18,13 @@
- VIP + 金币充值
- SVIP + 基础功能
- 超级VIP + 高级功能
-

12个月

+ @click="currIndex = i, getQrcode(price)"> +

{{ price.remark }}

¥ - 88 + {{ price.price }}
¥ - 88 + {{ price.originPrice }}
@@ -55,7 +55,8 @@ 88
- + +
@@ -80,11 +81,40 @@ return { isShow: false, tabIndex: 0, - currIndex: 0 + currIndex: 0, + qrcode: '', + priceList: [] } }, + mounted() { + this.getPriceList() + }, + methods: { + getPriceList() { + this.$http.post(`/api/priceConfig/page?module=2`).then(res => { + if (res.code === 0) { + this.priceList = res.data.records + } + }) + }, + + getQrcode(item) { + this.$http.post(`/api/order/createOrder`, null, { + params: { + priceConfigId: item.id + } + }).then(res => { + if (res?.data?.id) { + return res.data.id + } + }).then(id => this.$http.post(`/api/order/createPrepayOrder?id=${id}`)).then(res => { + if (res?.data) { + this.qrcode = res.data.codeUrl + } + }) + }, show () { this.isShow = true }, @@ -120,8 +150,9 @@ top: 50%; left: 50%; z-index: 11; - width: 900px; - padding: 40px 40px; + width: 1100px; + height: 560px; + padding: 40px 60px; transform: translate(-50%, -50%); border-radius: 12px; overflow: hidden; @@ -130,7 +161,7 @@ .top { display: flex; align-items: center; - margin-bottom: 30px; + margin-bottom: 60px; img { width: 40px; @@ -180,6 +211,7 @@ .middle { display: flex; + height: 380px; .left { flex: 1; @@ -295,6 +327,7 @@ display: flex; flex-direction: column; align-items: center; + justify-content: center; margin-left: 40px; padding: 20px 0 20px 0; @@ -330,7 +363,7 @@ } } - .code img { + .code { width: 150px; height: 150px; margin: 14px 0; diff --git a/src/components/print/Print.vue b/src/components/print/Print.vue index 08e4375..f85a7f9 100644 --- a/src/components/print/Print.vue +++ b/src/components/print/Print.vue @@ -44,42 +44,18 @@ 素材
- -
-
图片素材
-
- -
- -
-
文字素材
-
- -
+
+
图片素材
+
+
+
文字素材
+
动态数据(如日期) @@ -119,15 +95,7 @@ 自定义纸张 - + 模板库
@@ -144,6 +112,61 @@ 取消
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -227,35 +274,29 @@ html: '', isShowPreview: false, hiprintTemplate: null, + isShowTemplate: false, + templateList: [], curPaper: { type: 'other', width: 200, height: 200 }, paperTypes: { - 'A3': { - width: 420, - height: 296.6 + '100 * 100': { + width: 200, + height: 200 }, - 'A4': { - width: 210, - height: 296.6 + '100 * 80': { + width: 200, + height: 160 }, - 'A5': { - width: 210, - height: 147.6 + '80 * 60': { + width: 160, + height: 120 }, - 'B3': { - width: 500, - height: 352.6 - }, - 'B4': { - width: 250, - height: 352.6 - }, - 'B5': { - width: 250, - height: 175.6 + '60 * 40': { + width: 120, + height: 80 } }, paperPopVisible: false, @@ -267,7 +308,25 @@ dynamicFromList: [], panel: null, contents: [], - images: [] + images: [], + search: { + current: 1, + size: 10, + type: 1 + }, + searchTemplate: { + current: 1, + size: 10, + type: 1 + }, + templateTotal: 0, + isShowImage: false, + tableData: [], + total: 0, + templateColConfigs: [ + { prop: 'name', label: '模板名称', align: 'left' } + ], + templateLoading: false } }, @@ -275,7 +334,6 @@ template: { handler(value) { if (value && this.hiprintTemplate && !this.isPrint) { - console.log(value) const config = value.panels[0] this.hiprintTemplate.update(value) this.curPaper = {type: 'other', width: config.width, height: config.height} @@ -302,6 +360,20 @@ } } return type + }, + + colConfigs () { + if (this.search.type === 1) { + return [ + { slot: 'image' }, + { prop: 'remark', label: '描述', align: 'center' } + ] + } + + return [ + { prop: 'contents', label: '文本', align: 'center' }, + { prop: 'remark', label: '描述', align: 'center' } + ] } }, @@ -315,6 +387,8 @@ this.buildLeftElement() this.buildDesigner() this.getConfig() + + this.getTemplateList() } }, @@ -322,25 +396,62 @@ addField() { const num = this.dynamicFromList.length > 9 ? this.dynamicFromList.length + 1 : `0${this.dynamicFromList.length + 1}` + // eslint-disable-next-line no-empty if (this.dynamicFromList.length && !this.dynamicFromList.at(-1)[`field_${num}`]) { } else { this.$set(this.dynamicFrom, `field_${num}`, '') } this.isShowDynamicForm = true - - console.log(this.dynamicFrom) }, removeField(index) { this.dynamicFromList.splice(index, 1) }, - getConfig() { - this.$http.post(`/api/material/getPage?page=1&size=-1`).then(res => { + updateTempate(row) { + this.templateLoading = true + this.$http.post(`/api/templateRecommend/detail?id=${row.id}`).then(res => { if (res.code === 0) { - this.images = res.data.records.filter(v => v.type === '1') - this.contents = res.data.records.filter(v => v.type === '0') + const config = JSON.parse(res.data.content) + this.hiprintTemplate.update(config) + this.hiprintTemplate.setPaper(config.panels[0].width, config.panels[0].height) + + this.dynamicFromList = JSON.parse(res.data.params) + this.isShowTemplate = false + } + + this.templateLoading = false + }) + }, + + getTemplateList() { + this.$http.post(`/api/templateRecommend/getRecommendPage`, null, { + params: this.searchTemplate + }).then(res => { + if (res.code === 0) { + this.templateList = res.data.records + this.templateTotal = res.data.total + } + }) + }, + + showTemplate (row) { + this.templateLoading = true + this.$http.post(`/api/templateRecommend/detail?id=${row.id}`).then(res => { + this.templateLoading = false + if (res.code === 0) { + this.html = res.data.codes + this.isShowPreview = true + } + }) + }, + + getConfig() { + this.$http.post(`/api/material/getPage?current=${this.search.current}&size=${this.search.size}&type=${this.search.type}`).then(res => { + if (res.code === 0) { + this.tableData = res.data.records + this.total = res.data.total } }) }, @@ -352,7 +463,8 @@ left: 70.5, top: 58.5, src: src, - widthHeightSync: true + width: 100, + height: 100 } }) const el = this.hiprintTemplate.printPanels[0].printElements.at(-1) @@ -361,7 +473,7 @@ el.design(void 0, designPaper) }, - addText(text, isSetField = true) { + addText(text, isSetField = false) { this.panel.addPrintText({ options: { field: isSetField ? text : '', @@ -372,6 +484,7 @@ width: 140, height: 20, coordinateSync: true, + contentPaddingLeft: 5.25, textContentVerticalAlign: 'middle', widthHeightSync: true, hideTitle: true, @@ -386,7 +499,7 @@ }, addItemToCanvas(name) { - this.addText(name) + this.addText(name, true) }, onConfirm() { @@ -561,8 +674,9 @@ ::v-deep(.hiprint-printPanel) { display: block; - & > div { - // margin: 0 auto !important; + .dynamicField { + background-color: #bfc2e9; + border-color: #bfc2e9; } } @@ -621,6 +735,8 @@ flex-direction: column; align-items: center; justify-content: center; + left: 0!important; + top: 0!important; width: 100px; margin-bottom: 10px; margin-right: 10px; diff --git a/src/components/print/customProvider.js b/src/components/print/customProvider.js index e8b2f48..7789a48 100644 --- a/src/components/print/customProvider.js +++ b/src/components/print/customProvider.js @@ -1,5 +1,7 @@ +/* eslint-disable no-undef */ import { hiprint } from 'vue-plugin-hiprint' -export const customProvider = function (options) { + +export const customProvider = function () { const addElementTypes = function (context) { context.removePrintElementTypes('customProvider') context.addPrintElementTypes('customProvider', [ @@ -13,10 +15,10 @@ export const customProvider = function (options) { const elId = options.elId || 'barCode-' + new Date().getTime() const codeWidth = parseInt((options.width - 22) * 0.85) let printData = { - labelCode: 96778555251, - productSkuId: 6606980005, - skuExtCode: 'AAA1100mWh-orange', - skuSpecName: '8pcs' + labelCode: 123456789, + productSkuId: `XXXXXXXXXXXXXX`, + skuExtCode: 'XXXXXXXXXXXXXX', + skuSpecName: 'XXXXX' } options.elId = `${elId}` @@ -24,29 +26,25 @@ export const customProvider = function (options) { printData = sukData } - // eslint-disable-next-line no-undef $('body').append(`
`) - // eslint-disable-next-line no-undef JsBarcode('#' + elId, printData.labelCode, { format: 'CODE128B', width: 2, - height: parseInt(hinnn.pt.toPx(options.height - 22).toString()) * 0.6, + height: parseInt(hinnn.pt.toPx(options.height - 22).toString()) * 0.6, margin: 0, displayValue: false }) - // eslint-disable-next-line no-undef const codeHtml = $(`#codewrapper-${elId}`).html() - // eslint-disable-next-line no-undef $(`body>#codewrapper-${elId}`).remove() - // eslint-disable-next-line no-undef + const resizeObserver = new ResizeObserver(() => { - JsBarcode('#'+ elId, printData.labelCode, { + JsBarcode('#' + elId, printData.labelCode, { format: "CODE128B", width: 2, - height: parseInt(hinnn.pt.toPx(options.height - 22).toString()) * 0.6, + height: parseInt(hinnn.pt.toPx(options.height - 22).toString()) * 0.6, margin: 0, displayValue: false }) @@ -61,8 +59,8 @@ export const customProvider = function (options) { var html = `
-
${ printData.skuExtCode }
-
${ printData.skuSpecName }
+
${printData.skuExtCode || printData.productSkcId}
+
${printData.skuSpecName}
@@ -70,7 +68,7 @@ export const customProvider = function (options) {
-
${ printData.productSkuId }
+
${printData.productSkuId}
Made in China
@@ -85,37 +83,37 @@ export const customProvider = function (options) { printElementType: { } }, - { - tid: 'providerModule1.barcode', - title: '条形码', - data: 'XS888888888', - type: 'text', - options: { - field: 'barcode', - testData: 'XS888888888', - height: 32, - fontSize: 12, - lineHeight: 18, - textAlign: 'left', - textType: 'barcode', - hideTitle: false - } - }, - { - tid: 'providerModule1.qrcode', - title: '二维码', - data: 'XS888888888', - type: 'text', - options: { - field: '', - testData: '', - height: 32, - fontSize: 12, - lineHeight: 18, - textType: 'qrcode', - hideTitle: false - } - }, + // { + // tid: 'providerModule1.barcode', + // title: '条形码', + // data: 'XS888888888', + // type: 'text', + // options: { + // field: 'barcode', + // testData: 'XS888888888', + // height: 32, + // fontSize: 12, + // lineHeight: 18, + // textAlign: 'left', + // textType: 'barcode', + // hideTitle: false + // } + // }, + // { + // tid: 'providerModule1.qrcode', + // title: '二维码', + // data: 'XS888888888', + // type: 'text', + // options: { + // field: '', + // testData: '', + // height: 32, + // fontSize: 12, + // lineHeight: 18, + // textType: 'qrcode', + // hideTitle: false + // } + // }, { tid: 'providerModule1.image', title: '图片', diff --git a/src/components/print/vue-plugin-hiprint.js b/src/components/print/vue-plugin-hiprint.js index c023199..4e34559 100644 --- a/src/components/print/vue-plugin-hiprint.js +++ b/src/components/print/vue-plugin-hiprint.js @@ -7466,10 +7466,11 @@ }, t.prototype.mathroundToporleft = function (t) { var e = p.a.instance.movingDistance; return Math.round(t / e) * e - }, t.prototype.appendDesignPrintElement = function (t, e, i) { + }, t.prototype.appendDesignPrintElement = function (t, e, i, className) { e.setCurrenttemplateData(void 0); var n = e.getDesignTarget(t); - n.addClass("design"), i && e.initSizeByHtml(n), t.append(n) + const isAddClass = !!e.options.field + n.addClass(`design ${isAddClass ? 'dynamicField' : ''}`), i && e.initSizeByHtml(n), t.append(n) }, t.prototype.createNewPage = function (t, e) { t = new T(this.templateId, this.index, this.watermarkOptions, this.panelPageRule, this.scale, this.width, this.height, this.paperHeader, this.paperFooter, this.paperNumberLeft, this.paperNumberTop, this.paperNumberDisabled, this.paperNumberContinue, this.paperNumberFormat, t, e); return t.setFooter(this.firstPaperFooter, this.evenPaperFooter, this.oddPaperFooter, this.lastPaperFooter), t.setOffset(this.leftOffset, this.topOffset), t diff --git a/src/view/Home.vue b/src/view/Home.vue index 62870bf..6f14ded 100644 --- a/src/view/Home.vue +++ b/src/view/Home.vue @@ -192,16 +192,23 @@ 数据统计 --> - + - 模板管理 - 标签打印 + + + 模板管理 + 标签打印 + diff --git a/src/view/lables/AddTemplate.vue b/src/view/lables/AddTemplate.vue index c61d594..996c0eb 100644 --- a/src/view/lables/AddTemplate.vue +++ b/src/view/lables/AddTemplate.vue @@ -16,7 +16,7 @@ @@ -100,26 +117,34 @@ data () { return { colConfigs: [ - { type: 'selection' }, { prop: 'mallName', label: '店铺名称', align: 'left' }, { prop: 'labelCode', label: '条码编码', align: 'center' }, { prop: 'productSkcId', label: 'SKC', align: 'center' }, { prop: 'productSkuId', label: 'SKU', align: 'center' }, { prop: 'skuExtCode', label: 'SKU货号', align: 'center' }, - { prop: 'skuSpecName', label: '次销售属性', align: 'center' } + { prop: 'skuSpecName', label: '次销售属性', align: 'center' }, + { prop: 'deliveryNum', label: '发货数', align: 'center' } ], search: { mallId: '', productSkuId: '', productSkcId: '', page: 1, - size: -1 + size: -1, + templateId: '' }, addType: '1', isLoading: false, lableList: [], height: 600, - skuChoosedList: [] + skuChoosedList: [], + isShow: false, + form: { + count: 1 + }, + printData: [], + templateList: [], + page: 1 } }, @@ -134,26 +159,76 @@ }, mounted() { + this.getTemplateList() this.$nextTick(() => { this.height = document.querySelector('.ai-list__content--right').clientHeight - 140 }) }, methods: { + getTemplateList () { + this.$http.post('/api/template/getPage?size=-1').then(res => { + if (res.code === 0) { + this.templateList = res.data.records + } + }) + }, + toPrint(row) { this.isLoading = true - this.$http.post(`/api/template/detail?id=${row.templateId}`).then(res => { - this.isLoading = false - const params = JSON.parse(res.data.params) - const getValue = v => params.filter(e => e.fieldValue === v)[0].fieldName - Object.keys(row).forEach(key => { - if (params.findIndex(v => v.fieldValue === key) > -1) { - row[getValue(key)] = row[key] + if (this.addType === '1') { + this.$http.post(`/api/template/getPage?productSkuId=${row.productSkuId}`).then(res => { + if (!res.data.records.length) { + this.isLoading = false + return this.$message.error('该SKU未配置模板') + } + + this.$http.post(`/api/template/detail?id=${res.data.records[0].id}`).then(res => { + this.isLoading = false + if (res.code === 0) { + const params = JSON.parse(res.data.params) + const getValue = v => params.filter(e => e.fieldValue === v)[0].fieldName + Object.keys(row).forEach(key => { + if (params.findIndex(v => v.fieldValue === key) > -1) { + row[getValue(key)] = row[key] + } + }) + + this.$refs.printRef.toPrint(JSON.parse(res.data.content), new Array(row.deliveryNum).fill(row)) + } + }) + }) + } else { + this.$http.post(`/api/template/detail?id=${row.templateId}`).then(res => { + this.isLoading = false + if (res.code === 0) { + if (!res.data) { + this.isLoading = false + return this.$message.error('该SKU未配置模板') + } + const params = JSON.parse(res.data.params) + const getValue = v => params.filter(e => e.fieldValue === v)[0].fieldName + Object.keys(row).forEach(key => { + if (params.findIndex(v => v.fieldValue === key) > -1) { + row[getValue(key)] = row[key] + } + }) + + this.printData = { + template: JSON.parse(res.data.content), + data: row + } + this.isShow = true } }) + } + }, - if (res.code === 0) { - this.$refs.printRef.toPrint(JSON.parse(res.data.content), row) + onConfirm () { + this.$refs.form.validate((valid) => { + if (valid) { + this.isShow = false + this.$refs.printRef.toPrint(this.printData.template, new Array(this.form.count).fill(this.printData.data)) } }) }, @@ -178,8 +253,97 @@ }) }, - handleSelectionChange(e) { - this.skuChoosedList = e + getDeliveryOrderSn (page) { + return new Promise(resolve => { + sendChromeAPIMessage({ + url: 'bgSongbird-api/supplier/deliverGoods/management/pageQueryDeliveryBatch', + needMallId: true, + mallId: this.search.mallId, + anti: true, + data: { + pageNo: page, + status: 1, + onlyTaxWarehouseWaitApply: false, + productLabelCodeStyle: 0, + pageSize: 200 + } + }).then(res => { + if (res.errorCode == 1000000) { + resolve({ + list: [].concat(res.result.list.map(v => v.deliveryOrderList.map(e => e.deliveryOrderSn)).flat()), + isHasNext: res.result.total && res.result.list.length && (res.result.list.length < 200 && res.result.total > 200) + }) + } else { + resolve({ list: [], isHasNext: false }) + } + }).catch(() => { + resolve({ list: [], isHasNext: false }) + }) + }) + }, + + getLabels (deliveryOrderSnList) { + return new Promise(resolve => { + sendChromeAPIMessage({ + url: 'bgSongbird-api/supplier/deliverGoods/management/printProductSkuLabel', + needMallId: true, + mallId: this.search.mallId, + anti: true, + data: { + deliveryOrderSnList: deliveryOrderSnList + } + }).then(res => { + if (res.errorCode == 1000000) { + resolve(res.result.map(v => { + return { + mallName: this.$store.state.mallList.filter(v => v.mallId === this.search.mallId)[0].mallName, + productName: v.productName, + productSkcId: v.productSkcId, + productSkuId: v.productSkuId, + labelCode: v.labelCode, + skuExtCode: v.skuExtCode, + deliveryNum: v.deliveryNum, + skuSpecName: v.secondarySpecVOList.map(item => { + return item.specName + }).join(',') + } + })) + } else { + resolve([]) + } + }).catch(() => { + resolve([]) + }) + }) + }, + + async searchSkuList () { + let page = 1 + let isHasNext = true + let list = [] + let deliveryOrderSnList = [] + this.isLoading = true + while (isHasNext) { + const result = await this.getDeliveryOrderSn(page) + page = page + 1 + isHasNext = result.isHasNext ? true : false + deliveryOrderSnList.push(...result.list) + + await this.$sleepSync(1000) + } + + const len = Math.ceil(deliveryOrderSnList.length / 100) + for (let i = 0; i < len; i++) { + this.page = 1 + const ids = [...new Set(deliveryOrderSnList)].slice(i * 100, i * 100 + 100) + const res = await this.getLabels(ids) + list.push(...res) + await this.$sleepSync(500) + } + + this.isLoading = false + + this.lableList = list } } } diff --git a/src/view/lables/SkuManage.vue b/src/view/lables/SkuManage.vue index 428e0b2..3cf8a9f 100644 --- a/src/view/lables/SkuManage.vue +++ b/src/view/lables/SkuManage.vue @@ -19,7 +19,7 @@ :auto-upload="false" :file-list="fileList" :on-change="onExcelChange"> - Excel导入 + Excel导入 Excel导出 - + @@ -176,7 +212,10 @@ total: 0, search: { current: 1, - size: 100 + size: -1, + productSkuId: '', + productSkcId: '', + isShowWhite: '' }, lableSearch: { current: 1, @@ -225,11 +264,25 @@ id: '', fileList: [], pageShow: false, - relationList: [] + relationList: [], + btnLoading: false } }, computed: { + list () { + if (!this.skuList.length) { + return [] + } + + if (this.search.isShowWhite !== '1') { + return this.skuList + } + + const keys = this.relationList.map(v => v.field) + return this.skuList.filter(v => keys.some(e => !v[e])) + }, + currMall () { if (!this.$store.state.mallList.length) { return {} @@ -239,7 +292,7 @@ }, colConfigs () { - const arr = this.isShow ? [] : this.relationList.map(v => { + const fields = this.isShow ? [] : this.relationList.map(v => { return { prop: v.field, label: v.name, @@ -256,7 +309,7 @@ { prop: 'productSkuId', label: 'SKU', align: 'center' }, { prop: 'skuExtCode', label: 'SKU货号', align: 'center' }, { prop: 'skuSpecName', label: '次销售属性', align: 'center' }, - ...arr + ...fields ] }, @@ -287,16 +340,13 @@ this.$http.post(`/api/templateRelation/getRelation?templateId=${this.$route.query.id}`).then(res => { if (res.code === 0) { this.relationList = res.data - - console.log(this.relationList) } }) }, readXLSX(file) { - return new Promise((resolve, reject) => { + return new Promise(resolve => { const reader = new FileReader() - reader.readAsBinaryString(file) reader.onload = evt => { const data = evt.target.result @@ -313,7 +363,6 @@ onExcelChange (file) { this.pageShow = true this.readXLSX(file.raw).then(res => { - console.log(res) this.$http.post(`/api/templateSku/updateBatchSku`, res.map(v => { const result = { templateId: this.id @@ -322,7 +371,6 @@ result[this.jsonFields[item]] = v[item] }) - console.log(result) return result })).then(res => { if (res.code === 0) { @@ -341,7 +389,6 @@ }, handleSelectionChange(e) { - console.log(e) this.chooseSkuList = e }, @@ -353,7 +400,7 @@ mallId: this.lableSearch.mallId, anti: true, data: { - page: 1, + page, pageSize: 200, catIds: catIds } @@ -361,7 +408,7 @@ if (res.errorCode == 1000000) { resolve({ list: res.result.pageItems.map(v => v.productSkcId), - isHasNext: page * 200 < res.result.total + isHasNext: res.result.total && res.result.pageItems.length && (res.result.pageItems.length < 200 && res.result.total > 200) }) } else { resolve({ list: [], isHasNext: false }) @@ -373,35 +420,28 @@ }, 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) + 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) - } + await this.$sleepSync(1000) + } - 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 = '' - }) + 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(500) + } }, requestSKUList(flag) { @@ -437,7 +477,7 @@ if (res.result.total > this.lableList.length) { this.skuReqParams.page++ - await this.$sleepSync(5000) + await this.$sleepSync(500) await this.requestSKUList() } else { !flag && (this.isLoading = false) @@ -451,22 +491,25 @@ return this.$message.error('请选择店铺') } - this.$userCheck(this.lableSearch.mallId).then(() => { - this.lableList = [] - this.skuReqParams.page = 1 - this.isLoading = true - this.requestSKUList() - }).catch(() => { - this.lableSearch.mallId = '' - }) + this.lableList = [] + this.skuReqParams.page = 1 + this.isLoading = true + this.requestSKUList() }, getList () { - this.$http.post(`/api/templateSku/getPage?size=-1&templateId=${this.id}`).then(res => { + this.pageShow = true + this.$http.post(`/api/templateSku/getPage`, null, { + params: { + ...this.search, + templateId: this.id + } + }).then(res => { if (res.code === 0) { this.skuList = res.data.records - // this.total = res.data.total } + + this.pageShow = false }) }, @@ -475,6 +518,7 @@ return this.$message.error('请选择SKU') } + this.btnLoading = true this.$http.post(`/api/templateSku/addBatchSku`, this.chooseSkuList.map(v => { return { ...v, @@ -486,8 +530,24 @@ this.isShow = false this.getList() } + + this.btnLoading = false }) - } + }, + + remove (id) { + this.$confirm('确定删除该数据?', '温馨提示', { + type: 'warning' + }).then(() => { + this.$http.post(`/api/templateSku/removeById?id=${id}`).then(res => { + if (res.code == 0) { + this.$message.success('删除成功') + + this.getList() + } + }) + }) + }, } } diff --git a/src/view/lables/Template.vue b/src/view/lables/Template.vue index feceea0..7145ca9 100644 --- a/src/view/lables/Template.vue +++ b/src/view/lables/Template.vue @@ -8,10 +8,42 @@