Files
zyt/server/public/admin/assets/list-9YRENGkm.js
T
2026-08-25 14:53:17 +08:00

2 lines
11 KiB
JavaScript

import{o as K,ap as fe,be,q as m,r as N,v as l,D as i,b9 as ye,u as o,b6 as ve,b7 as ge,b8 as ke,bm as Ve,bn as he,K as Ce,L as s,bg as xe,ac as k,bi as we,O as b,P as R,s as V,bj as Ee,bk as Re,br as Ae,T as E,C as J,bM as De,bc as Se,bf as Le,J as Ne,I as Ue,bt as Ie,ba as z,M as h,p as Pe}from"./.pnpm-Dwh6tNxD.js";import{_ as $e}from"./index.vue_vue_type_script_setup_true_lang-D0KAQf1t.js";import{u as Be,c as Oe,i as y,_ as Me}from"./index-CLwe6ftX.js";import{t as Ge,y as Te,z as Fe,A as Je}from"./tcm-BzzBMfBw.js";import{u as ze}from"./usePaging-DOuAwzL9.js";import{M as Ke}from"./index-Bptrs_vp.js";import je from"./PrescriptionAiBatchGenerateDialog-CzgaslXb.js";import qe from"./PrescriptionAiReportDialog-CLrnR3-M.js";import"./medicine-K52GUWS-.js";const He={class:"prescription-library"},Qe={class:"mt-4"},We={key:0},Xe={key:1,class:"text-gray-400"},Ye={class:"flex mt-4 justify-end"},Ze={class:"w-full"},el={class:"flex flex-col gap-1 leading-none"},ll=K({name:"prescriptionLibrary"}),tl=K({...ll,setup(al){const _=z({prescription_name:"",formula_type:"",is_public:""}),f=h(!1),p=h("add"),A=h(!1),D=h(),U=h(),I=h(),n=z({id:0,prescription_name:"",formula_type:"主方",herbs:[],is_public:0,disable_edit:0}),j={prescription_name:[{required:!0,message:"请输入处方名称",trigger:"blur"}]},S=Be(),q=Pe(()=>{const a=S.perms||[];return a.includes("*")||a.includes("tcm.prescriptionLibrary/missingAiReports")&&a.includes("tcm.prescriptionLibrary/generateAiReports")}),H=[0,3],{pager:C,getLists:x,resetParams:Q,resetPage:P}=ze({fetchFun:Ge,params:_}),W=a=>{var e;return Number(a.creator_id)===Number((e=S.userInfo)==null?void 0:e.id)},X=()=>{const a=S.userInfo;if(!a)return!1;if(Number(a.root)===1)return!0;const e=Array.isArray(a.role_ids)?a.role_ids.map(v=>Number(v)):[];return H.some(v=>e.includes(v))},$=a=>X()||W(a),Y=$,Z=a=>{var e;(e=U.value)==null||e.open(a)},ee=()=>{var a;(a=I.value)==null||a.open()},le=()=>{n.herbs.push({name:"",dosage:0})},te=a=>{n.herbs.splice(a,1)},ae=()=>{n.id=0,n.prescription_name="",n.formula_type="主方",n.herbs=[],n.is_public=0,n.disable_edit=0},ie=()=>{ae(),p.value="add",f.value=!0},oe=a=>{p.value="view",n.id=a.id,n.prescription_name=a.prescription_name||"",n.formula_type=a.formula_type||"主方",n.herbs=a.herbs?JSON.parse(JSON.stringify(a.herbs)):[],n.is_public=a.is_public??0,n.disable_edit=a.disable_edit??0,f.value=!0},ne=a=>{p.value="edit",n.id=a.id,n.prescription_name=a.prescription_name||"",n.formula_type=a.formula_type||"主方",n.herbs=a.herbs?JSON.parse(JSON.stringify(a.herbs)):[],n.is_public=a.is_public??0,n.disable_edit=a.disable_edit??0,f.value=!0},se=async()=>{if(D.value){if(await D.value.validate(),!n.herbs||n.herbs.length===0){y.msgError("请至少添加一味药材");return}for(let a=0;a<n.herbs.length;a++){const e=n.herbs[a];if(!e.name||!e.name.trim()){y.msgError(`第${a+1}味药材名称不能为空`);return}if(!e.dosage||e.dosage<=0){y.msgError(`第${a+1}味药材剂量必须大于0`);return}}A.value=!0;try{const a={...n};p.value==="add"?(await Te(a),y.msgSuccess("添加成功")):(await Fe(a),y.msgSuccess("编辑成功")),f.value=!1,x()}catch(a){console.error(a)}finally{A.value=!1}}},re=async a=>{await y.confirm("确定要删除该处方吗?"),await Je({id:a}),y.msgSuccess("删除成功"),x()};return fe(()=>{x()}),(a,e)=>{const v=ge,c=ve,g=he,B=Ve,u=Ce,O=ye,M=xe,de=Oe,d=Re,L=Ae,G=Ee,pe=$e,T=Le,ue=Se,me=Ne,F=Ue,ce=Ie,w=be("perms"),_e=we;return m(),N("div",He,[l(M,{class:"!border-none",shadow:"never"},{default:i(()=>[l(O,{class:"mb-[-16px]",model:o(_),inline:""},{default:i(()=>[l(c,{class:"w-[280px]",label:"处方名称"},{default:i(()=>[l(v,{modelValue:o(_).prescription_name,"onUpdate:modelValue":e[0]||(e[0]=t=>o(_).prescription_name=t),placeholder:"请输入处方名称",clearable:"",onKeyup:ke(o(P),["enter"])},null,8,["modelValue","onKeyup"])]),_:1}),l(c,{class:"w-[200px]",label:"处方类型"},{default:i(()=>[l(B,{modelValue:o(_).formula_type,"onUpdate:modelValue":e[1]||(e[1]=t=>o(_).formula_type=t),placeholder:"全部",clearable:""},{default:i(()=>[l(g,{label:"全部",value:""}),l(g,{label:"主方",value:"主方"}),l(g,{label:"辅方",value:"辅方"})]),_:1},8,["modelValue"])]),_:1}),l(c,{class:"w-[200px]",label:"是否公开"},{default:i(()=>[l(B,{modelValue:o(_).is_public,"onUpdate:modelValue":e[2]||(e[2]=t=>o(_).is_public=t),placeholder:"全部",clearable:""},{default:i(()=>[l(g,{label:"全部",value:""}),l(g,{label:"仅自己可见",value:0}),l(g,{label:"所有人可见",value:1})]),_:1},8,["modelValue"])]),_:1}),l(c,null,{default:i(()=>[l(u,{type:"primary",onClick:o(P)},{default:i(()=>[...e[10]||(e[10]=[s("查询",-1)])]),_:1},8,["onClick"]),l(u,{onClick:o(Q)},{default:i(()=>[...e[11]||(e[11]=[s("重置",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["model"])]),_:1}),k((m(),b(M,{class:"mt-4 !border-none",shadow:"never"},{default:i(()=>[k((m(),b(u,{type:"primary",onClick:ie},{icon:i(()=>[l(de,{name:"el-icon-Plus"})]),default:i(()=>[e[12]||(e[12]=s(" 新增处方 ",-1))]),_:1})),[[w,["wcf.prescription/add"]]]),o(q)?(m(),b(u,{key:0,type:"primary",plain:"",onClick:ee},{default:i(()=>[...e[13]||(e[13]=[s(" 批量生成报告 ",-1)])]),_:1})):R("",!0),V("div",Qe,[l(G,{data:o(C).lists,size:"large"},{default:i(()=>[l(d,{label:"ID",prop:"id","min-width":"60"}),l(d,{label:"处方名称",prop:"prescription_name","min-width":"200","show-overflow-tooltip":""}),l(d,{label:"处方类型","min-width":"100"},{default:i(({row:t})=>[l(L,{type:t.formula_type==="辅方"?"warning":"primary",size:"small"},{default:i(()=>[s(E(t.formula_type||"主方"),1)]),_:2},1032,["type"])]),_:1}),l(d,{label:"药材数量","min-width":"100"},{default:i(({row:t})=>{var r;return[s(E(((r=t.herbs)==null?void 0:r.length)||0)+"味 ",1)]}),_:1}),l(d,{label:"药材明细","min-width":"300","show-overflow-tooltip":""},{default:i(({row:t})=>[t.herbs&&t.herbs.length>0?(m(),N("span",We,E(t.herbs.map(r=>`${r.name} ${r.dosage}g`).join("、")),1)):(m(),N("span",Xe,"暂无药材"))]),_:1}),l(d,{label:"是否公开","min-width":"120"},{default:i(({row:t})=>[l(L,{type:t.is_public?"success":"info"},{default:i(()=>[s(E(t.is_public?"所有人可见":"仅自己可见"),1)]),_:2},1032,["type"])]),_:1}),l(d,{label:"禁用修改","min-width":"100"},{default:i(({row:t})=>[l(L,{type:t.disable_edit?"danger":"info"},{default:i(()=>[s(E(t.disable_edit?"已禁用":"可修改"),1)]),_:2},1032,["type"])]),_:1}),l(d,{label:"创建人",prop:"creator_name","min-width":"100"}),l(d,{label:"创建时间",prop:"create_time","min-width":"160"}),l(d,{label:"操作",width:"240",fixed:"right"},{default:i(({row:t})=>[k((m(),b(u,{type:"primary",link:"",onClick:r=>oe(t)},{default:i(()=>[...e[14]||(e[14]=[s(" 查看 ",-1)])]),_:1},8,["onClick"])),[[w,["wcf.prescription/read"]]]),k((m(),b(u,{type:"primary",link:"",onClick:r=>Z(t)},{default:i(()=>[...e[15]||(e[15]=[s(" AI解释 ",-1)])]),_:1},8,["onClick"])),[[w,["tcm.prescriptionLibrary/aiReports","wcf.prescription/read"]]]),$(t)?k((m(),b(u,{key:0,type:"primary",link:"",onClick:r=>ne(t)},{default:i(()=>[...e[16]||(e[16]=[s(" 编辑 ",-1)])]),_:1},8,["onClick"])),[[w,["wcf.prescription/edit"]]]):R("",!0),o(Y)(t)?k((m(),b(u,{key:1,type:"danger",link:"",onClick:r=>re(t.id)},{default:i(()=>[...e[17]||(e[17]=[s(" 删除 ",-1)])]),_:1},8,["onClick"])),[[w,["wcf.prescription/delete"]]]):R("",!0)]),_:1})]),_:1},8,["data"])]),V("div",Ye,[l(pe,{modelValue:o(C),"onUpdate:modelValue":e[3]||(e[3]=t=>J(C)?C.value=t:null),onChange:o(x)},null,8,["modelValue","onChange"])])]),_:1})),[[_e,o(C).loading]]),l(ce,{modelValue:o(f),"onUpdate:modelValue":e[9]||(e[9]=t=>J(f)?f.value=t:null),title:o(p)==="add"?"新增处方":o(p)==="edit"?"编辑处方":"查看处方",width:"800px","close-on-click-modal":!1},De({default:i(()=>[l(O,{ref_key:"formRef",ref:D,model:o(n),rules:j,"label-width":"120px",disabled:o(p)==="view"},{default:i(()=>[l(c,{label:"处方名称",prop:"prescription_name"},{default:i(()=>[l(v,{modelValue:o(n).prescription_name,"onUpdate:modelValue":e[4]||(e[4]=t=>o(n).prescription_name=t),placeholder:"请输入处方名称,例如:六味地黄丸、补中益气汤",maxlength:"100","show-word-limit":""},null,8,["modelValue"])]),_:1}),l(c,{label:"处方类型",prop:"formula_type"},{default:i(()=>[l(ue,{modelValue:o(n).formula_type,"onUpdate:modelValue":e[5]||(e[5]=t=>o(n).formula_type=t)},{default:i(()=>[l(T,{value:"主方"},{default:i(()=>[...e[18]||(e[18]=[s("主方",-1)])]),_:1}),l(T,{value:"辅方"},{default:i(()=>[...e[19]||(e[19]=[s("辅方",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1}),l(c,{label:"药材配方",prop:"herbs",required:""},{default:i(()=>[V("div",Ze,[l(u,{type:"primary",size:"small",onClick:le,disabled:o(p)==="view"},{default:i(()=>[...e[20]||(e[20]=[s(" 添加药材 ",-1)])]),_:1},8,["disabled"]),l(G,{data:o(n).herbs,class:"mt-2",border:""},{default:i(()=>[l(d,{label:"序号",type:"index",width:"60"}),l(d,{label:"药材名称","min-width":"220"},{default:i(({row:t})=>[l(Ke,{modelValue:t.name,"onUpdate:modelValue":r=>t.name=r,"medicine-id":t.medicine_id,"onUpdate:medicineId":r=>t.medicine_id=r,disabled:o(p)==="view"},null,8,["modelValue","onUpdate:modelValue","medicine-id","onUpdate:medicineId","disabled"])]),_:1}),l(d,{label:"剂量(克)","min-width":"150"},{default:i(({row:t})=>[l(me,{modelValue:t.dosage,"onUpdate:modelValue":r=>t.dosage=r,min:0,precision:1,step:.5,placeholder:"剂量",class:"w-full",disabled:o(p)==="view"},null,8,["modelValue","onUpdate:modelValue","disabled"])]),_:1}),o(p)!=="view"?(m(),b(d,{key:0,label:"操作",width:"80"},{default:i(({$index:t})=>[l(u,{type:"danger",link:"",onClick:r=>te(t)},{default:i(()=>[...e[21]||(e[21]=[s(" 删除 ",-1)])]),_:1},8,["onClick"])]),_:1})):R("",!0)]),_:1},8,["data"])])]),_:1}),l(c,{label:"是否公开",prop:"is_public"},{default:i(()=>[l(F,{modelValue:o(n).is_public,"onUpdate:modelValue":e[6]||(e[6]=t=>o(n).is_public=t),"active-value":1,"inactive-value":0,"active-text":"所有人可见","inactive-text":"仅自己可见"},null,8,["modelValue"]),e[22]||(e[22]=V("div",{class:"text-xs text-gray-400 mt-1"}," 勾选后,所有医生都可以查看和使用此处方模板 ",-1))]),_:1}),l(c,{label:"禁用修改",prop:"disable_edit"},{default:i(()=>[V("div",el,[l(F,{modelValue:o(n).disable_edit,"onUpdate:modelValue":e[7]||(e[7]=t=>o(n).disable_edit=t),"active-value":1,"inactive-value":0,"active-text":"开启","inactive-text":"关闭"},null,8,["modelValue"]),e[23]||(e[23]=V("div",{class:"text-xs text-gray-400 leading-relaxed"}," 开启后,导入此模板到处方时将锁定整张处方的药材,不可增删改,只能再次导入覆盖 ",-1))])]),_:1})]),_:1},8,["model","disabled"])]),_:2},[o(p)!=="view"?{name:"footer",fn:i(()=>[l(u,{onClick:e[8]||(e[8]=t=>f.value=!1)},{default:i(()=>[...e[24]||(e[24]=[s("取消",-1)])]),_:1}),l(u,{type:"primary",onClick:se,loading:o(A)},{default:i(()=>[...e[25]||(e[25]=[s(" 确定 ",-1)])]),_:1},8,["loading"])]),key:"0"}:void 0]),1032,["modelValue","title"]),l(qe,{ref_key:"aiReportDialogRef",ref:U},null,512),l(je,{ref_key:"aiBatchGenerateDialogRef",ref:I,onChanged:o(x)},null,8,["onChanged"])])}}}),cl=Me(tl,[["__scopeId","data-v-abbf0b98"]]);export{cl as default};