整合公共店铺配置与动态员工管理,保留最新订单功能及历史账兼容
This commit is contained in:
commit
b87f774386
84 files changed
+1622
-715
No files matched your search
@@ -13,7 +13,7 @@ function editingPendingPriceLock(form=$('#price-lock-create-form')){return !!(pr
|
||||
function priceLockPendingNeedsApproval(entry,input=entry.inputs){return session.user.role==='assistant'&&(entry.requiresApproval!==false||input.date!==state.today);}
|
||||
function priceLockPendingEditReviewHTML(entry){
|
||||
const approval=priceLockPendingNeedsApproval(entry);
|
||||
return `<section class="panel lock-pending-review"><p class="note" data-lock-edit-notice>${approval?'提交修改申请,麦麦复核同意后生效;待批期间沿用原锁价记账。':'保存后按核实后的整单资料更正锁价记录、收款与原锁料费。'}</p>${entry.conflicted?`<div class="error">原锁价单已有新记录,已填写内容已保留。请重新读取当前资料后核对。${button('使用当前锁价资料','reset-lock-edit','quiet',`data-id="${e(entry.id)}"`)}</div>`:''}<label>修改原因<textarea name="pending_edit_reason" required maxlength="200" rows="2">${e(entry.reason||'')}</textarea></label><label class="check"><input type="checkbox" name="pending_edit_verified" required>已核实整单商品、原锁金料、客户实际已付款与账户,确认本次更正。</label><div class="actions">${button('退出修改','leave-lock-edit','quiet')}</div></section>`;
|
||||
return `<section class="panel lock-pending-review"><p class="note" data-lock-edit-notice>${approval?'提交修改申请,店主复核同意后生效;待批期间沿用原锁价记账。':'保存后按核实后的整单资料更正锁价记录、收款与原锁料费。'}</p>${entry.conflicted?`<div class="error">原锁价单已有新记录,已填写内容已保留。请重新读取当前资料后核对。${button('使用当前锁价资料','reset-lock-edit','quiet',`data-id="${e(entry.id)}"`)}</div>`:''}<label>修改原因<textarea name="pending_edit_reason" required maxlength="200" rows="2">${e(entry.reason||'')}</textarea></label><label class="check"><input type="checkbox" name="pending_edit_verified" required>已核实整单商品、原锁金料、客户实际已付款与账户,确认本次更正。</label><div class="actions">${button('退出修改','leave-lock-edit','quiet')}</div></section>`;
|
||||
}
|
||||
function syncPendingPriceLockEditDraft(data,form){
|
||||
if(!editingPendingPriceLock(form))return false;
|
||||
@@ -21,7 +21,7 @@ function syncPendingPriceLockEditDraft(data,form){
|
||||
localStorage.setItem(priceLockEditDraftKey(entry.id),JSON.stringify({id:entry.id,revision:entry.revision,inputs:entry.inputs,reason:entry.reason}));
|
||||
const approval=priceLockPendingNeedsApproval(entry,data),submit=form.querySelector('[data-lock-create-submit]'),notice=form.querySelector('[data-lock-edit-notice]');
|
||||
if(submit){submit.textContent=approval?'提交修改申请':'保存锁价修改';submit.disabled=entry.conflicted||!!pending();}
|
||||
if(notice)notice.textContent=approval?'提交修改申请,麦麦复核同意后生效;待批期间沿用原锁价记账。':'保存后按核实后的整单资料更正锁价记录、收款与原锁料费。';return true;
|
||||
if(notice)notice.textContent=approval?'提交修改申请,店主复核同意后生效;待批期间沿用原锁价记账。':'保存后按核实后的整单资料更正锁价记录、收款与原锁料费。';return true;
|
||||
}
|
||||
async function startPriceLockEdit(id,reset=false){
|
||||
if(pending())throw new Error('请先恢复上次未确认的操作,再修改锁价单。');
|
||||
@@ -44,7 +44,7 @@ async function openPriceLockCancel(id){
|
||||
const result=await api('/api/price-locks/'+encodeURIComponent(id)+'/edit-context');if(request!==priceLockPendingRequest||session.user.id!==user||!dialog.open)return;
|
||||
if(result?.eligible!==true||result.lock?.id!==id||result.lock.status!=='pending'||!Number.isSafeInteger(result.revision)||typeof result.requiresApproval!=='boolean')throw new Error(result.reason||'这张锁价单暂不能作废,请重新读取。');
|
||||
priceLockPendingAction={id,user,revision:result.revision,requiresApproval:result.requiresApproval,inputs:result.inputs,lock:result.lock};const approval=priceLockPendingNeedsApproval(priceLockPendingAction);
|
||||
dialog.innerHTML=`<button class="dialog-close" data-action="close-price-lock" aria-label="关闭">×</button><div class="order-header"><div class="eyebrow">VOID PRICE LOCK</div><h2>${approval?'申请作废':'作废'} · ${e(result.lock.customer)}</h2></div>${priceLockFacts(result.lock)}<div class="note"><strong>录错作废</strong><p>生效后撤销本单有效收款、手填购料与信用卡手续费记账,同日释放料池预留;跨天按原锁定克重和原成本回到实际作废日料池,参与当天加权,历史订单成本不变。保留原单和作废记录。适用于录错单据。</p><p>本操作不登记真实客户退款,也不登记实物退料。</p></div><form id="price-lock-cancel-form"><label>作废原因<textarea name="reason" required maxlength="200" rows="2"></textarea></label><label class="check"><input name="verified" type="checkbox" required>已核实这是一张录错的待交付锁价单,确认整单作废。</label>${approval?'<p class="note">提交申请后,麦麦复核同意才撤销记账;待批期间原锁价单保持有效。</p>':''}<div class="actions">${button('返回锁价详情','open-price-lock','quiet',`data-id="${e(id)}"`)}<button class="danger" type="submit">${approval?'提交作废申请':'确认整单作废'}</button></div><div id="price-lock-action-error" aria-live="polite"></div></form>`;
|
||||
dialog.innerHTML=`<button class="dialog-close" data-action="close-price-lock" aria-label="关闭">×</button><div class="order-header"><div class="eyebrow">VOID PRICE LOCK</div><h2>${approval?'申请作废':'作废'} · ${e(result.lock.customer)}</h2></div>${priceLockFacts(result.lock)}<div class="note"><strong>录错作废</strong><p>生效后撤销本单有效收款、手填购料与信用卡手续费记账,同日释放料池预留;跨天按原锁定克重和原成本回到实际作废日料池,参与当天加权,历史订单成本不变。保留原单和作废记录。适用于录错单据。</p><p>本操作不登记真实客户退款,也不登记实物退料。</p></div><form id="price-lock-cancel-form"><label>作废原因<textarea name="reason" required maxlength="200" rows="2"></textarea></label><label class="check"><input name="verified" type="checkbox" required>已核实这是一张录错的待交付锁价单,确认整单作废。</label>${approval?'<p class="note">提交申请后,店主复核同意才撤销记账;待批期间原锁价单保持有效。</p>':''}<div class="actions">${button('返回锁价详情','open-price-lock','quiet',`data-id="${e(id)}"`)}<button class="danger" type="submit">${approval?'提交作废申请':'确认整单作废'}</button></div><div id="price-lock-action-error" aria-live="polite"></div></form>`;
|
||||
}
|
||||
async function submitPriceLockCancel(form){
|
||||
const entry=priceLockPendingAction;if(!entry||entry.user!==session.user.id)throw new Error('请重新读取锁价单后再作废。');const reason=lockFormValue(form,'reason').trim();if(!reason)throw new Error('请填写作废原因。');if(!form.querySelector('[name="verified"]')?.checked)throw new Error('请核实录错单据并勾选整单作废。');
|
||||
@@ -57,7 +57,7 @@ async function finishPendingPriceLockSave(url,data,result){
|
||||
if(request&&data.action==='edit')localStorage.removeItem(priceLockEditDraftKey(id));
|
||||
priceLockEditEntry=null;priceLockPendingAction=null;priceLockChangeEntry=null;priceLockDeliveryId='';++priceLockPendingRequest;++priceLockChangesRequest;invalidatePriceLockViews();if(typeof invalidateMaterialPools==='function')invalidateMaterialPools();if(typeof invalidateReport==='function')invalidateReport();$('#price-lock-dialog')?.close();$('#price-lock-changes-dialog')?.close();tab='price-locks';
|
||||
const title=request?'锁价申请已提交':review?(url.endsWith('/approve')?'锁价申请已批准':'锁价申请已驳回'):url.endsWith('/cancel')?'锁价单已作废':'锁价修改已保存';
|
||||
$('#main').innerHTML=heading('PRICE LOCK SAVED',title,request?'原锁价单在麦麦复核同意后更新;待批期间按原记录记账。':review?'复核结果已经保存,可重新查看申请与锁价单。':'原单号保留,相关有效记账已按本次核实结果更新。')+`<section class="panel"><div class="actions">${button('查看锁价单','open-price-lock','primary',`data-id="${e(id)}"`)}${button('返回待交付','refresh-price-locks')}${button('查看修改与作废申请','price-lock-changes-open')}</div></section>`;
|
||||
$('#main').innerHTML=heading('PRICE LOCK SAVED',title,request?'原锁价单在店主复核同意后更新;待批期间按原记录记账。':review?'复核结果已经保存,可重新查看申请与锁价单。':'原单号保留,相关有效记账已按本次核实结果更新。')+`<section class="panel"><div class="actions">${button('查看锁价单','open-price-lock','primary',`data-id="${e(id)}"`)}${button('返回待交付','refresh-price-locks')}${button('查看修改与作废申请','price-lock-changes-open')}</div></section>`;
|
||||
document.querySelectorAll('nav button').forEach(button=>button.classList.toggle('active',button.dataset.tab===tab));toast(title);
|
||||
}
|
||||
function priceLockPendingError(error,form){
|
||||
@@ -70,7 +70,7 @@ async function openPriceLockChanges(){
|
||||
}
|
||||
async function loadPriceLockChanges(){
|
||||
const request=++priceLockChangesRequest,user=session.user.id,root=$('#price-lock-changes-content'),dialog=$('#price-lock-changes-dialog');if(!root)return;
|
||||
try{const result=await api('/api/price-lock-changes?status='+priceLockChangesStatus);if(request!==priceLockChangesRequest||user!==session.user.id||!dialog.open||root!==$('#price-lock-changes-content'))return;if(!Array.isArray(result.rows))throw new Error('锁价申请未完整返回,请重新读取。');root.innerHTML=result.rows.length?`<div class="table-wrap"><table class="price-lock-change-list"><thead><tr><th>原锁价单/客户</th><th>申请</th><th>申请人/日期</th><th>状态</th><th>操作</th></tr></thead><tbody>${result.rows.map(row=>`<tr><td>${e(row.number||row.before?.number||'锁价单')}<div class="small muted">${e(row.customer||row.before?.customer||'')}</div></td><td>${row.action==='cancel'?'录错作废':'修改整单'}<div class="small muted">${e(row.reason||'')}</div></td><td>${e(row.requester_name||row.requester||'')}<div class="small muted">${e(row.created||'')}</div></td><td>${e(({pending:'待麦麦复核',approved:'已批准',rejected:'已驳回'})[row.status]||row.status)}</td><td>${button('查看申请','price-lock-change-open','',`data-id="${e(row.requestId||row.id)}"`)}</td></tr>`).join('')}</tbody></table></div>`:'<p class="empty">暂无符合条件的申请。</p>';}catch(error){if(request===priceLockChangesRequest&&root===$('#price-lock-changes-content'))root.innerHTML=`<div class="error">${e(error.message)} ${button('重新读取','price-lock-changes-reload')}</div>`;}
|
||||
try{const result=await api('/api/price-lock-changes?status='+priceLockChangesStatus);if(request!==priceLockChangesRequest||user!==session.user.id||!dialog.open||root!==$('#price-lock-changes-content'))return;if(!Array.isArray(result.rows))throw new Error('锁价申请未完整返回,请重新读取。');root.innerHTML=result.rows.length?`<div class="table-wrap"><table class="price-lock-change-list"><thead><tr><th>原锁价单/客户</th><th>申请</th><th>申请人/日期</th><th>状态</th><th>操作</th></tr></thead><tbody>${result.rows.map(row=>`<tr><td>${e(row.number||row.before?.number||'锁价单')}<div class="small muted">${e(row.customer||row.before?.customer||'')}</div></td><td>${row.action==='cancel'?'录错作废':'修改整单'}<div class="small muted">${e(row.reason||'')}</div></td><td>${e(row.requester_name||row.requester||'')}<div class="small muted">${e(row.created||'')}</div></td><td>${e(({pending:'待店主复核',approved:'已批准',rejected:'已驳回'})[row.status]||row.status)}</td><td>${button('查看申请','price-lock-change-open','',`data-id="${e(row.requestId||row.id)}"`)}</td></tr>`).join('')}</tbody></table></div>`:'<p class="empty">暂无符合条件的申请。</p>';}catch(error){if(request===priceLockChangesRequest&&root===$('#price-lock-changes-content'))root.innerHTML=`<div class="error">${e(error.message)} ${button('重新读取','price-lock-changes-reload')}</div>`;}
|
||||
}
|
||||
function priceLockChangeSnapshotHTML(snapshot,title){
|
||||
if(!snapshot)return `<div><h3>${e(title)}</h3><p>未提供</p></div>`;
|
||||
|
||||
Reference in new issue
Block a user