import{i as e,t}from"./react-B8IZ02wI.js";import{M as n,N as r,P as i}from"./authStore-BvQBJ9ky.js";import{ct as a,n as o,pt as s,st as c,ut as l}from"./index-Bg7bo8aA.js";import{t as u}from"./WarehouseSelect-BfCPVJ_3.js";var d=e(t(),1),f=o();function p({open:e,resourceType:t,resourceId:r=null,resourceIds:o,title:p,onClose:m,onSuccess:h}){let[g]=s.useForm(),[_,v]=(0,d.useState)(!1),y=o&&o.length>0?o:r==null?[]:[r];return(0,f.jsx)(c,{title:p||(y.length>1?`批量回收（${y.length}）`:`回收至库房`),open:e,onCancel:m,onOk:async()=>{if(y.length)try{let e=await g.validateFields();v(!0);let r=0,i=0;for(let a of y)try{await n.recover({resource_type:t,resource_id:a,warehouse_id:e.warehouse_id,remark:e.remark}),r+=1}catch{i+=1}r?a.success(y.length>1?`已回收 ${r} 条${i?`，失败 ${i} 条`:``}`:t===`DEVICE`?`设备已回收至所选库房`:`号码已回收至所选库房`):a.error(`回收失败`),g.resetFields(),h(),m()}catch(e){if(e&&typeof e==`object`&&`errorFields`in e)return;a.error(i(e,`回收失败`))}finally{v(!1)}},confirmLoading:_,destroyOnHidden:!0,children:(0,f.jsxs)(s,{form:g,layout:`vertical`,children:[(0,f.jsx)(s.Item,{name:`warehouse_id`,label:`目标库房`,rules:[{required:!0,message:`请选择库房`}],children:(0,f.jsx)(u,{style:{width:`100%`}})}),(0,f.jsx)(s.Item,{name:`remark`,label:`备注`,children:(0,f.jsx)(l.TextArea,{rows:2})})]})})}function m({open:e,resourceType:t,resourceId:n,currentWarehouseName:o,onClose:p,onSuccess:m}){let[h]=s.useForm(),[g,_]=(0,d.useState)(!1);return(0,f.jsxs)(c,{title:`库间调拨`,open:e,onCancel:()=>{h.resetFields(),p()},onOk:async()=>{if(n)try{let e=await h.validateFields();_(!0),await r.transfer({resource_type:t,resource_id:n,to_warehouse_id:e.to_warehouse_id,remark:e.remark}),a.success(`已调拨到目标库房`),h.resetFields(),m(),p()}catch(e){if(e&&typeof e==`object`&&`errorFields`in e)return;a.error(i(e,`调拨失败`))}finally{_(!1)}},confirmLoading:g,destroyOnHidden:!0,children:[o&&(0,f.jsxs)(`p`,{style:{marginBottom:12,color:`#6b7280`},children:[`当前库房：`,o]}),(0,f.jsxs)(s,{form:h,layout:`vertical`,children:[(0,f.jsx)(s.Item,{name:`to_warehouse_id`,label:`调入库房`,rules:[{required:!0,message:`请选择目标库房`}],children:(0,f.jsx)(u,{allowClear:!1})}),(0,f.jsx)(s.Item,{name:`remark`,label:`备注`,children:(0,f.jsx)(l.TextArea,{rows:2})})]})]})}export{p as n,m as t};