suyuan-breed/public/admin/assets/edit.10fdb7a8.js

2 lines
7.7 KiB
JavaScript

import{B as Y,C as Z,G as q,H as ee,c as te,P as le,D as ue,k as ae}from"./element-plus.ae8e286c.js";import{a as oe}from"./useDictOptions.7b4b6189.js";import{P as ie}from"./index.0d3bed35.js";import{c as U,d as V,a as re,e as de,f as ne}from"./device.719ac6f2.js";import"./lodash.e92d81a1.js";import{a as se,e as x,d as pe}from"./index.fccb4ef5.js";import{d as P,s as w,r as E,b as me,_ as h,a3 as ce,o as i,c as n,T as a,K as o,u as b,U as f,a6 as v,J as s,Q as D}from"./@vue.108c970a.js";import"./@vueuse.d3d080b7.js";import"./@element-plus.d6eabd08.js";import"./lodash-es.29c53eac.js";import"./dayjs.664390f6.js";import"./axios.4ebfdb3f.js";import"./async-validator.fb49d0f5.js";import"./@ctrl.82a509e0.js";import"./@popperjs.36402333.js";import"./escape-html.e5dfadb9.js";import"./normalize-wheel-es.8aeb3683.js";import"./vue-router.ed788fee.js";import"./pinia.eff1ffd5.js";import"./vue-demi.ebc8116b.js";import"./css-color-function.dbf33394.js";import"./color.e1b5fced.js";import"./clone.0a4e8ac3.js";import"./color-convert.755d189f.js";import"./color-name.e7a4e1d3.js";import"./color-string.e356f5de.js";import"./balanced-match.d2a36341.js";import"./debug.f174a91e.js";import"./ms.a9ae1d6d.js";import"./nprogress.d7c3ab1b.js";import"./vue-clipboard3.add720e2.js";import"./clipboard.01ea18f5.js";import"./echarts.8d7a50ae.js";import"./zrender.1084fa23.js";import"./tslib.60310f1a.js";import"./highlight.js.4ebdf9a4.js";import"./@highlightjs.241b9b5d.js";const _e={class:"edit-popup"},fe=["src"],ve={key:1,class:"avatar-uploader-icon"},Be=P({name:"deviceEdit"}),ge=P({...Be,props:{dictData:{type:Object,default:()=>({})}},emits:["success","close"],setup(B,{expose:R,emit:C}){const k=w(),F=w(),y=E("add"),A=E(".png, .jpg, .jpeg, image/png, image/jpeg"),S=E(`${x.baseUrl}${x.urlPrefix}/upload/image`),j=se(),L=(u,e)=>{if(u.code==0){ae.error(u.msg);return}t.image=u.data.uri},T=me(()=>y.value=="edit"?"\u7F16\u8F91\u8BBE\u5907":"\u65B0\u589E\u8BBE\u5907"),t=h({id:"",product_id:"",code:"",iccid:"",name:"",video_url:"",type:"",monitor_item:[],status:"",is_online:"",image:""}),O=h({name:[{required:!0,message:"\u8BF7\u8F93\u5165\u8BBE\u5907\u540D\u79F0",trigger:["blur"]}],type:[{required:!0,message:"\u8BF7\u9009\u62E9\u8BBE\u5907\u7C7B\u578B",trigger:["blur"]}],status:[{required:!0,message:"\u8BF7\u9009\u62E9\u8BBE\u5907\u72B6\u6001",trigger:["blur"]}],is_online:[{required:!0,message:"\u8BF7\u9009\u62E9\u662F\u5426\u5728\u7EBF",trigger:["blur"]}]}),N=async u=>{const e=await V({deviceId:u!=null?u:""}).catch(p=>{t.iccid="",t.monitor_item=""});e.length!=0&&(t.iccid=e[0].iccid,e[0].type==0&&(t.monitor_item=["temperature"]),e[0].type==1&&(t.monitor_item=["ambient_temperature","ambient_humidity"]),e[0].type==2&&(t.monitor_item=["nitrogen"]),e[0].type==3&&(t.monitor_item=["methane"]),e[0].type==4&&(t.monitor_item=["noise"]),e[0].type==5&&(t.monitor_item=["fireproof"]))},I=async u=>{for(const e in t)u[e]!=null&&u[e]!=null&&(t[e]=u[e])},{optionsData:g}=oe({product:{api:U,params:{all:1}},deviceIccids:{api:V,params:{all:1}}}),m=E(!1),$=async u=>{m.value=!0;const e=await U({name:u!=null?u:""});g.product=e,m.value=!1},G=async u=>{m.value=!0;const e=await V({deviceId:u!=null?u:""});g.deviceIccids=e,m.value=!1},H=async u=>{const e=await re({id:u.id});I(e)},J=async()=>{var e,p;await((e=k.value)==null?void 0:e.validate());const u={...t};y.value=="edit"?await de(u):await ne(u),(p=F.value)==null||p.close(),C("success")},K=(u="add")=>{var e;y.value=u,(e=F.value)==null||e.open()},M=()=>{C("close")};return R({open:K,setFormData:I,getDetail:H}),(u,e)=>{const p=Y,d=Z,c=q,_=ee,Q=ce("Plus"),z=te,W=le,X=ue;return i(),n("div",_e,[a(ie,{ref_key:"popupRef",ref:F,title:b(T),async:!0,width:"550px",onConfirm:J,onClose:M},{default:o(()=>[a(X,{ref_key:"formRef",ref:k,model:t,"label-width":"120px",rules:O},{default:o(()=>[a(d,{label:"\u8BBE\u5907\u540D\u79F0",prop:"name"},{default:o(()=>[a(p,{modelValue:t.name,"onUpdate:modelValue":e[0]||(e[0]=l=>t.name=l),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u8BBE\u5907\u540D\u79F0"},null,8,["modelValue"])]),_:1}),a(d,{label:"\u8BBE\u5907\u7C7B\u578B",prop:"type"},{default:o(()=>[a(_,{class:"flex-1",modelValue:t.type,"onUpdate:modelValue":e[1]||(e[1]=l=>t.type=l),clearable:"",placeholder:"\u8BF7\u9009\u62E9\u8BBE\u5907\u7C7B\u578B"},{default:o(()=>[(i(!0),n(f,null,v(B.dictData.device_type,(l,r)=>(i(),s(c,{key:r,label:l.name,value:parseInt(l.value)},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(d,{label:"\u6240\u5C5E\u4EA7\u54C1",prop:"product_id"},{default:o(()=>[a(_,{modelValue:t.product_id,"onUpdate:modelValue":e[2]||(e[2]=l=>t.product_id=l),remote:"",filterable:"",placeholder:"\u8BF7\u8F93\u5165\u4EA7\u54C1\u4FE1\u606F","remote-method":$,loading:m.value},{default:o(()=>[(i(!0),n(f,null,v(b(g).product,(l,r)=>(i(),s(c,{key:r,label:l.productinfo,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","loading"])]),_:1}),t.type==1?(i(),s(d,{key:0,label:"\u8BBE\u5907\u7F16\u7801",prop:"code",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u8BBE\u5907\u7F16\u7801",trigger:["blur"]}]},{default:o(()=>[a(_,{modelValue:t.code,"onUpdate:modelValue":e[3]||(e[3]=l=>t.code=l),remote:"",filterable:"","remote-method":G,onChange:N,loading:m.value},{default:o(()=>[(i(!0),n(f,null,v(b(g).deviceIccids,(l,r)=>(i(),s(c,{key:r,label:l.device_sn,value:l.device_sn},null,8,["label","value"]))),128))]),_:1},8,["modelValue","loading"])]),_:1})):D("",!0),t.type==1?(i(),s(d,{key:1,label:"\u786C\u4EF6ICCID",prop:"iccid"},{default:o(()=>[a(p,{modelValue:t.iccid,"onUpdate:modelValue":e[4]||(e[4]=l=>t.iccid=l),disabled:"",placeholder:"\u8BF7\u8F93\u5165ICCID"},null,8,["modelValue"])]),_:1})):D("",!0),t.type==1?(i(),s(d,{key:2,label:"\u76D1\u6D4B\u9879",prop:"monitor_item"},{default:o(()=>[a(_,{class:"flex-1",modelValue:t.monitor_item,"onUpdate:modelValue":e[5]||(e[5]=l=>t.monitor_item=l),multiple:"",disabled:"",placeholder:"\u8BF7\u9009\u62E9\u8BBE\u5907\u76D1\u6D4B\u9879"},{default:o(()=>[(i(!0),n(f,null,v(B.dictData.monitor_item,(l,r)=>(i(),s(c,{key:r,label:l.name,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})):D("",!0),a(d,{label:"\u8BBE\u5907\u56FE",prop:"image"},{default:o(()=>[a(W,{class:"avatar-uploader",accept:A.value,modelValue:t.image,"onUpdate:modelValue":e[6]||(e[6]=l=>t.image=l),data:{cid:1},headers:{Token:b(j).token},action:S.value,"show-file-list":!1,"on-success":L},{default:o(()=>[t.image?(i(),n("img",{key:0,src:t.image,class:"avatar"},null,8,fe)):(i(),n("div",ve,[a(z,null,{default:o(()=>[a(Q)]),_:1})]))]),_:1},8,["accept","modelValue","headers","action"])]),_:1}),a(d,{label:"\u89C6\u9891\u5730\u5740",prop:"video_url"},{default:o(()=>[a(p,{modelValue:t.video_url,"onUpdate:modelValue":e[7]||(e[7]=l=>t.video_url=l),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u89C6\u9891\u5730\u5740"},null,8,["modelValue"])]),_:1}),a(d,{label:"\u8BBE\u5907\u72B6\u6001",prop:"status"},{default:o(()=>[a(_,{class:"flex-1",modelValue:t.status,"onUpdate:modelValue":e[8]||(e[8]=l=>t.status=l),clearable:"",placeholder:"\u8BF7\u9009\u62E9\u8BBE\u5907\u72B6\u6001"},{default:o(()=>[(i(!0),n(f,null,v(B.dictData.device_status,(l,r)=>(i(),s(c,{key:r,label:l.name,value:parseInt(l.value)},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(d,{label:"\u662F\u5426\u5728\u7EBF",prop:"is_online"},{default:o(()=>[a(_,{class:"flex-1",modelValue:t.is_online,"onUpdate:modelValue":e[9]||(e[9]=l=>t.is_online=l),clearable:"",placeholder:"\u8BF7\u9009\u62E9\u662F\u5426\u5728\u7EBF"},{default:o(()=>[(i(!0),n(f,null,v(B.dictData.device_online_status,(l,r)=>(i(),s(c,{key:r,label:l.name,value:parseInt(l.value)},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["title"])])}}});const lt=pe(ge,[["__scopeId","data-v-d965f3ec"]]);export{lt as default};