diff --git a/src/assets/typeScriptDeclaration.ts b/src/assets/typeScriptDeclaration.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/src/components/reportTemplate/ReportTemplate.vue b/src/components/reportTemplate/ReportTemplate.vue
index 9068c6d..045df3f 100644
--- a/src/components/reportTemplate/ReportTemplate.vue
+++ b/src/components/reportTemplate/ReportTemplate.vue
@@ -41,6 +41,16 @@
+
+
+
+
@@ -64,24 +74,51 @@
-
{{this.infos}}
+
-
diff --git a/src/assets/hightlight.js b/src/components/reportTemplate/rescource/hightlight.js
similarity index 96%
rename from src/assets/hightlight.js
rename to src/components/reportTemplate/rescource/hightlight.js
index 5ddac08..93d359a 100644
--- a/src/assets/hightlight.js
+++ b/src/components/reportTemplate/rescource/hightlight.js
@@ -65,8 +65,6 @@ export function hightlight(table) {
});
$(document).mouseup(function() {
- var text = $('.selected').text();
- console.log(text);
isMouseDown = false;
});
}
diff --git a/src/assets/methodTool.ts b/src/components/reportTemplate/rescource/methodTool.ts
similarity index 52%
rename from src/assets/methodTool.ts
rename to src/components/reportTemplate/rescource/methodTool.ts
index a3420f1..c833eb0 100644
--- a/src/assets/methodTool.ts
+++ b/src/components/reportTemplate/rescource/methodTool.ts
@@ -1,5 +1,62 @@
-import data from '@/assets/data'; // userdata for testing use
+import data from '@/components/reportTemplate/rescource/orderDetails'; // use data for testing use
+const orderDetails: {
+ [index: string]: string | object;
+ orderNo: string;
+ clientName: string;
+ soldDate: string;
+ contactName: string;
+ contactNo: string;
+ deliveryAddress: string;
+ addOn: string;
+ boards: Array<{
+ [index: string]: number | string | object;
+ id: number;
+ material: string;
+ color: string;
+ boardInfos: Array<{
+ houseName: string;
+ closetName: string;
+ boardNo: string;
+ boardName: string;
+ length: number;
+ width: number;
+ thickness: number;
+ quantity: number;
+ area: number;
+ mutation: string;
+ shape: string;
+ direction: string;
+ stripe: string;
+ boardAddOn: string;
+
+ [index: string]: number | string;
+ }>;
+ }>;
+} = data;
+
+interface BoardFormat {
+ id: number;
+ material: string;
+ color: string;
+ boardInfos: Array<{
+ houseName: string;
+ closetName: string;
+ boardNo: string;
+ boardName: string;
+ length: number;
+ width: number;
+ thickness: number;
+ quantity: number;
+ area: number;
+ mutation: string;
+ shape: string;
+ direction: string;
+ stripe: string;
+ boardAddOn: string;
+ [index: string]: number | string;
+ }>;
+}
const subKeyWords = [
'sublength',
'subwidth',
@@ -14,21 +71,46 @@ const totalKeyWords = [
'totalquantity',
'totalarea',
];
+const tagsObject: any = {
+ '${订单号}': 'orderNo',
+ '${客户名}': 'clientName',
+ '${出售日期}': 'soldDate',
+ '${联系人}': 'contactName',
+ '${联系电话}': 'contactNo',
+ '${送货地址}': 'deliveryAddress',
+ '${订单备注}': 'addOn',
+ '${板材材料}': 'material',
+ '${板材颜色}': 'color',
+ '${板材房名}': 'houseName',
+ '${板材柜名}': 'closetName',
+ '${板材号}': 'boardNo',
+ '${板材名}': 'boardName',
+ '${长度}': 'length',
+ '${宽度}': 'width',
+ '${厚度}': 'thickness',
+ '${数量}': 'quantity',
+ '${面积}': 'area',
+ '${变异}': 'mutation',
+ '${形状}': 'shape',
+ '${方向}': 'direction',
+ '${条纹}': 'stripe',
+ '${板材备注}': 'boardAddOn',
+};
const orderDetailsKeys: string[] = [];
const banCaiHeaderKeys: string[] = [];
const banCaiDetailsKeys: string[] = [];
const temRowHolder: string[] = [];
-for (const key in data) {
+for (const key in orderDetails) {
if (key !== 'boards') {
orderDetailsKeys.push(key);
}
}
-for (const key in data.boards[0]) {
+for (const key in orderDetails.boards[0]) {
if (key !== 'boardInfos') {
banCaiHeaderKeys.push(key);
}
}
-for (const key of Object.keys(data.boards[0].boardInfos[0])) {
+for (const key of Object.keys(orderDetails.boards[0].boardInfos[0])) {
banCaiDetailsKeys.push(key);
}
@@ -91,15 +173,26 @@ const Tool = {
for (const cell in row.cells) {
if (row.cells[cell].cellId === that.selectedCell) {
row.cells.splice(Number(cell), 1);
+
+ // Vue.nextTick(() => {
+ // row.cells.splice(Number(cell), 1);
+ // });
}
}
}
that.selectedCell = 9000;
},
+ isTagName(cellTitle: string) {
+ if (cellTitle.slice(0, 2) === '${') {
+ return true;
+ } else {
+ return false;
+ }
+ },
addTotalAmount: (query: string) => {
- let total = 0;
+ let total: any = 0;
const query1 = query.slice(5);
- for (const board of data.boards) {
+ for (const board of orderDetails.boards) {
for (const eachBoardInfo of board.boardInfos) {
if (Object.keys(eachBoardInfo).indexOf(query1) !== -1) {
total += eachBoardInfo[query1];
@@ -112,8 +205,8 @@ const Tool = {
return total.toFixed(3);
}
},
- addSubAmount: (query, board) => {
- let sub = 0;
+ addSubAmount: (query: string, board: BoardFormat) => {
+ let sub: any = 0;
const query1 = query.slice(3);
for (const eachBoardInfo of board.boardInfos) {
@@ -127,7 +220,7 @@ const Tool = {
return sub.toFixed(3);
}
},
- addBoardInfoAmount: (that, board) => {
+ addBoardInfoAmount: (that: any, board: BoardFormat) => {
for (const row of that.infos) {
for (const cell of row.cells) {
if (cell.title === 'bancaiinfoamount') {
@@ -167,7 +260,7 @@ const Tool = {
}
return remainingFormHolder;
},
- pasteRemainingForm: (that, remainingFormHolder) => {
+ pasteRemainingForm: (that: any, remainingFormHolder: any[]) => {
for (const eachRemainingRow of remainingFormHolder) {
for (const row of that.infos) {
if (row.cells.length === 0) {
@@ -184,7 +277,7 @@ const Tool = {
}
}
},
- pasteBanCaiHeadTemplate: (that, copyBanCaiTemplate: any) => {
+ pasteBanCaiHeadTemplate: (that: any, copyBanCaiTemplate: any) => {
const temCopyBanCaiTemplate = copyBanCaiTemplate;
for (const banCaiRow of temCopyBanCaiTemplate) {
for (const row of that.infos) {
@@ -195,11 +288,25 @@ const Tool = {
}
}
},
- pasteBanCaiBody: (that, boardIndex: number) => {
- const boardInfosTemplateHolder = [];
- const copyBanCaiBodyTemplateIndex: any = that.copyBanCaiBodyTemplate();
+ copyBanCaiBodyTemplate: (that) => {
+ for (const row of that.infos) {
+ for (const cell of row.cells) {
+ if (
+ Object.keys(data.boards[0].boardInfos[0]).indexOf(
+ tagsObject[cell.title],
+ ) !== -1
+ ) {
+ return that.infos.indexOf(row);
+ }
+ }
+ }
+ },
- for (const i of data.boards[boardIndex].boardInfos) {
+ pasteBanCaiBody: (that: any, boardIndex: number) => {
+ const boardInfosTemplateHolder = [];
+ const copyBanCaiBodyTemplateIndex: any = Tool.copyBanCaiBodyTemplate(that);
+
+ for (const i of orderDetails.boards[boardIndex].boardInfos) {
boardInfosTemplateHolder.push(
that.copySingleRow(that.infos[copyBanCaiBodyTemplateIndex].rowId),
);
@@ -207,9 +314,9 @@ const Tool = {
for (let i = 0; i < boardInfosTemplateHolder.length; i++) {
for (const cell of boardInfosTemplateHolder[i].cells) {
- for (const key in data.boards[boardIndex].boardInfos[i]) {
- if (key === cell.title) {
- cell.title = data.boards[boardIndex].boardInfos[i][key];
+ for (const key in orderDetails.boards[boardIndex].boardInfos[i]) {
+ if (key === tagsObject[cell.title]) {
+ cell.title = orderDetails.boards[boardIndex].boardInfos[i][key];
}
}
}
@@ -224,28 +331,29 @@ const Tool = {
);
}
},
- addBanCaiHeader: (that, index: number) => {
+ addBanCaiHeader: (that: any, index: number) => {
for (const row of that.infos) {
for (const cell of row.cells) {
- if (banCaiHeaderKeys.indexOf(cell.title) !== -1) {
+ if (banCaiHeaderKeys.indexOf(tagsObject[cell.title]) !== -1) {
if (temRowHolder.indexOf(row) === -1) {
temRowHolder.push(that.copySingleRow(row.rowId));
}
- cell.title = data.boards[index][cell.title];
+
+ cell.title = orderDetails.boards[index][tagsObject[cell.title]];
}
}
}
},
- addOrderDetails: (that) => {
+ addOrderDetails: (that: any) => {
for (const row of that.infos) {
for (const cell of row.cells) {
- if (orderDetailsKeys.indexOf(cell.title) !== -1) {
- cell.title = data[cell.title];
+ if (orderDetailsKeys.indexOf(tagsObject[cell.title]) !== -1) {
+ cell.title = orderDetails[tagsObject[cell.title]];
}
}
}
},
- addsubQuantity: (that, board: any) => {
+ addsubQuantity: (that: any, board: any) => {
for (const row of that.infos) {
for (const cell of row.cells) {
if (subKeyWords.indexOf(cell.title) !== -1) {
@@ -254,5 +362,53 @@ const Tool = {
}
}
},
+ exportAsExcel: () => {
+ const tabs = document.getElementsByTagName('table');
+ let allElementText: any = '';
+ for (const tab of tabs) {
+ let tabText: string = '';
+ for (let i = 1; i < tab.rows.length; i++) {
+ const tds = tab.rows[i].getElementsByTagName('td');
+ let tdText = '';
+ for (const td of tds) {
+ tdText += td.outerHTML;
+ }
+ tabText += tdText + '
';
+ }
+ allElementText += tabText + '
';
+ }
+
+ window.open(
+ 'data:application/vnd.ms-excel,' + encodeURIComponent(allElementText),
+ );
+ },
+ printAsPdf: () => {
+ const tabs = document.getElementsByTagName('table');
+ let allElementText: any = '';
+ for (const tab of tabs) {
+ let tabText: string =
+ '';
+ for (let i = 1; i < tab.rows.length; i++) {
+ const tds = tab.rows[i].getElementsByTagName('td');
+ let tdText = '';
+ for (const td of tds) {
+ tdText += td.outerHTML;
+ }
+ tabText += tdText + '
';
+ }
+ allElementText += tabText + '
';
+ }
+
+ const WinPrint: any = window.open(
+ '',
+ '',
+ 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0',
+ );
+ WinPrint.document.write(allElementText);
+ WinPrint.document.close();
+ WinPrint.focus();
+ WinPrint.print();
+ WinPrint.close();
+ },
};
export { Tool };
diff --git a/src/assets/data.ts b/src/components/reportTemplate/rescource/orderDetails.ts
similarity index 100%
rename from src/assets/data.ts
rename to src/components/reportTemplate/rescource/orderDetails.ts
diff --git a/src/assets/startUpRowColumn.ts b/src/components/reportTemplate/rescource/startUpRowColumn.ts
similarity index 100%
rename from src/assets/startUpRowColumn.ts
rename to src/components/reportTemplate/rescource/startUpRowColumn.ts
diff --git a/src/assets/templateInitialData.ts b/src/components/reportTemplate/rescource/templateInitialData.ts
similarity index 92%
rename from src/assets/templateInitialData.ts
rename to src/components/reportTemplate/rescource/templateInitialData.ts
index cdf2767..4de422e 100644
--- a/src/assets/templateInitialData.ts
+++ b/src/components/reportTemplate/rescource/templateInitialData.ts
@@ -243,7 +243,7 @@ const initialTemplateData = [
{
cellId: 9002,
title: '订单号',
- colspan: '3',
+ colspan: 3,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -251,8 +251,8 @@ const initialTemplateData = [
},
{
cellId: 9003,
- title: 'orderNo',
- colspan: '4',
+ title: '${订单号}',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -261,7 +261,7 @@ const initialTemplateData = [
{
cellId: 9004,
title: '客户名',
- colspan: '4',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -269,8 +269,8 @@ const initialTemplateData = [
},
{
cellId: 9005,
- title: 'clientName',
- colspan: '4',
+ title: '${客户名}',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -279,7 +279,7 @@ const initialTemplateData = [
{
cellId: 9006,
title: '出售日期',
- colspan: '5',
+ colspan: 5,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -287,8 +287,8 @@ const initialTemplateData = [
},
{
cellId: 9007,
- title: 'soldDate',
- colspan: '4',
+ title: '${出售日期}',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -303,7 +303,7 @@ const initialTemplateData = [
{
cellId: 9008,
title: '联系人',
- colspan: '3',
+ colspan: 3,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -311,8 +311,8 @@ const initialTemplateData = [
},
{
cellId: 9009,
- title: 'contactName',
- colspan: '4',
+ title: '${联系人}',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -321,7 +321,7 @@ const initialTemplateData = [
{
cellId: 9010,
title: '联系电话',
- colspan: '4',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -329,8 +329,8 @@ const initialTemplateData = [
},
{
cellId: 9011,
- title: 'contactNo',
- colspan: '4',
+ title: '${联系电话}',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -339,7 +339,7 @@ const initialTemplateData = [
{
cellId: 9012,
title: '送货地址',
- colspan: '5',
+ colspan: 5,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -347,8 +347,8 @@ const initialTemplateData = [
},
{
cellId: 9013,
- title: 'deliveryAddress',
- colspan: '4',
+ title: '${送货地址}',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -363,7 +363,7 @@ const initialTemplateData = [
{
cellId: 9014,
title: '备注',
- colspan: '4',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -371,8 +371,8 @@ const initialTemplateData = [
},
{
cellId: 9015,
- title: 'addOn',
- colspan: '4',
+ title: '${订单备注}',
+ colspan: 4,
height: 30,
textAlign: 'center',
fontSize: 16,
@@ -387,7 +387,7 @@ const initialTemplateData = [
{
cellId: 9016,
title: '材料',
- colspan: '4',
+ colspan: 4,
height: 30,
textAlign: 'left',
fontSize: 16,
@@ -395,8 +395,8 @@ const initialTemplateData = [
},
{
cellId: 9017,
- title: 'material',
- colspan: '4',
+ title: '${板材材料}',
+ colspan: 4,
height: 30,
textAlign: 'left',
fontSize: 16,
@@ -405,7 +405,7 @@ const initialTemplateData = [
{
cellId: 9018,
title: '颜色',
- colspan: '4',
+ colspan: 4,
height: 30,
textAlign: 'left',
fontSize: 16,
@@ -413,8 +413,8 @@ const initialTemplateData = [
},
{
cellId: 19018,
- title: 'color',
- colspan: '4',
+ title: '${板材颜色}',
+ colspan: 4,
height: 30,
textAlign: 'left',
fontSize: 16,
@@ -423,7 +423,7 @@ const initialTemplateData = [
{
cellId: 29018,
title: '板材信息数量:',
- colspan: '4',
+ colspan: 4,
height: 30,
textAlign: 'right',
fontSize: 16,
@@ -432,7 +432,7 @@ const initialTemplateData = [
{
cellId: 9060,
title: 'bancaiinfoamount',
- colspan: '4',
+ colspan: 4,
height: 30,
textAlign: 'left',
fontSize: 16,
@@ -446,7 +446,7 @@ const initialTemplateData = [
cells: [
{
cellId: 9019,
- title: '房名',
+ title: '板材房名',
colspan: 2,
height: 30,
textAlign: 'center',
@@ -455,7 +455,7 @@ const initialTemplateData = [
},
{
cellId: 9020,
- title: '柜名',
+ title: '板材柜名',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -578,7 +578,7 @@ const initialTemplateData = [
cells: [
{
cellId: 9033,
- title: 'houseName',
+ title: '${板材房名}',
colspan: 2,
height: 30,
textAlign: 'center',
@@ -587,7 +587,7 @@ const initialTemplateData = [
},
{
cellId: 9034,
- title: 'closetName',
+ title: '${板材柜名}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -596,7 +596,7 @@ const initialTemplateData = [
},
{
cellId: 9035,
- title: 'boardNo',
+ title: '${板材号}',
colspan: 2,
height: 30,
textAlign: 'center',
@@ -605,7 +605,7 @@ const initialTemplateData = [
},
{
cellId: 9036,
- title: 'boardName',
+ title: '${板材名}',
colspan: 2,
height: 30,
textAlign: 'center',
@@ -614,7 +614,7 @@ const initialTemplateData = [
},
{
cellId: 9037,
- title: 'length',
+ title: '${长度}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -623,7 +623,7 @@ const initialTemplateData = [
},
{
cellId: 9038,
- title: 'width',
+ title: '${宽度}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -632,7 +632,7 @@ const initialTemplateData = [
},
{
cellId: 9039,
- title: 'thickness',
+ title: '${厚度}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -641,7 +641,7 @@ const initialTemplateData = [
},
{
cellId: 9040,
- title: 'quantity',
+ title: '${数量}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -650,7 +650,7 @@ const initialTemplateData = [
},
{
cellId: 9041,
- title: 'area',
+ title: '${面积}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -659,7 +659,7 @@ const initialTemplateData = [
},
{
cellId: 9042,
- title: 'mutation',
+ title: '${变异}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -668,7 +668,7 @@ const initialTemplateData = [
},
{
cellId: 9043,
- title: 'shape',
+ title: '${形状}',
colspan: 0,
height: 30,
textAlign: 'center',
@@ -677,7 +677,7 @@ const initialTemplateData = [
},
{
cellId: 9044,
- title: 'direction',
+ title: '${方向}',
colspan: 3,
height: 30,
textAlign: 'center',
@@ -686,7 +686,7 @@ const initialTemplateData = [
},
{
cellId: 9045,
- title: 'stripe',
+ title: '${条纹}',
colspan: 2,
height: 30,
textAlign: 'center',
@@ -695,7 +695,7 @@ const initialTemplateData = [
},
{
cellId: 9046,
- title: 'boardAddOn',
+ title: '${板材备注}',
colspan: 5,
height: 30,
textAlign: 'center',
diff --git a/tsconfig.json b/tsconfig.json
index e24b286..f4a9fca 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -11,30 +11,19 @@
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
- "types": [
- "node",
- "jest"
- ],
+ "types": ["node", "jest"],
"paths": {
- "@/*": [
- "src/*"
- ]
+ "@/*": ["src/*"]
},
- "lib": [
- "esnext",
- "dom",
- "dom.iterable",
- "scripthost"
- ]
+ "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
- "tests/**/*.tsx"
+ "tests/**/*.tsx",
+ "src/components/reportTemplate/rescource/hightlight.js"
],
- "exclude": [
- "node_modules"
- ]
+ "exclude": ["node_modules"]
}