mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-12-01 17:23:40 +08:00
1 line
2.2 KiB
JavaScript
1 line
2.2 KiB
JavaScript
import{Cn as e,_n as t,kn as n,wn as r}from"./Card-B_oozRxS.js";import{W as i,z as a}from"./toString-BWDzaUQG.js";import{U as o,Vt as s}from"./store-BGk8Kj6h.js";import{listPeople as c}from"./people-BA0yvZ_x.js";import{t as l}from"./useTablePro-1AVtUfum.js";import{m as u,u as d}from"./Switch-B4B45bkJ.js";import{t as f}from"./DemoPage-CJFmBY0O.js";import{t as p}from"./DemoResult-DB6s8vEk.js";import{t as m}from"./people-C08APQny.js";function h(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Object]`&&!n(e)}var g=r({name:`TableDemoHooksSelection`,setup(){let{t:n}=s(),[r,{isReady:g,getCurrentPageData:_,getTableInstance:v}]=l(),{data:y}=c(),b=a([]),x=i(new Set),S=t(()=>[{type:`selection`,width:44},...m(e=>n(`table.${e}`)).slice(0,4).map(e=>`key`in e&&e.key===`age`?{...e,sorter:(e,t)=>e.age-t.age}:e),{title:n(`tableHooks.markColumn`),key:`marked`,width:110,render:({id:e})=>n(x.value.has(e)?`tableHooks.marked`:`tableHooks.unmarked`)}]),C=()=>_().map(e=>e.id).filter(e=>typeof e==`string`),w=()=>{b.value=[...new Set([...b.value,...C()])]},T=()=>{let e=new Set(C());b.value=b.value.filter(t=>!e.has(t))},E=()=>{x.value=new Set([...x.value,...b.value]),b.value=[]};return()=>{let t,i,a,s,c,l;return e(f,{title:n(`menu.TableHooksSelection`),description:n(`tableHooks.selectionDescription`)},{default:()=>[e(d,null,{default:()=>[e(u,{type:`primary`,disabled:!g.value,onClick:w},h(t=n(`tableHooks.selectPage`))?t:{default:()=>[t]}),e(u,{disabled:!g.value||!b.value.length,onClick:T},h(i=n(`tableHooks.unselectPage`))?i:{default:()=>[i]}),e(u,{disabled:!b.value.length,onClick:()=>{b.value=[]}},h(a=n(`tableHooks.clearAll`))?a:{default:()=>[a]}),e(u,{disabled:!b.value.length,onClick:E},h(s=n(`tableHooks.markSelected`))?s:{default:()=>[s]}),e(u,{disabled:!g.value,onClick:()=>v()?.clearSorter()},h(c=n(`tableHooks.clearSort`))?c:{default:()=>[c]})]}),e(p,{label:n(`tableHooks.selectionResult`)},h(l=n(`tableHooks.selectionDetails`,{selected:b.value.length,marked:x.value.size}))?l:{default:()=>[l]}),e(o,{onRegister:r,title:n(`table.directory`),columns:S.value,data:y,checkedRowKeys:b.value,"onUpdate:checkedRowKeys":e=>b.value=e,search:[{key:`name`,label:n(`table.name`),placeholder:n(`table.nameHint`)}],scrollX:716},null)]})}}});export{g as default}; |