import{j as e}from"./index-3808da28.js";import{r as o,F as s,B as u,P as h,T,X as q,I as n,y as j,V as S,m as c}from"./vendor-61f0f29a.js";const E=()=>{const[p,C]=o.useState([]),[y,d]=o.useState(!1),[t]=s.useForm(),[m,x]=o.useState(null),g=[{title:"服务类型",dataIndex:"serviceType",key:"serviceType"},{title:"操作",key:"action",render:(r,i)=>e.jsxs(j,{children:[e.jsx(u,{type:"link",onClick:()=>k(i),children:"编辑"}),e.jsx(u,{type:"link",danger:!0,onClick:()=>b(i.id),children:"删除"})]})}],I=async r=>{try{m?c.success("更新成功"):c.success("添加成功"),d(!1),t.resetFields()}catch{c.error("操作失败")}},k=r=>{x(r.id),t.setFieldsValue({serviceType:r.serviceType,details:r.details||[]}),d(!0)},b=async r=>{try{c.success("删除成功")}catch{c.error("删除失败")}};return e.jsxs("div",{children:[e.jsxs(u,{type:"primary",onClick:()=>{x(null),t.resetFields(),d(!0)},style:{marginBottom:16},children:[e.jsx(h,{})," 新增服务类型"]}),e.jsx(T,{columns:g,dataSource:p,rowKey:"id"}),e.jsx(q,{title:m?"编辑服务类型":"新增服务类型",open:y,onOk:()=>t.submit(),onCancel:()=>{d(!1),t.resetFields()},width:800,children:e.jsxs(s,{form:t,onFinish:I,children:[e.jsx(s.Item,{label:"服务类型",name:"serviceType",rules:[{required:!0,message:"请输入服务类型"}],children:e.jsx(n,{})}),e.jsx(s.List,{name:"details",children:(r,{add:i,remove:v})=>e.jsxs(e.Fragment,{children:[r.map(({key:f,name:l,...a})=>e.jsxs(j,{align:"baseline",children:[e.jsx(s.Item,{...a,name:[l,"projectDetail"],rules:[{required:!0,message:"请输入项目明细"}],children:e.jsx(n,{placeholder:"项目明细"})}),e.jsx(s.Item,{...a,name:[l,"description"],rules:[{required:!0,message:"请输入描述"}],children:e.jsx(n,{placeholder:"描述"})}),e.jsx(s.Item,{...a,name:[l,"quantity"],rules:[{required:!0,message:"请输入数量"}],children:e.jsx(n,{placeholder:"数量",type:"number"})}),e.jsx(s.Item,{...a,name:[l,"unit"],rules:[{required:!0,message:"请输入单位"}],children:e.jsx(n,{placeholder:"单位"})}),e.jsx(s.Item,{...a,name:[l,"price"],rules:[{required:!0,message:"请输入单价"}],children:e.jsx(n,{placeholder:"单价",type:"number"})}),e.jsx(S,{onClick:()=>v(l)})]},f)),e.jsx(s.Item,{children:e.jsx(u,{type:"dashed",onClick:()=>i(),block:!0,icon:e.jsx(h,{}),children:"添加项目明细"})})]})})]})})]})};export{E as default};
//# sourceMappingURL=index-c535d235.js.map
