|
/*01234567890123456789012345678901234567890123456789012345678901234567890123456789
* 合同主体类
* 时间: 2022/10/24
*********************************************************************************/
class Order{
constructor(id,orderId,customer,totalValue,approvalPerson,operator,receiveSample,
receiveDate,reportSending,paymentTerm,invoiceDate,paymentDate,reportDate,note){
this.id = id; //右上角序号
this.orderId = orderId;
this.customer = customer;
this.totalValue = totalValue;
this.approvalPerson = approvalPerson;
this.operator = operator;
this.receiveSample = receiveSample;
this.receiveDate = receiveDate;
this.reportSending = reportSending;
this.paymentTerm = paymentTerm;
this.invoiceDate = invoiceDate;
this.paymentDate = paymentDate;
this.reportDate = reportDate;
this.note=note;
}
newContents() { //填写订单表目录
const orderContentsSheet=Sheets(OrderContentsStr);
var i = 3;
// 查找序号,如果找到就修改,没有找到就在最上边插入新行
while(orderContentsSheet.Cells(i,1) != "[END]") {
if(orderContentsSheet.Cells(i,1) == this.id) {
var exist=true;
break;
}
i++;
};
if(!exist) {
i = 3;
orderContentsSheet.Rows("3:3").Insert(xlShiftDown, undefined);
}
orderContentsSheet.Cells(i,1).Value2 = this.id;
orderContentsSheet.Cells(i,2).Value2 = this.orderId;
orderContentsSheet.Cells(i,3.).Value2 = this.customer;
orderContentsSheet.Cells(i,4).Value2 = this.totalValue;
orderContentsSheet.Cells(i,5).Value2 = this.approvalPerson;
orderContentsSheet.Cells(i,6).Value2 = this.operator;
orderContentsSheet.Cells(i,7).Value2 = this.receiveSample;
orderContentsSheet.Cells(i,8).Value2 = this.receiveDate;
orderContentsSheet.Cells(i,9).Value2 = this.reportSending;
orderContentsSheet.Cells(i,10).Value2 = this.paymentTerm;
orderContentsSheet.Cells(i,11).Value2 = this.invoiceDate;
orderContentsSheet.Cells(i,12).Value2 = this.paymentDate;
orderContentsSheet.Cells(i,13).Value2 = this.reportDate;
orderContentsSheet.Cells(i,14).Value2 = this.note;
}
newItems() { //填写合同明细表
const orderItemsSheet = Sheets(OrderItemsStr);
let orderIdRange = orderItemsSheet.Range("$A:$A");
// 删除已有的相同订单号的行
do {
var orderIdCell = orderIdRange.Find(this.orderId);
if(orderIdCell != null){
orderIdCell.EntireRow.Delete();
}
}while(orderIdCell != null);
// 写入订单明细工作表
for(let i = 0;i < this.items.length;i++){
orderItemsSheet.Rows("2:2").Insert(xlShiftDown, undefined);
for(let j = 0;j < this.items[i].length;j++){
orderItemsSheet.Cells(2,1).Value2 = this.orderId;
orderItemsSheet.Cells(2,j+2).Value2 = this.items[i][j];
}
}
}
delete() { //删除合同
const orderContentsSheet=Sheets(OrderContentsStr);
var i=3;
// 查找目录序号,如果找到就删除
while(orderContentsSheet.Cells(i,1) != "[END]") {
if(orderContentsSheet.Cells(i,1) == this.id) {
let r = String(i) + ":" + String(i);
orderContentsSheet.Rows(r).Delete();
break;
}
i++;
};
// 查找明细订单号,删除记录
const orderItemsSheet = Sheets(OrderItemsStr);
let orderIdRange = orderItemsSheet.Range("$A:$A");
if(this.orderId != undefined) {
do {
var orderIdCell = orderIdRange.Find(this.orderId);
if(orderIdCell != null){
orderIdCell.EntireRow.Delete();
}
}while(orderIdCell != null);
}
}
}
|
评分
-
2
查看全部评分
-
|