Files
yuezi-saas/frontend/dist/assets/health-metrics-2n4seMhw.js
T

1 line
7.4 KiB
JavaScript

import{$ as e,H as t,L as n,P as r,V as i,Wt as a,_ as o,_t as s,d as c,et as l,i as u,lt as d,p as f,st as p,u as m,v as h,z as g}from"./runtime-core.esm-bundler-DbRZbT7v.js";import{o as _,s as v}from"./index-Mgun2LFs.js";import"./request-DG5cMCYw.js";import{t as y}from"./iconify-f5JHLb1p.js";import{a as b}from"./care-9BSIs94M.js";import{i as x}from"./crm-COsPApQ4.js";var S={class:`p-6 space-y-4`},C={class:`bg-white rounded-2xl border border-gray-100 shadow-sm p-4 flex items-center flex-wrap gap-3`},w={class:`bg-white rounded-2xl border border-gray-100 shadow-sm`},T={class:`flex items-center justify-between px-5 py-4 border-b border-gray-50`},E={class:`px-2`},D={class:`font-medium text-rose-600`},O={class:`text-xs text-gray-400 ml-1`},k={class:`px-5 py-3 border-t border-gray-50`},A={__name:`index`,setup(A){let j=d([]),M=d(0),N=d(!1),P=d(!1),F=d(!1),I=d([]),L=p({customer_id:``,metric_type:``,date_from:``,date_to:``}),R=p({page:1,per_page:20}),z=d(null),B=p({customer_id:``,metric_type:``,value:``,unit:``,recorded_at:``,note:``}),V={blood_pressure:`血压`,weight:`体重`,temperature:`体温`,heart_rate:`心率`,blood_sugar:`血糖`,lochia:`恶露`,fundus:`宫底高度`,other:`其他`},H={blood_pressure:`mmHg`,weight:`kg`,temperature:`°C`,heart_rate:`次/分`,blood_sugar:`mmol/L`,lochia:``,fundus:`cm`,other:``},U={customer_id:[{required:!0,message:`请选择客户`,trigger:`change`}],metric_type:[{required:!0,message:`请选择指标类型`,trigger:`change`}],value:[{required:!0,message:`请输入指标值`,trigger:`blur`}],recorded_at:[{required:!0,message:`请选择记录时间`,trigger:`change`}]};function W(e){B.unit=H[e]||``}async function G(){N.value=!0;try{let e=await b.getList({...L,...R});j.value=e.data?.list||e.data?.data||[],M.value=e.data?.total||0}catch{v.error(`加载失败`)}finally{N.value=!1}}async function K(){try{let e=await x.getList({per_page:500,status:3});I.value=e.data?.list||e.data?.data||[]}catch{}}function q(){R.page=1,G()}function J(){Object.assign(L,{customer_id:``,metric_type:``,date_from:``,date_to:``}),q()}function Y(){Object.assign(B,{customer_id:``,metric_type:``,value:``,unit:``,recorded_at:``,note:``}),P.value=!0}function X(e){_.confirm(`确定删除该健康指标记录吗?`,`删除确认`,{type:`warning`}).then(()=>{j.value=j.value.filter(t=>t.id!==e.id),v.success(`已移除`)}).catch(()=>{})}async function Z(){z.value&&await z.value.validate(async e=>{if(e){F.value=!0;try{await b.create(B),v.success(`记录成功`),P.value=!1,G()}catch{v.error(`操作失败`)}finally{F.value=!1}}})}function Q(e){R.page=e,G()}function $(e){R.per_page=e,R.page=1,G()}return r(()=>{G(),K()}),(r,d)=>{let p=i(`el-option`),_=i(`el-select`),v=i(`el-date-picker`),b=i(`el-button`),x=i(`el-table-column`),A=i(`el-table`),H=i(`el-pagination`),G=i(`el-form-item`),K=i(`el-input`),ee=i(`el-form`),te=i(`el-dialog`),ne=t(`loading`);return n(),f(`div`,S,[m(`div`,C,[h(_,{modelValue:L.customer_id,"onUpdate:modelValue":d[0]||=e=>L.customer_id=e,placeholder:`选择客户`,clearable:``,filterable:``,style:{width:`180px`}},{default:e(()=>[(n(!0),f(u,null,g(I.value,e=>(n(),c(p,{key:e.id,label:e.name,value:e.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`]),h(_,{modelValue:L.metric_type,"onUpdate:modelValue":d[1]||=e=>L.metric_type=e,placeholder:`指标类型`,clearable:``,style:{width:`140px`}},{default:e(()=>[(n(),f(u,null,g(V,(e,t)=>h(p,{key:t,label:e,value:t},null,8,[`label`,`value`])),64))]),_:1},8,[`modelValue`]),h(v,{modelValue:L.date_from,"onUpdate:modelValue":d[2]||=e=>L.date_from=e,type:`date`,"value-format":`YYYY-MM-DD`,placeholder:`开始日期`,style:{width:`150px`}},null,8,[`modelValue`]),h(v,{modelValue:L.date_to,"onUpdate:modelValue":d[3]||=e=>L.date_to=e,type:`date`,"value-format":`YYYY-MM-DD`,placeholder:`结束日期`,style:{width:`150px`}},null,8,[`modelValue`]),h(b,{type:`primary`,onClick:q},{default:e(()=>[h(s(y),{icon:`solar:magnifer-bold-duotone`,class:`mr-1`}),d[13]||=o(`查询 `,-1)]),_:1}),h(b,{onClick:J},{default:e(()=>[...d[14]||=[o(`重置`,-1)]]),_:1})]),m(`div`,w,[m(`div`,T,[d[16]||=m(`div`,{class:`flex items-center gap-2`},[m(`span`,{class:`w-1 h-5 bg-rose-500 rounded-full inline-block`}),m(`span`,{class:`font-semibold text-gray-700`},`健康指标记录`)],-1),h(b,{type:`primary`,onClick:Y},{default:e(()=>[h(s(y),{icon:`solar:add-circle-bold-duotone`,class:`mr-1`}),d[15]||=o(`新增记录 `,-1)]),_:1})]),m(`div`,E,[l((n(),c(A,{data:j.value,style:{width:`100%`}},{default:e(()=>[h(x,{label:`客户`,"min-width":`100`},{default:e(({row:e})=>[o(a(e.customer_name||`-`),1)]),_:1}),h(x,{label:`指标类型`,width:`110`,align:`center`},{default:e(({row:e})=>[o(a(V[e.metric_type]||e.metric_type||`-`),1)]),_:1}),h(x,{label:`指标值`,width:`130`,align:`center`},{default:e(({row:e})=>[m(`span`,D,a(e.value),1),m(`span`,O,a(e.unit),1)]),_:1}),h(x,{prop:`note`,label:`备注`,"min-width":`160`,"show-overflow-tooltip":``}),h(x,{prop:`created_by_name`,label:`记录人`,width:`100`}),h(x,{prop:`recorded_at`,label:`记录时间`,"min-width":`160`}),h(x,{label:`操作`,width:`80`,fixed:`right`,align:`center`},{default:e(({row:t})=>[h(b,{size:`small`,type:`danger`,text:``,onClick:e=>X(t)},{default:e(()=>[...d[17]||=[o(`删除`,-1)]]),_:1},8,[`onClick`])]),_:1})]),_:1},8,[`data`])),[[ne,N.value]])]),m(`div`,k,[h(H,{"current-page":R.page,"onUpdate:currentPage":d[4]||=e=>R.page=e,"page-size":R.per_page,"onUpdate:pageSize":d[5]||=e=>R.per_page=e,total:M.value,"page-sizes":[10,20,50],layout:`total,sizes,prev,pager,next,jumper`,background:``,onCurrentChange:Q,onSizeChange:$},null,8,[`current-page`,`page-size`,`total`])])]),h(te,{modelValue:P.value,"onUpdate:modelValue":d[12]||=e=>P.value=e,title:`新增健康指标`,width:`520px`,"destroy-on-close":``},{footer:e(()=>[h(b,{onClick:d[11]||=e=>P.value=!1},{default:e(()=>[...d[18]||=[o(`取消`,-1)]]),_:1}),h(b,{type:`primary`,loading:F.value,onClick:Z},{default:e(()=>[...d[19]||=[o(`确定`,-1)]]),_:1},8,[`loading`])]),default:e(()=>[h(ee,{ref_key:`formRef`,ref:z,model:B,rules:U,"label-width":`90px`},{default:e(()=>[h(G,{label:`客户`,prop:`customer_id`},{default:e(()=>[h(_,{modelValue:B.customer_id,"onUpdate:modelValue":d[6]||=e=>B.customer_id=e,filterable:``,style:{width:`100%`},placeholder:`请选择客户`},{default:e(()=>[(n(!0),f(u,null,g(I.value,e=>(n(),c(p,{key:e.id,label:e.name,value:e.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`])]),_:1}),h(G,{label:`指标类型`,prop:`metric_type`},{default:e(()=>[h(_,{modelValue:B.metric_type,"onUpdate:modelValue":d[7]||=e=>B.metric_type=e,style:{width:`100%`},onChange:W},{default:e(()=>[(n(),f(u,null,g(V,(e,t)=>h(p,{key:t,label:e,value:t},null,8,[`label`,`value`])),64))]),_:1},8,[`modelValue`])]),_:1}),h(G,{label:`指标值`,prop:`value`},{default:e(()=>[h(K,{modelValue:B.value,"onUpdate:modelValue":d[8]||=e=>B.value=e,placeholder:`请输入数值`,style:{width:`100%`}},{append:e(()=>[o(a(B.unit||`单位`),1)]),_:1},8,[`modelValue`])]),_:1}),h(G,{label:`记录时间`,prop:`recorded_at`},{default:e(()=>[h(v,{modelValue:B.recorded_at,"onUpdate:modelValue":d[9]||=e=>B.recorded_at=e,type:`datetime`,"value-format":`YYYY-MM-DD HH:mm:ss`,placeholder:`请选择记录时间`,style:{width:`100%`}},null,8,[`modelValue`])]),_:1}),h(G,{label:`备注`},{default:e(()=>[h(K,{modelValue:B.note,"onUpdate:modelValue":d[10]||=e=>B.note=e,type:`textarea`,rows:2,placeholder:`补充说明(可选)`},null,8,[`modelValue`])]),_:1})]),_:1},8,[`model`])]),_:1},8,[`modelValue`])])}}};export{A as default};