import{d as A,f as c,u as t,h as N,e as O,U as m,a2 as E,a3 as S,k as r,af as f,a4 as w,V as q,G as y,a5 as K,ag as j}from"./vue-vendor-CxLCUzY4.js";import{B as z}from"./index-CF_FJn6P.js";import{a8 as G,aY as J,a5 as H,n as P,h as W,u as X,_ as Y}from"./index-CYriLmQo.js";const x=A({name:"JImportModal",components:{BasicModal:z},props:{url:{type:String,default:"",required:!1},biz:{type:String,default:"",required:!1},online:{type:Boolean,default:!1,required:!1}},emits:["ok","register"],setup(e,{emit:s,refs:M}){const{createMessage:h,createWarningModal:k}=X(),[B,{closeModal:v}]=G(a=>{b(a)}),u=J(),C=H(),i=c(!1),o=c([]),_=c(""),d=c(""),g=c(0),$=Object.assign({},t(e),t(C));N(()=>{e.url&&(_.value=`${u.uploadUrl}${e.url}`)});const D=O(()=>!(t(o).length>0));function F(){v(),b()}function L(a){g.value=a?1:0}function V(a){const p=t(o).indexOf(a),n=t(o).slice();n.splice(p,1),o.value=n}function R(a){return o.value=[...t(o),a],!1}function U(){let{biz:a,online:p}=e;const n=new FormData;a&&n.append("isSingleTableImport",a),t(d)&&t(d).length>0&&n.append("foreignKeys",t(d)),P(d.value)&&n.append("foreignKeys",JSON.stringify(d.value)),p&&n.append("validateStatus",t(g)),t(o).forEach(l=>{n.append("files[]",l)}),i.value=!0;let T={"Content-Type":"multipart/form-data;boundary = "+new Date().getTime()};W.post({url:e.url,params:n,headers:T},{isTransformResponse:!1}).then(l=>{i.value=!1,l.success?(l.code==201?I(l.message,l.result):h.success(l.message),F(),b(),s("ok")):h.warning(l.message)}).catch(()=>{i.value=!1})}function I(a,p){let n=u.uploadUrl+p;k({title:"导入成功,但是有错误数据!",centered:!1,content:`<div>
                        <span>${a}</span><br/>
                        <span>具体详情请<a href = ${n} target="_blank"> 点击下载 </a> </span>
                      </div>`})}function b(a){o.value=[],i.value=!1,d.value=a,g.value=0}return{register:B,getBindValue:$,uploadDisabled:D,fileList:o,uploading:i,validateStatus:g,handleClose:F,handleChangeValidateStatus:L,handleRemove:V,beforeUpload:R,handleImport:U}}}),Q={key:0,style:{margin:"0 5px 5px"}},Z={style:{"margin-left":"6px"}};function ee(e,s,M,h,k,B){const v=m("a-switch"),u=m("a-button"),C=m("a-upload"),i=m("BasicModal");return E(),S("div",null,[r(i,j(e.$attrs,{onRegister:e.register,title:"导入EXCEL",width:600,onCancel:e.handleClose,confirmLoading:e.uploading,destroyOnClose:""}),{footer:f(()=>[r(u,{onClick:e.handleClose},{default:f(()=>s[2]||(s[2]=[y("关闭")])),_:1},8,["onClick"]),r(u,{type:"primary",onClick:e.handleImport,disabled:e.uploadDisabled,loading:e.uploading},{default:f(()=>[y(K(e.uploading?"上传中...":"开始上传"),1)]),_:1},8,["onClick","disabled","loading"])]),default:f(()=>[e.online?(E(),S("div",Q,[s[0]||(s[0]=w("span",{style:{display:"inline-block",height:"32px","line-height":"32px","vertical-align":"middle"}},"是否开启校验:",-1)),w("span",Z,[r(v,{checked:e.validateStatus==1,onChange:e.handleChangeValidateStatus,"checked-children":"是","un-checked-children":"否"},null,8,["checked","onChange"])])])):q("",!0),r(C,{name:"file",accept:".xls,.xlsx",multiple:!0,fileList:e.fileList,onRemove:e.handleRemove,beforeUpload:e.beforeUpload},{default:f(()=>[r(u,{preIcon:"ant-design:upload-outlined"},{default:f(()=>s[1]||(s[1]=[y("选择导入文件")])),_:1})]),_:1},8,["fileList","onRemove","beforeUpload"])]),_:1},16,["onRegister","onCancel","confirmLoading"])])}const oe=Y(x,[["render",ee]]);export{oe as o};
