1import{f as B,y as W,Y as A,z as G,D as x,$ as M,e0 as U,F as _,e1 as K,a2 as Q,r as f,j as t,aE as v,a4 as Y,Q as C,aO as R,cy as I,S as $,a5 as H,B as P,m as J,W as X,bB as S}from"./index-DUoAJW6O.js";const D=()=>{const{t:r}=B(),[i,y]=W(),N=i.get("city"),c=i.get("posId"),b=N?Number(N):void 0,T=A(),u=G(),{data:d,isLoading:j}=x(u.organizationId?["get-pos",b,u.organizationId]:null,()=>M({placementId:b,organizationId:u.organizationId}),{revalidateOnFocus:!1,revalidateOnReconnect:!1,keepPreviousData:!0,shouldRetryOnError:!1}),{data:l,isLoading:w}=x(c?["get-consumption-rate",c]:null,()=>U(Number(c)),{revalidateOnFocus:!1,revalidateOnReconnect:!1,keepPreviousData:!0,shouldRetryOnError:!1}),{trigger:E,isMutating:F}=_(["patch-program-coeff",c],async(e,{arg:a})=>K(Number(c),a)),{data:p}=x("get-city",Q,{shouldRetryOnError:!1}),O=[...(p==null?void 0:p.map(e=>({label:e.region,value:String(e.id)})))||[]],k=[...(d==null?void 0:d.map(e=>({label:e.name,value:String(e.id)})))||[]],[n,g]=f.useState(l);f.useEffect(()=>{if(l){const e=[...l].sort((a,s)=>a.programTypeName.localeCompare(s.programTypeName));g(e)}},[l]),f.useEffect(()=>{if(l){const e=[...l].sort((a,s)=>a.programTypeName.localeCompare(s.programTypeName));g(e)}},[l]);const z=(e,a,s)=>{g(o=>{const h=o==null?void 0:o.map(m=>m.id===e?{...m,[a]:s}:m);return h==null?void 0:h.sort((m,V)=>m.programTypeName.localeCompare(V.programTypeName))})},L=async()=>{if(n&&n.some(o=>o.literRate<0||o.concentration<0))return;const a=(n==null?void 0:n.map(o=>({programTechRateId:o.id,literRate:Number(o.literRate),concentration:Number(o.concentration)})))||[];await E({valueData:a})&&X(["get-consumption-rate",c])},q=[{title:r("equipment.program"),dataIndex:"programTypeName",key:"programTypeName",render:e=>t.jsx("span",{children:e.programTypeName})},{title:r("equipment.consumption"),dataIndex:"literRate",key:"literRate",render:(e,a)=>t.jsx(v,{type:"number",value:e.literRate,changeValue:s=>a(e.id,"literRate",s.target.value),error:e.literRate<0})},{title:r("equipment.concentration"),dataIndex:"concentration",key:"concentration",render:(e,a)=>t.jsx(v,{type:"number",value:e.concentration,changeValue:s=>a(e.id,"concentration",s.target.value),error:e.concentration<0})}];return t.jsxs("div",{children:[t.jsx("div",{className:"ml-12 md:ml-0 mb-5",children:t.jsx("div",{className:"flex items-center space-x-2",children:t.jsx("span",{className:"text-xl sm:text-3xl font-normal text-text01",children:r("routes.consumption")})})}),t.jsxs(Y,{count:(n==null?void 0:n.length)||0,display:["count"],children:[t.jsxs("div",{className:"w-full sm:w-80",children:[t.jsx("label",{className:"block mb-1 text-sm font-medium text-gray-700",children:r("pos.city")}),t.jsx(C,{showSearch:!0,allowClear:!1,className:"w-full",placeholder:r("chemical.select"),value:I(i,"city","")||null,onChange:e=>{R(i,y,{city:e,page:S})},options:O,optionFilterProp:"label",filterOption:(e,a)=>((a==null?void 0:a.label)??"").toString().toLowerCase().includes(e.toLowerCase())})]}),t.jsxs("div",{className:"w-full sm:w-80",children:[t.jsx("label",{className:"block mb-1 text-sm font-medium text-gray-700",children:r("analysis.posId")}),t.jsx(C,{showSearch:!0,allowClear:!1,placeholder:r("chemical.select"),value:I(i,"posId")||null,onChange:e=>{R(i,y,{posId:e,page:S})},loading:j,className:"w-full",options:k,optionFilterProp:"label",filterOption:(e,a)=>((a==null?void 0:a.label)??"").toString().toLowerCase().includes(e.toLowerCase()),notFoundContent:j?t.jsx($,{size:"small"}):null})]})]}),t.jsx("div",{className:"mt-8",children:t.jsx(H,{dataSource:n,columns:q.map(e=>({...e,render:(a,s)=>e.render?e.render(s,z):a})),rowKey:"id",pagination:!1,scroll:{x:"max-content"},loading:w})}),n&&n.length>0&&t.jsxs("div",{className:"flex mt-4 space-x-4",children:[t.jsx(P,{className:"w-[168px] btn-outline-primary",children:r("organizations.cancel")}),t.jsx(J,{requiredPermissions:[{action:"manage",subject:"Incident"},{action:"update",subject:"Incident"}],userPermissions:T,children:e=>e&&t.jsx(P,{htmlType:"submit",loading:F,onClick:L,className:"w-[168px] btn-primary",children:r("organizations.save")})})]})]})};export{D as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.