This commit is contained in:
faiz 2024-05-23 18:31:45 +08:00
parent 39e06e08a7
commit 11caa29bb8
17 changed files with 9300 additions and 9064 deletions

View File

@ -3,11 +3,11 @@ ENV = 'development'
# http://192.168.1.43:8324/admin # http://192.168.1.43:8324/admin
# http://mer.crmeb.net/admin # http://mer.crmeb.net/admin
# base api # base api
VUE_APP_BASE_API = 'http://192.168.1.50:8080' VUE_APP_BASE_API = 'https://api.tropjoin.com/'
# VUE_APP_BASE_API = 'https://plus.hwms.shop' # VUE_APP_BASE_API = 'https://plus.hwms.shop'
# socket 连接地址 # socket 连接地址
VUE_APP_WS_URL = 'ws://192.168.1.50:8080' VUE_APP_WS_URL = 'ws://https://api.tropjoin.com/'
# VUE_APP_WS_URL = 'ws://plus.hwms.shop' # VUE_APP_WS_URL = 'ws://plus.hwms.shop'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable, # vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,

View File

@ -90,6 +90,7 @@
"vuedraggable": "2.20.0", "vuedraggable": "2.20.0",
"vuex": "3.1.0", "vuex": "3.1.0",
"wangeditor": "^4.7.12", "wangeditor": "^4.7.12",
"worker-loader": "^3.0.8",
"xlsx": "0.14.1" "xlsx": "0.14.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -183,7 +183,7 @@ export default {
info: [ info: [
{ {
title: '标题', title: '标题',
value: '促销单品', value: '特惠专区',
tips: '选填不超过4个字', tips: '选填不超过4个字',
max: 4 max: 4
}, },

View File

@ -230,7 +230,7 @@ export default {
info: [ info: [
{ {
title: '标题', title: '标题',
value: '促销单品', value: '特惠专区',
tips: '选填不超过4个字', tips: '选填不超过4个字',
max: 4 max: 4
}, },
@ -247,7 +247,7 @@ export default {
info: [ info: [
{ {
title: '标题', title: '标题',
value: '促销单品', value: '特惠专区',
tips: '选填不超过4个字', tips: '选填不超过4个字',
max: 4 max: 4
}, },

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,7 @@
"font_family": "iconfont", "font_family": "iconfont",
"css_prefix_text": "icon-", "css_prefix_text": "icon-",
"description": "外包项目图标添加", "description": "外包项目图标添加",
"glyphs": [ "glyphs": [{
{
"icon_id": "5387812", "icon_id": "5387812",
"name": "购物_o", "name": "购物_o",
"font_class": "gouwu_o", "font_class": "gouwu_o",
@ -756,7 +755,7 @@
}, },
{ {
"icon_id": "25889479", "icon_id": "25889479",
"name": "促销单品", "name": "特惠专区",
"font_class": "cuxiaodanpin", "font_class": "cuxiaodanpin",
"unicode": "e7b7", "unicode": "e7b7",
"unicode_decimal": 59319 "unicode_decimal": 59319

View File

@ -207,7 +207,7 @@ const objTitle = {
title: '体积(m³)' title: '体积(m³)'
} }
} }
const proOptions = [{ name: '是否热卖', value: 'is_hot' }, { name: '优品推荐', value: 'is_good' }, { name: '促销单品', value: 'is_benefit' }, { name: '是否精品', value: 'is_best' }, { name: '是否新品', value: 'is_new' }] const proOptions = [{ name: '是否热卖', value: 'is_hot' }, { name: '优品推荐', value: 'is_good' }, { name: '特惠专区', value: 'is_benefit' }, { name: '是否精品', value: 'is_best' }, { name: '是否新品', value: 'is_new' }]
export default { export default {
name: 'Info', name: 'Info',
props: { props: {

View File

@ -251,7 +251,7 @@ const objTitle2 = {
title: '体积(m³)' title: '体积(m³)'
} }
} }
const proOptions = [{ name: '是否热卖', value: 'is_hot' }, { name: '优品推荐', value: 'is_good' }, { name: '促销单品', value: 'is_benefit' }, { name: '是否精品', value: 'is_best' }, { name: '是否新品', value: 'is_new' }] const proOptions = [{ name: '是否热卖', value: 'is_hot' }, { name: '优品推荐', value: 'is_good' }, { name: '特惠专区', value: 'is_benefit' }, { name: '是否精品', value: 'is_best' }, { name: '是否新品', value: 'is_new' }]
export default { export default {
name: 'Info', name: 'Info',
props: { props: {

View File

@ -207,7 +207,7 @@ const objTitle = {
title: '体积(m³)' title: '体积(m³)'
} }
} }
const proOptions = [{ name: '热门榜单', value: 'is_hot' }, { name: '促销单品', value: 'is_benefit' }, { name: '精品推荐', value: 'is_best' }, { name: '首发新品', value: 'is_new' }] const proOptions = [{ name: '热门榜单', value: 'is_hot' }, { name: '特惠专区', value: 'is_benefit' }, { name: '精品推荐', value: 'is_best' }, { name: '首发新品', value: 'is_new' }]
export default { export default {
name: 'Info', name: 'Info',
props: { props: {

View File

@ -378,6 +378,8 @@ import createWorkBook from '@/utils/newToExcel.js';
import cardsData from "@/components/cards/index"; import cardsData from "@/components/cards/index";
import { fromList } from "@/libs/constants.js"; import { fromList } from "@/libs/constants.js";
import timeOptions from '@/utils/timeOptions'; import timeOptions from '@/utils/timeOptions';
import * as FileSaver from 'file-saver'
import Worker from "worker-loader!@/worker/calcWorker.js";
export default { export default {
components: { orderDetail, cardsData, userDetails }, components: { orderDetail, cardsData, userDetails },
data() { data() {
@ -540,31 +542,34 @@ export default {
this.userDawer = v; this.userDawer = v;
}, },
// csv // csv
exportCsv(columns, dataList, fileName) { // exportCsv(columns, dataList, fileName) {
let title = columns.map(item => item); // let title = columns.map(item => item);
let keyArray = columns.map(item => item.key); // let keyArray = columns.map(item => item.key);
let str = []; // let str = [];
console.log(dataList); // str.push(title.join(',') + '\n');
console.log(title); // for (let i = 0; i < dataList.length; i++) {
str.push(title.join(',') + '\n'); // const temp = [];
for (let i = 0; i < dataList.length; i++) { // for (let j = 0; j < keyArray.length; j++) {
const temp = []; // console.log(dataList[i][j]);
for (let j = 0; j < keyArray.length; j++) { // temp.push(dataList[i][j]);
console.log(dataList[i][j]); // }
temp.push(dataList[i][j]); // str.push(temp.join(',') + '\n');
} // }
str.push(temp.join(',') + '\n'); // let uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str.join(''));
} // let downloadLink = document.createElement('a');
console.log(str) // downloadLink.href = uri;
let uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str.join('')); // downloadLink.download = fileName;
let downloadLink = document.createElement('a'); // document.body.appendChild(downloadLink);
downloadLink.href = uri; // downloadLink.click();
downloadLink.download = fileName; // document.body.removeChild(downloadLink);
document.body.appendChild(downloadLink); // },
downloadLink.click();
document.body.removeChild(downloadLink);
},
async exports() { async exports() {
const loading = this.$loading({
lock: true,
text: '导出中...',
spinner: 'el-icon-loading',
background: 'hsla(0, 0%, 100%, .9)'
});
let excelData = JSON.parse(JSON.stringify(this.tableFrom)), data = [] let excelData = JSON.parse(JSON.stringify(this.tableFrom)), data = []
excelData.page = 1 excelData.page = 1
excelData.limit = 200 excelData.limit = 200
@ -584,7 +589,35 @@ export default {
excelData.page++ excelData.page++
} }
} }
this.exportCsv(lebData.header,data,lebData.filename) console.log('开始处理');
//
let start = performance.now();
// 线
let worker = new Worker();
// 线postMessage
worker.postMessage({
header:lebData.header,
title: lebData.title,
data,
foot: lebData.foot,
filename:lebData.filename
});
// message
worker.addEventListener("message", (e) => {
// 线
worker.terminate();
//
let end = performance.now();
//
let durationTime = end - start;
console.log('计算结果:', e.data);
let { blob, filename } = e.data
FileSaver.saveAs(blob, filename + '.xlsx')
loading.close();
console.log(`代码执行了 ${durationTime} 毫秒`);
});
// this.exportCsv(lebData.header,data,lebData.filename)
// createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename) // createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename)
// work.saveAndDowloade(lebData.filename) // work.saveAndDowloade(lebData.filename)
return return

View File

@ -814,7 +814,7 @@ const proOptions = [
value: "is_hot", value: "is_hot",
}, },
{ {
name: "促销单品", name: "特惠专区",
value: "is_benefit", value: "is_benefit",
}, },
{ {
@ -880,7 +880,7 @@ export default {
value: "hot", value: "hot",
}, },
{ {
name: "促销单品", name: "特惠专区",
value: "good", value: "good",
}, },
{ {

View File

@ -769,7 +769,7 @@ const objTitle = {
const proOptions = [ const proOptions = [
{ name: "是否热卖", value: "is_hot" }, { name: "是否热卖", value: "is_hot" },
{ name: "优品推荐", value: "is_good" }, { name: "优品推荐", value: "is_good" },
{ name: "促销单品", value: "is_benefit" }, { name: "特惠专区", value: "is_benefit" },
{ name: "是否精品", value: "is_best" }, { name: "是否精品", value: "is_best" },
{ name: "是否新品", value: "is_new" }, { name: "是否新品", value: "is_new" },
]; ];

View File

@ -438,7 +438,7 @@
class="value" class="value"
> >
<span class="value-item" v-if="productData.is_benefit" <span class="value-item" v-if="productData.is_benefit"
>促销单品</span >特惠专区</span
> >
<span class="value-item" v-if="productData.is_new" <span class="value-item" v-if="productData.is_new"
>首发新品</span >首发新品</span

View File

@ -363,9 +363,9 @@
<el-divider></el-divider> <el-divider></el-divider>
</div> </div>
<div> <div>
<span class="spBlock spTitle mb10">热门榜单/ 精品推荐/ 首发新品/促销单品</span> <span class="spBlock spTitle mb10">热门榜单/ 精品推荐/ 首发新品/特惠专区</span>
<span class="spBlock mb5">地址<i>/pages/columnGoods/HotNewGoods/index</i></span> <span class="spBlock mb5">地址<i>/pages/columnGoods/HotNewGoods/index</i></span>
<span class="spBlock mb5">参数<i>type: 区分列表best为精品推荐hot为热门榜单new为首发新品good为促销单品</i></span> <span class="spBlock mb5">参数<i>type: 区分列表best为精品推荐hot为热门榜单new为首发新品good为特惠专区</i></span>
<span class="spBlock spEx">例如<i>/pages/columnGoods/HotNewGoods/index?type=best</i></span> <span class="spBlock spEx">例如<i>/pages/columnGoods/HotNewGoods/index?type=best</i></span>
<el-divider></el-divider> <el-divider></el-divider>
</div> </div>

View File

@ -24,9 +24,9 @@
<el-divider /> <el-divider />
</div> </div>
<div> <div>
<span class="spBlock spTitle mb10">热门榜单/ 精品推荐/ 首发新品/促销单品</span> <span class="spBlock spTitle mb10">热门榜单/ 精品推荐/ 首发新品/特惠专区</span>
<span class="spBlock mb5">地址<i>/goods_list</i></span> <span class="spBlock mb5">地址<i>/goods_list</i></span>
<span class="spBlock mb5">参数<i>type: 区分列表best为精品推荐hot为热门榜单new为首发新品good为促销单品</i></span> <span class="spBlock mb5">参数<i>type: 区分列表best为精品推荐hot为热门榜单new为首发新品good为特惠专区</i></span>
<span class="spBlock spEx">例如<i>/goods_list?type=best</i></span> <span class="spBlock spEx">例如<i>/goods_list?type=best</i></span>
<el-divider></el-divider> <el-divider></el-divider>
</div> </div>

191
src/worker/calcWorker.js Normal file
View File

@ -0,0 +1,191 @@
// importScripts("https://cdn.bootcdn.net/ajax/libs/exceljs/4.3.0/exceljs.js");
import ExcelJS from 'exceljs'
onmessage = (res) => {
const letter = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
let lcomun = 1;
let worksheet;
let { header, title, data, foot, filename, sheets } = res.data;
const workBook = new ExcelJS.Workbook();
let long = header.length;
/**
* 创建工作薄
* @param {*} sheets
*/
function createSheets(sheets) {
let sheet = Array.isArray(sheets) ? sheets[0] : sheets;
let style = Array.isArray(sheets) ? sheets[1] : {};
worksheet = workBook.addWorksheet(sheet, style);
}
/**
* 设置表名介绍等
* @param {*} title
* @param {*} long
*/
function setTitle(title, long) {
title = Array.isArray(title) ? title : title.split(',');
for (let i = 0; i < title.length; i++) {
let ti = worksheet.getRow(i + 1);
ti.getCell(1).value = title[i];
ti.height = 30;
ti.font = { bold: true, size: 20, vertAlign: 'subscript', };
ti.alignment = { vertical: 'bottom', horizontal: 'center' };
ti.outlineLevel = 1;
worksheet.mergeCells(i + 1, 1, i + 1, long)
ti.commit();
lcomun++;
}
}
/**
* 设置表头行
* @param {*} header
*/
function setHeader(header) {
const headerRow = worksheet.getRow(lcomun);
for (let index = 1; index <= header.length; index++) {
headerRow.getCell(index).value = header[index - 1];
}
headerRow.height = 25;
headerRow.width = 50;
headerRow.font = { bold: true, size: 18, vertAlign: 'subscript', };
headerRow.alignment = { vertical: 'bottom', horizontal: 'center' };
headerRow.outlineLevel = 1;
headerRow.commit();
lcomun++;
}
/**
* 导出内容
* @param {*} data
*/
function setContent(data) {
for (let h = 0; h < data.length; h++) {
let satarLcomun = lcomun;
let lcomunNow = worksheet.getRow(lcomun);
let hasMerge = false;
let starKey = 0;
let endKey = 0;
/** 循环列 */
//需要操作第几列
let sk = 0;
for (let l = 0; l < data[h].length; l++) {
if (Array.isArray(data[h][l])) {
//数组长度
starKey = sk;
hasMerge = true;
setArrayContent(data[h][l], sk);
if (data[h][l][0]) {
sk = sk + data[h][l][0].length
}
endKey = sk;
} else {
//不是数组
lcomunNow.getCell(getLetter(sk)).value = data[h][l];
lcomunNow.getCell(getLetter(sk)).border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } };
lcomunNow.alignment = { vertical: 'middle', horizontal: 'center' };
sk++
}
}
if (hasMerge) setMergeLcomun(satarLcomun, lcomun, starKey, endKey);
lcomunNow.height = 25;
lcomunNow.commit();
lcomun++
}
}
/**
* 占多行的数组
* @param {*} arr
* @param {*} sk
*/
function setArrayContent(arr, sk) {
/**
* 循环二维数组,在循环行
*/
let al = arr.length;
let sl = al - 1;
for (let i = 0; i < arr.length; i++) {
let lcomunNow = worksheet.getRow(lcomun);
for (let v = 0; v < arr[i].length; v++) {
lcomunNow.getCell(getLetter(sk + v)).value = arr[i][v];
lcomunNow.getCell(getLetter(sk + v)).border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } };
lcomunNow.alignment = { vertical: 'middle', horizontal: 'center' };
}
lcomunNow.height = 25;
lcomunNow.commit()
if (i < sl) lcomun++
}
}
/**
* 合并操作
* @param {*} satarLcomun
* @param {*} endLcomun
* @param {*} starKey
* @param {*} endKey
*/
function setMergeLcomun(satarLcomun, endLcomun, starKey, endKey) {
for (let ml = 0; ml < long; ml++) {
if (ml < starKey || ml >= endKey) {
worksheet.mergeCells(getLetter(ml) + satarLcomun + ':' + getLetter(ml) + endLcomun)
}
}
}
/**
* 设置表末尾统计备注等
* @param {*} footData
*/
function setFoot(footData) {
if (Array.isArray(footData)) {
for (let f = 0; f < footData.length; f++) {
let lcomunNow = worksheet.getRow(lcomun);
lcomunNow.getCell(1).value = footData[f];
lcomunNow.getCell(1).border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } };
lcomunNow.alignment = { vertical: 'middle', horizontal: 'left' };
worksheet.mergeCells('A' + lcomun + ':' + getLetter(long - 1) + lcomun)
lcomun++
}
} else {
let lcomunNow = worksheet.getRow(lcomun);
lcomunNow.getCell(1).value = footData;
lcomunNow.getCell(1).border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } };
lcomunNow.alignment = { vertical: 'middle', horizontal: 'left' };
worksheet.mergeCells('A' + lcomun + ':' + getLetter(long - 1) + lcomun)
}
}
/**
* 处理超过26个字母的列
* @param {*} number
* @returns
*/
function getLetter(number) {
if (number < 26) {
return letter[number];
} else {
let n = number % 26
let l = Math.floor(number % 26)
return letter[l] + letter[n]
}
}
/**
* 导出下载
* @param {*} filename
*/
function saveAndDowloade(filename) {
if (!filename) filename = new Date().getTime();
workBook.xlsx.writeBuffer().then(data => {
const blob = new Blob([data], { type: 'application/octet-stream' })
postMessage({ blob, filename })
})
}
createSheets(sheets);
setTitle(title, long);
setHeader(header);
setContent(data);
setFoot(foot);
saveAndDowloade(filename)
}

View File

@ -68,6 +68,11 @@ module.exports = {
config.plugins.delete('preload') // TODO: need test config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test config.plugins.delete('prefetch') // TODO: need test
config.module
.rule('worker')
.test(/\.worker\.js$/)
.use('worker')
.loader('worker-loader')
// set svg-sprite-loader // set svg-sprite-loader
config.module config.module
.rule('svg') .rule('svg')