joy-admin-components 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/joy-admin-components.es.js +939 -306
- package/dist/joy-admin-components.umd.js +1 -1
- package/package.json +6 -12
- package/src/index.d.ts +3 -0
- package/src/utils/index.d.ts +193 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("element-plus"),require("vue"),require("lodash"),require("vue-i18n")):typeof define=="function"&&define.amd?define(["exports","element-plus","vue","lodash","vue-i18n"],x):(u=typeof globalThis<"u"?globalThis:u||self,x(u.JoyAdminComponents={},u.ElementPlus,u.Vue,u._,u.VueI18n))})(this,function(u,x,e,T,Y){"use strict";const K=e.defineComponent({name:"LayOutForm",setup(o,{slots:i,attrs:n,emit:l}){const a=e.ref(null),p=()=>i.default?i.default().filter(d=>d.type!==Symbol.for("v-cmt")).map(d=>d.type===Symbol.for("v-fgt")?d.children:d).flat().map(d=>{var s;return e.h(x.ElCol,{span:((s=d.props)==null?void 0:s.span)||24},{default:()=>d})}):null;e.onMounted(()=>{l("ref",a.value)});function r(){return e.h(x.ElForm,{...n,ref:a},()=>e.h(x.ElRow,{gutter:n.gutter??20},{default:()=>p()}))}return r}}),se="",D=(o,i)=>{const n=o.__vccOpts||o;for(const[l,a]of i)n[l]=a;return n},U=D({__name:"index",props:e.mergeModels({api:{type:Function},showCheckAll:{type:Boolean,default:!0},optionClick:{type:Function},maxLimit:{type:Number,default:void 0},minLimit:{type:Number,default:void 0},data:{type:Array},labelValue:{type:Object,default:()=>({label:"label",labelEn:"labelEn",value:"value"})},changeLocal:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["success","change"],["update:modelValue"]),setup(o,{emit:i}){const n=o,l=e.useAttrs(),{t:a,locale:p}=Y.useI18n(),r=e.useModel(o,"modelValue"),d=e.computed({get(){if(l.multiple==null||r.value==null)return!1;let c=n.data?n.data:C.value,t=T.difference(c.map(_=>l["value-key"]?_:_[n.labelValue.value]),r.value).length==0;return r.value.length==c.length&&t},set(c){return c}}),s=i,C=e.ref([]),h=async()=>{const{data:c}=await n.api();C.value=[...c],s("success",C)};n.api&&h();const g=n.labelValue.label.split("-"),V=c=>{if(g.length==1){if(n.changeLocal)return a(c[n.labelValue.label]);let t=p.value=="en_us"?c[n.labelValue.labelEn||"i18nName"]:c[n.labelValue.label];return t=t||c[n.labelValue.label],t}else{let t=[];return g.forEach(_=>{t.push(c[_])}),t.join("-")}};function F(c){let t=n.data?n.data:C.value;r.value=c?t.map(_=>l["value-key"]?_:_[n.labelValue.value]):[],e.nextTick(()=>{s("change",r.value)})}function $(c){n.optionClick&&n.optionClick(c),n.optionClick&&s("change",l["value-key"]?c:c[n.labelValue.value])}function B(c){s("change",c)}function E(c){return l.multiple!=null&&l.multiple!=!1&&n.maxLimit>0?r.value.length>=n.maxLimit&&!r.value.includes(c[n.labelValue.value]):l.multiple!=null&&l.multiple!=!1&&n.minLimit>0?r.value.length<=n.minLimit&&r.value.includes(c[n.labelValue.value]):!1}return(c,t)=>{const _=e.resolveComponent("el-checkbox"),N=e.resolveComponent("el-option"),k=e.resolveComponent("el-select");return e.openBlock(),e.createBlock(k,e.mergeProps({modelValue:r.value,"onUpdate:modelValue":t[1]||(t[1]=b=>r.value=b)},e.unref(l),{filterable:"","collapse-tags":"","collapse-tags-tooltip":"",clearable:"",onClear:B,onChange:B}),{default:e.withCtx(()=>[e.unref(l).multiple!=null&&e.unref(l).multiple!=!1&&o.showCheckAll?e.renderSlot(c.$slots,"header",{key:0},()=>[e.createVNode(_,{class:"mgl20",modelValue:d.value,"onUpdate:modelValue":t[0]||(t[0]=b=>d.value=b),onChange:F},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.$t("quan-xuan")),1)]),_:1},8,["modelValue"])],!0):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.data?o.data:C.value,(b,A)=>(e.openBlock(),e.createBlock(N,{key:A,disabled:E(b),label:V(b),onClick:e.withModifiers(R=>$(b),["stop"]),value:e.unref(l)["value-key"]?b:b[o.labelValue.value]},null,8,["disabled","label","onClick","value"]))),128))]),_:3},16,["modelValue"])}}},[["__scopeId","data-v-02dd2f72"]]),G={__name:"index",emits:["ok","no"],setup(o,{emit:i}){const n=i,l=T.debounce(()=>{n("ok")},500);function a(){n("no")}return(p,r)=>{const d=e.resolveComponent("el-link"),s=e.resolveComponent("el-popconfirm");return e.openBlock(),e.createBlock(s,e.mergeProps(p.$attrs,{onConfirm:e.unref(l),onCancel:a}),{reference:e.withCtx(()=>[e.createVNode(d,{underline:"never",type:p.$attrs.type},{default:e.withCtx(()=>[e.renderSlot(p.$slots,"default")]),_:3},8,["type"])]),_:3},16,["onConfirm"])}}},de="",J=["accept"],Q=D({__name:"index",props:{accept:{type:String,default:".xlsx,.xls"},loading:{type:Boolean,default:!1}},emits:["fileChange"],setup(o,{emit:i}){const n=i,l=e.ref(null);function a(p){let r=p.target.files[0];n("fileChange",r),l.value.value=null}return(p,r)=>{const d=e.resolveComponent("el-button");return e.openBlock(),e.createElementBlock("span",null,[e.createVNode(d,{loading:o.loading,class:"mgr10",onClick:r[0]||(r[0]=s=>l.value.click())},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.$t("dao-ru")),1)]),_:1},8,["loading"]),e.createElementVNode("input",{onChange:a,ref_key:"input",ref:l,accept:o.accept,style:{position:"absolute",width:"0px",height:"0px",opacity:"0"},type:"file"},null,40,J)])}}},[["__scopeId","data-v-5f1449ad"]]),me="",W=e.defineComponent({props:{name:{tyepe:String,required:!0}}});function X(o,i,n,l,a,p){const r=e.resolveComponent("el-icon");return e.openBlock(),e.createBlock(r,{class:"cmp-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.name)))]),_:1})}const q=D(W,[["render",X],["__scopeId","data-v-733f9daa"]]),fe="",Z={key:0},v={class:"btns"},ee={class:"left"},te={class:"right"},I=D({__name:"index",props:{form:{type:Object,required:!0}},emits:["confirm","reset"],setup(o,{emit:i}){const n=i,l=e.ref(!0),a=e.ref(null),{t:p}=Y.useI18n(),r=e.computed(()=>l.value?p("guan-bi"):p("zhan-kai"));function d(){n("confirm")}function s(){n("reset")}function C(){n("confirm")}return(h,g)=>{const V=e.resolveComponent("el-input"),F=e.resolveComponent("el-date-picker"),$=e.resolveComponent("el-form-item"),B=e.resolveComponent("el-form"),E=e.resolveComponent("el-link"),c=e.resolveComponent("el-button");return e.openBlock(),e.createElementBlock("div",{class:"searchBar-container mgt10 mgb10",onKeydown:e.withKeys(d,["enter"])},[e.createElementVNode("div",{class:"searchBar",style:e.normalizeStyle({height:l.value?"auto":"42px"})},[e.createVNode(B,{inline:"",model:o.form.data},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.form.items.filter(t=>!t.hidden),t=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t.key},[t.type=="br"?(e.openBlock(),e.createElementBlock("br",Z)):(e.openBlock(),e.createBlock($,{key:1,label:t.name},{default:e.withCtx(()=>{var _,N;return[t.type==="input"?(e.openBlock(),e.createBlock(V,{key:0,modelValue:t.value,"onUpdate:modelValue":k=>t.value=k,class:e.normalizeClass(((_=t.option)==null?void 0:_.class)||"w150"),placeholder:h.$t("qing-shu-ru"),clearable:""},null,8,["modelValue","onUpdate:modelValue","class","placeholder"])):t.type==="custom"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.render),{key:1})):e.createCommentVNode("",!0),t.type==="select"?(e.openBlock(),e.createBlock(U,e.mergeProps({key:2,class:((N=t.option)==null?void 0:N.class)||"w150",modelValue:t.value,"onUpdate:modelValue":k=>t.value=k},{ref_for:!0},t.option,{onChange:d,onClear:d}),null,16,["class","modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),t.type==="date"?(e.openBlock(),e.createBlock(F,{key:3,class:e.normalizeClass({datetimerange:"w300",daterange:"w200"}[t.dateType]||"w100"),modelValue:t.value,"onUpdate:modelValue":k=>t.value=k,"value-format":{datetimerange:"YYYY-MM-DD HH:mm:ss",daterange:"YYYY-MM-DD"}[t.dateType]||"YYYY-MM-DD",type:t.dateType||"date",onFocus:k=>a.value=t,onChange:k=>C(),placeholder:h.$t("qing-xuan-ze"),"start-placeholder":h.$t("kai-shi-shi-jian"),"end-placeholder":h.$t("jie-shu-shi-jian")},null,8,["class","modelValue","onUpdate:modelValue","value-format","type","onFocus","onChange","placeholder","start-placeholder","end-placeholder"])):e.createCommentVNode("",!0)]}),_:2},1032,["label"]))],64))),128))]),_:1},8,["model"])],4),e.createElementVNode("div",v,[e.createElementVNode("div",ee,[e.renderSlot(h.$slots,"table-header-left",{},void 0,!0)]),e.createElementVNode("div",te,[e.createVNode(E,{underline:"never",class:"mgr10",onClick:g[0]||(g[0]=t=>l.value=!l.value)},{default:e.withCtx(()=>[e.createVNode(q,{name:l.value?"ArrowUp":"ArrowDown"},null,8,["name"]),e.createTextVNode(" "+e.toDisplayString(r.value),1)]),_:1}),e.createVNode(c,{type:"primary",onClick:d},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.$t("shai-xuan")),1)]),_:1}),e.createVNode(c,{type:"primary",onClick:s},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.$t("chong-zhi")),1)]),_:1}),e.renderSlot(h.$slots,"btn",{},void 0,!0)])])],32)}}},[["__scopeId","data-v-f3f60f9c"]]);function ne(o){return o?Array.isArray(o)?o:o.split(",").map(i=>i.trim()).filter(Boolean):[]}function M(o){let i={};return o.forEach(n=>{const{key:l,type:a,option:p={},value:r,dateType:d,toArr:s}=n;if(a=="input"&&(p!=null&&p.multiple))i[l]=ne(r);else if(a=="date")if(d.includes("range")){const[C,h]=l;let[g,V]=r||[];g&&d=="daterange"&&(g=x.dayjs(g).format("YYYY-MM-DD 00:00:00"),V=x.dayjs(V).format("YYYY-MM-DD 23:59:59")),i[C]=g,i[h]=V}else i[l]=r;else a=="select"?i[l]=s?[r]:r:i[l]=r}),i}const he="",oe={class:"center"},le=D({__name:"index",props:{id:{type:String,required:!0},loading:{type:Boolean,default:!1},immediate:{type:Boolean,default:!0},searchForm:{type:Object,default:()=>({items:[],selections:[],showSearch:!1,showPage:!1,showShadow:!1,showCheckBox:!1})},api:{type:Function},data:{type:Array},tableConfig:{type:Object,default:()=>({})}},setup(o,{expose:i}){const{t:n,locale:l}=Y.useI18n(),a=o,p=e.ref(!1),r=e.ref([]),d=T.cloneDeep(a.searchForm.items),s=e.reactive({pageNo:1,pageSize:10,total:0}),C=e.ref(null),h=e.ref(450),g=T.debounce(()=>{e.nextTick(()=>{if(!C.value)return;const f=C.value.getBoundingClientRect(),y=window.innerHeight,w=f.top,S=100,H=y-w-S,j=200;h.value=Math.max(H,j)})},100),V=()=>{g()};e.onMounted(()=>{g(),window.addEventListener("resize",V)}),e.onUnmounted(()=>{window.removeEventListener("resize",V)});const F=e.computed(()=>k.value.height||h.value);async function $(m){const{dataFormat:f}=a.tableConfig;p.value=!0;const{code:y,data:w={}}=await a.api(m).finally(()=>{p.value=!1,a.searchForm.selections=[]});if(y==200){let S=w.rows||[];r.value=f?f(S):S,s.total=w.totalRows||0}}function B(m={}){$({...s,...M(a.searchForm.items),...m})}async function E(){const{reset:m}=a.tableConfig;a.searchForm.items.forEach(f=>{const y=d.find(w=>w.key==f.key);y&&(f.value=y.value)}),m&&await m(),B()}a.api&&a.immediate&&B();function c(){return{...s,...M(a.searchForm.items)}}const t=e.ref(null);i({tableRef:t,getList:B,getPrm:c,calculateTableHeight:g});const _=e.reactive({storage:!0}),N=e.reactive({drag:!0,resizable:!0,maxFixedSize:0}),k=e.computed(()=>{const{customConfig:m,columnConfig:f,...y}=a.tableConfig;return{headerAlign:"left",align:"center",customConfig:{..._,...m},"column-config":{...N,...f},"virtual-x-config":{enabled:!1,scrollToLeftOnChange:!0},"virtual-y-config":{enabled:!0,gt:100},...y}}),b=m=>{s.pageNo=m,$({...s,...M(a.searchForm.items)})},A=m=>{s.pageSize=m,s.pageNo=1,$({...s,...M(a.searchForm.items)})};function R(){const m=t.value.getCheckboxRecords();a.searchForm.selections=m}const O=m=>{const f=t.value;if(f){f.toggleCheckboxRow(m);const y=t.value.getCheckboxRecords();a.searchForm.selections=y}};return(m,f)=>{const y=e.resolveComponent("el-button"),w=e.resolveComponent("el-checkbox"),S=e.resolveComponent("el-text"),H=e.resolveComponent("vxe-column"),j=e.resolveComponent("VxeTable"),ae=e.resolveComponent("el-pagination");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({box:o.searchForm.showShadow})},[o.searchForm.showSearch?(e.openBlock(),e.createBlock(I,{key:0,form:o.searchForm,onReset:E,onConfirm:f[1]||(f[1]=z=>B())},{btn:e.withCtx(()=>[e.renderSlot(m.$slots,"search-bar-btn",{},void 0,!0),e.createVNode(y,{round:"",onClick:f[0]||(f[0]=z=>t.value.openCustom())},{default:e.withCtx(()=>[e.createVNode(q,{name:"Tools"})]),_:1})]),_:3},8,["form"])):e.createCommentVNode("",!0),e.renderSlot(m.$slots,"table-header-left",{},void 0,!0),e.createElementVNode("div",{ref_key:"tableContentRef",ref:C},[e.createVNode(j,e.mergeProps({id:o.id,ref_key:"tableRef",ref:t,loading:o.loading||p.value,data:o.api?r.value:o.data},k.value,{height:F.value,onCheckboxChange:R,onCheckboxAll:R,border:""}),{default:e.withCtx(()=>[o.searchForm.showCheckBox?(e.openBlock(),e.createBlock(H,{key:0,type:"checkbox",width:e.unref(l)=="zh_cn"?80:150,fixed:"left",title:m.$t("xu-hao")},{checkbox:e.withCtx(({rowIndex:z,row:P,checked:re,disabled:L,indeterminate:_e})=>[e.createElementVNode("div",oe,[re?(e.openBlock(),e.createBlock(w,{key:0,checked:!0,disabled:L,size:"default",onClick:e.withModifiers(ce=>!L&&O(P),["stop"])},null,8,["disabled","onClick"])):(e.openBlock(),e.createBlock(w,{key:1,disabled:L,checked:!1,size:"default",onClick:e.withModifiers(ce=>!L&&O(P),["stop"])},null,8,["disabled","onClick"])),e.createVNode(S,{type:"info",class:"mgl5"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(z+1),1)]),_:2},1024)])]),_:1},8,["width","title"])):e.createCommentVNode("",!0),e.renderSlot(m.$slots,"default",{},void 0,!0)]),_:3},16,["id","loading","data","height"])],512),o.searchForm.showPage?(e.openBlock(),e.createBlock(ae,{key:1,"current-page":s.pageNo,"onUpdate:currentPage":f[2]||(f[2]=z=>s.pageNo=z),class:"myPagination mgt10",background:"",layout:"total, sizes, prev, pager, next",total:s.total,"page-size":s.pageSize,"page-sizes":[10,50,100,500],onCurrentChange:b,onSizeChange:A},null,8,["current-page","total","page-size"])):e.createCommentVNode("",!0)],2)}}},[["__scopeId","data-v-7b74503d"]]);u.CmpDictionary=U,u.ConfrimButton=G,u.ImportButton=Q,u.LayOutForm=K,u.ListPage=le,u.SearchBar=I,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("element-plus"),require("vue"),require("lodash"),require("vue-i18n"),require("crypto-js"),require("file-saver"),require("exceljs"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","element-plus","vue","lodash","vue-i18n","crypto-js","file-saver","exceljs","dayjs"],O):(h=typeof globalThis<"u"?globalThis:h||self,O(h.JoyAdminComponents={},h.ElementPlus,h.Vue,h._,h.VueI18n,h.CryptoJS,h.fileSaver,h.ExcelJS,h.dayjs))})(this,function(h,O,e,U,A,z,ee,R,H){"use strict";const te=e.defineComponent({name:"LayOutForm",setup(o,{slots:t,attrs:n,emit:a}){const r=e.ref(null),u=()=>t.default?t.default().filter(f=>f.type!==Symbol.for("v-cmt")).map(f=>f.type===Symbol.for("v-fgt")?f.children:f).flat().map(f=>{var i;return e.h(O.ElCol,{span:((i=f.props)==null?void 0:i.span)||24},{default:()=>f})}):null;e.onMounted(()=>{a("ref",r.value)});function l(){return e.h(O.ElForm,{...n,ref:r},()=>e.h(O.ElRow,{gutter:n.gutter??20},{default:()=>u()}))}return l}}),Re="",I=(o,t)=>{const n=o.__vccOpts||o;for(const[a,r]of t)n[a]=r;return n},q=I({__name:"index",props:e.mergeModels({api:{type:Function},showCheckAll:{type:Boolean,default:!0},optionClick:{type:Function},maxLimit:{type:Number,default:void 0},minLimit:{type:Number,default:void 0},data:{type:Array},labelValue:{type:Object,default:()=>({label:"label",labelEn:"labelEn",value:"value"})},changeLocal:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["success","change"],["update:modelValue"]),setup(o,{emit:t}){const n=o,a=e.useAttrs(),{t:r,locale:u}=A.useI18n(),l=e.useModel(o,"modelValue"),f=e.computed({get(){if(a.multiple==null||l.value==null)return!1;let d=n.data?n.data:k.value,s=U.difference(d.map(y=>a["value-key"]?y:y[n.labelValue.value]),l.value).length==0;return l.value.length==d.length&&s},set(d){return d}}),i=t,k=e.ref([]),C=async()=>{const{data:d}=await n.api();k.value=[...d],i("success",k)};n.api&&C();const S=n.labelValue.label.split("-"),m=d=>{if(S.length==1){if(n.changeLocal)return r(d[n.labelValue.label]);let s=u.value=="en_us"?d[n.labelValue.labelEn||"i18nName"]:d[n.labelValue.label];return s=s||d[n.labelValue.label],s}else{let s=[];return S.forEach(y=>{s.push(d[y])}),s.join("-")}};function w(d){let s=n.data?n.data:k.value;l.value=d?s.map(y=>a["value-key"]?y:y[n.labelValue.value]):[],e.nextTick(()=>{i("change",l.value)})}function g(d){n.optionClick&&n.optionClick(d),n.optionClick&&i("change",a["value-key"]?d:d[n.labelValue.value])}function c(d){i("change",d)}function p(d){return a.multiple!=null&&a.multiple!=!1&&n.maxLimit>0?l.value.length>=n.maxLimit&&!l.value.includes(d[n.labelValue.value]):a.multiple!=null&&a.multiple!=!1&&n.minLimit>0?l.value.length<=n.minLimit&&l.value.includes(d[n.labelValue.value]):!1}return(d,s)=>{const y=e.resolveComponent("el-checkbox"),x=e.resolveComponent("el-option"),b=e.resolveComponent("el-select");return e.openBlock(),e.createBlock(b,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":s[1]||(s[1]=T=>l.value=T)},e.unref(a),{filterable:"","collapse-tags":"","collapse-tags-tooltip":"",clearable:"",onClear:c,onChange:c}),{default:e.withCtx(()=>[e.unref(a).multiple!=null&&e.unref(a).multiple!=!1&&o.showCheckAll?e.renderSlot(d.$slots,"header",{key:0},()=>[e.createVNode(y,{class:"mgl20",modelValue:f.value,"onUpdate:modelValue":s[0]||(s[0]=T=>f.value=T),onChange:w},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.$t("quan-xuan")),1)]),_:1},8,["modelValue"])],!0):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.data?o.data:k.value,(T,V)=>(e.openBlock(),e.createBlock(x,{key:V,disabled:p(T),label:m(T),onClick:e.withModifiers(D=>g(T),["stop"]),value:e.unref(a)["value-key"]?T:T[o.labelValue.value]},null,8,["disabled","label","onClick","value"]))),128))]),_:3},16,["modelValue"])}}},[["__scopeId","data-v-02dd2f72"]]),ne={__name:"index",emits:["ok","no"],setup(o,{emit:t}){const n=t,a=U.debounce(()=>{n("ok")},500);function r(){n("no")}return(u,l)=>{const f=e.resolveComponent("el-link"),i=e.resolveComponent("el-popconfirm");return e.openBlock(),e.createBlock(i,e.mergeProps(u.$attrs,{onConfirm:e.unref(a),onCancel:r}),{reference:e.withCtx(()=>[e.createVNode(f,{underline:"never",type:u.$attrs.type},{default:e.withCtx(()=>[e.renderSlot(u.$slots,"default")]),_:3},8,["type"])]),_:3},16,["onConfirm"])}}},qe="",oe=["accept"],ae=I({__name:"index",props:{accept:{type:String,default:".xlsx,.xls"},loading:{type:Boolean,default:!1}},emits:["fileChange"],setup(o,{emit:t}){const n=t,a=e.ref(null);function r(u){let l=u.target.files[0];n("fileChange",l),a.value.value=null}return(u,l)=>{const f=e.resolveComponent("el-button");return e.openBlock(),e.createElementBlock("span",null,[e.createVNode(f,{loading:o.loading,class:"mgr10",onClick:l[0]||(l[0]=i=>a.value.click())},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.$t("dao-ru")),1)]),_:1},8,["loading"]),e.createElementVNode("input",{onChange:r,ref_key:"input",ref:a,accept:o.accept,style:{position:"absolute",width:"0px",height:"0px",opacity:"0"},type:"file"},null,40,oe)])}}},[["__scopeId","data-v-5f1449ad"]]),Ze="",re=e.defineComponent({props:{name:{tyepe:String,required:!0}}});function le(o,t,n,a,r,u){const l=e.resolveComponent("el-icon");return e.openBlock(),e.createBlock(l,{class:"cmp-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.name)))]),_:1})}const K=I(re,[["render",le],["__scopeId","data-v-733f9daa"]]),We="",ie={key:0},se={class:"btns"},ce={class:"left"},ue={class:"right"},Z=I({__name:"index",props:{form:{type:Object,required:!0}},emits:["confirm","reset"],setup(o,{emit:t}){const n=t,a=e.ref(!0),r=e.ref(null),{t:u}=A.useI18n(),l=e.computed(()=>a.value?u("guan-bi"):u("zhan-kai"));function f(){n("confirm")}function i(){n("reset")}function k(){n("confirm")}return(C,S)=>{const m=e.resolveComponent("el-input"),w=e.resolveComponent("el-date-picker"),g=e.resolveComponent("el-form-item"),c=e.resolveComponent("el-form"),p=e.resolveComponent("el-link"),d=e.resolveComponent("el-button");return e.openBlock(),e.createElementBlock("div",{class:"searchBar-container mgt10 mgb10",onKeydown:e.withKeys(f,["enter"])},[e.createElementVNode("div",{class:"searchBar",style:e.normalizeStyle({height:a.value?"auto":"42px"})},[e.createVNode(c,{inline:"",model:o.form.data},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.form.items.filter(s=>!s.hidden),s=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s.key},[s.type=="br"?(e.openBlock(),e.createElementBlock("br",ie)):(e.openBlock(),e.createBlock(g,{key:1,label:s.name},{default:e.withCtx(()=>{var y,x;return[s.type==="input"?(e.openBlock(),e.createBlock(m,{key:0,modelValue:s.value,"onUpdate:modelValue":b=>s.value=b,class:e.normalizeClass(((y=s.option)==null?void 0:y.class)||"w150"),placeholder:C.$t("qing-shu-ru"),clearable:""},null,8,["modelValue","onUpdate:modelValue","class","placeholder"])):s.type==="custom"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.render),{key:1})):e.createCommentVNode("",!0),s.type==="select"?(e.openBlock(),e.createBlock(q,e.mergeProps({key:2,class:((x=s.option)==null?void 0:x.class)||"w150",modelValue:s.value,"onUpdate:modelValue":b=>s.value=b},{ref_for:!0},s.option,{onChange:f,onClear:f}),null,16,["class","modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),s.type==="date"?(e.openBlock(),e.createBlock(w,{key:3,class:e.normalizeClass({datetimerange:"w300",daterange:"w200"}[s.dateType]||"w100"),modelValue:s.value,"onUpdate:modelValue":b=>s.value=b,"value-format":{datetimerange:"YYYY-MM-DD HH:mm:ss",daterange:"YYYY-MM-DD"}[s.dateType]||"YYYY-MM-DD",type:s.dateType||"date",onFocus:b=>r.value=s,onChange:b=>k(),placeholder:C.$t("qing-xuan-ze"),"start-placeholder":C.$t("kai-shi-shi-jian"),"end-placeholder":C.$t("jie-shu-shi-jian")},null,8,["class","modelValue","onUpdate:modelValue","value-format","type","onFocus","onChange","placeholder","start-placeholder","end-placeholder"])):e.createCommentVNode("",!0)]}),_:2},1032,["label"]))],64))),128))]),_:1},8,["model"])],4),e.createElementVNode("div",se,[e.createElementVNode("div",ce,[e.renderSlot(C.$slots,"table-header-left",{},void 0,!0)]),e.createElementVNode("div",ue,[e.createVNode(p,{underline:"never",class:"mgr10",onClick:S[0]||(S[0]=s=>a.value=!a.value)},{default:e.withCtx(()=>[e.createVNode(K,{name:a.value?"ArrowUp":"ArrowDown"},null,8,["name"]),e.createTextVNode(" "+e.toDisplayString(l.value),1)]),_:1}),e.createVNode(d,{type:"primary",onClick:f},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.$t("shai-xuan")),1)]),_:1}),e.createVNode(d,{type:"primary",onClick:i},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.$t("chong-zhi")),1)]),_:1}),e.renderSlot(C.$slots,"btn",{},void 0,!0)])])],32)}}},[["__scopeId","data-v-f3f60f9c"]]);function fe(o){return o?Array.isArray(o)?o:o.split(",").map(t=>t.trim()).filter(Boolean):[]}function L(o){let t={};return o.forEach(n=>{const{key:a,type:r,option:u={},value:l,dateType:f,toArr:i}=n;if(r=="input"&&(u!=null&&u.multiple))t[a]=fe(l);else if(r=="date")if(f.includes("range")){const[k,C]=a;let[S,m]=l||[];S&&f=="daterange"&&(S=O.dayjs(S).format("YYYY-MM-DD 00:00:00"),m=O.dayjs(m).format("YYYY-MM-DD 23:59:59")),t[k]=S,t[C]=m}else t[a]=l;else r=="select"?t[a]=i?[l]:l:t[a]=l}),t}const Qe="",de={class:"center"},he=I({__name:"index",props:{id:{type:String,required:!0},loading:{type:Boolean,default:!1},immediate:{type:Boolean,default:!0},searchForm:{type:Object,default:()=>({items:[],selections:[],showSearch:!1,showPage:!1,showShadow:!1,showCheckBox:!1})},api:{type:Function},data:{type:Array},tableConfig:{type:Object,default:()=>({})}},setup(o,{expose:t}){const{t:n,locale:a}=A.useI18n(),r=o,u=e.ref(!1),l=e.ref([]),f=U.cloneDeep(r.searchForm.items),i=e.reactive({pageNo:1,pageSize:10,total:0}),k=e.ref(null),C=e.ref(450),S=U.debounce(()=>{e.nextTick(()=>{if(!k.value)return;const $=k.value.getBoundingClientRect(),B=window.innerHeight,v=$.top,N=100,Y=B-v-N,P=200;C.value=Math.max(Y,P)})},100),m=()=>{S()};e.onMounted(()=>{S(),window.addEventListener("resize",m)}),e.onUnmounted(()=>{window.removeEventListener("resize",m)});const w=e.computed(()=>b.value.height||C.value);async function g(_){const{dataFormat:$}=r.tableConfig;u.value=!0;const{code:B,data:v={}}=await r.api(_).finally(()=>{u.value=!1,r.searchForm.selections=[]});if(B==200){let N=v.rows||[];l.value=$?$(N):N,i.total=v.totalRows||0}}function c(_={}){g({...i,...L(r.searchForm.items),..._})}async function p(){const{reset:_}=r.tableConfig;r.searchForm.items.forEach($=>{const B=f.find(v=>v.key==$.key);B&&($.value=B.value)}),_&&await _(),c()}r.api&&r.immediate&&c();function d(){return{...i,...L(r.searchForm.items)}}const s=e.ref(null);t({tableRef:s,getList:c,getPrm:d,calculateTableHeight:S});const y=e.reactive({storage:!0}),x=e.reactive({drag:!0,resizable:!0,maxFixedSize:0}),b=e.computed(()=>{const{customConfig:_,columnConfig:$,...B}=r.tableConfig;return{headerAlign:"left",align:"center",customConfig:{...y,..._},"column-config":{...x,...$},"virtual-x-config":{enabled:!1,scrollToLeftOnChange:!0},"virtual-y-config":{enabled:!0,gt:100},...B}}),T=_=>{i.pageNo=_,g({...i,...L(r.searchForm.items)})},V=_=>{i.pageSize=_,i.pageNo=1,g({...i,...L(r.searchForm.items)})};function D(){const _=s.value.getCheckboxRecords();r.searchForm.selections=_}const E=_=>{const $=s.value;if($){$.toggleCheckboxRow(_);const B=s.value.getCheckboxRecords();r.searchForm.selections=B}};return(_,$)=>{const B=e.resolveComponent("el-button"),v=e.resolveComponent("el-checkbox"),N=e.resolveComponent("el-text"),Y=e.resolveComponent("vxe-column"),P=e.resolveComponent("VxeTable"),je=e.resolveComponent("el-pagination");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({box:o.searchForm.showShadow})},[o.searchForm.showSearch?(e.openBlock(),e.createBlock(Z,{key:0,form:o.searchForm,onReset:p,onConfirm:$[1]||($[1]=F=>c())},{btn:e.withCtx(()=>[e.renderSlot(_.$slots,"search-bar-btn",{},void 0,!0),e.createVNode(B,{round:"",onClick:$[0]||($[0]=F=>s.value.openCustom())},{default:e.withCtx(()=>[e.createVNode(K,{name:"Tools"})]),_:1})]),_:3},8,["form"])):e.createCommentVNode("",!0),e.renderSlot(_.$slots,"table-header-left",{},void 0,!0),e.createElementVNode("div",{ref_key:"tableContentRef",ref:k},[e.createVNode(P,e.mergeProps({id:o.id,ref_key:"tableRef",ref:s,loading:o.loading||u.value,data:o.api?l.value:o.data},b.value,{height:w.value,onCheckboxChange:D,onCheckboxAll:D,border:""}),{default:e.withCtx(()=>[o.searchForm.showCheckBox?(e.openBlock(),e.createBlock(Y,{key:0,type:"checkbox",width:e.unref(a)=="zh_cn"?80:150,fixed:"left",title:_.$t("xu-hao")},{checkbox:e.withCtx(({rowIndex:F,row:J,checked:Ye,disabled:M,indeterminate:Je})=>[e.createElementVNode("div",de,[Ye?(e.openBlock(),e.createBlock(v,{key:0,checked:!0,disabled:M,size:"default",onClick:e.withModifiers(Pe=>!M&&E(J),["stop"])},null,8,["disabled","onClick"])):(e.openBlock(),e.createBlock(v,{key:1,disabled:M,checked:!1,size:"default",onClick:e.withModifiers(Pe=>!M&&E(J),["stop"])},null,8,["disabled","onClick"])),e.createVNode(N,{type:"info",class:"mgl5"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(F+1),1)]),_:2},1024)])]),_:1},8,["width","title"])):e.createCommentVNode("",!0),e.renderSlot(_.$slots,"default",{},void 0,!0)]),_:3},16,["id","loading","data","height"])],512),o.searchForm.showPage?(e.openBlock(),e.createBlock(je,{key:1,"current-page":i.pageNo,"onUpdate:currentPage":$[2]||($[2]=F=>i.pageNo=F),class:"myPagination mgt10",background:"",layout:"total, sizes, prev, pager, next",total:i.total,"page-size":i.pageSize,"page-sizes":[10,50,100,500],onCurrentChange:T,onSizeChange:V},null,8,["current-page","total","page-size"])):e.createCommentVNode("",!0)],2)}}},[["__scopeId","data-v-7b74503d"]]);function me(o,t={}){const n={inForm:!0,required:!0,...t},a={phone:/^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/,password:/(?=.*\d)(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,12}/,email:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/}[o],{inForm:r,value:u,required:l,msg:f="请输入正确内容"}=n;return r?function(i,k,C){if(l){a.test(k)?C():C(new Error(f));return}k&&!a.test(k)?C(new Error(f)):C()}:a.test(u)}const ge={encrypt(o,t){t=t||"1CFEC667A1E6D42DC12565AAAA460494";var n=z.enc.Utf8.parse(t),a=z.enc.Utf8.parse(o),r=z.AES.encrypt(a,n,{mode:z.mode.ECB,padding:z.pad.Pkcs7});return r.toString()},decrypt(o,t){t=t||"1CFEC667A1E6D42DC12565AAAA460494";var n=z.enc.Utf8.parse(t),a=z.AES.decrypt(o,n,{mode:z.mode.ECB,padding:z.pad.Pkcs7});return z.enc.Utf8.stringify(a).toString()}};var W=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function G(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Q={exports:{}};(function(o,t){(function(n,a){o.exports=a()})(W,function(){var n="minute",a=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(u,l,f){var i=l.prototype;f.utc=function(c){var p={date:c,utc:!0,args:arguments};return new l(p)},i.utc=function(c){var p=f(this.toDate(),{locale:this.$L,utc:!0});return c?p.add(this.utcOffset(),n):p},i.local=function(){return f(this.toDate(),{locale:this.$L,utc:!1})};var k=i.parse;i.parse=function(c){c.utc&&(this.$u=!0),this.$utils().u(c.$offset)||(this.$offset=c.$offset),k.call(this,c)};var C=i.init;i.init=function(){if(this.$u){var c=this.$d;this.$y=c.getUTCFullYear(),this.$M=c.getUTCMonth(),this.$D=c.getUTCDate(),this.$W=c.getUTCDay(),this.$H=c.getUTCHours(),this.$m=c.getUTCMinutes(),this.$s=c.getUTCSeconds(),this.$ms=c.getUTCMilliseconds()}else C.call(this)};var S=i.utcOffset;i.utcOffset=function(c,p){var d=this.$utils().u;if(d(c))return this.$u?0:d(this.$offset)?S.call(this):this.$offset;if(typeof c=="string"&&(c=function(b){b===void 0&&(b="");var T=b.match(a);if(!T)return null;var V=(""+T[0]).match(r)||["-",0,0],D=V[0],E=60*+V[1]+ +V[2];return E===0?0:D==="+"?E:-E}(c),c===null))return this;var s=Math.abs(c)<=16?60*c:c;if(s===0)return this.utc(p);var y=this.clone();if(p)return y.$offset=s,y.$u=!1,y;var x=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(y=this.local().add(s+x,n)).$offset=s,y.$x.$localOffset=x,y};var m=i.format;i.format=function(c){var p=c||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return m.call(this,p)},i.valueOf=function(){var c=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*c},i.isUTC=function(){return!!this.$u},i.toISOString=function(){return this.toDate().toISOString()},i.toString=function(){return this.toDate().toUTCString()};var w=i.toDate;i.toDate=function(c){return c==="s"&&this.$offset?f(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():w.call(this)};var g=i.diff;i.diff=function(c,p,d){if(c&&this.$u===c.$u)return g.call(this,c,p,d);var s=this.local(),y=f(c).local();return g.call(s,y,p,d)}}})})(Q);var pe=Q.exports;const ye=G(pe);var X={exports:{}};(function(o,t){(function(n,a){o.exports=a()})(W,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},a={};return function(r,u,l){var f,i=function(m,w,g){g===void 0&&(g={});var c=new Date(m),p=function(d,s){s===void 0&&(s={});var y=s.timeZoneName||"short",x=d+"|"+y,b=a[x];return b||(b=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:d,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:y}),a[x]=b),b}(w,g);return p.formatToParts(c)},k=function(m,w){for(var g=i(m,w),c=[],p=0;p<g.length;p+=1){var d=g[p],s=d.type,y=d.value,x=n[s];x>=0&&(c[x]=parseInt(y,10))}var b=c[3],T=b===24?0:b,V=c[0]+"-"+c[1]+"-"+c[2]+" "+T+":"+c[4]+":"+c[5]+":000",D=+m;return(l.utc(V).valueOf()-(D-=D%1e3))/6e4},C=u.prototype;C.tz=function(m,w){m===void 0&&(m=f);var g,c=this.utcOffset(),p=this.toDate(),d=p.toLocaleString("en-US",{timeZone:m}),s=Math.round((p-new Date(d))/1e3/60),y=15*-Math.round(p.getTimezoneOffset()/15)-s;if(!Number(y))g=this.utcOffset(0,w);else if(g=l(d,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(y,!0),w){var x=g.utcOffset();g=g.add(c-x,"minute")}return g.$x.$timezone=m,g},C.offsetName=function(m){var w=this.$x.$timezone||l.tz.guess(),g=i(this.valueOf(),w,{timeZoneName:m}).find(function(c){return c.type.toLowerCase()==="timezonename"});return g&&g.value};var S=C.startOf;C.startOf=function(m,w){if(!this.$x||!this.$x.$timezone)return S.call(this,m,w);var g=l(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return S.call(g,m,w).tz(this.$x.$timezone,!0)},l.tz=function(m,w,g){var c=g&&w,p=g||w||f,d=k(+l(),p);if(typeof m!="string")return l(m).tz(p);var s=function(T,V,D){var E=T-60*V*1e3,_=k(E,D);if(V===_)return[E,V];var $=k(E-=60*(_-V)*1e3,D);return _===$?[E,_]:[T-60*Math.min(_,$)*1e3,Math.max(_,$)]}(l.utc(m,c).valueOf(),d,p),y=s[0],x=s[1],b=l(y).utcOffset(x);return b.$x.$timezone=p,b},l.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},l.tz.setDefault=function(m){f=m}}})})(X);var Ce=X.exports;const ke=G(Ce);H.extend(ye),H.extend(ke);async function _e(o,t){const{fields:n,range:a=1}=t;if(!n)throw new Error("请输入列字段映射");let r=new R.Workbook;await r.xlsx.load(o);const u={};return r.eachSheet(function(l,f){const i=[];l.eachRow(function(k,C){if(C>a){let S={},m=!0;Object.keys(n).forEach(w=>{const g=k.getCell(n[w]).value;S[w]=g,g&&(m=!1)}),m||i.push(S)}}),u[l._name]=i}),r=null,u}const be={columnWidth:30};async function we(o,t,n=[],a={}){if(!o||!t)return;const{columnStyle:r}=a,{columnWidth:u}=be;t.forEach(i=>{i.width=i.width?i.width:u});const{workbook:l,worksheet:f}=$e();f.columns=t,f.addRows(n),r&&await Se(l,f,r);try{const i=await l.xlsx.writeBuffer(),k=new File([i],o,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});ee.saveAs(k)}catch(i){console.log(i)}}function $e(){const o=new R.Workbook;o.creator="distributor System",o.lastModifiedBy="distributor System",o.created=new Date,o.modified=new Date,o.lastPrinted=new Date;const t=o.addWorksheet("Sheet1");return{workbook:o,worksheet:t}}async function Se(o,t,n){const a=Object.keys(n);for(const r of a){const u=n[r],{type:l}=u;switch(l){case"IMG":await xe(o,t,r);break}}}async function xe(o,t,n,a){const r=t.getColumn(n),u=r.values;t.getColumn(n).width=20,t.eachRow((l,f)=>{f>1&&(l.height=40)});for(let l=0,f=u.length;l<f;l++){if(l<2)continue;let i=u[l];i&&(t.getCell(r.letter+l).value="",await Te(o,t,i,{width:100,height:50,col:r._number-1,row:l-1}))}}async function Te(o,t,n,a){const{col:r,row:u,width:l,height:f}=a,{success:i,base64:k}=await Ve(n,.3);if(i){const C=o.addImage({base64:k,extension:"jpeg"});t.addImage(C,{tl:{col:r,row:u},ext:{width:l,height:f}})}}function Ve(o,t=1){const n=new Image;return n.setAttribute("crossOrigin","anonymous"),n.crossOrigin="anonymous",n.src=o,new Promise((a,r)=>{n.onload=()=>{const u=document.createElement("canvas");u.width=n.width,u.height=n.height,u.getContext("2d").drawImage(n,0,0,u.width,u.height),a({success:!0,base64:u.toDataURL("image/jpeg",t)})},n.onerror=()=>{a({success:!1})}})}function Be(o){if(o<26)return String.fromCharCode(65+o);{const t=String.fromCharCode(65+Math.floor((o-26)/26)),n=String.fromCharCode(65+(o-26)%26);return t+n}}class De{constructor(t={}){this.config={clientCode:t.clientCode||"one-portal",casServerUrl:`https://one-portal${t.isTest?"-test":""}.joy-group.com/api`,casPortalUrl:`https://one-portal${t.isTest?"-test":""}.joy-group.com`,serviceUrl:t.serviceUrl||window.location.origin+"/cas/callback",tokenKey:t.tokenKey||"one_portal_token",userKey:t.userKey||"one_portal_user",debug:t.debug||!1,autoLogin:t.autoLogin!==!1,loginCallback:t.loginCallback||null,logoutCallback:t.logoutCallback||null,errorCallback:t.errorCallback||null},this.token=null,this.user=null,this.init()}init(){this.log("OnePortal CAS SDK 初始化中..."),this.loadFromStorage();const n=new URLSearchParams(window.location.search).get("ticket");this.isLoggedIn()&&this.config.loginCallback?this.config.loginCallback(this.user,this.token):n?(this.log("检测到ST票据:",n),this.validateTicket(n)):this.config.autoLogin&&!this.isLoggedIn()&&(this.log("用户未登录,准备跳转到CAS登录页面"),this.login())}loadFromStorage(){try{this.token=localStorage.getItem(this.config.tokenKey);const t=localStorage.getItem(this.config.userKey);t&&(this.user=JSON.parse(t)),this.log("从本地存储加载数据:",{token:!!this.token,user:!!this.user})}catch(t){this.log("加载本地存储数据失败:",t)}}saveToStorage(){try{this.token&&localStorage.setItem(this.config.tokenKey,this.token),this.user&&localStorage.setItem(this.config.userKey,JSON.stringify(this.user)),this.log("数据已保存到本地存储")}catch(t){this.log("保存到本地存储失败:",t)}}clearStorage(){try{localStorage.removeItem(this.config.tokenKey),localStorage.removeItem(this.config.userKey),this.log("本地存储已清除")}catch(t){this.log("清除本地存储失败:",t)}}isLoggedIn(){return!!(this.token&&this.user)}getUser(){return this.user}getToken(){return this.token}login(){const t=`${this.config.casPortalUrl}?appCode=${this.config.clientCode}&redirectUrl=${encodeURIComponent(this.config.serviceUrl)}`;this.log("跳转到CAS登录页面:",t),window.location.href=t}async validateTicket(t){try{this.log("验证ST票据:",t);const n=await fetch(`${this.config.casServerUrl}/auth/validateST?ticket=${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);const a=await n.json();if(a.success&&a.data)return this.token=a.data.token,this.user=a.data.user,this.saveToStorage(),this.clearTicketFromUrl(),this.log("ST票据验证成功,用户登录成功:",this.user),this.config.loginCallback&&this.config.loginCallback(this.user,this.token),!0;throw new Error(a.message||"ST票据验证失败")}catch(n){return this.log("ST票据验证失败:",n),this.handleError(n),!1}}clearTicketFromUrl(){const t=new URL(window.location);t.searchParams.delete("ticket"),window.history.replaceState({},document.title,t.toString())}async logout(t=!0){try{if(this.log("用户登出"),this.token)try{await fetch(`${this.config.casServerUrl}/auth/logout`,{method:"POST",headers:{AppId:this.config.clientCode,Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"}})}catch(n){this.log("调用服务端登出接口失败:",n)}this.token=null,this.user=null,this.clearStorage(),this.config.logoutCallback&&this.config.logoutCallback(),t&&this.login()}catch(n){this.log("登出失败:",n),this.handleError(n)}}async request(t,n={}){const a={headers:{"Content-Type":"application/json",...n.headers},...n};a.headers.appId=this.config.clientCode,this.token&&(a.headers.Authorization=`Bearer ${this.token}`);try{const r=await fetch(t,a);return r.status===401?(this.log("Token已过期,需要重新登录"),this.logout(),null):r}catch(r){throw this.log("请求失败:",r),r}}async fetchUserInfo(){try{const t=await this.request(`${this.config.casServerUrl}/auth/user`);if(t&&t.ok){const n=await t.json();if(n.success&&n.data)return this.user=n.data,this.saveToStorage(),this.user}return null}catch(t){return this.log("获取用户信息失败:",t),null}}async refreshToken(){this.log("Token刷新功能暂未实现")}handleError(t){this.log("发生错误:",t),this.config.errorCallback&&this.config.errorCallback(t)}log(...t){this.config.debug&&console.log("[OnePortal CAS SDK]",...t)}checkLoginStatus(){return!this.isLoggedIn()&&this.config.autoLogin?(this.login(),!1):this.isLoggedIn()}setConfig(t,n){this.config[t]=n}getConfig(t){return this.config[t]}}function Ee(o){return new Promise(t=>{setTimeout(()=>{t()},o)})}function ze(o){return JSON.parse(JSON.stringify(o))}function Oe(o){let t=[],n={},a=(r,u)=>Object.prototype.hasOwnProperty.call(r,u);for(const r of o){n[r.id]={...r,children:a(n,r.id)?n[r.id].children:[]};const u=n[r.id];r.pid==-1?t.push(u):(a(n,r.pid)||(n[r.pid]={children:[]}),n[r.pid].children.push(u))}return t}function ve(o,t=" "){return o?o.split(t).filter(n=>n.trim()):[]}class j{constructor(t,n=["label","value","labelEn"]){this.list=t,this.map=new Map(t.map(a=>{let r={...a,label:a[n[0]],value:a[n[1]]};return n[2]&&(r.labelEn=a[n[2]]),[a[n[1]],r]}))}getName(t,n){if(!this.has(t))return"-";const{label:a,labelEn:r}=this.map.get(t);return(n=="zh_cn"?a:r)||a||"-"}getTag(t){if(!this.has(t))return"info";const{tag:n="info"}=this.map.get(t);return n}getItem(t){return this.has(t)?this.map.get(t):null}getColor(t){if(!this.has(t))return null;const{color:n}=this.map.get(t);return n}has(t){return this.map.has(t)}}function Ne(o,t=[],n="i18nName"){if(o.length==0)return new j([]);if(t.length<2)throw new Error("keys 长度必须大于2 默认前两位为 label value ");let a=o.map(r=>{let u={};return n&&(u.labelEn=r[n]),t.forEach((l,f)=>{f===0?u.label=r[l]:f===1?u.value=r[l]:u[l]=r[l]}),u});return new j(a)}function Ie(o){return o?o.replace(/<[^>]+>/g,""):""}function Fe(o){return o?(o.includes("\\\\u")&&(o=o.replace(/\\/g,"")),o.replace(/\\u[\dA-F]{4}/gi,t=>String.fromCharCode(parseInt(t.replace(/\\u/g,""),16)))):""}function Ue(o,t=10){let n=1048576*t;return!(o.size>n)}function Le(o){return Array.from(10).fill(0).map((n,a)=>o+"_"+a)}function Me(o){let t={};return o.map((n,a)=>{let{key:r,option:u,type:l}=n,f=Be(a);u?t[r]=`${f}---option`:l==="image"?t[r]=`${f}---image`:t[r]=f}),t}function Ae(o,t){return t.split(".").reduce((n,a)=>n&&n[a],o)}h.CmpDictionary=q,h.ConfrimButton=ne,h.ImportButton=ae,h.LayOutForm=te,h.ListPage=he,h.OnePortalCasSDK=De,h.SearchBar=Z,h.StatusMap=j,h._toRaw=ze,h.arrToStatusMap=Ne,h.arrayToTree=Oe,h.checkFileSize=Ue,h.creatValidator=me,h.createImportFields=Me,h.createListPageId=Le,h.crypto=ge,h.exportExcel=we,h.getValueBykey=Ae,h.importExcel=_e,h.sleep=Ee,h.stringToArray=ve,h.stripHtmlTags=Ie,h.unicode2Str=Fe,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joy-admin-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"main": "./dist/joy-admin-components.umd.js",
|
|
5
5
|
"module": "./dist/joy-admin-components.es.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -14,24 +14,18 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
16
|
"src/index.d.ts",
|
|
17
|
-
"src/components/**/*.d.ts"
|
|
17
|
+
"src/components/**/*.d.ts",
|
|
18
|
+
"src/utils/index.d.ts"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
21
|
"dev": "vite",
|
|
21
22
|
"build": "vite build",
|
|
22
23
|
"preview": "vite preview",
|
|
23
|
-
"pub-patch": "npm version patch && npm publish",
|
|
24
|
-
"pub-minor": "npm version minor && npm publish",
|
|
25
|
-
"pub-major": "npm version major && npm publish"
|
|
24
|
+
"pub-patch": "npm run build && npm version patch && npm publish",
|
|
25
|
+
"pub-minor": "npm run build && npm version minor && npm publish",
|
|
26
|
+
"pub-major": "npm run build && npm version major && npm publish"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"vue": "^3.3.4",
|
|
30
|
-
"element-plus": "^2.3.8",
|
|
31
|
-
"@vitejs/plugin-vue": "^4.2.3",
|
|
32
|
-
"vite": "^4.4.6",
|
|
33
|
-
"vue-i18n": "^9.10.1"
|
|
34
|
-
},
|
|
35
29
|
"devDependencies": {
|
|
36
30
|
"@vitejs/plugin-vue": "^4.6.2",
|
|
37
31
|
"element-plus": "^2.13.2",
|
package/src/index.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export * from './components/ImportButton/index';
|
|
|
6
6
|
export * from './components/ListPage/index';
|
|
7
7
|
export * from './components/SearchBar/index';
|
|
8
8
|
|
|
9
|
+
// 导出工具函数类型
|
|
10
|
+
export * from './utils/index';
|
|
11
|
+
|
|
9
12
|
// 导出组件
|
|
10
13
|
export { default as LayOutForm } from './components/LayOutForm/index.vue';
|
|
11
14
|
export { default as CmpDictionary } from './components/CmpDictionary/index.vue';
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// 验证工具类型
|
|
2
|
+
export interface ValidatorOptions {
|
|
3
|
+
/** 是否在表单中使用,默认 true */
|
|
4
|
+
inForm?: boolean;
|
|
5
|
+
/** 是否必填,默认 true */
|
|
6
|
+
required?: boolean;
|
|
7
|
+
/** 要验证的值(非表单模式) */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** 错误提示信息 */
|
|
10
|
+
msg?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 创建表单验证器
|
|
15
|
+
* @param type 验证类型:'phone' | 'password' | 'email'
|
|
16
|
+
* @param opt 验证选项
|
|
17
|
+
*/
|
|
18
|
+
export function creatValidator(
|
|
19
|
+
type: 'phone' | 'password' | 'email',
|
|
20
|
+
opt?: ValidatorOptions
|
|
21
|
+
): boolean | ((rule: any, value: any, callback: any) => void);
|
|
22
|
+
|
|
23
|
+
// 加密工具类型
|
|
24
|
+
export interface CryptoUtil {
|
|
25
|
+
/**
|
|
26
|
+
* AES 加密
|
|
27
|
+
* @param word 要加密的内容
|
|
28
|
+
* @param keyStr 加密密钥,默认使用内置密钥
|
|
29
|
+
*/
|
|
30
|
+
encrypt(word: string, keyStr?: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* AES 解密
|
|
33
|
+
* @param word 要解密的内容
|
|
34
|
+
* @param keyStr 解密密钥,默认使用内置密钥
|
|
35
|
+
*/
|
|
36
|
+
decrypt(word: string, keyStr?: string): string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const crypto: CryptoUtil;
|
|
40
|
+
|
|
41
|
+
// Excel 工具类型
|
|
42
|
+
export interface ImportExcelOptions {
|
|
43
|
+
/** 其他选项 */
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ExportExcelOptions {
|
|
48
|
+
/** 其他选项 */
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 导入 Excel 文件
|
|
54
|
+
* @param file Excel 文件对象
|
|
55
|
+
* @param options 导入选项
|
|
56
|
+
*/
|
|
57
|
+
export function importExcel(file: File, options?: ImportExcelOptions): Promise<any>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 导出 Excel 文件
|
|
61
|
+
* @param tableName 表格名称
|
|
62
|
+
* @param tableHeader 表头配置
|
|
63
|
+
* @param tableData 表格数据
|
|
64
|
+
* @param options 导出选项
|
|
65
|
+
*/
|
|
66
|
+
export function exportExcel(
|
|
67
|
+
tableName: string,
|
|
68
|
+
tableHeader: any[],
|
|
69
|
+
tableData?: any[],
|
|
70
|
+
options?: ExportExcelOptions
|
|
71
|
+
): Promise<void>;
|
|
72
|
+
|
|
73
|
+
// 单点登录 SDK 类型
|
|
74
|
+
export default class OnePortalCasSDK {
|
|
75
|
+
constructor(...args: any[]);
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 通用工具函数类型
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 延迟执行(Promise 版本)
|
|
83
|
+
* @param wait 等待时间(毫秒)
|
|
84
|
+
*/
|
|
85
|
+
export function sleep(wait: number): Promise<void>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 深度克隆对象(通过 JSON 序列化)
|
|
89
|
+
* @param data 要克隆的数据
|
|
90
|
+
*/
|
|
91
|
+
export function _toRaw<T>(data: T): T;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 将扁平数组转换为树形结构
|
|
95
|
+
* @param items 扁平数组,每项需包含 id 和 pid 属性
|
|
96
|
+
*/
|
|
97
|
+
export function arrayToTree<T extends { id: any; pid: any }>(items: T[]): T[];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 将字符串按指定字符分割为数组
|
|
101
|
+
* @param str 要分割的字符串
|
|
102
|
+
* @param split 分隔符,默认为空格
|
|
103
|
+
*/
|
|
104
|
+
export function stringToArray(str: string, split?: string): string[];
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* StatusMap 类 - 创建一个可遍历、可快速取值的状态映射数据结构
|
|
108
|
+
*/
|
|
109
|
+
export class StatusMap {
|
|
110
|
+
list: any[];
|
|
111
|
+
map: Map<any, any>;
|
|
112
|
+
|
|
113
|
+
constructor(arrStatus: any[], keys?: string[]);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 根据 key 获取名称(支持多语言)
|
|
117
|
+
* @param key 状态值
|
|
118
|
+
* @param locale 语言环境,如 'zh_cn' 或 'en_us'
|
|
119
|
+
*/
|
|
120
|
+
getName(key: any, locale?: string): string;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 根据 key 获取标签类型
|
|
124
|
+
* @param key 状态值
|
|
125
|
+
*/
|
|
126
|
+
getTag(key: any): string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 根据 key 获取完整数据项
|
|
130
|
+
* @param key 状态值
|
|
131
|
+
*/
|
|
132
|
+
getItem(key: any): any | null;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 根据 key 获取颜色
|
|
136
|
+
* @param key 状态值
|
|
137
|
+
*/
|
|
138
|
+
getColor(key: any): string | null;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 检查是否包含某个 key
|
|
142
|
+
* @param key 状态值
|
|
143
|
+
*/
|
|
144
|
+
has(key: any): boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 将数组转换为 StatusMap 对象
|
|
149
|
+
* @param arr 数组数据
|
|
150
|
+
* @param keys 键名映射数组,至少需要 2 个元素 [label键, value键, ...]
|
|
151
|
+
* @param labelEn 英文标签字段名,默认 'i18nName'
|
|
152
|
+
*/
|
|
153
|
+
export function arrToStatusMap(arr: any[], keys: string[], labelEn?: string): StatusMap;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 去除 HTML 标签
|
|
157
|
+
* @param html 包含 HTML 标签的字符串
|
|
158
|
+
*/
|
|
159
|
+
export function stripHtmlTags(html: string): string;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 将 Unicode 编码转换为普通字符串
|
|
163
|
+
* @param unicodeStr Unicode 字符串
|
|
164
|
+
*/
|
|
165
|
+
export function unicode2Str(unicodeStr: string): string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 检查文件大小是否超过限制
|
|
169
|
+
* @param file 要检查的文件对象
|
|
170
|
+
* @param size 限制的文件大小(单位:MB),默认 10MB
|
|
171
|
+
* @returns 如果文件大小未超过限制,返回 true;否则返回 false
|
|
172
|
+
*/
|
|
173
|
+
export function checkFileSize(file: File, size?: number): boolean;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 根据页面名称创建 ListPage 的 ID 数组
|
|
177
|
+
* @param name 页面名称
|
|
178
|
+
*/
|
|
179
|
+
export function createListPageId(name: string): string[];
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 根据表头生成导入字段映射
|
|
183
|
+
* @param header 表头配置数组
|
|
184
|
+
* @returns 字段映射对象
|
|
185
|
+
*/
|
|
186
|
+
export function createImportFields(header: any[]): Record<string, string>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 根据链式 key 获取对象的值
|
|
190
|
+
* @param object 目标对象
|
|
191
|
+
* @param chainKey 链式 key,如 'a.b.c'
|
|
192
|
+
*/
|
|
193
|
+
export function getValueBykey<T = any>(object: any, chainKey: string): T | undefined;
|