"use strict";const e=require("vue"),r=require("../Shared/base-iCmnU-fv.js"),V=require("../Shared/Index.vue_vue_type_script_setup_true_lang-Dd2V82en.js"),P=require("../Shared/Index.vue_vue_type_script_setup_true_lang-p08PZCov.js"),$=require("../Shared/language-D6gRWx8H.js"),w={class:"paginate-statistic"},F={class:"paginate-list"},O={class:"pagination"},q=["onClick"],A=["innerHTML"],J={key:0,class:"paginate-limit"},T={key:1,class:"paginate-jump"},j=e.defineComponent({name:"ClPaginate",__name:"Index",props:{isShowLimit:{type:Boolean,default:!0},limitValue:{type:Number,default:10},limitData:Array,isShowJump:{type:Boolean,default:!0},totalCount:{type:Number,default:0},currentPage:{type:Number,default:1},isDisabled:{type:Boolean,default:!1}},emits:["onChange"],setup(m,{emit:y}){const l=m,x=y,{optPageLanguage:u,getPageLanguage:M}=$.useLanguage();M("paginate");const I=e.reactive({keyIndex:`paginate-${r.CommonBase.getRandom(8)}`}),D=()=>{let t=l.limitValue.toString();if(l.isShowLimit&&h.value.length>0){let n=!1,a="";h.value.forEach((o,i)=>{const f=o.id.toString();i===0&&(a=f),t===f&&(n=!0)}),n||(t=a)}return t},h=e.computed(()=>{const t=l.limitData;return t&&!r.CommonBase.isEmpty(t)?r.CommonBase.getListClone(t):[{id:10,name:`10${u.value.pageStrip}`},{id:20,name:`20${u.value.pageStrip}`},{id:30,name:`30${u.value.pageStrip}`},{id:50,name:`50${u.value.pageStrip}`},{id:100,name:`100${u.value.pageStrip}`}]}),E=D(),p=e.ref(E),v=e.ref(""),L=e.computed(()=>{const t=parseInt(p.value),n=l.currentPage,a=l.totalCount;let o=(n-1)*t,i=n*t;return a>0?(o=o+1,i=i>a?a:i):(o=0,i=0),r.CommonBase.convertStringFormat(u.value.statistic,{s:o,e:i,_total:a})}),S=e.computed(()=>{let t=!1,n=!1,a=!1,o=!1,i=0;const f=parseInt(p.value),c=l.currentPage,b=l.totalCount;b>0&&(i=Math.ceil(b/f),t=c===1,n=t,a=c===i,o=a);const d=[];if(d.push({title:"<i class='clIconFont clIcon-angle-double-left paginate-first-icon'></i>",active:!1,disabled:t,page:1}),d.push({title:"<i class='clIconFont clIcon-angle-left paginate-prev-icon'></i>",active:!1,disabled:n,page:t?1:c-1}),i>0){let s=[];if(i>7){const B=i-5+1+1;c<=4?(s=r.CommonBase.getArrByMinMax(1,5),s.push("…"),s.push(i)):c>=B?(s=r.CommonBase.getArrByMinMax(B-1,i),s.unshift("…"),s.unshift(1)):(s=r.CommonBase.getArrByMinMax(c-1,c+1),s.unshift("…"),s.unshift(1),s.push("…"),s.push(i))}else s=r.CommonBase.getArrByMinMax(1,i);s.forEach(g=>{d.push({title:g,active:g===c,isOmit:g==="…",page:g})})}return d.push({title:"<i class='clIconFont clIcon-angle-right paginate-next-icon'></i>",active:!1,disabled:o,page:a?i:c+1}),d.push({title:"<i class='clIconFont clIcon-angle-double-right paginate-last-icon'></i>",active:!1,disabled:a,page:i}),d});e.watch(()=>l.limitValue,t=>{p.value=t.toString()});const _=(t,n)=>{x("onChange",parseInt(t),parseInt(n))},k=t=>{l.isDisabled||!t.active&&!t.disabled&&!t.isOmit&&(v.value="",_(t.page,p.value))},N=t=>{l.isDisabled||(v.value="",_(1,t))},C=t=>{!l.isDisabled&&!r.CommonBase.isEmpty(t)&&_(t,p.value)};return(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"panel-paginate":!0,"paginate-disabled":m.isDisabled})},[e.createElementVNode("div",w,e.toDisplayString(L.value),1),e.createElementVNode("div",F,[e.createElementVNode("ul",O,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,(a,o)=>(e.openBlock(),e.createElementBlock("li",{key:`${I.keyIndex}_${o}`,class:e.normalizeClass({"paginate-disabled":a.disabled||m.isDisabled,"paginate-active":a.active,"paginate-omit":a.isOmit}),onClick:i=>k(a)},[e.createElementVNode("span",{innerHTML:a.title},null,8,A)],10,q))),128))])]),m.isShowLimit?(e.openBlock(),e.createElementBlock("div",J,[e.createVNode(P._sfc_main,{list:h.value,value:p.value,disabled:m.isDisabled,onOnChange:N},null,8,["list","value","disabled"])])):e.createCommentVNode("",!0),m.isShowJump?(e.openBlock(),e.createElementBlock("div",T,[e.createElementVNode("span",null,e.toDisplayString(e.unref(u).jumpTo),1),e.createVNode(V._sfc_main,{value:v.value,"onUpdate:value":n[0]||(n[0]=a=>v.value=a),disabled:m.isDisabled,onOnKeyupEnter:C,onOnChangeBlur:C,onOnClear:C},null,8,["value","disabled"]),e.createElementVNode("span",null,e.toDisplayString(e.unref(u).page),1)])):e.createCommentVNode("",!0)],2))}});module.exports=j;
//# sourceMappingURL=ClPaginate.cjs.map
