Files
zyt/server/public/admin/assets/PrescriptionAiBatchGenerateDialog-mXwacLx5.js
T
Your NameandClaude Opus 5 18a0989c00 业务订单已发货后不能再修改服用天数
- 已发货判定:履约状态已发货/已签收/已完成,或已填快递单号,或药房回传已发货(洛阳 SHIPPED/COMPLETED、甘草 20/30)
- 已发货后「修改服用参数」与订单编辑中的主方/辅方开立天数、订单服用天数不可修改(服务端拦截);次数、袋数仍可改;
  订单未单独设置天数时以处方开立天数为准,不会误判为修改
- 订单详情返回 days_locked,详情抽屉、订单列表(含 H5)编辑时禁用天数输入并提示
- 重新构建管理后台

Co-Authored-By: Claude Opus 5 <[EMAIL]>
2026-11-30 14:04:17 +08:00

2 lines
10 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{o as de,q as r,O as g,D as u,s as l,v as c,bf as ce,u as t,r as h,bz as pe,by as ve,T as i,K as fe,L as v,F as me,bp as ge,P as C,bO as _e,bn as ye,bo as he,C as be,a2 as ke,M as d,p as X,ac as we}from"./.pnpm-DnXobOVo.js";import{y as Ce,f as L,z as Ee,_ as Me}from"./index-BOegMRMJ.js";const $e={class:"batch-dialog-body"},xe={key:0,class:"loading-state"},Ae={key:1,class:"load-error-state"},Ie={class:"state-description"},Be={class:"overview-panel"},ze={class:"overview-meta"},Re={key:0,class:"refresh-error"},Se={key:2,class:"progress-panel"},Te={class:"progress-heading"},Ne={key:0,class:"current-prescription"},Ge={class:"counter-grid"},Le={class:"counter-item counter-processed"},Ve={class:"counter-item counter-success"},qe={class:"counter-item counter-partial"},Pe={class:"counter-item counter-failed"},De={key:3,class:"issues-panel"},Fe={class:"section-heading"},We={class:"issue-name"},je={class:"state-description"},Oe={key:5,class:"pending-panel"},He={class:"section-heading"},Ke={class:"pending-count"},Ue={class:"dialog-footer"},Je={key:0,class:"footer-tip"},Qe={key:1},I=500,Xe=de({__name:"PrescriptionAiBatchGenerateDialog",emits:["changed"],setup(Ye,{expose:Y,emit:Z}){const ee=Z,E=d(!1),T=d(0),B=d(0),N=d(!1),z=d(""),R=d(""),f=d([]),M=d(0),V=d(I),F=d(!1),p=d(!1),_=d(!1),W=d("idle"),y=d(0),w=d(0),j=d(0),q=d(0),G=d(0),b=d(null),$=d([]),P=we(null),te=X(()=>y.value?Math.min(100,Math.round(w.value/y.value*100)):0),se=X(()=>{const s=Math.max(0,M.value-f.value.length);return s>0?`待生成数量超过单次上限,本次最多处理 ${f.value.length} 份;完成后可再次继续处理其余约 ${s} 份。`:`后端标记清单已截断,本次最多处理 ${V.value} 份;完成后可再次继续。`}),H=()=>{_.value=!1,W.value="idle",y.value=0,w.value=0,j.value=0,q.value=0,G.value=0,b.value=null,$.value=[]},K=()=>{N.value=!1,z.value="",R.value="",f.value=[],M.value=0,V.value=I,F.value=!1,H()},O=s=>{if(typeof s=="string"&&s.trim())return s;if(s&&typeof s=="object"){const e=s,n=e.response,a=n==null?void 0:n.data,o=e.msg||e.message||e.error||(a==null?void 0:a.msg)||(a==null?void 0:a.message);if(typeof o=="string"&&o.trim())return o}return"请求失败,请稍后重试"},k=s=>s===T.value&&E.value,D=async(s=T.value,e={})=>{const n=++B.value;e.silent||(N.value=!0,z.value="");try{const a=await Ce({limit:I});if(!k(s)||n!==B.value)return;const o=Array.isArray(a.items)?a.items.slice(0,I):[];f.value=o,M.value=Math.max(o.length,Number(a.total||0)),V.value=Math.min(I,Math.max(1,Number(a.limit||I))),F.value=a.truncated===!0||M.value>o.length,R.value=""}catch(a){if(!k(s)||n!==B.value)return;e.silent?R.value=`本轮已结束,但最新待生成清单读取失败:${O(a)}`:z.value=O(a)}finally{k(s)&&n===B.value&&(N.value=!1)}},U=s=>(s.results||[]).filter(n=>n.status==="error").map(n=>`${n.model_label||n.model_name}: ${n.error_message||"生成失败"}`).join(";")||"模型未返回完整报告",le=(s,e)=>{const n=Number(e.success_count||0),a=Number(e.failure_count||0),o=e.status==="partial"||e.partial===!0||n>0&&a>0,S=e.status==="error"||a>0&&n===0;return o?(q.value+=1,$.value.push({id:s.id,prescription_name:s.prescription_name||`处方 #${s.id}`,status:"partial",message:U(e)}),!0):S?(G.value+=1,$.value.push({id:s.id,prescription_name:s.prescription_name||`处方 #${s.id}`,status:"failed",message:U(e)}),!1):(j.value+=1,!0)},ae=(s,e)=>{G.value+=1,$.value.push({id:s.id,prescription_name:s.prescription_name||`处方 #${s.id}`,status:"failed",message:O(e)})},J=()=>{!p.value||_.value||(_.value=!0)},ne=async()=>{if(p.value||!f.value.length)return;const s=T.value,e=f.value.slice(0,I);try{await L.confirm(`确定按顺序为 ${e.length} 份处方生成 AI 报告吗?每份会调用双模型,过程中可请求停止。`)}catch{return}if(!k(s)||p.value)return;H(),y.value=e.length,p.value=!0,R.value="";const n=new Set;try{for(const a of e){if(!k(s)||_.value)break;b.value=a;try{const o=await Ee({id:a.id});if(!k(s))return;le(a,o)&&n.add(a.id)}catch(o){if(!k(s))return;ae(a,o)}w.value+=1,b.value=null}}finally{if(!k(s))return;const a=_.value&&w.value<y.value;W.value=a?"stopped":"completed",p.value=!1,b.value=null,n.size&&(f.value=f.value.filter(S=>!n.has(S.id)),M.value=Math.max(0,M.value-n.size)),w.value>0&&ee("changed");const o=P.value;if(P.value=null,o){o();return}if(await D(s,{silent:!0}),!k(s))return;a?L.msgWarning(`已停止,本轮共处理 ${w.value} 份处方`):G.value>0||q.value>0?L.msgWarning("批量生成已完成,请查看失败与部分成功明细"):L.msgSuccess("批量生成报告完成")}},oe=s=>{if(!p.value){s();return}J(),P.value=s,L.msgWarning("已请求停止,当前处方完成后将关闭窗口")},ie=()=>{++T.value,++B.value,P.value=null,p.value=!1,K()};return Y({open:()=>{if(p.value){E.value=!0;return}const s=++T.value;++B.value,K(),E.value=!0,D(s)}}),(s,e)=>{const n=ce,a=pe,o=fe,S=ve,x=ge,re=_e,A=he,Q=ye,ue=ke;return r(),g(ue,{modelValue:t(E),"onUpdate:modelValue":e[3]||(e[3]=m=>be(E)?E.value=m:null),class:"prescription-ai-batch-dialog",width:"min(820px, calc(100vw - 32px))",top:"6vh",title:"批量生成处方 AI 报告","close-on-click-modal":!1,"destroy-on-close":"","before-close":oe,onClosed:ie},{footer:u(()=>[l("div",Ue,[t(p)?(r(),h("span",Je,"生成请求不会自动重试,也不会并发执行。")):(r(),h("span",Qe)),l("div",null,[t(p)?C("",!0):(r(),g(o,{key:0,onClick:e[2]||(e[2]=m=>E.value=!1)},{default:u(()=>[...e[20]||(e[20]=[v("关闭",-1)])]),_:1})),t(p)?(r(),g(o,{key:1,type:"warning",plain:"",disabled:t(_),onClick:J},{default:u(()=>[v(i(t(_)?"正在停止…":"停止"),1)]),_:1},8,["disabled"])):(r(),g(o,{key:2,type:"primary",disabled:t(N)||!!t(z)||!t(f).length,onClick:ne},{default:u(()=>[v(i(t(y)>0?"继续生成剩余报告":"开始批量生成"),1)]),_:1},8,["disabled"]))])])]),default:u(()=>[l("div",$e,[c(n,{type:"info",closable:!1,"show-icon":"",title:"仅统计完全没有任何 AI 报告的处方;已有报告不会被本批次覆盖。"}),t(N)?(r(),h("div",xe,[c(a,{rows:5,animated:""})])):t(z)?(r(),h("div",Ae,[c(S,{description:"待生成清单加载失败","image-size":72},{default:u(()=>[l("p",Ie,i(t(z)),1),c(o,{type:"primary",plain:"",onClick:e[0]||(e[0]=m=>D())},{default:u(()=>[...e[4]||(e[4]=[v("重新加载",-1)])]),_:1})]),_:1})])):(r(),h(me,{key:2},[l("section",Be,[l("div",null,[e[5]||(e[5]=l("span",{class:"overview-label"},"当前完全缺失报告",-1)),l("strong",null,i(t(M)),1),e[6]||(e[6]=l("span",{class:"overview-unit"},"份处方",-1))]),l("div",ze,[v(" 本次载入 "+i(t(f).length)+" 份 ",1),c(x,{size:"small",type:"info",effect:"plain"},{default:u(()=>[v("上限 "+i(t(V)),1)]),_:1})])]),t(R)?(r(),h("div",Re,[c(n,{type:"error",closable:!1,"show-icon":"",title:t(R)},null,8,["title"]),c(o,{type:"primary",plain:"",onClick:e[1]||(e[1]=m=>D())},{default:u(()=>[...e[7]||(e[7]=[v("重新读取清单",-1)])]),_:1})])):C("",!0),t(F)?(r(),g(n,{key:1,class:"truncated-alert",type:"warning",closable:!1,"show-icon":"",title:t(se)},null,8,["title"])):C("",!0),t(p)||t(y)>0?(r(),h("section",Se,[l("div",Te,[l("div",null,[e[8]||(e[8]=l("span",{class:"section-kicker"},"本轮进度",-1)),l("strong",null,i(t(w))+" / "+i(t(y)),1)]),t(p)&&!t(_)?(r(),g(x,{key:0,type:"primary"},{default:u(()=>[...e[9]||(e[9]=[v("顺序生成中",-1)])]),_:1})):t(p)&&t(_)?(r(),g(x,{key:1,type:"warning"},{default:u(()=>[...e[10]||(e[10]=[v("等待当前请求完成",-1)])]),_:1})):t(W)==="stopped"?(r(),g(x,{key:2,type:"warning"},{default:u(()=>[...e[11]||(e[11]=[v("已停止",-1)])]),_:1})):(r(),g(x,{key:3,type:"success"},{default:u(()=>[...e[12]||(e[12]=[v("本轮完成",-1)])]),_:1}))]),c(re,{percentage:t(te),"stroke-width":10},null,8,["percentage"]),t(b)?(r(),h("div",Ne,[e[13]||(e[13]=l("span",null,"当前处方",-1)),l("strong",null,i(t(b).prescription_name||`处方 #${t(b).id}`),1),l("small",null,"#"+i(t(b).id)+" · "+i(t(b).formula_type||"未分类"),1)])):C("",!0),l("div",Ge,[l("div",Le,[e[14]||(e[14]=l("span",null,"已处理",-1)),l("strong",null,i(t(w)),1)]),l("div",Ve,[e[15]||(e[15]=l("span",null,"成功",-1)),l("strong",null,i(t(j)),1)]),l("div",qe,[e[16]||(e[16]=l("span",null,"部分成功",-1)),l("strong",null,i(t(q)),1)]),l("div",Pe,[e[17]||(e[17]=l("span",null,"失败",-1)),l("strong",null,i(t(G)),1)])]),t(_)&&t(p)?(r(),g(n,{key:1,class:"stop-alert",type:"warning",closable:!1,"show-icon":"",title:"已请求停止;当前处方生成完成后,不会继续发起下一条请求。"})):C("",!0)])):C("",!0),t($).length?(r(),h("section",De,[l("div",Fe,[e[18]||(e[18]=l("div",null,[l("span",{class:"section-kicker"},"失败清单"),l("strong",null,"失败与部分成功明细")],-1)),c(x,{type:"danger",effect:"plain"},{default:u(()=>[v(i(t($).length)+" 条",1)]),_:1})]),c(Q,{data:t($),"max-height":"240",size:"small"},{default:u(()=>[c(A,{label:"处方","min-width":"180"},{default:u(({row:m})=>[l("div",We,i(m.prescription_name),1),l("small",null,"#"+i(m.id),1)]),_:1}),c(A,{label:"结果",width:"100"},{default:u(({row:m})=>[c(x,{size:"small",type:m.status==="partial"?"warning":"danger"},{default:u(()=>[v(i(m.status==="partial"?"部分成功":"失败"),1)]),_:2},1032,["type"])]),_:1}),c(A,{label:"原因","min-width":"300","show-overflow-tooltip":"",prop:"message"})]),_:1},8,["data"])])):C("",!0),!t(f).length&&!t(p)?(r(),g(S,{key:4,description:t(y)>0?"当前范围已无待生成处方":"暂无完全缺失 AI 报告的处方","image-size":76},{default:u(()=>[l("p",je,i(t(y)>0?"已重新读取数据库中的最新待生成清单。":"所有可见处方均已有至少一份持久化报告。"),1)]),_:1},8,["description"])):t(p)?C("",!0):(r(),h("section",Oe,[l("div",He,[e[19]||(e[19]=l("div",null,[l("span",{class:"section-kicker"},"待生成清单"),l("strong",null,"本次将按以下顺序逐条处理")],-1)),l("span",Ke,i(t(f).length)+" 份",1)]),c(Q,{data:t(f),"max-height":"280",size:"small"},{default:u(()=>[c(A,{label:"ID",prop:"id",width:"80"}),c(A,{label:"处方名称",prop:"prescription_name","min-width":"220","show-overflow-tooltip":""}),c(A,{label:"类型",prop:"formula_type",width:"100"}),c(A,{label:"药材数",width:"100",align:"right"},{default:u(({row:m})=>[v(i(m.herb_count)+" 味",1)]),_:1})]),_:1},8,["data"])]))],64))])]),_:1},8,["modelValue"])}}}),st=Me(Xe,[["__scopeId","data-v-e1699253"]]);export{st as default};