page-content.e0c7af12.js 17 KB

1
  1. import{a as R,r as O,ao as se,b as y,c,j as _,h as k,f as d,e as x,i as H,F as j,ap as ue,aq as B,u as s,y as ie,P as K,l as v,x as Z,p as ee,m as W,O as ce,am as de,Q as pe,R as fe,_ as me,Z as ge,$ as he,W as ye,o as be,ar as _e,w as ve,as as ke}from"./index.4d061c66.js";import{R as Ce}from"./remote-select.36ee67a3.js";import{I as Pe}from"./image.e35d846c.js";import{I as we}from"./image.4c97dbe3.js";import"./use-page-search.0f272301.js";import{u as F}from"./hooks.9f8f44e2.js";import{a as X,u as Ve}from"./useNav.5e73c372.js";import{T as Ae}from"./index.e63aea62.js";import{r as te}from"./responseHandle.fe68d5aa.js";import{u as oe}from"./useAsync.df7387ce.js";const Se={formItems:{type:Array,default:()=>[]},formGroup:{type:Array,default:()=>[]},itemStyle:{type:Object,default:()=>({paddingRight:"20px"})},disabled:{type:Boolean,default:!1},colLayout:{type:Object,default:()=>({xl:4,lg:6,md:8,sm:12,xs:24})},formData:{type:Object,required:!0},contact:{type:String},divider:{type:Boolean},labelWidth:{type:String},rules:{type:Object}},yt=t=>/^[A-Za-z]+$/.test(t),Ue=t=>/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(t),Be=t=>{let l=!0;const n=t.split("-");return n.length===3?l=ne(n[0])&&J(n[1])&&ae(n[2]):l=!1,l},Oe=t=>{let l=!0;const n=t.split("-");return n.length===2?l=ne(n[0])&&J(n[1]):l=!1,l},Re=t=>{let l=!0;const n=t.split("-");return n.length===2?l=J(n[0])&&ae(n[1]):l=!1,l},De=t=>{let l=!0;const n=t.split("-");return n.length===1?l=J(n[0]):l=!1,l},ne=t=>/0\d{2,3}?$/.test(t)&&(t.length==3||t.length==4),J=t=>/\d{7,8}$/.test(t)&&(t.length==7||t.length==8),ae=t=>/\d{1,6}$/.test(t)&&t.length>0&&t.length<7,bt=t=>/^[0-9]*$/.test(t),_t=t=>/^[0-9A-Za-z]*$/.test(t),G={required:!0,message:"\u8054\u7CFB\u65B9\u5F0F\u683C\u5F0F\u4E0D\u6B63\u786E"},le=[{value:"0",label:"\u533A-\u56FA-\u5206",rule:{...G,validator(t,l){return Be(l)}}},{value:"1",label:"\u533A-\u56FA",rule:{...G,validator(t,l){return Oe(l)}}},{value:"2",label:"\u56FA-\u5206",rule:{...G,validator(t,l){return Re(l||"")}}},{value:"3",label:"\u56FA",rule:{...G,validator(t,l){return De(l||"")}}},{value:"4",label:"\u624B\u673A\u53F7",rule:{...G,validator(t,l){return Ue(l||"")}}}],ze=t=>(pe("data-v-e8ff031c"),t=t(),fe(),t),Ie={key:14,class:"flex-ul clear"},xe={class:"fl flex-li"},Fe=ze(()=>W("div",{class:"fl flex-li-middle"},"\u81F3",-1)),qe={class:"fl flex-li"},je=R({__name:"basic-form",props:Se,setup(t,{expose:l}){const n=t,u=O(null),o=se(n,"formData");function f(r){var h;(h=u.value)==null||h.validate(m=>{r&&r(m)})}return l({validate:f}),(r,h)=>{const m=y("el-input"),i=y("el-input-number"),g=y("el-option"),b=y("el-select"),V=y("el-radio"),$=y("el-radio-group"),D=y("el-image"),A=y("el-checkbox"),L=y("el-checkbox-group"),q=y("el-date-picker"),z=y("el-form-item"),p=y("el-col"),C=y("el-row");return c(),_(s(de),{ref_key:"formRef",ref:u,modelValue:s(o),"onUpdate:modelValue":h[1]||(h[1]=e=>ce(o)?o.value=e:null),model:s(o),disabled:r.disabled,"label-width":r.labelWidth,rules:r.rules},{default:k(()=>[d(C,null,{default:k(()=>[(c(!0),x(j,null,H(r.formItems,(e,P)=>(c(),x(j,{key:P},[e.isHidden?v("",!0):(c(),_(p,ue(B({key:0},e.span?{span:e.span}:r.colLayout)),{default:k(()=>[d(z,{label:e.label,prop:e.field,rules:e.type!=="contact"?e.rules:s(le)[r.contact].rule,"label-width":e.labelWidth,style:ie(r.itemStyle)},{default:k(()=>{var S,E,I,N;return[e.slot?K(r.$slots,e.slot,{key:0},void 0,!0):v("",!0),e.type==="input"?(c(),_(m,{key:1,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a,placeholder:e.placeholder,clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"])):v("",!0),e.type==="textarea"?(c(),_(m,{key:2,type:"textarea",modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a,placeholder:e.placeholder,clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"])):v("",!0),e.type==="number"?(c(),_(i,B({key:3,style:{width:"100%"},modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a},e.otherOptions,{placeholder:e.placeholder,clearable:""}),null,16,["modelValue","onUpdate:modelValue","placeholder"])):v("",!0),e.type==="select"?(c(),_(b,{key:4,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a,placeholder:e.placeholder,clearable:""},{default:k(()=>[(c(!0),x(j,null,H(e.options,(a,U)=>(c(),_(g,{key:U,label:a.label,value:a.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder"])):v("",!0),e.type==="radio"?(c(),_($,{key:5,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a},{default:k(()=>[(c(!0),x(j,null,H(e.options,(a,U)=>(c(),_(V,{key:U,label:a.value},{default:k(()=>[Z(ee(a.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):v("",!0),e.type==="img_preview"?(c(),_(D,{key:6,src:s(o)[e.field]},null,8,["src"])):v("",!0),e.type==="input_group"?(c(),_(m,{key:7,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a},{prepend:k(()=>[d(b,{modelValue:s(o)[e.type_field],"onUpdate:modelValue":a=>s(o)[e.type_field]=a,placeholder:"Select",style:{width:"150px"}},{default:k(()=>{var a;return[(c(!0),x(j,null,H((a=e.otherOptions)==null?void 0:a.inputGroupOptions,U=>(c(),_(g,{value:U.value,label:U.label,key:U.value},null,8,["value","label"]))),128))]}),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["modelValue","onUpdate:modelValue"])):v("",!0),e.type==="img_upload"?(c(),_(s(Pe),{key:8,url:s(o)[e.field],"onUpdate:url":a=>s(o)[e.field]=a,descs:["\u5C0F\u4E8E1Mb"],disabled:r.disabled,types:["png","jpg","jpeg"]},null,8,["url","onUpdate:url","disabled"])):v("",!0),e.type==="img_upload_list"?(c(),_(s(we),{key:9,urls:s(o)[e.field],"onUpdate:urls":a=>s(o)[e.field]=a,descs:["\u5C0F\u4E8E1Mb"],disabled:r.disabled,types:["png","jpg","jpeg"]},null,8,["urls","onUpdate:urls","disabled"])):v("",!0),e.type==="checkbox"?(c(),_(L,{key:10,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a},{default:k(()=>[(c(!0),x(j,null,H(e.options,(a,U)=>(c(),_(A,{key:U,label:a.value},{default:k(()=>[Z(ee(a.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):v("",!0),e.type==="date_picker"?(c(),_(q,B({key:11,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a},e.otherOptions,{placeholder:e.placeholder,style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","placeholder"])):v("",!0),e.type==="contact"?(c(),_(m,{key:12,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a},{prepend:k(()=>[d(b,{style:{width:"115px"},modelValue:r.contact,"onUpdate:modelValue":h[0]||(h[0]=a=>r.contact=a)},{default:k(()=>[(c(!0),x(j,null,H(s(le),a=>(c(),_(g,{key:a.value,label:a.label,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:2},1032,["modelValue","onUpdate:modelValue"])):v("",!0),e.type==="remote-select"?(c(),_(s(Ce),{key:13,modelValue:s(o)[e.field],"onUpdate:modelValue":a=>s(o)[e.field]=a,api:e.otherOptions.api,placeholder:e.placeholder,"response-label-prop":e.otherOptions.responseLabelProp,"response-val-prop":e.otherOptions.responseValProp,"request-prop":e.otherOptions.requesetProp,"is-root":e.otherOptions.isRoot,prop:e.otherOptions.prop},null,8,["modelValue","onUpdate:modelValue","api","placeholder","response-label-prop","response-val-prop","request-prop","is-root","prop"])):v("",!0),e.type==="range"?(c(),x("div",Ie,[W("div",xe,[d(i,{style:{width:"100%"},modelValue:s(o)[e.field][0],"onUpdate:modelValue":a=>s(o)[e.field][0]=a,precision:(S=e.otherOptions)==null?void 0:S.precision,controls:!1,placeholder:(E=e.otherOptions)==null?void 0:E.startPlaceholder},null,8,["modelValue","onUpdate:modelValue","precision","placeholder"])]),Fe,W("div",qe,[d(i,{style:{width:"100%"},modelValue:s(o)[e.field][1],"onUpdate:modelValue":a=>s(o)[e.field][1]=a,precision:(I=e.otherOptions)==null?void 0:I.precision,controls:!1,placeholder:(N=e.otherOptions)==null?void 0:N.endPlaceholder},null,8,["modelValue","onUpdate:modelValue","precision","placeholder"])])])):v("",!0)]}),_:2},1032,["label","prop","rules","label-width","style"])]),_:2},1040))],64))),128)),d(z,null,{default:k(()=>[K(r.$slots,"action",{},void 0,!0)]),_:3})]),_:3}),d(z,null,{default:k(()=>[K(r.$slots,"footer",{},void 0,!0)]),_:3})]),_:3},8,["modelValue","model","disabled","label-width","rules"])}}}),$e=me(je,[["__scopeId","data-v-e8ff031c"]]);function Le(t){var n,u;const l={};for(const o of t){const f=o.type==="checkbox",r=o.type==="date_picker",h=o.type==="range";if(o.type==="input_group"){const i=((u=(n=o.otherOptions)==null?void 0:n.inputGroupOptions[0])==null?void 0:u.value)||"";l[o.field]="",l[o.type_field]=i}else l[o.field]=f||r||h?[]:""}return l}const Te={formConfig:{type:Object,required:!0}},Ee={class:"w-99/100"},He={class:"bg-white pl-4 pt-4 page-search"},Ne={style:{width:"100%"},flex:"","gap-2":""},vt=R({__name:"page-search",props:Te,emits:["searchBtnClick","resetBtnClick"],setup(t,{emit:l}){const n=t,{searchParams:u={}}=X(),o=Le(n.formConfig.formItems),f=n.formConfig.isHide,r=O({...u.basic?u.basic:o});function h(){r.value={...o},l("resetBtnClick")}function m(){l("searchBtnClick",r.value)}if(u.basic){const{formConfig:i}=n,{formItems:g}=i;g.forEach(b=>{const{field:V,otherOptions:$={}}=b,{startProp:D,endProp:A}=$;(D||A)&&(r.value[V]=[u.basic[D],u.basic[A]],delete r.value[D],delete r.value[A])})}return(i,g)=>{const b=y("el-button");return c(),x("div",Ee,[ge(W("div",He,[d(s($e),B(i.formConfig,{size:"small","form-data":r.value,"onUpdate:form-data":g[0]||(g[0]=V=>r.value=V)}),{action:k(()=>[W("div",Ne,[i.formConfig.formItems.length>0?(c(),_(b,{key:0,type:"primary",size:"small",icon:s(F)("search"),onClick:m},{default:k(()=>[Z(" \u641C\u7D22 ")]),_:1},8,["icon"])):v("",!0),i.formConfig.formItems.length>0?(c(),_(b,{key:1,icon:s(F)("refresh"),size:"small",onClick:h},{default:k(()=>[Z(" \u91CD\u7F6E ")]),_:1},8,["icon"])):v("",!0),K(i.$slots,"action")])]),_:3},16,["form-data"])],512),[[he,!s(f)]])])}}}),Ge={contentConfig:{type:Object,required:!0},pageSize:{type:Number,default:15},powers:{type:Array,default:()=>[]}},Y={config:{type:Object},isRequesetArray:{type:Boolean},statusConfig:{type:Object}},Q={delete:"httpDelete",status:"httpStatus",resetPwd:"httpResetPwd"};function Me(t){const l=Object.keys(Q),n={};return l.forEach(u=>{n[u]=!!t[Q[u]]}),n}function M(t,l){return{config:{api:l[Q[t]]}}}function We({pagination:t,basicParams:l}){if(!t)return l;const{currentPage:n,pageSize:u}=t;return{page:n,size:u,...l}}function Ke(t,{onSearch:l}){const{pageSize:n,contentConfig:u}=t,{searchParams:o={}}=X();if(u.notPagination)return{};const f=ye(o.pagination?o.pagination:{total:0,pageSize:n,currentPage:1,background:!0});async function r(g){f.currentPage=g,await l()}async function h(g){f.pageSize=g,f.currentPage=1,await l()}function m(){return f}function i(g,b){f[g]=b}return{onSizeChange:h,onCurrentChange:r,pagination:f,getPagination:m,changePagination:i}}function Ze(){const{searchParams:t={}}=X(),l=O(t.basic?t.basic:{});function n(o={}){l.value=o}function u(){return l.value}return{changeBasicParams:n,getBasicParams:u}}function Qe(t){const{logout:l}=Ve(),{contentConfig:n}=t,{mockData:u}=n,o=O(!1),f=O(u||[]),r=O(!t.contentConfig.notReuqiredInit),{getBasicParams:h,changeBasicParams:m}=Ze(),i=Ke(t,{onSearch:V}),{changePagination:g,getPagination:b}=i;async function V(){const{contentConfig:A}=t,{apis:L,isTree:q,mockData:z}=A;if(!r.value||z)return r.value=!0;o.value=!0;const{code:p,data:C,message:e}=await L.httpList(We({pagination:b?b():{},basicParams:h()}));te({code:p,message:e,logout:l,handler:()=>{const P=Array.isArray(C)?C:C.list;f.value=q?_e(P!=null?P:[]):P,g("total",C.count)}}),o.value=!1}function $(A={}){g&&g("currentPage",1),m&&m(A),V()}async function D(A,L={},q){const{contentConfig:z}=t,{apis:p}=z,C=Q[A];o.value=!0;const{code:e,message:P}=await p[C](L);q&&q(),te({code:e,message:P,logout:l,handler:()=>V()}),o.value=!1}return be(()=>V()),{loading:o,dataList:f,getBasicParams:h,getPagination:b,onBeforeAction:D,paginationConfig:i,getPageData:$,onSearch:V}}const Je=R({name:"ActionDelete",props:{...Y,row:{type:Object,required:!0},prop:{type:String},delTooltip:{type:String}},emits:["reload"],setup(t,{emit:l}){const n=oe();async function u(){const{config:o,row:f,prop:r}=t,{code:h,message:m}=await o.api({...r?{[r]:f[r]}:{id:f.id}});n({code:h,message:m,handler:()=>l("reload")})}return()=>d(y("el-popconfirm"),{title:t.delTooltip||"\u662F\u5426\u786E\u8BA4\u5220\u9664",placement:"top",onConfirm:u},{reference:()=>d(y("el-button"),{class:"reset-margin",link:!0,size:"small",type:"primary",icon:F("delete")},null)})}}),Xe=R({name:"ActionUpdate",emits:["update"],setup(t,{emit:l}){return()=>d(y("el-button"),{class:"reset-margin",onClick:()=>l("update"),link:!0,size:"small",type:"primary",icon:F("edits")},null)}}),Ye=R({name:"ActionPreview",props:{isInv:{type:Boolean}},emits:["preview"],setup(t,{emit:l}){return()=>d(y("el-button"),{class:"reset-margin",link:!0,size:"small",type:"primary",onClick:()=>l("preview"),icon:F(t.isInv?"scaletooriginal":"eye-view")},null)}}),et=R({name:"ActionDelete",props:{...Y,row:{type:Object,required:!0},prop:{type:String}},emits:["reload"],setup(t,{emit:l}){const n=oe();async function u(){const{config:o,row:f,isRequesetArray:r}=t,{status:h,id:m}=f,i=String(h)==="1"?"0":"1",{code:g,message:b}=await o.api({...t.prop?{[t.prop]:f[t.prop]}:{id:r?[m]:m},status:i});n({code:g,message:b,handler:()=>l("reload")})}return()=>d(y("el-popconfirm"),{title:String(t.row.status)==="1"?"\u6539\u4E3A\u7981\u7528\uFF1F":"\u6539\u4E3A\u542F\u7528\uFF1F",onConfirm:u},{reference:()=>d(y("el-button"),{class:"reset-margin",link:!0,size:"small",type:"primary",icon:F(t.row.status+""=="1"?"close-circle-line":"checkbox-circle-line")},null)})}}),tt=R({name:"ActionDelete",props:{...Y,row:{type:Object,required:!0},prop:{type:String}},emits:["resetPwd"],setup(t,{emit:l}){async function n(){const{row:u}=t;l("resetPwd",u.id)}return()=>d(y("el-popconfirm"),{title:"\u662F\u5426\u786E\u8BA4\u91CD\u7F6E",placement:"top",onConfirm:n},{reference:()=>d(y("el-button"),{class:"reset-margin",link:!0,size:"small",type:"primary",icon:F("delete")},null)})}}),lt=R({name:"ActionChangePwd",emits:["changePwd"],setup(t,{emit:l}){return()=>d(y("el-button"),{class:"reset-margin",onClick:()=>l("changePwd"),link:!0,size:"small",type:"primary",icon:F("lock")},null)}}),ot=R({name:"ActionLog",emits:["log"],setup(t,{emit:l}){return()=>d(y("el-button"),{class:"reset-margin",link:!0,size:"small",type:"primary",onClick:()=>l("log"),icon:F("tickets")},null)}}),T={ChangePwd:lt,Delete:Je,Log:ot,Preview:Ye,ResetPwd:tt,Status:et,Update:Xe};function nt(){return{selects:O([])}}function at(t){const l=t;let n=!1;const u=O([...l]),o=l[l.length-1],f=l.slice(0,2),r=O([...l.map(({prop:i})=>i).filter(i=>i)]);function h(){n=!0,r.value=[...l.map(({prop:i})=>i).filter(i=>i)]}function m(i,g){u.value[g].fixed=i}return ve(()=>r.value,i=>{const g=l.filter(({prop:b})=>i.includes(b)).map(b=>({...b,fiexed:n?"":b.fixed}));u.value=[...f,...g,o],n=!1}),{_raw:l,fixed:m,reset:h,columns:u,displayColumns:r}}const rt=R({name:"PageContent",props:Ge,emits:["updateBtnClick","previewBtnClick","statusBtnClick","selectionChange","changePwdBtnClick","resetPwdBtnClick","logBtnClick"],setup(t,{expose:l,emit:n,slots:u}){const o=Me(t.contentConfig.apis),f=O(null),{loading:r,dataList:h,onSearch:m,getPageData:i,onBeforeAction:g,paginationConfig:b}=Qe(t),{selects:V}=nt(),{columns:$}=at(t.contentConfig.columns);function D(p){V.value=p,n("selectionChange",p)}function A(p){const{contentConfig:C,powers:e}=t,{inv:P,apis:S,notPreview:E,showPreview:I,showDelete:N,isRequesetArray:a}=C,U=I?I(p):!0,re=N?N(p):!0;return d(j,null,[!E&&U&&e.some(w=>w=="007")&&d(T.Preview,{isInv:P,onPreview:()=>n("previewBtnClick",p)},null),u.custom&&u.custom(p),e.some(w=>w=="005")&&d(T.Update,B({onUpdate:()=>n("updateBtnClick",p)},M("update",S)),null),o.status&&(e.some(w=>w=="003")&&p.status+""=="0"||e.some(w=>w=="004")&&p.status+""=="1")&&d(T.Status,B({row:p,prop:C.statusProp,onReload:()=>m(),isRequesetArray:a},M("status",S)),null),re&&o.delete&&e.some(w=>w=="006")&&d(T.Delete,B({row:p,prop:C.deleteProp,onReload:()=>m()},M("delete",S)),null),e.some(w=>w=="012")&&d(T.ChangePwd,B({row:p,onChangePwd:()=>n("changePwdBtnClick",p)},M("changePwd",S)),null),o.resetPwd&&e.some(w=>w=="013")&&d(T.ResetPwd,B({row:p,prop:C.resetPwdProp,onResetPwd:()=>n("resetPwdBtnClick",p)},M("resetPwd",S)),null),e.some(w=>w=="022")&&d(T.Log,{isInv:P,onLog:()=>n("logBtnClick",p)},null)])}function L(){return d("div",{style:{display:"flex",gap:"5px"}},[u.header&&u.header()])}function q(p){return u.expand&&u.expand(p)}function z(p,C){const{contentConfig:e}=t,{treeProps:P,rowKey:S,isTree:E}=e;return d(ke,B({ref:E&&f,border:!0,stripe:!0,defaultExp:!0,align:"left",showOverflowTooltip:!0,"table-layout":"auto",size:"small",rowKey:S,columns:$.value,treeProps:P,data:h.value,checkList:C,paginationSmall:p==="small",headerCellStyle:{background:"#fafafa",color:"#606266"},onSelectionChange:D},b),{operation:({row:I})=>A(I),expand:({row:I})=>q(I)})}return l({onSearch:m,getPageData:i,onBeforeAction:g}),()=>{var e;const{contentConfig:p}=t,{title:C}=p;return d(Ae,{tableRef:(e=f.value)==null?void 0:e.getTableRef(),title:C,dataList:h.value,onRefresh:m,loading:r.value},{buttons:()=>L(),default:({size:P,checkList:S})=>z(P,S)})}}}),kt=rt;export{$e as B,kt as P,vt as _,bt as a,_t as i,yt as v};