import{e as G}from"./index-b6aa4cff.js";import{G as L,E as M,r,a as U,B as q,b as m,c as z,d as $,f as a,h as s,i as _,e as A,F as H,k as J,C as K}from"./index-dd5fae99.js";const Q={class:"flex"},W=J({name:"coreBusiness"}),Z=Object.assign(W,{props:{detail:{type:Object},basicInfoData:{type:Object},isSupplemented:{type:Boolean,default:!1}},setup(N,{expose:R}){const l=N,S=L(M.userStore).userInfo||{},d=r({}),D=r(),T={coreBusiness:[{required:!1,message:"请至少选择一个核心业务"}]},V=()=>{c.value=!0,y({pageNumber:1,pageSize:10},!0)},h=[{type:"index",label:"序号",width:60},{label:"业务名称",key:"matterName",prop:"matterName"},{label:"所属单位",key:"orgName",prop:"orgName"}],g=r(),v=r([]),k=r(0),j=[{type:"selection"},{label:"业务名称",prop:"matterName",key:"matterName"},{label:"所属单位",prop:"orgName",key:"orgName"}],c=r(!1),y=async(n=(o=>(o=g.value)==null?void 0:o.pageParams)(),e)=>{var f,u;var t=[];(f=l==null?void 0:l.basicInfoData)!=null&&f.baseManDeprtDing&&t.push(l.basicInfoData.baseManDeprtDing),(u=l==null?void 0:l.basicInfoData)!=null&&u.baseBuildDeprtDing&&t.push(l.basicInfoData.baseBuildDeprtDing);const p=await G({...n,businessName:B.businessName,orgCode:(t==null?void 0:t.join(","))||""});v.value=p.data.data,k.value=p.data.total,await K(),e&&v.value&&v.value.forEach(i=>{(d.value.coreBusiness&&d.value.coreBusiness.map(C=>C.id*1)||[]).includes(i.id)?g.value.toggleRowSelect(i,!0):g.value.toggleRowSelect(i,!1)})},E=()=>{y()},w=r(),O=n=>{w.value=n},B=U({businessName:void 0}),P=()=>{B.businessName=""},F=()=>{d.value.coreBusiness=w.value,c.value=!1},x=r();return R({formRef:D,formData:d}),q(()=>l.detail,n=>{var e,o,t;n&&(l.isSupplemented&&(x.value=n.apply),d.value={coreBusiness:((t=(o=(e=n.apply)==null?void 0:e.baseCoreBusinessCode)==null?void 0:o.split(";"))==null?void 0:t.map((p,f)=>{var u,i;return{id:p,matterName:(i=(u=n.apply)==null?void 0:u.baseCoreBusiness)==null?void 0:i.split(";")[f],orgName:S.value.empPosUnitName}}))||[]})}),(n,e)=>{const o=m("el-button"),t=m("el-col"),p=m("table-list"),f=m("el-form-item"),u=m("el-row"),i=m("el-form"),I=m("el-input"),C=m("el-dialog");return z(),$(H,null,[a(i,{ref_key:"formRef",ref:D,model:d.value,rules:T,"label-position":"right","label-width":"0","label-suffix":":","scroll-to-error":""},{default:s(()=>[a(u,{gutter:40},{default:s(()=>[a(t,{span:24,class:"mb-16"},{default:s(()=>{var b;return[a(o,{type:"primary",class:"float-right",disabled:((b=x.value)==null?void 0:b.baseCoreBusinessCode)&&N.isSupplemented,onClick:V},{default:s(()=>e[2]||(e[2]=[_(" 选择核心业务 ")])),_:1},8,["disabled"])]}),_:1}),a(t,{span:24},{default:s(()=>[a(f,null,{default:s(()=>[a(p,{pagination:!1,style:{width:"100%"},column:h,data:d.value.coreBusiness,"empty-temp":!1},null,8,["data"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"]),a(C,{title:"选择核心业务","close-on-click-modal":!1,"before-close":()=>c.value=!1,"model-value":c.value,width:"700px"},{footer:s(()=>[a(o,{type:"primary",onClick:F},{default:s(()=>e[5]||(e[5]=[_(" 提交 ")])),_:1}),a(o,{onClick:e[1]||(e[1]=b=>c.value=!1)},{default:s(()=>e[6]||(e[6]=[_(" 关闭 ")])),_:1})]),default:s(()=>[a(u,{style:{"margin-bottom":"16px"},gutter:20},{default:s(()=>[a(t,{span:12},{default:s(()=>[a(I,{modelValue:B.businessName,"onUpdate:modelValue":e[0]||(e[0]=b=>B.businessName=b),placeholder:"请输入"},null,8,["modelValue"])]),_:1}),a(t,{span:12},{default:s(()=>[A("div",Q,[a(o,{type:"primary",onClick:E},{default:s(()=>e[3]||(e[3]=[_("查询")])),_:1}),a(o,{onClick:P},{default:s(()=>e[4]||(e[4]=[_("重置")])),_:1})])]),_:1})]),_:1}),a(p,{ref_key:"tableListRef",ref:g,column:j,data:v.value,total:k.value,onSelectionChange:O,onGetTableData:y},null,8,["data","total"])]),_:1},8,["before-close","model-value"])],64)}}});export{Z as default};