import{_ as D}from"./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";import"./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";import{B as v}from"./Table-0PViRYCf.js";import{V as c,Z as O,d as x,bl as B,r as Q,c as F,o as I,l as a,w as K,j as h,ac as U,cZ as V}from"./index-9PRMimni.js";import{B as j}from"./BasicForm-dL_oCSPM.js";import{u as A}from"./useForm-CKmgcynv.js";import{l as E,m as Z}from"./jobPlanDetails-5wu16ZE_.js";import{u as $}from"./useModal-CO65vga3.js";import{p as W}from"./pick-Cg3anC-c.js";import{h as X}from"./head-aneRfQQJ.js";const{t:e}=c(),Y=[{label:e("equipmentLibrary.equipmentMainLibrary.optionYes"),value:!0},{label:e("equipmentLibrary.equipmentMainLibrary.optionNo"),value:!1}];function z(){return[{key:"selection",type:"selection",multiple:!1,width:80},{title:e("equipmentLibrary.equipmentMainLibrary.tableNum"),key:"num",width:80,render:(t,n)=>n+1},{title:e("equipmentLibrary.equipmentMainLibrary.equipmentCode"),key:"productCode",width:150},{title:e("equipmentLibrary.equipmentMainLibrary.equipmentName"),key:"productName",width:150},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.partNumber"),key:"partNumber",width:130},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.itemDescription"),key:"itemDescription",width:150},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.itemSpecification"),key:"itemSpecification",width:150},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.UOM"),key:"uomName",width:90},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.drawingPlateNumber"),key:"plateDrawingNumber",width:180,render:t=>t.drawingUrl?O("a",{href:t.drawingUrl,target:"_blank"},t.plateDrawingNumber):t.plateDrawingNumber},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.critical"),key:"critical",width:100,render:t=>Y.find(n=>n.value===t.critical)?.label},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.workingQty"),key:"workingQuantity",width:120},{title:e("equipmentLibrary.equipmentMainLibrary.spareParts.classEssentialQty"),key:"classEssentialQuantity",width:150}]}const{t:q}=c();function G(){return[{field:"partNumber",component:"NInput",label:q("equipmentLibrary.equipmentMainLibrary.spareParts.partNumber")},{field:"itemDescription",component:"NInput",label:q("equipmentLibrary.equipmentMainLibrary.spareParts.itemDescription")}]}const le=x({__name:"index",props:{data:{}},emits:["refresh"],setup(b,{expose:t,emit:n}){const d=b,L=n,y=V(),{t:o}=c(),l=B("basicTableRef"),u=Q([]),[w,{openModal:k,closeModal:g,setSubLoading:f,setProps:M}]=$({title:"",width:1200}),[N,{getFieldsValue:R}]=A({gridProps:{cols:5},schemas:G(),labelWidth:"auto",labelPlacement:"top",showAdvancedButton:!1});async function P(r,i){try{return await E({showSub:!1,...d.data??{},...r,...i})}catch{return{list:[],total:0}}}function _(){M({title:o("equipmentLibrary.equipmentMainLibrary.selectTitle")}),k(),U(()=>{p()})}function p(){l.value?.restReload()}function C(r,i){u.value=a(i)}async function T(){if(!u.value?.length){y.error(o("equipmentLibrary.equipmentMainLibrary.job.selectTips")),f(!1);return}const r=W(X(a(u)),["partNumber","plannedQuantity"]),i={...d.data??{},sparePartNumber:r.partNumber,plannedQuantity:r.plannedQuantity??0};try{await Z(i),y.success(o("common.optionsAddSuccessText")),g(),L("refresh")}catch(s){console.error(s)}finally{f(!1)}}function S(){l.value?.restCheckedRowKeys()}return t({handleOpenModal:_}),(r,i)=>{const s=D;return I(),F(s,{ref:"modalRef",onRegister:a(w),onOnOk:T,onOnClose:S},{default:K(()=>[h(a(j),{onRegister:a(N),onSubmit:p,onReset:p},null,8,["onRegister"]),h(a(v),{ref_key:"basicTableRef",ref:l,columns:a(z)(),request:m=>P(m,a(R)()),"row-key":m=>m.partNumber,immediate:!1,autoScrollX:"",virtualScroll:"",isKeepRowKeys:"",onCheckedRowChange:C},null,8,["columns","request","row-key"])]),_:1},8,["onRegister"])}}});export{le as _};
