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