zcui/saber3/src/frontend/dist/assets/Category-CFl3FUvo.js

2 lines
4.0 KiB
JavaScript
Raw Normal View History

2026-06-16 14:07:58 +08:00
import{_ as A,U as h,o as B,c as E,e as t,f as l,j as s,k as m,h as u,a as y,S as J,E as C,q as U}from"./index-CsXfDo-r.js";const $={class:"expert-category"},j={class:"card-header"},q={__name:"Category",setup(M){const d=m(!1),f=m(""),p=m(null),a=U({name:"",description:""}),S={name:[{required:!0,message:"请输入分类名称",trigger:"blur"}],description:[{required:!0,message:"请输入分类说明",trigger:"blur"}]},x=m([]),k=()=>[{id:1,code:"CAT001",name:"药学",description:"药品研发、生产、质量控制、临床应用等领域",expertCount:3},{id:2,code:"CAT002",name:"医疗器械",description:"医疗设备、器械的研发、生产、质量管理等",expertCount:2},{id:3,code:"CAT003",name:"临床医学",description:"临床诊疗、疾病治疗、医疗技术等",expertCount:2},{id:4,code:"CAT004",name:"中医药",description:"中医诊疗、中药材、中成药等",expertCount:2},{id:5,code:"CAT005",name:"质量管理",description:"质量标准、检验检测、质量控制等",expertCount:1}],g=()=>{const n=localStorage.getItem("expertCategories");let e=n?JSON.parse(n):[];e.length===0&&(e=k(),localStorage.setItem("expertCategories",JSON.stringify(e))),x.value=e};h(()=>{g()});const V=()=>{f.value="新增分类",Object.keys(a).forEach(n=>a[n]=""),d.value=!0,p.value&&p.value.clearValidate()},w=n=>{f.value="编辑分类",Object.assign(a,n),d.value=!0},D=async n=>{try{await J.confirm("确定要删除该分类吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"});const e=localStorage.getItem("expertCategories");let o=e?JSON.parse(e):[];o=o.filter(r=>r.id!==n.id),localStorage.setItem("expertCategories",JSON.stringify(o)),C.success("删除成功"),g()}catch(e){e!=="cancel"&&C.error("删除失败")}},T=()=>{p.value&&p.value.validate(n=>{if(n){const e=localStorage.getItem("expertCategories"),o=e?JSON.parse(e):[],r={...a,id:a.id||Date.now(),code:a.code||`CAT${String(o.length+1).padStart(3,"0")}`,expertCount:a.expertCount||0};if(a.id){const c=o.findIndex(_=>_.id===a.id);c!==-1&&(o[c]=r)}else o.push(r);localStorage.setItem("expertCategories",JSON.stringify(o)),C.success("保存成功"),d.value=!1,g()}})};return(n,e)=>{const o=s("el-button"),r=s("el-table-column"),c=s("el-table"),_=s("el-card"),v=s("el-input"),b=s("el-form-item"),N=s("el-form"),I=s("el-dialog");return B(),E("div",$,[t(_,null,{header:l(()=>[y("div",j,[e[5]||(e[5]=y("span",null,"专业分类管理",-1)),t(o,{type:"primary",onClick:V},{default:l(()=>[...e[4]||(e[4]=[u("新增分类",-1)])]),_:1})])]),default:l(()=>[t(c,{data:x.value,border:""},{default:l(()=>[t(r,{prop:"code",label:"分类编码",width:"120"}),t(r,{prop:"name",label:"分类名称",width:"150"}),t(r,{prop:"description",label:"分类说明","min-width":"200"}),t(r,{prop:"expertCount",label:"专家数量",width:"100"}),t(r,{label:"操作",width:"150",fixed:"right"},{default:l(({row:i})=>[t(o,{link:"",type:"primary",onClick:O=>w(i)},{default:l(()=>[...e[6]||(e[6]=[u("编辑",-1)])]),_:1},8,["onClick"]),t(o,{link:"",type:"danger",onClick:O=>D(i)},{default:l(()=>[...e[7]||(e[7]=[u("删除",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1}),t(I,{modelValue:d.value,"onUpdate:modelValue":e[3]||(e[3]=i=>d.value=i),title:f.value,width:"600px"},{footer:l(()=>[t(o,{onClick:e[2]||(e[2]=i=>d.value=!1)},{default:l(()=>[...e[8]||(e[8]=[u("取消",-1)])]),_:1}),t(o,{type:"primary",onClick:T},{default:l(()=>[...e[9]||(e[9]=[u("提交",-1)])]),_:1})]),default:l(()=>[t(N,{model:a,rules:S,ref_key:"formRef",ref:p,"label-width":"100px"},{default:l(()=>[t(b,{label:"分类名称",prop:"name"},{default:l(()=>[t(v,{modelValue:a.name,"onUpdate:modelValue":e[0]||(e[0]=i=>a.name=i),placeholder:"请输入分类名称"},null,8,["modelValue"])]),_:1}),t(b,{label:"分类说明",prop:"description"},{default:l(()=>[t(v,{modelValue:a.description,"onUpdate:modelValue":e[1]||(e[1]=i=>a.description=i),type:"textarea",rows:3,placeholder:"请输入分类说明"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}},z=A(q,[["__scopeId","data-v-51f28a97