增加订单内部备注,支持修改审批并与客户打印内容隔离

This commit is contained in:
summer committed 2026-10-28 18:41:14 +08:00
1 parent 5e1e4c600c
commit 3ef8a16eca
16 files changed
+176 -39

No files matched your search

+5 -4
View File
@@ -130,7 +130,7 @@ class Ledger {
`);
// 增量升级旧库,不改写历史订单金额、单号和成本。
const columns=this.rows('PRAGMA table_info(orders)').map(r=>r.name);
for(const [name,definition] of Object.entries({paper_date:"TEXT NOT NULL DEFAULT ''",payment_account:"TEXT NOT NULL DEFAULT '助理微信'",fee_items:"TEXT NOT NULL DEFAULT '[]'",fees_date:"TEXT NOT NULL DEFAULT ''",rounding_mode:"TEXT NOT NULL DEFAULT 'cent'"})){
for(const [name,definition] of Object.entries({paper_date:"TEXT NOT NULL DEFAULT ''",payment_account:"TEXT NOT NULL DEFAULT '助理微信'",fee_items:"TEXT NOT NULL DEFAULT '[]'",fees_date:"TEXT NOT NULL DEFAULT ''",rounding_mode:"TEXT NOT NULL DEFAULT 'cent'",internal_note:"TEXT NOT NULL DEFAULT ''"})){
if(!columns.includes(name))this.db.exec(`ALTER TABLE orders ADD COLUMN ${name} ${definition}`);
}
// 只加可空分项,不把历史原人数归给任一助理,也不改历史版本及录入信息。
@@ -406,12 +406,13 @@ class Ledger {
const autoNumber=prior?.paper_date&&prior.paper_number.match(/^\d{8}-?(\d+)$/);
const paper=newNumber?this.paperNumber(date,true):autoNumber?date.replaceAll('-','')+autoNumber[1]:prior.paper_number;
if(this.one("SELECT id FROM orders WHERE REPLACE(paper_number,'-','')=? AND id<>?",paper.replaceAll('-',''),id||''))fail('该日期已有相同纸单号,请保留原日期或取消后重开',409);
const common=[date,customer,salesperson,text(input.note,'客户单备注',240,true),paper,JSON.stringify(lines),discount,total];
const internalNote=text(input.internal_note===undefined?prior?.internal_note:input.internal_note,'内部备注',500,true);
const common=[date,customer,salesperson,text(input.note,'客户单备注',240,true),internalNote,paper,JSON.stringify(lines),discount,total];
if(id){
this.run('UPDATE orders SET date=?,customer=?,salesperson=?,note=?,paper_number=?,lines=?,discount=?,total=? WHERE id=?',...common,id);this.touch(id);
this.run('UPDATE orders SET date=?,customer=?,salesperson=?,note=?,internal_note=?,paper_number=?,lines=?,discount=?,total=? WHERE id=?',...common,id);this.touch(id);
} else {
id=randomUUID();const number='MM'+today().replaceAll('-','')+'-'+randomUUID().slice(0,8).toUpperCase();
this.run('INSERT INTO orders(id,number,date,customer,salesperson,note,paper_number,lines,discount,total,status,created) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)',id,number,...common,'draft',now());this.assignMember('order',id,member,{fresh:true});this.enqueue('order:'+id);
this.run('INSERT INTO orders(id,number,date,customer,salesperson,note,internal_note,paper_number,lines,discount,total,status,created) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)',id,number,...common,'draft',now());this.assignMember('order',id,member,{fresh:true});this.enqueue('order:'+id);
}
this.run('UPDATE orders SET paper_date=?,payment_account=?,fee_items=?,fees_date=?,rounding_mode=? WHERE id=?',newNumber||autoNumber?date:prior?.paper_date||'',account,JSON.stringify(fees),feesDate,roundingMode,id);
this.audit(id,'保存草稿',actor,{revision:this.rawOrder(id).revision});return {id};