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

2
src/renderer/src/App.vue

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

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

@ -51,6 +51,7 @@
import _ from 'lodash' import _ from 'lodash'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import ExcelJS from "exceljs";
import tablecomponent from "../components/tablecomponent.vue" import tablecomponent from "../components/tablecomponent.vue"
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
export default { export default {
@ -218,6 +219,9 @@ export default {
m: 0//Quantity per container(EG) m: 0//Quantity per container(EG)
}) })
} }
}
for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j];
if (Number(storeItem.k)) { if (Number(storeItem.k)) {
itemTemp.push({ itemTemp.push({
g: storeItem.g,//Store g: storeItem.g,//Store
@ -230,6 +234,9 @@ export default {
m: 0//Quantity per container(EG) m: 0//Quantity per container(EG)
}) })
} }
}
for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j];
if (Number(storeItem.l)) { if (Number(storeItem.l)) {
itemTemp.push({ itemTemp.push({
g: storeItem.g,//Store g: storeItem.g,//Store
@ -242,6 +249,9 @@ export default {
m: 0//Quantity per container(EG) m: 0//Quantity per container(EG)
}) })
} }
}
for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j];
if (Number(storeItem.m)) { if (Number(storeItem.m)) {
itemTemp.push({ itemTemp.push({
g: storeItem.g,//Store g: storeItem.g,//Store
@ -328,28 +338,74 @@ export default {
}, },
// //
async exportData() { async exportData() {
let that = this let that = this;
let listCopy = _.cloneDeep(that.fileData2) 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 newHeaders = [
let lilstLocal = [] "Order", "Sku", "Description", "Type of merchandise",
for (let i = 0; i < listCopy.length; i++) { "Quantity to deliver", "Store", "Quantity of containers",
let item = listCopy[i]; "Barcode", "Quantity per container", "Total", "Cluster",
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]; let lilstLocal = listCopy.map(item => ({
// ...item,
jsonWorkSheet[`${XLSX.utils.encode_cell({ c: index, r: 0 })}`].v = element 'Quantity to deliver': item["Quantity to deliver"] ? item["Quantity to deliver"].toFixed(3) : ""
} }));
let workBook = {
SheetNames: ["sheet1"], // 簿
Sheets: { let workbook = new ExcelJS.Workbook();
["sheet1"]: jsonWorkSheet, 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() { }, async mounted() { },

Loading…
Cancel
Save