popupForm-TdMifzR7.js 5.2 KB

1
  1. import{d as W,a as $,az as j,a2 as E,r as L,w as X,K as i,aq as v,e as l,y as b,L as o,u as t,t as k,m as y,f as p,am as x,n as C,j as d,i as r,G as A,ae as G,ac as M,C as _,p as H,l as J}from"./vue-A59npLRR.js";import{F as O}from"./index-r6iTpmP6.js";import{b as U}from"./validate-_EUdkMt3.js";import{h as Q,d as R}from"./dataimport-YAr5iWFf.js";import{$ as h,a0 as Y,_ as Z}from"./index-EwE51S_X.js";import"./index-K8IR974I.js";import"./baTable-MdxYOkAk.js";import"./index-XALue448.js";import"./echarts-cxb9vJr1.js";const c=u=>(H("data-v-aa4a940d"),u=u(),J(),u),ee={class:"title"},te={key:1,class:"template-text-info"},ae={key:0,class:"upload-file-box"},oe=c(()=>r("div",{class:"el-upload__text"},[y("拖拽 .xls[x] 文件至此处 "),r("em",null,"或点击我上传")],-1)),le={key:1,class:"upload-file-box"},se=c(()=>r("div",{class:"el-upload__text"},"上传中...",-1)),de={key:2,class:"upload-file-box"},re=c(()=>r("div",{class:"el-upload__text"},"文件上传成功,正在处理...",-1)),ie=c(()=>r("p",null,"1、导入数据内无`主键`字段或`主键留空`则可以使用主键自动递增",-1)),ne=c(()=>r("p",null,"2、若数据表有设计`create_time`、`update_time`字段且导入数据内未设定这两个字段的值,则自动填充",-1)),me=c(()=>r("p",null," 3、所有已设定值的导入数据,将原样导入,比如:`create_time`字段,数据表设计为时间戳则请导入时间戳,`status:0=隐藏,1=开启`,请导入`0`或`1` ",-1)),pe=W({__name:"popupForm",setup(u){const S=$(),e=j("baTable"),{t:f}=E(),I=L({data_table:[U({name:"required",message:"请选择数据表"})],file:[U({name:"required",message:"请选择导入数据文件"})]}),F=m=>{if(!m||!m.raw)return;h.configure({showSpinner:!1}),h.start(),e.form.extend.fileUploadStatus="uploading";let a=new FormData;a.append("file",m.raw),Y(a,{},!0,{onUploadProgress:s=>{h.set(s.progress)}}).then(s=>{s.code==1&&Q(e.form.items.data_table,s.data.file.url).then(n=>{e.table.extend.showPreImport=!0,e.table.extend.fields=n.data.fields,e.table.extend.rowCount=n.data.rowCount,e.table.extend.data=n.data.data,e.table.extend.file_url=s.data.file.url,e.form.extend.fileUploadStatus="success"}).catch(()=>{e.form.extend.fileUploadStatus="wait"})}).catch(()=>{e.form.extend.fileUploadStatus="wait"}).finally(()=>{h.done()})},z=()=>{window.location.href=R(e.form.items.data_table)};return X(()=>e.table.extend.showPreImport,m=>{m===!1&&(e.form.extend.fileUploadStatus="wait")}),(m,a)=>{const s=i("el-form-item"),n=i("Icon"),V=i("el-upload"),D=i("el-alert"),P=i("el-form"),N=i("el-scrollbar"),T=i("el-button"),B=i("el-dialog"),q=v("drag"),K=v("zoom"),w=v("loading");return l(),b(B,{class:"ba-operate-dialog","close-on-click-modal":!1,"model-value":["Add","Edit"].includes(t(e).form.operate),onClose:t(e).toggleForm,width:"50%"},{header:o(()=>[x((l(),p("div",ee,[y(k(t(e).form.operate?t(f)(t(e).form.operate):""),1)])),[[q,[".ba-operate-dialog",".el-dialog__header"]],[K,".ba-operate-dialog"]])]),footer:o(()=>[r("div",{style:C("width: calc(100% - "+t(e).form.labelWidth/1.8+"px)")},[d(T,{onClick:a[3]||(a[3]=g=>t(e).toggleForm(""))},{default:o(()=>[y(k(t(f)("Cancel")),1)]),_:1})],4)]),default:o(()=>[x((l(),b(N,{class:"ba-table-form-scrollbar"},{default:o(()=>[r("div",{class:A(["ba-operate-form","ba-"+t(e).form.operate+"-form"]),style:C("width: calc(100% - "+t(e).form.labelWidth/2+"px)")},[t(e).form.loading?_("",!0):(l(),b(P,{key:0,ref_key:"formRef",ref:S,onSubmit:a[1]||(a[1]=G(()=>{},["prevent"])),onKeyup:a[2]||(a[2]=M(g=>t(e).onSubmit(S.value),["enter"])),model:t(e).form.items,"label-position":"right","label-width":t(e).form.labelWidth+"px",rules:I},{default:o(()=>[d(O,{label:t(f)("routine.dataimport.data_table"),type:"select",modelValue:t(e).form.items.data_table,"onUpdate:modelValue":a[0]||(a[0]=g=>t(e).form.items.data_table=g),prop:"data_table",data:{content:t(e).form.extend.tableList},placeholder:t(f)("Please select field",{field:t(f)("routine.dataimport.data_table")})},null,8,["label","modelValue","data","placeholder"]),d(s,{label:"导入模板"},{default:o(()=>[t(e).form.items.data_table?(l(),p("div",{key:0,onClick:z,class:"template-text-success"}," 点击下载导入模板文件 ")):(l(),p("div",te,"请先选择数据表后可下载导入模板文件"))]),_:1}),d(s,{label:"导入数据",prop:"file"},{default:o(()=>[d(V,{class:"upload-xls","show-file-list":!1,accept:".xlsx,.xls",drag:"","auto-upload":!1,onChange:F},{default:o(()=>[t(e).form.extend.fileUploadStatus=="wait"?(l(),p("div",ae,[d(n,{size:"50px",color:"#909399",name:"el-icon-UploadFilled"}),oe])):_("",!0),t(e).form.extend.fileUploadStatus=="uploading"?(l(),p("div",le,[x(d(n,{size:"50px",color:"#ffffff",name:"el-icon-UploadFilled"},null,512),[[w,!0]]),se])):_("",!0),t(e).form.extend.fileUploadStatus=="success"?(l(),p("div",de,[x(d(n,{size:"50px",color:"#ffffff",name:"el-icon-UploadFilled"},null,512),[[w,!0]]),re])):_("",!0)]),_:1})]),_:1}),t(e).form.items.data_table?(l(),b(s,{key:0},{default:o(()=>[d(D,{title:"提示",class:"import-tips",type:"success"},{default:o(()=>[ie,ne,me]),_:1})]),_:1})):_("",!0)]),_:1},8,["model","label-width","rules"]))],6)]),_:1})),[[w,t(e).form.loading]])]),_:1},8,["model-value","onClose"])}}}),ve=Z(pe,[["__scopeId","data-v-aa4a940d"]]);export{ve as default};