import{q as R,c as w,a as u,t as y,b as t,w as n,x as A,k as I,h as d,r as o,v as T,f as j,o as B,e as r,E as C}from"./index-NywRioUE.js";import{s as f}from"./index-IKxiqY7O.js";const F={class:"content-card"},G={class:"card-title"},L={__name:"ClientManage",setup(H){const v=d([]),_=d(!1),p=d(!1),g=d(!1),m=d(null),k=d(null),s=j({name:"",description:""}),D={name:[{required:!0,message:"请输入客户名称",trigger:"blur"}]};async function b(){_.value=!0;try{const l=await f.getClients();v.value=l.data}finally{_.value=!1}}function V(l){m.value=(l==null?void 0:l.id)||null,s.name=(l==null?void 0:l.name)||"",s.description=(l==null?void 0:l.description)||"",p.value=!0}async function $(){var e;if(await((e=k.value)==null?void 0:e.validate().catch(()=>!1))){g.value=!0;try{m.value?(await f.updateClient(m.value,s),C.success("更新成功")):(await f.createClient(s),C.success("创建成功")),p.value=!1,b()}finally{g.value=!1}}}async function E(l){await f.updateClient(l.id,{status:l.status===1?0:1}),C.success("状态已更新"),b()}return R(b),(l,e)=>{const c=o("el-button"),i=o("el-table-column"),M=o("el-tag"),N=o("el-table"),x=o("el-input"),h=o("el-form-item"),S=o("el-form"),U=o("el-dialog"),q=T("loading");return B(),w("div",null,[e[9]||(e[9]=u("div",{class:"page-header"},[u("h1",null,"客户/项目管理"),u("p",null,"管理您名下的客户与项目")],-1)),u("div",F,[u("div",G,[u("span",null,"我的客户 ("+y(v.value.length)+")",1),t(c,{type:"primary",onClick:e[0]||(e[0]=a=>V())},{default:n(()=>[...e[5]||(e[5]=[r("+ 新增客户",-1)])]),_:1})]),A((B(),I(N,{data:v.value,stripe:""},{default:n(()=>[t(i,{prop:"name",label:"客户/项目名称","min-width":"160"}),t(i,{prop:"description",label:"描述","min-width":"200"}),t(i,{prop:"status",label:"状态",width:"100"},{default:n(({row:a})=>[t(M,{type:a.status===1?"success":"info",effect:"dark",round:""},{default:n(()=>[r(y(a.status===1?"进行中":"已结算"),1)]),_:2},1032,["type"])]),_:1}),t(i,{prop:"total_hours",label:"总工时(h)",width:"110"}),t(i,{prop:"rd_count",label:"参与研发",width:"100"}),t(i,{prop:"created_at",label:"创建时间",width:"170"}),t(i,{label:"操作",width:"180"},{default:n(({row:a})=>[t(c,{size:"small",onClick:z=>V(a)},{default:n(()=>[...e[6]||(e[6]=[r("编辑",-1)])]),_:1},8,["onClick"]),t(c,{size:"small",type:a.status===1?"warning":"success",onClick:z=>E(a)},{default:n(()=>[r(y(a.status===1?"结算":"激活"),1)]),_:2},1032,["type","onClick"])]),_:1})]),_:1},8,["data"])),[[q,_.value]])]),t(U,{modelValue:p.value,"onUpdate:modelValue":e[4]||(e[4]=a=>p.value=a),title:m.value?"编辑客户":"新增客户",width:"460px","destroy-on-close":""},{footer:n(()=>[t(c,{onClick:e[3]||(e[3]=a=>p.value=!1)},{default:n(()=>[...e[7]||(e[7]=[r("取消",-1)])]),_:1}),t(c,{type:"primary",loading:g.value,onClick:$},{default:n(()=>[...e[8]||(e[8]=[r("保存",-1)])]),_:1},8,["loading"])]),default:n(()=>[t(S,{model:s,rules:D,ref_key:"formRef",ref:k,"label-width":"80px"},{default:n(()=>[t(h,{label:"名称",prop:"name"},{default:n(()=>[t(x,{modelValue:s.name,"onUpdate:modelValue":e[1]||(e[1]=a=>s.name=a),placeholder:"客户/项目名称"},null,8,["modelValue"])]),_:1}),t(h,{label:"描述"},{default:n(()=>[t(x,{modelValue:s.description,"onUpdate:modelValue":e[2]||(e[2]=a=>s.description=a),type:"textarea",rows:3,placeholder:"项目描述（选填）"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}};export{L as default};
