支持直接修改已生成订单并重算成本库存与利润
This commit is contained in:
1 parent
3bf9e8d82d
commit
34781b6cd1
14 files changed
+718
-31
No files matched your search
@@ -30,7 +30,7 @@ function orderTemplateHasDraft(draft,today){
|
||||
async function applyOrderTemplate(id,select){
|
||||
if(busy||orderCopyLoading||orderTemplateApplying)throw new Error('正在处理订单,请稍候再套用模板。');
|
||||
if(pending())throw new Error('请先恢复上次未确认的操作,再套用模板。');
|
||||
const user=session.user.id,form=$('#order-form');if(!form)throw new Error('请在普通开单页套用模板。');orderTemplateApplying=true;
|
||||
const user=session.user.id,form=$('#order-form');if(form?.dataset.orderEdit==='true')throw new Error('订单修改中不能套用模板,请先保存或取消修改。');if(!form)throw new Error('请在普通开单页套用模板。');orderTemplateApplying=true;
|
||||
try{
|
||||
const [template,latest]=await Promise.all([api('/api/order-templates/'+encodeURIComponent(id)),api('/api/session')]);
|
||||
if(session.user.id!==user||latest.user?.id!==user)throw new Error('登录账号已变化,请刷新后再套用模板。');
|
||||
@@ -50,7 +50,7 @@ function orderTemplateDialog(){
|
||||
function closeOrderTemplateDialog(){const dialog=$('#order-template-dialog');if(dialog){dialog.close();dialog.replaceChildren();}orderTemplateEntry=null;}
|
||||
function showOrderTemplateDialog(kind){
|
||||
if(busy||pending()||orderTemplateApplying)throw new Error('请先确认当前操作结果,再保存模板。');
|
||||
const form=$('#order-form');if(!form)throw new Error('请在普通开单页保存模板。');
|
||||
const form=$('#order-form');if(form?.dataset.orderEdit==='true')throw new Error('订单修改中不能保存开单模板,请先保存或取消修改。');if(!form)throw new Error('请在普通开单页保存模板。');
|
||||
const row=kind==='update'?orderTemplateRows?.find(row=>row.id===orderTemplateSelection):null;if(kind==='update'&&!row)throw new Error('请先选择需要更新的模板。');
|
||||
orderTemplateEntry={kind,id:row?.id,revision:row?.revision,user:session.user.id,form};
|
||||
const dialog=orderTemplateDialog();dialog.innerHTML=`<button class="dialog-close" data-action="close-order-template" aria-label="关闭模板">×</button><h2 id="order-template-title">${row?'更新模板':'保存为新模板'}</h2><p class="small muted">将当前普通开单表单保存为预设,允许金额和克重留空。客户、日期及订单编号不存入模板;本次正在填写的客户和日期会保留。</p><form id="order-template-form">${field('模板名称','template_name',row?.name||'','text','required maxlength="60" placeholder="例如:足金手链常用报价"')}<div class="form-actions"><button class="primary" type="submit">${row?'保存更新':'保存模板'}</button>${button('取消','close-order-template','quiet')}</div><div id="order-template-error" aria-live="polite"></div></form>`;
|
||||
|
||||
Reference in new issue
Block a user