保存同行基础版:店铺配置与员工管理
This commit is contained in:
1 parent
ecb8d6dec0
commit
b7b987064b
84 files changed
+1884
-573
No files matched your search
+3
-3
@@ -51,10 +51,10 @@ function detail(ledger,id,actor,env){
|
||||
pending:pending?publicRequest(ledger,pending,actor,env,current):null,
|
||||
history:requests.filter(row=>row.status!=='pending').map(row=>publicRequest(ledger,row,actor,env,current))};
|
||||
}
|
||||
function normalized(input,env){
|
||||
function normalized(input,env,original=null){
|
||||
if(typeof input.project!=='string'||typeof input.customer!=='string')env.fail('售后项目和客户称呼须填写文字');
|
||||
return {date:env.day(input.date),project:env.text(input.project,'售后项目',100),customer:env.text(input.customer,'客户称呼',60),
|
||||
amount:env.money(input.amount,'售后金额'),payer:env.pick(input.payer,['owner','assistant','assistant2'],'费用付款人')};
|
||||
amount:env.money(input.amount,'售后金额'),payer:env.validateMember(input.payer,'费用付款人',{original:original?.payer})};
|
||||
}
|
||||
function version(current,revision,env){if(!Number.isSafeInteger(revision)||revision!==current.revision)env.fail('售后记录已有变动,请刷新后核对再修改',409);}
|
||||
function apply(ledger,current,after,actor,env){
|
||||
@@ -71,7 +71,7 @@ function update(ledger,id,input,actor,env){return atomic(ledger,()=>{
|
||||
object(input,env);const current=state(ledger,id,actor,env);version(current,input.revision,env);
|
||||
if(Object.hasOwn(input,'member')&&input.member!==current.member)env.fail('已有记录的归属不能修改',403);
|
||||
if(ledger.one("SELECT id FROM after_sale_changes WHERE after_sale_id=? AND status='pending'",id))env.fail('这笔售后已有待审批修改,请先由麦麦处理',409);
|
||||
const after=normalized(input,env),before=values(current.row),reason=env.text(input.reason,'修改说明',200,true)||'修改售后记录';
|
||||
const after=normalized(input,env,current.row),before=values(current.row),reason=env.text(input.reason,'修改说明',200,true)||'修改售后记录';
|
||||
if(JSON.stringify(before)===JSON.stringify(after))env.fail('修改后内容与原售后记录相同');
|
||||
const currentDate=env.today(),direct=actor.role==='owner'||current.row.date===currentDate&&after.date===currentDate;
|
||||
if(direct){
|
||||
|
||||
Reference in new issue
Block a user