diff --git a/新账系统/order-note-tags.js b/新账系统/order-note-tags.js index 227c1eb..9cada12 100644 --- a/新账系统/order-note-tags.js +++ b/新账系统/order-note-tags.js @@ -5,7 +5,7 @@ function submission(ledger,input,actor,id=null){ ledger.selectedMember(input,actor,prior?ledger.entityMember('order',id):null); const note=String(input.internal_note===undefined?(prior?.internal_note??''):input.internal_note??'').trim(); const fail=message=>{const error=new Error(message);error.status=400;throw error;}; - if(note.replace(/\s/gu,'').length<5)fail('内部备注至少填写5个字,空格和换行不计入。'); + if(note.replace(/\s/gu,'').length<3)fail('内部备注至少填写3个字符,#号计入,空格和换行不计入。'); if(note.length>500)fail('内部备注最多填写500字。'); return {...input,internal_note:note}; } diff --git a/新账系统/public/app.js b/新账系统/public/app.js index a6e4f26..cdb2300 100644 --- a/新账系统/public/app.js +++ b/新账系统/public/app.js @@ -401,7 +401,7 @@ function savedOrderRoundingHint(order){ return orderRoundingHint({rounding_mode:'yuan',unroundedTotal,total:order.total,rounding_adjustment:order.rounding_adjustment??order.total-unroundedTotal}); } function orderInternalNoteField(value=''){ - return `
`; + return ``; } let orderNoteTags=[],orderNoteTagsRequest=0; function renderOrderNoteTags(){ @@ -484,7 +484,7 @@ function validateOrderIdentity(input,{requireInternalNote=true}={}){ const customer=String(input.customer??'').trim(),salesperson=String(input.salesperson??'').trim(); if(!customer||customer.length>60)throw new Error('客户称呼/代号必填,请填写 1~60 字。'); if(!salesperson||salesperson.length>30)throw new Error('开单人必填,请填写 1~30 字。'); - if(requireInternalNote&&String(input.internal_note??'').replace(/\s/gu,'').length<5)throw new Error('内部备注至少填写5个字,空格和换行不计入。'); + if(requireInternalNote&&String(input.internal_note??'').replace(/\s/gu,'').length<3)throw new Error('内部备注至少填写3个字符,#号计入,空格和换行不计入。'); if(String(input.internal_note??'').trim().length>500)throw new Error('内部备注最多填写500字。'); return {...input,customer,salesperson,...(requireInternalNote?{internal_note:String(input.internal_note??'').trim()}:{})}; } diff --git a/新账系统/test/order-entry-fields-ui.test.js b/新账系统/test/order-entry-fields-ui.test.js index 773d43e..18c124a 100644 --- a/新账系统/test/order-entry-fields-ui.test.js +++ b/新账系统/test/order-entry-fields-ui.test.js @@ -74,8 +74,8 @@ test('普通开单收集内部备注并恢复本地草稿,仅填内部备注 assert.throws(()=>h.run('validateOrderIdentity({customer:"客户",salesperson:"麦麦",internal_note:"字".repeat(501)})'),/内部备注最多填写500字/); }); -test('内部备注必填且至少5字,空格不能补长度;新建和修改共用字段支持标签入口',()=>{ - const h=harness();for(const note of ['', '一二三四', ' 一 二 三 四\n']){h.context.__draft=draft({internal_note:note});assert.throws(()=>h.run('validateIssueDraft(__draft)'),/至少填写5个字/);} - h.context.__draft=draft({internal_note:' 一二三四五 '});assert.equal(h.run('validateIssueDraft(__draft).internal_note'),'一二三四五'); - const html=h.run('orderInternalNoteField()');assert.match(html,/