import{_ as j,a5 as A,b as G,r as F,ah as v,bM as H,o as f,c as I,p as l,q as r,v as k,P as L,x as b,n as o,F as q,A as w,y as B,C as x,cG as z,cH as J,s as Q,E as W,i as X,k as Y,m as Z,l as ee,bv as ae,D as te}from"./index.8d733f79.js";import{E as ne}from"./el-input-number.60463ef8.js";import{h as oe,i as le,j as re}from"./faultType.8bb3732b.js";import ie from"./bearingLib.05230f01.js";import"./index.28f6da25.js";import"./deviceAnalysis.ce7ce4e7.js";const se={class:"dialog-footer"},ue=A({name:"FaultLib"}),ce=Object.assign(ue,{emits:["confirm"],setup(de,{expose:P,emit:h}){const{t:i}=G(),{proxy:g}=te(),c=F(!1),s=F([]),d=v({waveTime:"",pointId:"",deviceId:"",faultCaseId:H().caseId}),n=v({carrierFrequency:null,bearingIdentification:"",troubleLocation:"BPFI"}),V=v({carrierFrequency:[{required:!0,message:i("rotateFreqP"),trigger:"blur"}],bearingIdentification:[{required:!0,message:i("bearingP"),trigger:"change"}],troubleLocation:[{required:!0,message:i("faultComponentP"),trigger:"change"}]}),$=F([{value:"BPFI",label:i("innerRing"),key:"innerRing"},{value:"BPFO",label:i("outerRing"),key:"outerRing"},{value:"BSF",label:i("roller"),key:"roller"},{value:"FTF",label:i("holder"),key:"holder"}]),C=e=>{c.value=!0,d.pointId=e.pointId,d.deviceId=e.deviceId,d.waveTime=e.time,D()},D=async()=>{const e=await oe(d);n.carrierFrequency=e.data.carrierFrequency?+e.data.carrierFrequency:null,E(e.data.bearingIdentification||[])},E=async e=>{const a=await le(e);s.value=a.data||[]},T=()=>{const e=[];s.value.forEach(a=>{e.push({bearingId:a.faultLibraryDTO.id,bearingIdentification:a.identification,faultLibraryDTO:a.faultLibraryDTO})}),g.$refs.faultLibRef.showModal(e)},O=e=>{console.log("\u9009\u62E9\u7684",e),s.value=[],e.forEach(a=>{s.value.push({identification:a.bearingIdentification?a.bearingIdentification:`${a.factory}-${a.model}`,faultLibraryDTO:a.faultLibraryDTO?a.faultLibraryDTO:a})})},R=()=>{g.$refs.formRef.validate(e=>{if(e){const a=s.value.find(u=>u.identification===n.bearingIdentification).faultLibraryDTO,m=$.value.find(u=>u.value===n.troubleLocation).key,p={name:`${n.bearingIdentification}-${n.troubleLocation}`,value:(a[m]*n.carrierFrequency).toFixed(3)};h("confirm",p,"add"),M(),y()}else console.log("error submit!")})},M=()=>{const e={...d,carrierFrequency:n.carrierFrequency,bearingIdentification:s.value.map(a=>a.identification)};re(e).then(a=>{g.$modal.msgSuccess(a.msg)})},S=()=>{h("confirm"),y()};function y(){c.value=!1}return P({showModal:C}),(e,a)=>{const m=W,p=X,u=Y,N=ne,U=Z,_=ee,K=ae;return f(),I(q,null,[l(K,{title:e.$t("bearingFaultLib"),modelValue:o(c),"onUpdate:modelValue":a[4]||(a[4]=t=>Q(c)?c.value=t:null),width:"420","align-center":!0},{footer:r(()=>[k("div",se,[l(_,{onClick:y},{default:r(()=>[L(b(e.$t("cancel")),1)]),_:1}),l(_,{onClick:S},{default:r(()=>[L(b(e.$t("clearLine")),1)]),_:1}),l(_,{type:"primary",onClick:R},{default:r(()=>[L(b(e.$t("confirm")),1)]),_:1})])]),default:r(()=>[l(U,{ref:"formRef",model:o(n),rules:o(V),"label-width":"80","label-position":"left"},{default:r(()=>[l(u,{label:e.$t("bearing"),prop:"bearingIdentification"},{default:r(()=>[l(p,{modelValue:o(n).bearingIdentification,"onUpdate:modelValue":a[0]||(a[0]=t=>o(n).bearingIdentification=t),placeholder:e.$t("bearingP"),teleported:!1},{default:r(()=>[(f(!0),I(q,null,w(o(s),t=>(f(),B(m,{key:t.identification,label:t.identification,value:t.identification},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"]),k("div",{class:"btnLink",onClick:T},b(e.$t("bindBearing")),1)]),_:1},8,["label"]),l(u,{label:e.$t("faultComponent"),prop:"troubleLocation"},{default:r(()=>[l(p,{modelValue:o(n).troubleLocation,"onUpdate:modelValue":a[1]||(a[1]=t=>o(n).troubleLocation=t),placeholder:e.$t("faultComponentP"),teleported:!1},{default:r(()=>[(f(!0),I(q,null,w(o($),t=>(f(),B(m,{key:t.value,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),l(u,{label:e.$t("rotateFreq"),prop:"carrierFrequency",style:{width:"295px"}},{default:r(()=>[l(N,{class:"input-number",modelValue:o(n).carrierFrequency,"onUpdate:modelValue":a[2]||(a[2]=t=>o(n).carrierFrequency=t),placeholder:e.$t("rotateFreqP"),onMousewheel:a[3]||(a[3]=x(()=>{},["prevent"])),step:.001,min:.001,max:1e6,controls:!1,onKeydown:o(z),onPaste:o(J)},null,8,["modelValue","placeholder","step","min","onKeydown","onPaste"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"]),l(o(ie),{ref:"faultLibRef",onConfirm:O},null,512)],64)}}}),_e=j(ce,[["__scopeId","data-v-1ced8a0b"]]);export{_e as default};
