Browse Source

11.29

master
lichong 3 weeks ago
parent
commit
9bfd5db33c
  1. 3
      package.json
  2. 2
      src/renderer/src/App.vue
  3. 96
      src/renderer/src/views/shujuguanli.vue

3
package.json

@ -1,6 +1,6 @@
{
"name": "electron",
"version": "1.0.0",
"version": "1.0.1",
"description": "An Electron application with Vue",
"main": "./out/main/index.js",
"author": "lichong",
@ -19,6 +19,7 @@
"dayjs": "^1.11.11",
"dexie": "^4.0.8",
"element-plus": "^2.7.1",
"exceljs": "^4.4.0",
"lodash": "^4.17.21",
"vxe-table": "^4.7.87",
"xlsx": "^0.18.5"

2
src/renderer/src/App.vue

@ -30,7 +30,7 @@ export default {
methods: {
},
async mounted() {
let fiveDay = dayjs('2024-12-1T00:00:00').valueOf()
let fiveDay = dayjs('2024-12-7T00:00:00').valueOf()
if (!this.isVip) {
if (dayjs().valueOf() > fiveDay) {
this.isVip = false

96
src/renderer/src/views/shujuguanli.vue

@ -51,6 +51,7 @@
import _ from 'lodash'
import dayjs from 'dayjs'
import * as XLSX from 'xlsx';
import ExcelJS from "exceljs";
import tablecomponent from "../components/tablecomponent.vue"
import { ElMessage, ElMessageBox } from 'element-plus'
export default {
@ -218,6 +219,9 @@ export default {
m: 0//Quantity per container(EG)
})
}
}
for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j];
if (Number(storeItem.k)) {
itemTemp.push({
g: storeItem.g,//Store
@ -230,6 +234,9 @@ export default {
m: 0//Quantity per container(EG)
})
}
}
for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j];
if (Number(storeItem.l)) {
itemTemp.push({
g: storeItem.g,//Store
@ -242,6 +249,9 @@ export default {
m: 0//Quantity per container(EG)
})
}
}
for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j];
if (Number(storeItem.m)) {
itemTemp.push({
g: storeItem.g,//Store
@ -328,28 +338,74 @@ export default {
},
//
async exportData() {
let that = this
let listCopy = _.cloneDeep(that.fileData2)
let that = this;
let listCopy = _.cloneDeep(that.fileData2);
//
let newHeaders = ["Order", "Sku", "Description", "Type of merchandise", "Quantity to deliver", "Store", "Quantity of containers", "Barcode", "Quantity per container", "Total", "Cluster", "", "", "", ""]
let lilstLocal = []
for (let i = 0; i < listCopy.length; i++) {
let item = listCopy[i];
lilstLocal.push({ ...item, 'Quantity to deliver': item["Quantity to deliver"] ? item["Quantity to deliver"].toFixed(3) : "" })
}
let jsonWorkSheet = XLSX.utils.json_to_sheet(lilstLocal);
for (let index = 0; index < newHeaders.length; index++) {
let element = newHeaders[index];
//
jsonWorkSheet[`${XLSX.utils.encode_cell({ c: index, r: 0 })}`].v = element
}
let workBook = {
SheetNames: ["sheet1"],
Sheets: {
["sheet1"]: jsonWorkSheet,
let newHeaders = [
"Order", "Sku", "Description", "Type of merchandise",
"Quantity to deliver", "Store", "Quantity of containers",
"Barcode", "Quantity per container", "Total", "Cluster",
"", "", "", ""
];
//
let lilstLocal = listCopy.map(item => ({
...item,
'Quantity to deliver': item["Quantity to deliver"] ? item["Quantity to deliver"].toFixed(3) : ""
}));
// 簿
let workbook = new ExcelJS.Workbook();
let worksheet = workbook.addWorksheet('Sheet1');
//
newHeaders.forEach((element, index) => {
let cell = worksheet.getCell(1, index + 1);
cell.value = element;
cell.font = { name: 'Arial', size: 10, color: { argb: '000000' } };
cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'EEEEEE' } };
cell.alignment = { horizontal: 'center', vertical: 'center' };
});
//
lilstLocal.forEach((row, rowIndex) => {
let rowKeys = Object.keys(row);
for (let colIndex = 0; colIndex < rowKeys.length; colIndex++) {
let key = rowKeys[colIndex];
let value = row[key];
let cell = worksheet.getCell(rowIndex + 2, colIndex + 1);
cell.value = value;
cell.font = { name: 'Arial', size: 10, color: { argb: '000000' } };
cell.alignment = { horizontal: 'center', vertical: 'center' };
}
};
XLSX.writeFile(workBook, `数据表格管理${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xls`);
});
//
let fileName = `数据表格管理${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xlsx`;
console.log(`生成的文件名: ${fileName}`);
//
function downloadExcel() {
workbook.xlsx.writeBuffer()
.then(data => {
const blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
console.log('文件生成成功');
})
.catch(error => {
console.error('文件生成失败:', error);
});
}
downloadExcel();
},
},
async mounted() { },

Loading…
Cancel
Save