import{h as I,f as x,c as C,b as O,e as J,g as Q,r as R}from"./uploadAction.95992a5e.js";import{d as T,D as z,r as g,L as A,c as f,e as v,I as h,i as t,h as s,j as d,f as k,F as E,J as G,g as N,u as c,t as H,k as K,x as M}from"./index.d340e473.js";import{s as W,d as X}from"./securityPersonnelControl.9ffce8d1.js";const Y={class:"flex-1"},Z={class:"el-upload__tip"},ee=T({name:"editSupplierDialog"}),oe=Object.assign(ee,{props:{visible:{type:Boolean,default:!1,required:!0},data:Object},emits:["close"],setup(L,{emit:w}){const{proxy:b}=M(),F=z.dictStore.uploadUrl,y=L,_=w,m=g(!1),e=g({infoList:[{safetyProtocol:[]}]}),P=g(),$=async o=>{!o||o.validate(async a=>{if(a){m.value=!0;try{const r=e.value.infoList.map(l=>{var u;return{...l,supplierName:e.value.supplierName,projectCode:y.data.projectCode,safetyProtocol:((u=l==null?void 0:l.safetyProtocol)==null?void 0:u.length)&&JSON.stringify(Q(l.safetyProtocol))||void 0}});await W(r),b.$message.success("\u63D0\u4EA4\u6210\u529F\uFF01"),m.value=!1,_("close",!0)}catch{m.value=!1}}})},S=()=>{var o;if(((o=e.value.infoList)==null?void 0:o.length)>=10){b.$message.warning("\u6700\u591A\u589E\u52A010\u4E2A\uFF01");return}e.value.infoList.push({safetyQualification:[]})},U=o=>{var a;(a=e.value.infoList)==null||a.splice(o,1)},j=async()=>{var a,r;const o=await X(y.data.projectCode);e.value.supplierName=(a=o.data.supplierSafetyQualification)==null?void 0:a[0].supplierName,e.value.infoList=((r=o.data.supplierSafetyQualification)==null?void 0:r.map(l=>({...l,safetyProtocol:l.safetyProtocol?R(JSON.parse(l.safetyProtocol)):[]})))||[{}]};return A(()=>y.visible,async o=>{o?j():e.value={infoList:[{safetyProtocol:[]}]}}),(o,a)=>{const r=f("el-input"),l=f("el-form-item"),u=f("el-button"),D=f("el-upload"),q=f("el-form"),B=f("el-dialog");return v(),h(B,{"model-value":L.visible,title:"\u586B\u5199\u4F9B\u5E94\u5546\u5B89\u5168\u8D44\u8D28",width:"600px","destroy-on-close":"",onClose:a[3]||(a[3]=n=>_("close"))},{footer:t(()=>[s(u,{type:"primary",loading:m.value,onClick:a[1]||(a[1]=n=>$(P.value))},{default:t(()=>[d(" \u63D0\u4EA4 ")]),_:1},8,["loading"]),s(u,{onClick:a[2]||(a[2]=n=>_("close"))},{default:t(()=>[d(" \u5173\u95ED ")]),_:1})]),default:t(()=>[s(q,{ref_key:"dialogFormRef",ref:P,model:e.value,"label-width":"auto","status-icon":"",class:"mt-16","label-suffix":"\uFF1A"},{default:t(()=>[s(l,{label:"\u4F9B\u5E94\u5546\u540D\u79F0",prop:"supplierName",rules:[{required:!0,message:"\u8BF7\u586B\u5199"}]},{default:t(()=>[s(r,{modelValue:e.value.supplierName,"onUpdate:modelValue":a[0]||(a[0]=n=>e.value.supplierName=n),placeholder:"\u8BF7\u586B\u5199"},null,8,["modelValue"])]),_:1}),(v(!0),k(E,null,G(e.value.infoList,(n,p)=>{var V;return v(),k("div",{key:p,class:"flex items-start"},[N("div",Y,[s(l,{label:"\u5382\u5546\u4EBA\u5458\u540D\u79F0",prop:`infoList[${p}].username`,rules:[{required:!0,message:"\u8BF7\u586B\u5199"}]},{default:t(()=>[s(r,{modelValue:n.username,"onUpdate:modelValue":i=>n.username=i,placeholder:"\u8BF7\u586B\u5199"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["prop"]),s(l,{label:"\u8054\u7CFB\u65B9\u5F0F",prop:`infoList[${p}].contactInfo`,rules:[{required:!0,message:"\u8BF7\u586B\u5199"}]},{default:t(()=>[s(r,{modelValue:n.contactInfo,"onUpdate:modelValue":i=>n.contactInfo=i,placeholder:"\u8BF7\u586B\u5199",maxlength:11},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["prop"]),s(l,{label:"\u4FDD\u5BC6\u534F\u8BAE",prop:`infoList[${p}].safetyProtocol`,rules:[{required:!0,message:"\u8BF7\u4E0A\u4F20"}]},{default:t(()=>[s(D,{"file-list":e.value.infoList[p].safetyProtocol,"onUpdate:fileList":i=>e.value.infoList[p].safetyProtocol=i,class:"w-full",action:c(F),limit:1,"on-success":i=>c(I)(i,e.value.infoList[p].safetyProtocol,!0),"before-upload":i=>c(x)(i,{types:c(C)}),accept:c(C).map(i=>`.${i}`).join(","),"on-preview":c(O)},{tip:t(()=>[N("div",Z," \u652F\u6301"+H(c(J))+"\u6587\u4EF6 ",1)]),default:t(()=>[s(u,{type:"primary",plain:""},{default:t(()=>[d("\u9009\u62E9\u6587\u4EF6")]),_:1})]),_:2},1032,["file-list","onUpdate:fileList","action","on-success","before-upload","accept","on-preview"])]),_:2},1032,["prop"])]),((V=e.value.infoList)==null?void 0:V.length)>1?(v(),h(u,{key:0,icon:"Delete",type:"danger",plain:"",class:"ml-16",link:"",onClick:i=>U(p)},{default:t(()=>[d("\u5220\u9664")]),_:2},1032,["onClick"])):K("",!0)])}),128)),s(u,{icon:"Plus",type:"primary",plain:"",onClick:S},{default:t(()=>[d("\u589E\u52A0")]),_:1})]),_:1},8,["model"])]),_:1},8,["model-value"])}}});export{oe as default};