import{M,r as N,av as $,Y as z,I as E,aw as Q,a9 as G,a5 as W,aG as Y,F as Z,W as H}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897314.js";import{_ as K}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import"./index.170379627897327.js";import{b as X}from"./product.17037962789737.js";import{v as ee,w as te}from"./instance.1703796278973.js";import{a as ae}from"./comm.1703796278973.js";import oe from"./SaveProduct.1703796278973.js";import{d as le,k as _,v as se,m as ne,r as h,o as y,x as k,b as t,a,z as x,u as l,t as I,F as O,h as re,c as de,A as ie,M as ue}from"./vue.1703796278973.js";const me={style:{"margin-top":"10px"}},he=le({__name:"index",props:{data:{type:Object,default:void 0}},emits:["close","save"],setup(i,{emit:j}){const p=i,v=_([]),g=_(!1),u=_(!1),c=_(),s=se({productId:void 0,id:void 0,name:"",describe:"",photoUrl:ae("/device-gateway.png")}),F=async(n,e)=>{var m;if(!((m=p==null?void 0:p.data)!=null&&m.id)&&e){const r=await ee(e);return r.status===200&&r.result?Promise.reject("ID重复"):Promise.resolve()}else return Promise.resolve()};ne(()=>p.data,n=>{X({paging:!1,sorts:[{name:"createTime",order:"desc"}],terms:[{terms:[{termType:"eq",column:"state",value:1,type:"and"},{termType:"eq",column:"accessProvider",value:"official-edge-gateway"}]}]}).then(e=>{e.status===200&&(v.value=e.result)}),Object.assign(s,n)},{immediate:!0,deep:!0});const J=()=>{j("close"),c.value.resetFields()},S=()=>{u.value=!1},T=n=>{v.value.push(n)},V=()=>{c.value.validate().then(async n=>{g.value=!0;const e={...n};e.id||delete e.id,(await te(e).finally(()=>{g.value=!1})).status===200&&(M.success("操作成功！"),j("save"),c.value.resetFields())}).catch(n=>{console.log("error",n)})};return(n,e)=>{var C;const m=h("JProUpload"),r=N,f=$,b=h("AIcon"),w=z,P=E,U=Q,q=G,B=W,D=K,L=Y,R=Z,A=H;return y(),k(O,null,[t(A,{maskClosable:!1,width:"650px",visible:!0,title:(C=i.data)!=null&&C.id?"编辑":"新增",onOk:V,onCancel:J,confirmLoading:l(g)},{default:a(()=>[x("div",me,[t(R,{layout:"vertical",ref_key:"formRef",ref:c,model:l(s)},{default:a(()=>[t(U,{type:"flex"},{default:a(()=>[t(f,{flex:"180px"},{default:a(()=>[t(r,{name:"photoUrl"},{default:a(()=>[t(m,{accept:"image/jpeg,image/png",modelValue:l(s).photoUrl,"onUpdate:modelValue":e[0]||(e[0]=o=>l(s).photoUrl=o)},null,8,["modelValue"])]),_:1})]),_:1}),t(f,{flex:"auto"},{default:a(()=>[t(r,{name:"id",rules:[{pattern:/^[a-zA-Z0-9_\-]+$/,message:"请输入英文或者数字或者-或者_"},{max:64,message:"最多输入64个字符"},{validator:F,trigger:"blur"}]},{label:a(()=>[x("span",null,[I(" ID "),t(w,{title:"若不填写，系统将自动生成唯一ID"},{default:a(()=>[t(b,{type:"QuestionCircleOutlined",style:{"margin-left":"2px"}})]),_:1})])]),default:a(()=>{var o;return[t(P,{value:l(s).id,"onUpdate:value":e[1]||(e[1]=d=>l(s).id=d),placeholder:"请输入ID",disabled:!!((o=i.data)!=null&&o.id)},null,8,["value","disabled"])]}),_:1},8,["rules"]),t(r,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"},{max:64,message:"最多输入64个字符"}]},{default:a(()=>[t(P,{value:l(s).name,"onUpdate:value":e[2]||(e[2]=o=>l(s).name=o),placeholder:"请输入名称"},null,8,["value"])]),_:1})]),_:1})]),_:1}),t(U,null,{default:a(()=>[t(f,{span:22},{default:a(()=>[t(r,{name:"productId",rules:[{required:!0,message:"请选择所属产品"}]},{label:a(()=>[x("span",null,[I("所属产品 "),t(w,{title:"只能选择“正常”状态的产品"},{default:a(()=>[t(b,{type:"QuestionCircleOutlined",style:{"margin-left":"2px"}})]),_:1})])]),default:a(()=>{var o;return[t(B,{showSearch:"",value:l(s).productId,"onUpdate:value":e[3]||(e[3]=d=>l(s).productId=d),disabled:!!((o=i.data)!=null&&o.id),placeholder:"请选择所属产品"},{default:a(()=>[(y(!0),k(O,null,re(l(v),d=>(y(),de(q,{value:d.id,key:d.id,label:d.name},{default:a(()=>[I(ie(d.name),1)]),_:2},1032,["value","label"]))),128))]),_:1},8,["value","disabled"])]}),_:1})]),_:1}),t(f,{span:2,style:{"margin-top":"30px"}},{default:a(()=>[t(D,{type:"link",disabled:i.data.id,onClick:e[4]||(e[4]=o=>u.value=!0),hasPermission:"device/Product:add"},{default:a(()=>[t(b,{type:"PlusOutlined"})]),_:1},8,["disabled"])]),_:1})]),_:1}),t(r,{label:"说明",name:"describe",rules:[{max:200,message:"最多输入200个字符"}]},{default:a(()=>[t(L,{value:l(s).describe,"onUpdate:value":e[5]||(e[5]=o=>l(s).describe=o),placeholder:"请输入说明",showCount:"",maxlength:200},null,8,["value"])]),_:1})]),_:1},8,["model"])])]),_:1},8,["title","confirmLoading"]),t(oe,{visible:l(u),"onUpdate:visible":e[6]||(e[6]=o=>ue(u)?u.value=o:null),productId:l(s).productId,"onUpdate:productId":e[7]||(e[7]=o=>l(s).productId=o),channel:"official-edge-gateway",onClose:S,deviceType:"gateway",onSave:T},null,8,["visible","productId"])],64)}}});export{he as _};
