hand in for review

This commit is contained in:
郑茂强 2018-10-09 10:24:24 +08:00
parent a1cc5c7677
commit e2d7f832ad
4 changed files with 137 additions and 77 deletions

View File

@ -102,6 +102,101 @@ const data = {
},
],
},
{
id: 1234,
material: '颗粒板',
color: '暖白',
boardInfos: [
{
houseName: 'F01',
closetName: 'G01',
boardNo: 'B1816478862',
boardName: '背板',
length: 944,
width: 59,
thickness: 18,
quantity: 1,
area: 0.568,
mutation: '',
shape: '',
direction: '1/1/1/1 ',
stripe: '正纹',
boardAddOn: '1',
},
{
houseName: 'F01',
closetName: 'G01',
boardNo: 'B1816478862',
boardName: '层板',
length: 944,
width: 598,
thickness: 18,
quantity: 1,
area: 0.568,
mutation: '',
shape: '造型',
direction: '1/1/1/1 ',
stripe: '正纹',
boardAddOn: '2',
},
{
houseName: 'F01',
closetName: 'G01',
boardNo: 'B1816478875',
boardName: '右侧板',
length: 1198,
width: 548,
thickness: 18,
quantity: 1,
area: 0.66,
mutation: '',
shape: '造型',
direction: '1/1/1/1 ',
stripe: '正纹',
boardAddOn: '3',
},
],
},
{
id: 1235,
material: '生态板 ',
color: '暖黑',
boardInfos: [
{
houseName: 'F01',
closetName: 'G01',
boardNo: 'B1816478862',
boardName: '背板',
length: 944,
width: 598,
thickness: 18,
quantity: 1,
area: 0.568,
mutation: '',
shape: '',
direction: '1/1/1/1 ',
stripe: '正纹',
boardAddOn: '4',
},
{
houseName: 'F01',
closetName: 'G01',
boardNo: 'B1816478861',
boardName: '背板',
length: 944,
width: 598,
thickness: 18,
quantity: 1,
area: 0.568,
mutation: '',
shape: '',
direction: '1/1/1/1 ',
stripe: '正纹',
boardAddOn: '5',
},
],
},
],
};

View File

@ -1,10 +1,10 @@
const Tool = {
addRow: (that, rowId) => {
addRow: (that: any, rowId: number) => {
if (that.selectedRow) {
for (const index in that.infos) {
if (that.selectedRow === that.infos[index].rowId) {
that.infos.splice(Number(index), 0, {
rowId: rowId,
rowId,
rowTitle: rowId.toString(),
cells: [],
});
@ -20,21 +20,23 @@ const Tool = {
});
}
},
deleteRow: (that) => {
deleteRow: (that: any) => {
if (!that.selectedRow) {
return alert('请选择要删除行');
}
that.infos = that.infos.filter((item) => item.rowId !== that.selectedRow);
that.infos = that.infos.filter(
(item: any) => item.rowId !== that.selectedRow,
);
that.selectedRow = 0;
},
addCell: (that, cellId) => {
addCell: (that: any, cellId: number) => {
if (!that.selectedRow) {
return alert('请选择要添加单元的行');
}
for (const row of that.infos) {
if (that.selectedRow === row.rowId) {
row.cells.push({
cellId: cellId,
cellId,
title: '列' + cellId,
colspan: 0,
height: 30,
@ -46,7 +48,7 @@ const Tool = {
}
},
deleteCell: (that) => {
deleteCell: (that: any) => {
// 9000 is initial cell Id.
if (that.selectedCell === 9000) {
return alert('请选择要删除的单元');

View File

@ -728,30 +728,7 @@ const initialTemplateData = [
},
],
},
{
rowId: 9,
rowTitle: '9',
cells: [
{
cellId: 9050,
title: '总计:',
colspan: '10',
height: 30,
textAlign: 'right',
fontSize: 16,
fontStyle: 'bold',
},
{
cellId: 9051,
title: 'totalquantity',
colspan: '14',
height: 30,
textAlign: 'center',
fontSize: 16,
fontStyle: 'normal',
},
],
},
{ rowId: 10, rowTitle: '10', cells: [] },
{ rowId: 11, rowTitle: '11', cells: [] },
{ rowId: 12, rowTitle: '12', cells: [] },

View File

@ -42,16 +42,16 @@
<label for="three">居右</label>
<br>
<div>
<span>选择板材头模板</span><br>
<span>开始</span><input type="number" v-model="banCaiHeadStartLine"><br>
<span>结束</span><input type="number" v-model="banCaiHeadEndLine">
<button @click="copyBanCaiHeadTemplate">确定板材头</button>
</div>
<div>
<p style="color: blue">以下功能用于测试使用</p>
<div>
<span>选择板材头模板</span><br>
<span>开始</span><input type="number" v-model="banCaiHeadStartLine"><br>
<span>结束</span><input type="number" v-model="banCaiHeadEndLine">
<button @click="copyBanCaiHeadTemplate">确定板材头</button>
</div>
<button @click="importTemplate">导入设计样式</button>
<button @click="importData">导入数据</button><br>
<label>单元ID:</label>
@ -74,13 +74,9 @@ import data from '@/assets/data'; // userdata for testing use
import reportCell from './reportCell.vue';
import test from './orderTitle.vue';
import { Tool } from '@/assets/methodTool';
import { debug } from 'util';
let rowId = 30; // this figure is for testing use
let cellId = 9050; // this figure is for testing use
let undoRodoPointer = -1;
let isundoOrRedoClick = false;
let isUpdateInfos = true;
let copiedRowHolder: any;
export default Vue.extend({
@ -120,6 +116,8 @@ export default Vue.extend({
fontSize: number;
fontStyle: string;
};
banCaiHeadStartLine: string;
banCaiHeadEndLine: string;
} {
return {
infos: startUpRowColumn,
@ -143,8 +141,8 @@ export default Vue.extend({
fontSize: 0,
fontStyle: '',
},
banCaiHeadStartLine: 5,
banCaiHeadEndLine: 8,
banCaiHeadStartLine: '5',
banCaiHeadEndLine: '8',
};
},
computed: {
@ -235,7 +233,7 @@ export default Vue.extend({
},
copyBanCaiHeadTemplate() {
let temStartLine = Number(this.banCaiHeadStartLine);
let banCaiHeadTemplateHolder = [];
const banCaiHeadTemplateHolder = [];
while (temStartLine <= Number(this.banCaiHeadEndLine)) {
banCaiHeadTemplateHolder.push(
@ -245,7 +243,7 @@ export default Vue.extend({
}
return banCaiHeadTemplateHolder;
},
pasteBanCaiHeadTemplate(copyBanCaiTemplate) {
pasteBanCaiHeadTemplate(copyBanCaiTemplate: any) {
const temCopyBanCaiTemplate = copyBanCaiTemplate;
for (const banCaiRow of temCopyBanCaiTemplate) {
for (const row of this.infos) {
@ -268,11 +266,11 @@ export default Vue.extend({
}
}
},
pasteBanCaiBodyTemplate(boardIndex) {
pasteBanCaiBodyTemplate(boardIndex: number) {
const boardInfosTemplateHolder = [];
const copyBanCaiBodyTemplateIndex = this.copyBanCaiBodyTemplate();
const copyBanCaiBodyTemplateIndex: any = this.copyBanCaiBodyTemplate();
for (let i = 0; i < data.boards[boardIndex].boardInfos.length; i++) {
for (const i of data.boards[boardIndex].boardInfos) {
boardInfosTemplateHolder.push(
this.copySingleRow(this.infos[copyBanCaiBodyTemplateIndex].rowId),
);
@ -298,10 +296,10 @@ export default Vue.extend({
}
},
importData() {
const orderDetailsKeys = [];
const banCaiHeaderKeys = [];
const banCaiDetailsKeys = [];
const temRowHolder = [];
const orderDetailsKeys: string[] = [];
const banCaiHeaderKeys: string[] = [];
const banCaiDetailsKeys: string[] = [];
const temRowHolder: string[] = [];
const banCaiTemplateIndexHolder = [];
for (const key in data) {
if (key !== 'boards') {
@ -313,11 +311,11 @@ export default Vue.extend({
banCaiHeaderKeys.push(key);
}
}
for (const key in data.boards[0].boardInfos[0]) {
for (const key of Object.keys(data.boards[0].boardInfos[0])) {
banCaiDetailsKeys.push(key);
}
const orderDetails = () => {
const addOrderDetails = () => {
for (const row of this.infos) {
for (const cell of row.cells) {
if (orderDetailsKeys.indexOf(cell.title) !== -1) {
@ -327,21 +325,20 @@ export default Vue.extend({
}
};
const banCaiHeader = (index) => {
const addBanCaiHeader = (index: number) => {
for (const row of this.infos) {
for (const cell of row.cells) {
if (banCaiHeaderKeys.indexOf(cell.title) !== -1) {
if (temRowHolder.indexOf(row) === -1) {
temRowHolder.push(this.copySingleRow(row.rowId));
}
cell.title = data.boards[index][cell.title];
}
}
}
};
const subQuantityMatch = (query) => {
const subQuantityMatch = (query: string) => {
for (const row of this.infos) {
for (const cell of row.cells) {
if (cell.title === query) {
@ -350,33 +347,22 @@ export default Vue.extend({
}
}
};
const totalQuantityMatch = (query) => {
for (const row of this.infos) {
for (const cell of row.cells) {
if (cell.title === query) {
cell.title = '总共板材数量';
}
}
}
};
//
//
const copyBanCaiTemplate = [];
for (let i = 0; i < data.boards.length - 1; i++) {
for (const board of data.boards) {
copyBanCaiTemplate.push(this.copyBanCaiHeadTemplate());
}
// orderDetails();
for (let i = 0; i < data.boards.length - 1; i++) {
banCaiHeader(i);
addOrderDetails();
for (let i = 0; i < data.boards.length; i++) {
addBanCaiHeader(i);
this.pasteBanCaiBodyTemplate(i);
subQuantityMatch('subquantity');
this.pasteBanCaiHeadTemplate(copyBanCaiTemplate[i]);
banCaiHeader(i + 1);
this.pasteBanCaiBodyTemplate(i + 1);
subQuantityMatch('subquantity');
if (i < data.boards.length - 1) {
this.pasteBanCaiHeadTemplate(copyBanCaiTemplate[i]);
}
}
totalQuantityMatch('totalquantity');
},
// for testing use -----import data from other file