@banmao/hooks 0.0.5 → 0.0.6
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/index.cjs +1 -0
- package/dist/index.js +623 -4
- package/dist/useAsyncData/index.d.ts +2 -7
- package/dist/useDeviceInfo.d.ts +1 -1
- package/dist/useList/index.d.ts +5 -5
- package/dist/useList/types.d.ts +1 -1
- package/dist/useTableHeight.d.ts +1 -1
- package/package.json +4 -4
- package/dist/useAsyncData/index.js +0 -37
- package/dist/useAsyncData/types.js +0 -1
- package/dist/useDeviceInfo.js +0 -40
- package/dist/useExportRemoteFile/index.js +0 -56
- package/dist/useList/index.js +0 -127
- package/dist/useList/types.js +0 -1
- package/dist/useTableHeight.js +0 -39
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue");function ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q={exports:{}},le=Q.exports,re;function de(){return re||(re=1,function(e,s){(function(d,m){e.exports=m()})(le,function(){var d=1e3,m=6e4,g=36e5,w="millisecond",p="second",i="minute",a="hour",v="day",M="week",c="month",S="quarter",b="year",D="date",T="Invalid Date",G=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,X=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,O={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(l){var r=["th","st","nd","rd"],t=l%100;return"["+l+(r[(t-20)%10]||r[t]||r[0])+"]"}},j=function(l,r,t){var o=String(l);return!o||o.length>=r?l:""+Array(r+1-o.length).join(t)+l},R={s:j,z:function(l){var r=-l.utcOffset(),t=Math.abs(r),o=Math.floor(t/60),n=t%60;return(r<=0?"+":"-")+j(o,2,"0")+":"+j(n,2,"0")},m:function l(r,t){if(r.date()<t.date())return-l(t,r);var o=12*(t.year()-r.year())+(t.month()-r.month()),n=r.clone().add(o,c),f=t-n<0,h=r.clone().add(o+(f?-1:1),c);return+(-(o+(t-n)/(f?n-h:h-n))||0)},a:function(l){return l<0?Math.ceil(l)||0:Math.floor(l)},p:function(l){return{M:c,y:b,w:M,d:v,D,h:a,m:i,s:p,ms:w,Q:S}[l]||String(l||"").toLowerCase().replace(/s$/,"")},u:function(l){return l===void 0}},H="en",I={};I[H]=O;var q="$isDayjsObject",P=function(l){return l instanceof K||!(!l||!l[q])},N=function l(r,t,o){var n;if(!r)return H;if(typeof r=="string"){var f=r.toLowerCase();I[f]&&(n=f),t&&(I[f]=t,n=f);var h=r.split("-");if(!n&&h.length>1)return l(h[0])}else{var y=r.name;I[y]=r,n=y}return!o&&n&&(H=n),n||!o&&H},C=function(l,r){if(P(l))return l.clone();var t=typeof r=="object"?r:{};return t.date=l,t.args=arguments,new K(t)},$=R;$.l=N,$.i=P,$.w=function(l,r){return C(l,{locale:r.$L,utc:r.$u,x:r.$x,$offset:r.$offset})};var K=function(){function l(t){this.$L=N(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[q]=!0}var r=l.prototype;return r.parse=function(t){this.$d=function(o){var n=o.date,f=o.utc;if(n===null)return new Date(NaN);if($.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var h=n.match(G);if(h){var y=h[2]-1||0,x=(h[7]||"0").substring(0,3);return f?new Date(Date.UTC(h[1],y,h[3]||1,h[4]||0,h[5]||0,h[6]||0,x)):new Date(h[1],y,h[3]||1,h[4]||0,h[5]||0,h[6]||0,x)}}return new Date(n)}(t),this.init()},r.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},r.$utils=function(){return $},r.isValid=function(){return this.$d.toString()!==T},r.isSame=function(t,o){var n=C(t);return this.startOf(o)<=n&&n<=this.endOf(o)},r.isAfter=function(t,o){return C(t)<this.startOf(o)},r.isBefore=function(t,o){return this.endOf(o)<C(t)},r.$g=function(t,o,n){return $.u(t)?this[o]:this.set(n,t)},r.unix=function(){return Math.floor(this.valueOf()/1e3)},r.valueOf=function(){return this.$d.getTime()},r.startOf=function(t,o){var n=this,f=!!$.u(o)||o,h=$.p(t),y=function(V,_){var L=$.w(n.$u?Date.UTC(n.$y,_,V):new Date(n.$y,_,V),n);return f?L:L.endOf(v)},x=function(V,_){return $.w(n.toDate()[V].apply(n.toDate("s"),(f?[0,0,0,0]:[23,59,59,999]).slice(_)),n)},E=this.$W,W=this.$M,k=this.$D,Y="set"+(this.$u?"UTC":"");switch(h){case b:return f?y(1,0):y(31,11);case c:return f?y(1,W):y(0,W+1);case M:var z=this.$locale().weekStart||0,F=(E<z?E+7:E)-z;return y(f?k-F:k+(6-F),W);case v:case D:return x(Y+"Hours",0);case a:return x(Y+"Minutes",1);case i:return x(Y+"Seconds",2);case p:return x(Y+"Milliseconds",3);default:return this.clone()}},r.endOf=function(t){return this.startOf(t,!1)},r.$set=function(t,o){var n,f=$.p(t),h="set"+(this.$u?"UTC":""),y=(n={},n[v]=h+"Date",n[D]=h+"Date",n[c]=h+"Month",n[b]=h+"FullYear",n[a]=h+"Hours",n[i]=h+"Minutes",n[p]=h+"Seconds",n[w]=h+"Milliseconds",n)[f],x=f===v?this.$D+(o-this.$W):o;if(f===c||f===b){var E=this.clone().set(D,1);E.$d[y](x),E.init(),this.$d=E.set(D,Math.min(this.$D,E.daysInMonth())).$d}else y&&this.$d[y](x);return this.init(),this},r.set=function(t,o){return this.clone().$set(t,o)},r.get=function(t){return this[$.p(t)]()},r.add=function(t,o){var n,f=this;t=Number(t);var h=$.p(o),y=function(W){var k=C(f);return $.w(k.date(k.date()+Math.round(W*t)),f)};if(h===c)return this.set(c,this.$M+t);if(h===b)return this.set(b,this.$y+t);if(h===v)return y(1);if(h===M)return y(7);var x=(n={},n[i]=m,n[a]=g,n[p]=d,n)[h]||1,E=this.$d.getTime()+t*x;return $.w(E,this)},r.subtract=function(t,o){return this.add(-1*t,o)},r.format=function(t){var o=this,n=this.$locale();if(!this.isValid())return n.invalidDate||T;var f=t||"YYYY-MM-DDTHH:mm:ssZ",h=$.z(this),y=this.$H,x=this.$m,E=this.$M,W=n.weekdays,k=n.months,Y=n.meridiem,z=function(_,L,U,J){return _&&(_[L]||_(o,f))||U[L].slice(0,J)},F=function(_){return $.s(y%12||12,_,"0")},V=Y||function(_,L,U){var J=_<12?"AM":"PM";return U?J.toLowerCase():J};return f.replace(X,function(_,L){return L||function(U){switch(U){case"YY":return String(o.$y).slice(-2);case"YYYY":return $.s(o.$y,4,"0");case"M":return E+1;case"MM":return $.s(E+1,2,"0");case"MMM":return z(n.monthsShort,E,k,3);case"MMMM":return z(k,E);case"D":return o.$D;case"DD":return $.s(o.$D,2,"0");case"d":return String(o.$W);case"dd":return z(n.weekdaysMin,o.$W,W,2);case"ddd":return z(n.weekdaysShort,o.$W,W,3);case"dddd":return W[o.$W];case"H":return String(y);case"HH":return $.s(y,2,"0");case"h":return F(1);case"hh":return F(2);case"a":return V(y,x,!0);case"A":return V(y,x,!1);case"m":return String(x);case"mm":return $.s(x,2,"0");case"s":return String(o.$s);case"ss":return $.s(o.$s,2,"0");case"SSS":return $.s(o.$ms,3,"0");case"Z":return h}return null}(_)||h.replace(":","")})},r.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},r.diff=function(t,o,n){var f,h=this,y=$.p(o),x=C(t),E=(x.utcOffset()-this.utcOffset())*m,W=this-x,k=function(){return $.m(h,x)};switch(y){case b:f=k()/12;break;case c:f=k();break;case S:f=k()/3;break;case M:f=(W-E)/6048e5;break;case v:f=(W-E)/864e5;break;case a:f=W/g;break;case i:f=W/m;break;case p:f=W/d;break;default:f=W}return n?f:$.a(f)},r.daysInMonth=function(){return this.endOf(c).$D},r.$locale=function(){return I[this.$L]},r.locale=function(t,o){if(!t)return this.$L;var n=this.clone(),f=N(t,o,!0);return f&&(n.$L=f),n},r.clone=function(){return $.w(this.$d,this)},r.toDate=function(){return new Date(this.valueOf())},r.toJSON=function(){return this.isValid()?this.toISOString():null},r.toISOString=function(){return this.$d.toISOString()},r.toString=function(){return this.$d.toUTCString()},l}(),ne=K.prototype;return C.prototype=ne,[["$ms",w],["$s",p],["$m",i],["$H",a],["$W",v],["$M",c],["$y",b],["$D",D]].forEach(function(l){ne[l[1]]=function(r){return this.$g(r,l[0],l[1])}}),C.extend=function(l,r){return l.$i||(l(r,K,C),l.$i=!0),C},C.locale=N,C.isDayjs=P,C.unix=function(l){return C(1e3*l)},C.en=I[H],C.Ls=I,C.p={},C})}(Q)),Q.exports}var fe=de();const he=ce(fe);function ve(e){const s=new Blob([e],{type:"application/vnd.ms-excel"});return window.URL.createObjectURL(s)}function me(){return document.createElement("a")}function oe(e,s){const d=he().format("yyyy-MM-dd hh:mm:ss");function m(){const g=me(),w=ve(e);g.href=w,s?g.download=s||`${s}-${d}.xlsx`:g.download=`${d}.xlsx`,document.body.appendChild(g),g.click(),document.body.removeChild(g),window.URL.revokeObjectURL(w)}m()}function pe(e,s){throw new Error(`[naive/${e}]: ${s}`)}const ge="n-message-api";function we(){const e=u.inject(ge,null);return e===null&&pe("use-message","No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."),e}function $e(e,s={}){const{exportRequestFn:d,filterOption:m=u.ref(),callback:g,immediate:w=!0,code:p=200}=s,i=u.ref(!1),a=u.ref({page:1,pageSize:10,itemCount:0,showSizePicker:!0,pageSizes:[10,20,30,40],showQuickJumper:!0,prefix:O=>`共 ${O.itemCount} 条`}),v=u.ref([]),M=u.computed(()=>m.value),c=async(O=a.value.page,j)=>{i.value=!0;try{const{status:R,data:H}=await e({pageNum:O,pageSize:a.value.pageSize,...M.value,...j}),{list:I,pageNum:q,total:P,pageSize:N}=g&&g(H)||H;if(R===p&&Array.isArray(I))v.value=I,a.value={...a.value,page:q,itemCount:P,pageSize:N};else throw v.value=[],a.value={...a.value,pageSize:10,itemCount:0,page:1},new Error("list的数据类型错误")}catch(R){throw console.error("Error in loadData:",R),R}finally{i.value=!1}},S=we(),b=async()=>{if(!d||typeof d!="function")throw new Error("当前没有提供exportRequest函数");try{const{data:O,fileName:j}=await d(m.value);oe(O,j),S==null||S.success("成功导出")}catch(O){throw console.error("Error in handleExcelData:",O),O}},D=(O,j)=>{j!==void 0&&(a.value.pageSize=j),c(O)},T=O=>{D(O)},G=O=>{D(1,O)},X=O=>{if(O.sorter){const j=[...v.value].sort((R,H)=>O.order==="ascend"?R[O.columnKey]>H[O.columnKey]?1:-1:O.order==="descend"?R[O.columnKey]<H[O.columnKey]?1:-1:0);v.value=j}};return u.onMounted(()=>w&&c(a.value.page)),{dataSource:v,loading:i,pagination:a,handleExcelData:b,handlePageChange:T,handlePageSizeChange:G,handleSortChange:X,loadData:c}}function ie(e){return u.getCurrentScope()?(u.onScopeDispose(e),!0):!1}const ee=new WeakMap,ye=(...e)=>{var s;const d=e[0],m=(s=u.getCurrentInstance())==null?void 0:s.proxy;if(m==null&&!u.hasInjectionContext())throw new Error("injectLocal must be called in setup");return m&&ee.has(m)&&d in ee.get(m)?ee.get(m)[d]:u.inject(...e)},Me=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Se=Object.prototype.toString,be=e=>Se.call(e)==="[object Object]";function se(e){return e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e)}function Z(e){return Array.isArray(e)?e:[e]}function De(e){return u.getCurrentInstance()}function ue(e,s=!0,d){De()?u.onMounted(e,d):s?e():u.nextTick(e)}function Oe(e,s,d){return u.watch(e,s,{...d,immediate:!0})}const B=Me?window:void 0;function A(e){var s;const d=u.toValue(e);return(s=d==null?void 0:d.$el)!=null?s:d}function te(...e){const s=[],d=()=>{s.forEach(i=>i()),s.length=0},m=(i,a,v,M)=>(i.addEventListener(a,v,M),()=>i.removeEventListener(a,v,M)),g=u.computed(()=>{const i=Z(u.toValue(e[0])).filter(a=>a!=null);return i.every(a=>typeof a!="string")?i:void 0}),w=Oe(()=>{var i,a;return[(a=(i=g.value)==null?void 0:i.map(v=>A(v)))!=null?a:[B].filter(v=>v!=null),Z(u.toValue(g.value?e[1]:e[0])),Z(u.unref(g.value?e[2]:e[1])),u.toValue(g.value?e[3]:e[2])]},([i,a,v,M])=>{if(d(),!(i!=null&&i.length)||!(a!=null&&a.length)||!(v!=null&&v.length))return;const c=be(M)?{...M}:M;s.push(...i.flatMap(S=>a.flatMap(b=>v.map(D=>m(S,b,D,c)))))},{flush:"post"}),p=()=>{w(),d()};return ie(d),p}function xe(){const e=u.shallowRef(!1),s=u.getCurrentInstance();return s&&u.onMounted(()=>{e.value=!0},s),e}function ae(e){const s=xe();return u.computed(()=>(s.value,!!e()))}const Ce=Symbol("vueuse-ssr-width");function Ee(){const e=u.hasInjectionContext()?ye(Ce,null):null;return typeof e=="number"?e:void 0}function We(e,s={}){const{window:d=B,ssrWidth:m=Ee()}=s,g=ae(()=>d&&"matchMedia"in d&&typeof d.matchMedia=="function"),w=u.shallowRef(typeof m=="number"),p=u.shallowRef(),i=u.shallowRef(!1),a=v=>{i.value=v.matches};return u.watchEffect(()=>{if(w.value){w.value=!g.value;const v=u.toValue(e).split(",");i.value=v.some(M=>{const c=M.includes("not all"),S=M.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),b=M.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);let D=!!(S||b);return S&&D&&(D=m>=se(S[1])),b&&D&&(D=m<=se(b[1])),c?!D:D});return}g.value&&(p.value=d.matchMedia(u.toValue(e)),i.value=p.value.matches)}),te(p,"change",a,{passive:!0}),u.computed(()=>i.value)}function _e(e,s,d={}){const{window:m=B,...g}=d;let w;const p=ae(()=>m&&"ResizeObserver"in m),i=()=>{w&&(w.disconnect(),w=void 0)},a=u.computed(()=>{const c=u.toValue(e);return Array.isArray(c)?c.map(S=>A(S)):[A(c)]}),v=u.watch(a,c=>{if(i(),p.value&&m){w=new ResizeObserver(s);for(const S of c)S&&w.observe(S,g)}},{immediate:!0,flush:"post"}),M=()=>{i(),v()};return ie(M),{isSupported:p,stop:M}}function je(e,s={width:0,height:0},d={}){const{window:m=B,box:g="content-box"}=d,w=u.computed(()=>{var c,S;return(S=(c=A(e))==null?void 0:c.namespaceURI)==null?void 0:S.includes("svg")}),p=u.shallowRef(s.width),i=u.shallowRef(s.height),{stop:a}=_e(e,([c])=>{const S=g==="border-box"?c.borderBoxSize:g==="content-box"?c.contentBoxSize:c.devicePixelContentBoxSize;if(m&&w.value){const b=A(e);if(b){const D=b.getBoundingClientRect();p.value=D.width,i.value=D.height}}else if(S){const b=Z(S);p.value=b.reduce((D,{inlineSize:T})=>D+T,0),i.value=b.reduce((D,{blockSize:T})=>D+T,0)}else p.value=c.contentRect.width,i.value=c.contentRect.height},d);ue(()=>{const c=A(e);c&&(p.value="offsetWidth"in c?c.offsetWidth:s.width,i.value="offsetHeight"in c?c.offsetHeight:s.height)});const v=u.watch(()=>A(e),c=>{p.value=c?s.width:0,i.value=c?s.height:0});function M(){a(),v()}return{width:p,height:i,stop:M}}function ke(e={}){const{window:s=B,initialWidth:d=Number.POSITIVE_INFINITY,initialHeight:m=Number.POSITIVE_INFINITY,listenOrientation:g=!0,includeScrollbar:w=!0,type:p="inner"}=e,i=u.shallowRef(d),a=u.shallowRef(m),v=()=>{if(s)if(p==="outer")i.value=s.outerWidth,a.value=s.outerHeight;else if(p==="visual"&&s.visualViewport){const{width:c,height:S,scale:b}=s.visualViewport;i.value=Math.round(c*b),a.value=Math.round(S*b)}else w?(i.value=s.innerWidth,a.value=s.innerHeight):(i.value=s.document.documentElement.clientWidth,a.value=s.document.documentElement.clientHeight)};v(),ue(v);const M={passive:!0};if(te("resize",v,M),s&&p==="visual"&&s.visualViewport&&te(s.visualViewport,"resize",v,M),g){const c=We("(orientation: portrait)");u.watch(c,()=>v())}return{width:i,height:a}}function He(e,s){if(!e)throw new Error("tableRef are required");const d=u.computed(()=>{var a;return(a=e.value)==null?void 0:a.searchRef}),{height:m}=ke(),{height:g}=je(d),{height:w=0,minHeight:p=600}=s||{};return{height:u.computed(()=>{const a=m.value-g.value-w;return a>p?a:p})}}function Ie(e,s){const{immediate:d=!0}=s||{},m=u.ref(null),g=u.ref(!1),w=u.ref(null),p=async()=>{g.value=!0,w.value=null;try{const i=await e();m.value=i}catch(i){w.value=i}finally{g.value=!1}};return d&&p(),{data:m,loading:g,error:w,fetchData:p}}exports.useAsyncData=Ie;exports.useExportFile=oe;exports.useList=$e;exports.useTableHeight=He;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,623 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { inject as de, ref as Y, computed as A, onMounted as oe, nextTick as pe, getCurrentInstance as ue, watch as te, getCurrentScope as ge, onScopeDispose as we, hasInjectionContext as fe, shallowRef as T, toValue as P, watchEffect as $e, unref as ye } from "vue";
|
|
2
|
+
function Me(e) {
|
|
3
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
|
+
}
|
|
5
|
+
var X = { exports: {} }, Se = X.exports, ce;
|
|
6
|
+
function be() {
|
|
7
|
+
return ce || (ce = 1, function(e, s) {
|
|
8
|
+
(function(l, v) {
|
|
9
|
+
e.exports = v();
|
|
10
|
+
})(Se, function() {
|
|
11
|
+
var l = 1e3, v = 6e4, p = 36e5, g = "millisecond", m = "second", o = "minute", u = "hour", h = "day", y = "week", a = "month", M = "quarter", S = "year", b = "date", z = "Invalid Date", ne = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, re = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, D = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(c) {
|
|
12
|
+
var r = ["th", "st", "nd", "rd"], t = c % 100;
|
|
13
|
+
return "[" + c + (r[(t - 20) % 10] || r[t] || r[0]) + "]";
|
|
14
|
+
} }, C = function(c, r, t) {
|
|
15
|
+
var i = String(c);
|
|
16
|
+
return !i || i.length >= r ? c : "" + Array(r + 1 - i.length).join(t) + c;
|
|
17
|
+
}, I = { s: C, z: function(c) {
|
|
18
|
+
var r = -c.utcOffset(), t = Math.abs(r), i = Math.floor(t / 60), n = t % 60;
|
|
19
|
+
return (r <= 0 ? "+" : "-") + C(i, 2, "0") + ":" + C(n, 2, "0");
|
|
20
|
+
}, m: function c(r, t) {
|
|
21
|
+
if (r.date() < t.date()) return -c(t, r);
|
|
22
|
+
var i = 12 * (t.year() - r.year()) + (t.month() - r.month()), n = r.clone().add(i, a), d = t - n < 0, f = r.clone().add(i + (d ? -1 : 1), a);
|
|
23
|
+
return +(-(i + (t - n) / (d ? n - f : f - n)) || 0);
|
|
24
|
+
}, a: function(c) {
|
|
25
|
+
return c < 0 ? Math.ceil(c) || 0 : Math.floor(c);
|
|
26
|
+
}, p: function(c) {
|
|
27
|
+
return { M: a, y: S, w: y, d: h, D: b, h: u, m: o, s: m, ms: g, Q: M }[c] || String(c || "").toLowerCase().replace(/s$/, "");
|
|
28
|
+
}, u: function(c) {
|
|
29
|
+
return c === void 0;
|
|
30
|
+
} }, j = "en", H = {};
|
|
31
|
+
H[j] = D;
|
|
32
|
+
var Q = "$isDayjsObject", B = function(c) {
|
|
33
|
+
return c instanceof Z || !(!c || !c[Q]);
|
|
34
|
+
}, F = function c(r, t, i) {
|
|
35
|
+
var n;
|
|
36
|
+
if (!r) return j;
|
|
37
|
+
if (typeof r == "string") {
|
|
38
|
+
var d = r.toLowerCase();
|
|
39
|
+
H[d] && (n = d), t && (H[d] = t, n = d);
|
|
40
|
+
var f = r.split("-");
|
|
41
|
+
if (!n && f.length > 1) return c(f[0]);
|
|
42
|
+
} else {
|
|
43
|
+
var $ = r.name;
|
|
44
|
+
H[$] = r, n = $;
|
|
45
|
+
}
|
|
46
|
+
return !i && n && (j = n), n || !i && j;
|
|
47
|
+
}, x = function(c, r) {
|
|
48
|
+
if (B(c)) return c.clone();
|
|
49
|
+
var t = typeof r == "object" ? r : {};
|
|
50
|
+
return t.date = c, t.args = arguments, new Z(t);
|
|
51
|
+
}, w = I;
|
|
52
|
+
w.l = F, w.i = B, w.w = function(c, r) {
|
|
53
|
+
return x(c, { locale: r.$L, utc: r.$u, x: r.$x, $offset: r.$offset });
|
|
54
|
+
};
|
|
55
|
+
var Z = function() {
|
|
56
|
+
function c(t) {
|
|
57
|
+
this.$L = F(t.locale, null, !0), this.parse(t), this.$x = this.$x || t.x || {}, this[Q] = !0;
|
|
58
|
+
}
|
|
59
|
+
var r = c.prototype;
|
|
60
|
+
return r.parse = function(t) {
|
|
61
|
+
this.$d = function(i) {
|
|
62
|
+
var n = i.date, d = i.utc;
|
|
63
|
+
if (n === null) return /* @__PURE__ */ new Date(NaN);
|
|
64
|
+
if (w.u(n)) return /* @__PURE__ */ new Date();
|
|
65
|
+
if (n instanceof Date) return new Date(n);
|
|
66
|
+
if (typeof n == "string" && !/Z$/i.test(n)) {
|
|
67
|
+
var f = n.match(ne);
|
|
68
|
+
if (f) {
|
|
69
|
+
var $ = f[2] - 1 || 0, O = (f[7] || "0").substring(0, 3);
|
|
70
|
+
return d ? new Date(Date.UTC(f[1], $, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, O)) : new Date(f[1], $, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, O);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return new Date(n);
|
|
74
|
+
}(t), this.init();
|
|
75
|
+
}, r.init = function() {
|
|
76
|
+
var t = this.$d;
|
|
77
|
+
this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds();
|
|
78
|
+
}, r.$utils = function() {
|
|
79
|
+
return w;
|
|
80
|
+
}, r.isValid = function() {
|
|
81
|
+
return this.$d.toString() !== z;
|
|
82
|
+
}, r.isSame = function(t, i) {
|
|
83
|
+
var n = x(t);
|
|
84
|
+
return this.startOf(i) <= n && n <= this.endOf(i);
|
|
85
|
+
}, r.isAfter = function(t, i) {
|
|
86
|
+
return x(t) < this.startOf(i);
|
|
87
|
+
}, r.isBefore = function(t, i) {
|
|
88
|
+
return this.endOf(i) < x(t);
|
|
89
|
+
}, r.$g = function(t, i, n) {
|
|
90
|
+
return w.u(t) ? this[i] : this.set(n, t);
|
|
91
|
+
}, r.unix = function() {
|
|
92
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
93
|
+
}, r.valueOf = function() {
|
|
94
|
+
return this.$d.getTime();
|
|
95
|
+
}, r.startOf = function(t, i) {
|
|
96
|
+
var n = this, d = !!w.u(i) || i, f = w.p(t), $ = function(N, _) {
|
|
97
|
+
var L = w.w(n.$u ? Date.UTC(n.$y, _, N) : new Date(n.$y, _, N), n);
|
|
98
|
+
return d ? L : L.endOf(h);
|
|
99
|
+
}, O = function(N, _) {
|
|
100
|
+
return w.w(n.toDate()[N].apply(n.toDate("s"), (d ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(_)), n);
|
|
101
|
+
}, W = this.$W, E = this.$M, k = this.$D, U = "set" + (this.$u ? "UTC" : "");
|
|
102
|
+
switch (f) {
|
|
103
|
+
case S:
|
|
104
|
+
return d ? $(1, 0) : $(31, 11);
|
|
105
|
+
case a:
|
|
106
|
+
return d ? $(1, E) : $(0, E + 1);
|
|
107
|
+
case y:
|
|
108
|
+
var R = this.$locale().weekStart || 0, K = (W < R ? W + 7 : W) - R;
|
|
109
|
+
return $(d ? k - K : k + (6 - K), E);
|
|
110
|
+
case h:
|
|
111
|
+
case b:
|
|
112
|
+
return O(U + "Hours", 0);
|
|
113
|
+
case u:
|
|
114
|
+
return O(U + "Minutes", 1);
|
|
115
|
+
case o:
|
|
116
|
+
return O(U + "Seconds", 2);
|
|
117
|
+
case m:
|
|
118
|
+
return O(U + "Milliseconds", 3);
|
|
119
|
+
default:
|
|
120
|
+
return this.clone();
|
|
121
|
+
}
|
|
122
|
+
}, r.endOf = function(t) {
|
|
123
|
+
return this.startOf(t, !1);
|
|
124
|
+
}, r.$set = function(t, i) {
|
|
125
|
+
var n, d = w.p(t), f = "set" + (this.$u ? "UTC" : ""), $ = (n = {}, n[h] = f + "Date", n[b] = f + "Date", n[a] = f + "Month", n[S] = f + "FullYear", n[u] = f + "Hours", n[o] = f + "Minutes", n[m] = f + "Seconds", n[g] = f + "Milliseconds", n)[d], O = d === h ? this.$D + (i - this.$W) : i;
|
|
126
|
+
if (d === a || d === S) {
|
|
127
|
+
var W = this.clone().set(b, 1);
|
|
128
|
+
W.$d[$](O), W.init(), this.$d = W.set(b, Math.min(this.$D, W.daysInMonth())).$d;
|
|
129
|
+
} else $ && this.$d[$](O);
|
|
130
|
+
return this.init(), this;
|
|
131
|
+
}, r.set = function(t, i) {
|
|
132
|
+
return this.clone().$set(t, i);
|
|
133
|
+
}, r.get = function(t) {
|
|
134
|
+
return this[w.p(t)]();
|
|
135
|
+
}, r.add = function(t, i) {
|
|
136
|
+
var n, d = this;
|
|
137
|
+
t = Number(t);
|
|
138
|
+
var f = w.p(i), $ = function(E) {
|
|
139
|
+
var k = x(d);
|
|
140
|
+
return w.w(k.date(k.date() + Math.round(E * t)), d);
|
|
141
|
+
};
|
|
142
|
+
if (f === a) return this.set(a, this.$M + t);
|
|
143
|
+
if (f === S) return this.set(S, this.$y + t);
|
|
144
|
+
if (f === h) return $(1);
|
|
145
|
+
if (f === y) return $(7);
|
|
146
|
+
var O = (n = {}, n[o] = v, n[u] = p, n[m] = l, n)[f] || 1, W = this.$d.getTime() + t * O;
|
|
147
|
+
return w.w(W, this);
|
|
148
|
+
}, r.subtract = function(t, i) {
|
|
149
|
+
return this.add(-1 * t, i);
|
|
150
|
+
}, r.format = function(t) {
|
|
151
|
+
var i = this, n = this.$locale();
|
|
152
|
+
if (!this.isValid()) return n.invalidDate || z;
|
|
153
|
+
var d = t || "YYYY-MM-DDTHH:mm:ssZ", f = w.z(this), $ = this.$H, O = this.$m, W = this.$M, E = n.weekdays, k = n.months, U = n.meridiem, R = function(_, L, q, G) {
|
|
154
|
+
return _ && (_[L] || _(i, d)) || q[L].slice(0, G);
|
|
155
|
+
}, K = function(_) {
|
|
156
|
+
return w.s($ % 12 || 12, _, "0");
|
|
157
|
+
}, N = U || function(_, L, q) {
|
|
158
|
+
var G = _ < 12 ? "AM" : "PM";
|
|
159
|
+
return q ? G.toLowerCase() : G;
|
|
160
|
+
};
|
|
161
|
+
return d.replace(re, function(_, L) {
|
|
162
|
+
return L || function(q) {
|
|
163
|
+
switch (q) {
|
|
164
|
+
case "YY":
|
|
165
|
+
return String(i.$y).slice(-2);
|
|
166
|
+
case "YYYY":
|
|
167
|
+
return w.s(i.$y, 4, "0");
|
|
168
|
+
case "M":
|
|
169
|
+
return W + 1;
|
|
170
|
+
case "MM":
|
|
171
|
+
return w.s(W + 1, 2, "0");
|
|
172
|
+
case "MMM":
|
|
173
|
+
return R(n.monthsShort, W, k, 3);
|
|
174
|
+
case "MMMM":
|
|
175
|
+
return R(k, W);
|
|
176
|
+
case "D":
|
|
177
|
+
return i.$D;
|
|
178
|
+
case "DD":
|
|
179
|
+
return w.s(i.$D, 2, "0");
|
|
180
|
+
case "d":
|
|
181
|
+
return String(i.$W);
|
|
182
|
+
case "dd":
|
|
183
|
+
return R(n.weekdaysMin, i.$W, E, 2);
|
|
184
|
+
case "ddd":
|
|
185
|
+
return R(n.weekdaysShort, i.$W, E, 3);
|
|
186
|
+
case "dddd":
|
|
187
|
+
return E[i.$W];
|
|
188
|
+
case "H":
|
|
189
|
+
return String($);
|
|
190
|
+
case "HH":
|
|
191
|
+
return w.s($, 2, "0");
|
|
192
|
+
case "h":
|
|
193
|
+
return K(1);
|
|
194
|
+
case "hh":
|
|
195
|
+
return K(2);
|
|
196
|
+
case "a":
|
|
197
|
+
return N($, O, !0);
|
|
198
|
+
case "A":
|
|
199
|
+
return N($, O, !1);
|
|
200
|
+
case "m":
|
|
201
|
+
return String(O);
|
|
202
|
+
case "mm":
|
|
203
|
+
return w.s(O, 2, "0");
|
|
204
|
+
case "s":
|
|
205
|
+
return String(i.$s);
|
|
206
|
+
case "ss":
|
|
207
|
+
return w.s(i.$s, 2, "0");
|
|
208
|
+
case "SSS":
|
|
209
|
+
return w.s(i.$ms, 3, "0");
|
|
210
|
+
case "Z":
|
|
211
|
+
return f;
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}(_) || f.replace(":", "");
|
|
215
|
+
});
|
|
216
|
+
}, r.utcOffset = function() {
|
|
217
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
218
|
+
}, r.diff = function(t, i, n) {
|
|
219
|
+
var d, f = this, $ = w.p(i), O = x(t), W = (O.utcOffset() - this.utcOffset()) * v, E = this - O, k = function() {
|
|
220
|
+
return w.m(f, O);
|
|
221
|
+
};
|
|
222
|
+
switch ($) {
|
|
223
|
+
case S:
|
|
224
|
+
d = k() / 12;
|
|
225
|
+
break;
|
|
226
|
+
case a:
|
|
227
|
+
d = k();
|
|
228
|
+
break;
|
|
229
|
+
case M:
|
|
230
|
+
d = k() / 3;
|
|
231
|
+
break;
|
|
232
|
+
case y:
|
|
233
|
+
d = (E - W) / 6048e5;
|
|
234
|
+
break;
|
|
235
|
+
case h:
|
|
236
|
+
d = (E - W) / 864e5;
|
|
237
|
+
break;
|
|
238
|
+
case u:
|
|
239
|
+
d = E / p;
|
|
240
|
+
break;
|
|
241
|
+
case o:
|
|
242
|
+
d = E / v;
|
|
243
|
+
break;
|
|
244
|
+
case m:
|
|
245
|
+
d = E / l;
|
|
246
|
+
break;
|
|
247
|
+
default:
|
|
248
|
+
d = E;
|
|
249
|
+
}
|
|
250
|
+
return n ? d : w.a(d);
|
|
251
|
+
}, r.daysInMonth = function() {
|
|
252
|
+
return this.endOf(a).$D;
|
|
253
|
+
}, r.$locale = function() {
|
|
254
|
+
return H[this.$L];
|
|
255
|
+
}, r.locale = function(t, i) {
|
|
256
|
+
if (!t) return this.$L;
|
|
257
|
+
var n = this.clone(), d = F(t, i, !0);
|
|
258
|
+
return d && (n.$L = d), n;
|
|
259
|
+
}, r.clone = function() {
|
|
260
|
+
return w.w(this.$d, this);
|
|
261
|
+
}, r.toDate = function() {
|
|
262
|
+
return new Date(this.valueOf());
|
|
263
|
+
}, r.toJSON = function() {
|
|
264
|
+
return this.isValid() ? this.toISOString() : null;
|
|
265
|
+
}, r.toISOString = function() {
|
|
266
|
+
return this.$d.toISOString();
|
|
267
|
+
}, r.toString = function() {
|
|
268
|
+
return this.$d.toUTCString();
|
|
269
|
+
}, c;
|
|
270
|
+
}(), ae = Z.prototype;
|
|
271
|
+
return x.prototype = ae, [["$ms", g], ["$s", m], ["$m", o], ["$H", u], ["$W", h], ["$M", a], ["$y", S], ["$D", b]].forEach(function(c) {
|
|
272
|
+
ae[c[1]] = function(r) {
|
|
273
|
+
return this.$g(r, c[0], c[1]);
|
|
274
|
+
};
|
|
275
|
+
}), x.extend = function(c, r) {
|
|
276
|
+
return c.$i || (c(r, Z, x), c.$i = !0), x;
|
|
277
|
+
}, x.locale = F, x.isDayjs = B, x.unix = function(c) {
|
|
278
|
+
return x(1e3 * c);
|
|
279
|
+
}, x.en = H[j], x.Ls = H, x.p = {}, x;
|
|
280
|
+
});
|
|
281
|
+
}(X)), X.exports;
|
|
282
|
+
}
|
|
283
|
+
var De = be();
|
|
284
|
+
const Oe = /* @__PURE__ */ Me(De);
|
|
285
|
+
function xe(e) {
|
|
286
|
+
const s = new Blob([e], {
|
|
287
|
+
type: "application/vnd.ms-excel"
|
|
288
|
+
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
289
|
+
});
|
|
290
|
+
return window.URL.createObjectURL(s);
|
|
291
|
+
}
|
|
292
|
+
function We() {
|
|
293
|
+
return document.createElement("a");
|
|
294
|
+
}
|
|
295
|
+
function Ee(e, s) {
|
|
296
|
+
const l = Oe().format("yyyy-MM-dd hh:mm:ss");
|
|
297
|
+
function v() {
|
|
298
|
+
const p = We(), g = xe(e);
|
|
299
|
+
p.href = g, s ? p.download = s || `${s}-${l}.xlsx` : p.download = `${l}.xlsx`, document.body.appendChild(p), p.click(), document.body.removeChild(p), window.URL.revokeObjectURL(g);
|
|
300
|
+
}
|
|
301
|
+
v();
|
|
302
|
+
}
|
|
303
|
+
function _e(e, s) {
|
|
304
|
+
throw new Error(`[naive/${e}]: ${s}`);
|
|
305
|
+
}
|
|
306
|
+
const Ce = "n-message-api";
|
|
307
|
+
function ke() {
|
|
308
|
+
const e = de(Ce, null);
|
|
309
|
+
return e === null && _e("use-message", "No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."), e;
|
|
310
|
+
}
|
|
311
|
+
function Be(e, s = {}) {
|
|
312
|
+
const {
|
|
313
|
+
exportRequestFn: l,
|
|
314
|
+
filterOption: v = Y(),
|
|
315
|
+
callback: p,
|
|
316
|
+
immediate: g = !0,
|
|
317
|
+
code: m = 200
|
|
318
|
+
} = s, o = Y(!1), u = Y({
|
|
319
|
+
page: 1,
|
|
320
|
+
pageSize: 10,
|
|
321
|
+
itemCount: 0,
|
|
322
|
+
showSizePicker: !0,
|
|
323
|
+
pageSizes: [10, 20, 30, 40],
|
|
324
|
+
showQuickJumper: !0,
|
|
325
|
+
prefix: (D) => `共 ${D.itemCount} 条`
|
|
326
|
+
}), h = Y([]), y = A(() => v.value), a = async (D = u.value.page, C) => {
|
|
327
|
+
o.value = !0;
|
|
328
|
+
try {
|
|
329
|
+
const { status: I, data: j } = await e({
|
|
330
|
+
pageNum: D,
|
|
331
|
+
pageSize: u.value.pageSize,
|
|
332
|
+
...y.value,
|
|
333
|
+
...C
|
|
334
|
+
}), { list: H, pageNum: Q, total: B, pageSize: F } = p && p(j) || j;
|
|
335
|
+
if (I === m && Array.isArray(H))
|
|
336
|
+
h.value = H, u.value = {
|
|
337
|
+
...u.value,
|
|
338
|
+
page: Q,
|
|
339
|
+
itemCount: B,
|
|
340
|
+
pageSize: F
|
|
341
|
+
};
|
|
342
|
+
else
|
|
343
|
+
throw h.value = [], u.value = {
|
|
344
|
+
...u.value,
|
|
345
|
+
pageSize: 10,
|
|
346
|
+
itemCount: 0,
|
|
347
|
+
page: 1
|
|
348
|
+
}, new Error("list的数据类型错误");
|
|
349
|
+
} catch (I) {
|
|
350
|
+
throw console.error("Error in loadData:", I), I;
|
|
351
|
+
} finally {
|
|
352
|
+
o.value = !1;
|
|
353
|
+
}
|
|
354
|
+
}, M = ke(), S = async () => {
|
|
355
|
+
if (!l || typeof l != "function")
|
|
356
|
+
throw new Error("当前没有提供exportRequest函数");
|
|
357
|
+
try {
|
|
358
|
+
const { data: D, fileName: C } = await l(v.value);
|
|
359
|
+
Ee(D, C), M == null || M.success("成功导出");
|
|
360
|
+
} catch (D) {
|
|
361
|
+
throw console.error("Error in handleExcelData:", D), D;
|
|
362
|
+
}
|
|
363
|
+
}, b = (D, C) => {
|
|
364
|
+
C !== void 0 && (u.value.pageSize = C), a(D);
|
|
365
|
+
}, z = (D) => {
|
|
366
|
+
b(D);
|
|
367
|
+
}, ne = (D) => {
|
|
368
|
+
b(1, D);
|
|
369
|
+
}, re = (D) => {
|
|
370
|
+
if (D.sorter) {
|
|
371
|
+
const C = [...h.value].sort((I, j) => D.order === "ascend" ? I[D.columnKey] > j[D.columnKey] ? 1 : -1 : D.order === "descend" ? I[D.columnKey] < j[D.columnKey] ? 1 : -1 : 0);
|
|
372
|
+
h.value = C;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
return oe(() => g && a(u.value.page)), {
|
|
376
|
+
dataSource: h,
|
|
377
|
+
loading: o,
|
|
378
|
+
pagination: u,
|
|
379
|
+
handleExcelData: S,
|
|
380
|
+
handlePageChange: z,
|
|
381
|
+
handlePageSizeChange: ne,
|
|
382
|
+
handleSortChange: re,
|
|
383
|
+
loadData: a
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function he(e) {
|
|
387
|
+
return ge() ? (we(e), !0) : !1;
|
|
388
|
+
}
|
|
389
|
+
const se = /* @__PURE__ */ new WeakMap(), je = (...e) => {
|
|
390
|
+
var s;
|
|
391
|
+
const l = e[0], v = (s = ue()) == null ? void 0 : s.proxy;
|
|
392
|
+
if (v == null && !fe())
|
|
393
|
+
throw new Error("injectLocal must be called in setup");
|
|
394
|
+
return v && se.has(v) && l in se.get(v) ? se.get(v)[l] : de(...e);
|
|
395
|
+
}, He = typeof window < "u" && typeof document < "u";
|
|
396
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
397
|
+
const Ie = Object.prototype.toString, ze = (e) => Ie.call(e) === "[object Object]";
|
|
398
|
+
function le(e) {
|
|
399
|
+
return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
|
|
400
|
+
}
|
|
401
|
+
function ee(e) {
|
|
402
|
+
return Array.isArray(e) ? e : [e];
|
|
403
|
+
}
|
|
404
|
+
function Le(e) {
|
|
405
|
+
return ue();
|
|
406
|
+
}
|
|
407
|
+
function ve(e, s = !0, l) {
|
|
408
|
+
Le() ? oe(e, l) : s ? e() : pe(e);
|
|
409
|
+
}
|
|
410
|
+
function Te(e, s, l) {
|
|
411
|
+
return te(
|
|
412
|
+
e,
|
|
413
|
+
s,
|
|
414
|
+
{
|
|
415
|
+
...l,
|
|
416
|
+
immediate: !0
|
|
417
|
+
}
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
const J = He ? window : void 0;
|
|
421
|
+
function V(e) {
|
|
422
|
+
var s;
|
|
423
|
+
const l = P(e);
|
|
424
|
+
return (s = l == null ? void 0 : l.$el) != null ? s : l;
|
|
425
|
+
}
|
|
426
|
+
function ie(...e) {
|
|
427
|
+
const s = [], l = () => {
|
|
428
|
+
s.forEach((o) => o()), s.length = 0;
|
|
429
|
+
}, v = (o, u, h, y) => (o.addEventListener(u, h, y), () => o.removeEventListener(u, h, y)), p = A(() => {
|
|
430
|
+
const o = ee(P(e[0])).filter((u) => u != null);
|
|
431
|
+
return o.every((u) => typeof u != "string") ? o : void 0;
|
|
432
|
+
}), g = Te(
|
|
433
|
+
() => {
|
|
434
|
+
var o, u;
|
|
435
|
+
return [
|
|
436
|
+
(u = (o = p.value) == null ? void 0 : o.map((h) => V(h))) != null ? u : [J].filter((h) => h != null),
|
|
437
|
+
ee(P(p.value ? e[1] : e[0])),
|
|
438
|
+
ee(ye(p.value ? e[2] : e[1])),
|
|
439
|
+
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
440
|
+
P(p.value ? e[3] : e[2])
|
|
441
|
+
];
|
|
442
|
+
},
|
|
443
|
+
([o, u, h, y]) => {
|
|
444
|
+
if (l(), !(o != null && o.length) || !(u != null && u.length) || !(h != null && h.length))
|
|
445
|
+
return;
|
|
446
|
+
const a = ze(y) ? { ...y } : y;
|
|
447
|
+
s.push(
|
|
448
|
+
...o.flatMap(
|
|
449
|
+
(M) => u.flatMap(
|
|
450
|
+
(S) => h.map((b) => v(M, S, b, a))
|
|
451
|
+
)
|
|
452
|
+
)
|
|
453
|
+
);
|
|
454
|
+
},
|
|
455
|
+
{ flush: "post" }
|
|
456
|
+
), m = () => {
|
|
457
|
+
g(), l();
|
|
458
|
+
};
|
|
459
|
+
return he(l), m;
|
|
460
|
+
}
|
|
461
|
+
function Ae() {
|
|
462
|
+
const e = T(!1), s = ue();
|
|
463
|
+
return s && oe(() => {
|
|
464
|
+
e.value = !0;
|
|
465
|
+
}, s), e;
|
|
466
|
+
}
|
|
467
|
+
function me(e) {
|
|
468
|
+
const s = Ae();
|
|
469
|
+
return A(() => (s.value, !!e()));
|
|
470
|
+
}
|
|
471
|
+
const Re = Symbol("vueuse-ssr-width");
|
|
472
|
+
function Ne() {
|
|
473
|
+
const e = fe() ? je(Re, null) : null;
|
|
474
|
+
return typeof e == "number" ? e : void 0;
|
|
475
|
+
}
|
|
476
|
+
function Ye(e, s = {}) {
|
|
477
|
+
const { window: l = J, ssrWidth: v = Ne() } = s, p = me(() => l && "matchMedia" in l && typeof l.matchMedia == "function"), g = T(typeof v == "number"), m = T(), o = T(!1), u = (h) => {
|
|
478
|
+
o.value = h.matches;
|
|
479
|
+
};
|
|
480
|
+
return $e(() => {
|
|
481
|
+
if (g.value) {
|
|
482
|
+
g.value = !p.value;
|
|
483
|
+
const h = P(e).split(",");
|
|
484
|
+
o.value = h.some((y) => {
|
|
485
|
+
const a = y.includes("not all"), M = y.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), S = y.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
486
|
+
let b = !!(M || S);
|
|
487
|
+
return M && b && (b = v >= le(M[1])), S && b && (b = v <= le(S[1])), a ? !b : b;
|
|
488
|
+
});
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
p.value && (m.value = l.matchMedia(P(e)), o.value = m.value.matches);
|
|
492
|
+
}), ie(m, "change", u, { passive: !0 }), A(() => o.value);
|
|
493
|
+
}
|
|
494
|
+
function Ve(e, s, l = {}) {
|
|
495
|
+
const { window: v = J, ...p } = l;
|
|
496
|
+
let g;
|
|
497
|
+
const m = me(() => v && "ResizeObserver" in v), o = () => {
|
|
498
|
+
g && (g.disconnect(), g = void 0);
|
|
499
|
+
}, u = A(() => {
|
|
500
|
+
const a = P(e);
|
|
501
|
+
return Array.isArray(a) ? a.map((M) => V(M)) : [V(a)];
|
|
502
|
+
}), h = te(
|
|
503
|
+
u,
|
|
504
|
+
(a) => {
|
|
505
|
+
if (o(), m.value && v) {
|
|
506
|
+
g = new ResizeObserver(s);
|
|
507
|
+
for (const M of a)
|
|
508
|
+
M && g.observe(M, p);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
{ immediate: !0, flush: "post" }
|
|
512
|
+
), y = () => {
|
|
513
|
+
o(), h();
|
|
514
|
+
};
|
|
515
|
+
return he(y), {
|
|
516
|
+
isSupported: m,
|
|
517
|
+
stop: y
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
function Pe(e, s = { width: 0, height: 0 }, l = {}) {
|
|
521
|
+
const { window: v = J, box: p = "content-box" } = l, g = A(() => {
|
|
522
|
+
var a, M;
|
|
523
|
+
return (M = (a = V(e)) == null ? void 0 : a.namespaceURI) == null ? void 0 : M.includes("svg");
|
|
524
|
+
}), m = T(s.width), o = T(s.height), { stop: u } = Ve(
|
|
525
|
+
e,
|
|
526
|
+
([a]) => {
|
|
527
|
+
const M = p === "border-box" ? a.borderBoxSize : p === "content-box" ? a.contentBoxSize : a.devicePixelContentBoxSize;
|
|
528
|
+
if (v && g.value) {
|
|
529
|
+
const S = V(e);
|
|
530
|
+
if (S) {
|
|
531
|
+
const b = S.getBoundingClientRect();
|
|
532
|
+
m.value = b.width, o.value = b.height;
|
|
533
|
+
}
|
|
534
|
+
} else if (M) {
|
|
535
|
+
const S = ee(M);
|
|
536
|
+
m.value = S.reduce((b, { inlineSize: z }) => b + z, 0), o.value = S.reduce((b, { blockSize: z }) => b + z, 0);
|
|
537
|
+
} else
|
|
538
|
+
m.value = a.contentRect.width, o.value = a.contentRect.height;
|
|
539
|
+
},
|
|
540
|
+
l
|
|
541
|
+
);
|
|
542
|
+
ve(() => {
|
|
543
|
+
const a = V(e);
|
|
544
|
+
a && (m.value = "offsetWidth" in a ? a.offsetWidth : s.width, o.value = "offsetHeight" in a ? a.offsetHeight : s.height);
|
|
545
|
+
});
|
|
546
|
+
const h = te(
|
|
547
|
+
() => V(e),
|
|
548
|
+
(a) => {
|
|
549
|
+
m.value = a ? s.width : 0, o.value = a ? s.height : 0;
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
function y() {
|
|
553
|
+
u(), h();
|
|
554
|
+
}
|
|
555
|
+
return {
|
|
556
|
+
width: m,
|
|
557
|
+
height: o,
|
|
558
|
+
stop: y
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
function Fe(e = {}) {
|
|
562
|
+
const {
|
|
563
|
+
window: s = J,
|
|
564
|
+
initialWidth: l = Number.POSITIVE_INFINITY,
|
|
565
|
+
initialHeight: v = Number.POSITIVE_INFINITY,
|
|
566
|
+
listenOrientation: p = !0,
|
|
567
|
+
includeScrollbar: g = !0,
|
|
568
|
+
type: m = "inner"
|
|
569
|
+
} = e, o = T(l), u = T(v), h = () => {
|
|
570
|
+
if (s)
|
|
571
|
+
if (m === "outer")
|
|
572
|
+
o.value = s.outerWidth, u.value = s.outerHeight;
|
|
573
|
+
else if (m === "visual" && s.visualViewport) {
|
|
574
|
+
const { width: a, height: M, scale: S } = s.visualViewport;
|
|
575
|
+
o.value = Math.round(a * S), u.value = Math.round(M * S);
|
|
576
|
+
} else g ? (o.value = s.innerWidth, u.value = s.innerHeight) : (o.value = s.document.documentElement.clientWidth, u.value = s.document.documentElement.clientHeight);
|
|
577
|
+
};
|
|
578
|
+
h(), ve(h);
|
|
579
|
+
const y = { passive: !0 };
|
|
580
|
+
if (ie("resize", h, y), s && m === "visual" && s.visualViewport && ie(s.visualViewport, "resize", h, y), p) {
|
|
581
|
+
const a = Ye("(orientation: portrait)");
|
|
582
|
+
te(a, () => h());
|
|
583
|
+
}
|
|
584
|
+
return { width: o, height: u };
|
|
585
|
+
}
|
|
586
|
+
function Ke(e, s) {
|
|
587
|
+
if (!e) throw new Error("tableRef are required");
|
|
588
|
+
const l = A(() => {
|
|
589
|
+
var u;
|
|
590
|
+
return (u = e.value) == null ? void 0 : u.searchRef;
|
|
591
|
+
}), { height: v } = Fe(), { height: p } = Pe(l), { height: g = 0, minHeight: m = 600 } = s || {};
|
|
592
|
+
return {
|
|
593
|
+
height: A(() => {
|
|
594
|
+
const u = v.value - p.value - g;
|
|
595
|
+
return u > m ? u : m;
|
|
596
|
+
})
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function qe(e, s) {
|
|
600
|
+
const { immediate: l = !0 } = s || {}, v = Y(null), p = Y(!1), g = Y(null), m = async () => {
|
|
601
|
+
p.value = !0, g.value = null;
|
|
602
|
+
try {
|
|
603
|
+
const o = await e();
|
|
604
|
+
v.value = o;
|
|
605
|
+
} catch (o) {
|
|
606
|
+
g.value = o;
|
|
607
|
+
} finally {
|
|
608
|
+
p.value = !1;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
return l && m(), {
|
|
612
|
+
data: v,
|
|
613
|
+
loading: p,
|
|
614
|
+
error: g,
|
|
615
|
+
fetchData: m
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
export {
|
|
619
|
+
qe as useAsyncData,
|
|
620
|
+
Ee as useExportFile,
|
|
621
|
+
Be as useList,
|
|
622
|
+
Ke as useTableHeight
|
|
623
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { OptionsType } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* 异步请求数据的 Hook
|
|
4
4
|
* @param requestFn - 请求函数
|
|
@@ -6,9 +6,4 @@ import type { OptionsType } from './types';
|
|
|
6
6
|
* @param options.immediate - 是否立即执行,默认为 true
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function
|
|
10
|
-
data: import("vue").Ref<any, any>;
|
|
11
|
-
loading: import("vue").Ref<boolean, boolean>;
|
|
12
|
-
error: import("vue").Ref<any, any>;
|
|
13
|
-
fetchData: () => Promise<void>;
|
|
14
|
-
};
|
|
9
|
+
export declare function useAsyncData<T>(requestFn: () => Promise<T>, options?: OptionsType): any;
|
package/dist/useDeviceInfo.d.ts
CHANGED
package/dist/useList/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { OptionsType } from './types';
|
|
2
|
+
import { DataTableSortState } from 'naive-ui';
|
|
3
3
|
export declare function useList<T extends (...args: any) => Promise<any>>(listRequestFn: T, options?: OptionsType): {
|
|
4
|
-
dataSource: import(
|
|
5
|
-
loading: import(
|
|
6
|
-
pagination: import(
|
|
4
|
+
dataSource: import('vue').Ref<any[], any[]>;
|
|
5
|
+
loading: import('vue').Ref<boolean, boolean>;
|
|
6
|
+
pagination: import('vue').Ref<{
|
|
7
7
|
page: number;
|
|
8
8
|
pageSize: number;
|
|
9
9
|
itemCount: number;
|
package/dist/useList/types.d.ts
CHANGED
package/dist/useTableHeight.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@banmao/hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"glob": "^11.0.0",
|
|
21
21
|
"naive-ui": "^2.41.0",
|
|
22
22
|
"typescript": "~5.6.2",
|
|
23
|
-
"vite": "^6.
|
|
23
|
+
"vite": "^6.3.5",
|
|
24
24
|
"vite-plugin-compression": "^0.5.1",
|
|
25
|
-
"vue": "^3.5.
|
|
26
|
-
"vue-tsc": "^2.2.
|
|
25
|
+
"vue": "^3.5.14",
|
|
26
|
+
"vue-tsc": "^2.2.10"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"naive-ui": "^2.41.0",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ref } from 'vue';
|
|
2
|
-
/**
|
|
3
|
-
* 异步请求数据的 Hook
|
|
4
|
-
* @param requestFn - 请求函数
|
|
5
|
-
* @param options - 配置
|
|
6
|
-
* @param options.immediate - 是否立即执行,默认为 true
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export function useAsyncDat(requestFn, options = {}) {
|
|
10
|
-
const { immediate = true } = options;
|
|
11
|
-
const data = ref(null);
|
|
12
|
-
const loading = ref(false);
|
|
13
|
-
const error = ref(null);
|
|
14
|
-
const fetchData = async () => {
|
|
15
|
-
loading.value = true;
|
|
16
|
-
error.value = null;
|
|
17
|
-
try {
|
|
18
|
-
const response = await requestFn();
|
|
19
|
-
data.value = response;
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
error.value = err;
|
|
23
|
-
}
|
|
24
|
-
finally {
|
|
25
|
-
loading.value = false;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
if (immediate) {
|
|
29
|
-
fetchData();
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
data,
|
|
33
|
-
loading,
|
|
34
|
-
error,
|
|
35
|
-
fetchData,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/useDeviceInfo.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { UAParser } from 'ua-parser-js';
|
|
2
|
-
/**
|
|
3
|
-
* 单例模式下的 UAParser 实例管理
|
|
4
|
-
*/
|
|
5
|
-
const parserInstance = (function () {
|
|
6
|
-
let instance = null;
|
|
7
|
-
const initializing = (async () => {
|
|
8
|
-
try {
|
|
9
|
-
instance = new UAParser();
|
|
10
|
-
return instance;
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
console.error('Failed to initialize UAParser:', error);
|
|
14
|
-
throw error;
|
|
15
|
-
}
|
|
16
|
-
})();
|
|
17
|
-
return {
|
|
18
|
-
/**
|
|
19
|
-
* 获取 UAParser 实例
|
|
20
|
-
* @returns 返回 {Promise<UAParser>} 解析用户代理字符串的实例
|
|
21
|
-
*/
|
|
22
|
-
getInstance: async () => {
|
|
23
|
-
if (!instance) {
|
|
24
|
-
instance = await initializing;
|
|
25
|
-
}
|
|
26
|
-
return instance;
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
})();
|
|
30
|
-
/**
|
|
31
|
-
* 使用设备信息钩子
|
|
32
|
-
* 该钩子用于获取客户端设备的信息,如浏览器类型、操作系统等
|
|
33
|
-
* 它基于UAParser实例来解析用户代理字符串
|
|
34
|
-
*
|
|
35
|
-
* @returns {object} 返回解析后的设备信息对象
|
|
36
|
-
*/
|
|
37
|
-
export async function useDeviceInfo() {
|
|
38
|
-
const instance = await parserInstance.getInstance();
|
|
39
|
-
return instance.getResult();
|
|
40
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
/**
|
|
3
|
-
* 将给定的数据转换为 Blob 对象,并生成一个 URL 对象,用于下载或显示该 Blob 对象
|
|
4
|
-
* 此函数主要用于准备数据以便在浏览器中下载或展示
|
|
5
|
-
*
|
|
6
|
-
* @param data {BlobPart} - 需要转换为 Blob 的数据部分,可以是数组、Blob、字符串等
|
|
7
|
-
* @returns {string} 一个 URL 对象,表示新创建的 Blob 对象的位置
|
|
8
|
-
*/
|
|
9
|
-
function transformBlob(data) {
|
|
10
|
-
// 创建一个新的 Blob 对象,包含传入的数据部分,并指定 MIME 类型
|
|
11
|
-
// 此处的 MIME 类型为 'application/vnd.ms-excel',用于处理 Excel 文件
|
|
12
|
-
// 另一个 MIME 类型 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' 用于处理 Office Open XML 格式的 Excel 文件
|
|
13
|
-
const blob = new Blob([data], {
|
|
14
|
-
type: 'application/vnd.ms-excel',
|
|
15
|
-
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
16
|
-
});
|
|
17
|
-
// 使用 window.URL.createObjectURL 方法创建一个新的 URL 对象,指向 Blob 对象
|
|
18
|
-
// 这个 URL 可以在浏览器中直接访问,用于下载或展示 Blob 中的数据
|
|
19
|
-
const href = window.URL.createObjectURL(blob);
|
|
20
|
-
// 返回创建的 URL 对象
|
|
21
|
-
return href;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 创建一个新的 HTML 元素,通常是 <a> 标签,用于下载文件
|
|
25
|
-
*
|
|
26
|
-
* @returns {HTMLAnchorElement} 一个新创建的 <a> 标签元素
|
|
27
|
-
*/
|
|
28
|
-
function createElement() {
|
|
29
|
-
const downloadElement = document.createElement('a');
|
|
30
|
-
return downloadElement;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* 导出文件
|
|
34
|
-
*
|
|
35
|
-
* @param data - 要导出的数据
|
|
36
|
-
* @param fileName - 导出的文件名(可选)
|
|
37
|
-
*/
|
|
38
|
-
export function useExportFile(data, fileName) {
|
|
39
|
-
const time = dayjs().format('yyyy-MM-dd hh:mm:ss');
|
|
40
|
-
function download() {
|
|
41
|
-
const downloadDOM = createElement();
|
|
42
|
-
const href = transformBlob(data);
|
|
43
|
-
downloadDOM.href = href;
|
|
44
|
-
if (fileName) {
|
|
45
|
-
downloadDOM.download = fileName || `${fileName}-${time}.xlsx`;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
downloadDOM.download = `${time}.xlsx`;
|
|
49
|
-
}
|
|
50
|
-
document.body.appendChild(downloadDOM);
|
|
51
|
-
downloadDOM.click();
|
|
52
|
-
document.body.removeChild(downloadDOM);
|
|
53
|
-
window.URL.revokeObjectURL(href);
|
|
54
|
-
}
|
|
55
|
-
download();
|
|
56
|
-
}
|
package/dist/useList/index.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { useMessage } from 'naive-ui';
|
|
2
|
-
import { computed, onMounted, ref } from 'vue';
|
|
3
|
-
import { useExportFile } from '../useExportRemoteFile';
|
|
4
|
-
// import { getPagination } from '@/utils'
|
|
5
|
-
export function useList(listRequestFn, options = {}) {
|
|
6
|
-
const { exportRequestFn, filterOption = ref(), callback, immediate = true, code = 200, } = options;
|
|
7
|
-
// 加载态
|
|
8
|
-
const loading = ref(false);
|
|
9
|
-
const pagination = ref({
|
|
10
|
-
page: 1,
|
|
11
|
-
pageSize: 10,
|
|
12
|
-
itemCount: 0,
|
|
13
|
-
showSizePicker: true,
|
|
14
|
-
pageSizes: [10, 20, 30, 40],
|
|
15
|
-
showQuickJumper: true,
|
|
16
|
-
prefix: (info) => `共 ${info.itemCount} 条`,
|
|
17
|
-
});
|
|
18
|
-
// 数据
|
|
19
|
-
const dataSource = ref([]);
|
|
20
|
-
const searchParams = computed(() => {
|
|
21
|
-
return filterOption.value;
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* 加载数据
|
|
25
|
-
* @param page - 当前页
|
|
26
|
-
* @param pageSize - 页数
|
|
27
|
-
*/
|
|
28
|
-
const loadData = async (page = pagination.value.page, filterParams) => {
|
|
29
|
-
loading.value = true;
|
|
30
|
-
try {
|
|
31
|
-
const { status, data } = await listRequestFn({
|
|
32
|
-
pageNum: page,
|
|
33
|
-
pageSize: pagination.value.pageSize,
|
|
34
|
-
...searchParams.value,
|
|
35
|
-
...filterParams,
|
|
36
|
-
});
|
|
37
|
-
const { list, pageNum, total, pageSize } = (callback && callback(data)) || data;
|
|
38
|
-
if (status === code && Array.isArray(list)) {
|
|
39
|
-
dataSource.value = list;
|
|
40
|
-
pagination.value = {
|
|
41
|
-
...pagination.value,
|
|
42
|
-
page: pageNum,
|
|
43
|
-
itemCount: total,
|
|
44
|
-
pageSize,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
dataSource.value = [];
|
|
49
|
-
pagination.value = {
|
|
50
|
-
...pagination.value,
|
|
51
|
-
pageSize: 10,
|
|
52
|
-
itemCount: 0,
|
|
53
|
-
page: 1,
|
|
54
|
-
};
|
|
55
|
-
throw new Error('list的数据类型错误');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.error('Error in loadData:', error);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
finally {
|
|
63
|
-
loading.value = false;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const message = useMessage();
|
|
67
|
-
/**
|
|
68
|
-
* 导出文件
|
|
69
|
-
*/
|
|
70
|
-
const handleExcelData = async () => {
|
|
71
|
-
if (!exportRequestFn || typeof exportRequestFn !== 'function') {
|
|
72
|
-
throw new Error('当前没有提供exportRequest函数');
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const { data, fileName } = await exportRequestFn(filterOption.value);
|
|
76
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
77
|
-
useExportFile(data, fileName);
|
|
78
|
-
message?.success('成功导出');
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
console.error('Error in handleExcelData:', error);
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* 更新分页并加载数据
|
|
87
|
-
* @param page - 当前页
|
|
88
|
-
* @param pageSize - 每页条数
|
|
89
|
-
*/
|
|
90
|
-
const updatePaginationAndLoadData = (page, pageSize) => {
|
|
91
|
-
if (pageSize !== undefined) {
|
|
92
|
-
pagination.value.pageSize = pageSize;
|
|
93
|
-
}
|
|
94
|
-
loadData(page);
|
|
95
|
-
};
|
|
96
|
-
const handlePageChange = (page) => {
|
|
97
|
-
updatePaginationAndLoadData(page);
|
|
98
|
-
};
|
|
99
|
-
const handlePageSizeChange = (pageSize) => {
|
|
100
|
-
updatePaginationAndLoadData(1, pageSize);
|
|
101
|
-
};
|
|
102
|
-
const handleSortChange = (options) => {
|
|
103
|
-
if (options.sorter) {
|
|
104
|
-
const sortData = [...dataSource.value].sort((a, b) => {
|
|
105
|
-
if (options.order === 'ascend') {
|
|
106
|
-
return a[options.columnKey] > b[options.columnKey] ? 1 : -1;
|
|
107
|
-
}
|
|
108
|
-
if (options.order === 'descend') {
|
|
109
|
-
return a[options.columnKey] < b[options.columnKey] ? 1 : -1;
|
|
110
|
-
}
|
|
111
|
-
return 0;
|
|
112
|
-
});
|
|
113
|
-
dataSource.value = sortData;
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
onMounted(() => immediate && loadData(pagination.value.page));
|
|
117
|
-
return {
|
|
118
|
-
dataSource,
|
|
119
|
-
loading,
|
|
120
|
-
pagination,
|
|
121
|
-
handleExcelData,
|
|
122
|
-
handlePageChange,
|
|
123
|
-
handlePageSizeChange,
|
|
124
|
-
handleSortChange,
|
|
125
|
-
loadData,
|
|
126
|
-
};
|
|
127
|
-
}
|
package/dist/useList/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/useTableHeight.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useElementSize, useWindowSize } from '@vueuse/core';
|
|
2
|
-
import { computed } from 'vue';
|
|
3
|
-
/**
|
|
4
|
-
* useTableHeight
|
|
5
|
-
*
|
|
6
|
-
* @description 计算表格高度
|
|
7
|
-
* @example const { height } = useTableHeight(tableRef, { height: 100, minHeight: 600 })
|
|
8
|
-
*
|
|
9
|
-
* @param tableRef - 表格元素引用
|
|
10
|
-
* @param options - 表格高度配置
|
|
11
|
-
* @param options.height - 表格之外的高度值
|
|
12
|
-
* @param options.minHeight - 表格的最小高度
|
|
13
|
-
* @returns { height } - 表格高度
|
|
14
|
-
*/
|
|
15
|
-
export function useTableHeight(tableRef, options) {
|
|
16
|
-
// 验证参数
|
|
17
|
-
if (!tableRef)
|
|
18
|
-
throw new Error('tableRef are required');
|
|
19
|
-
// 获取搜索栏元素引用
|
|
20
|
-
const searchRef = computed(() => tableRef.value?.searchRef);
|
|
21
|
-
// 获取窗口高度和搜索栏高度
|
|
22
|
-
const { height: winHeight } = useWindowSize();
|
|
23
|
-
const { height: searchHeight } = useElementSize(searchRef.value);
|
|
24
|
-
// 获取表格高度和最小高度
|
|
25
|
-
const { height = 0, minHeight = 600 } = options || {};
|
|
26
|
-
// 计算表格高度
|
|
27
|
-
const tableHeight = computed(() => {
|
|
28
|
-
const h = winHeight.value -
|
|
29
|
-
searchHeight.value -
|
|
30
|
-
height;
|
|
31
|
-
if (h > minHeight) {
|
|
32
|
-
return h;
|
|
33
|
-
}
|
|
34
|
-
return minHeight;
|
|
35
|
-
});
|
|
36
|
-
return {
|
|
37
|
-
height: tableHeight
|
|
38
|
-
};
|
|
39
|
-
}
|