fix table page
This commit is contained in:
parent
13f45bcfef
commit
a6d8dfea39
@ -951,7 +951,8 @@ const _sfc_main = defineComponent({
|
||||
} },
|
||||
getRadioProps: { type: Function, default: () => {
|
||||
} },
|
||||
download: { default: "" }
|
||||
download: { default: "" },
|
||||
serverpage: { type: Boolean, default: false }
|
||||
},
|
||||
emits: [
|
||||
"change",
|
||||
@ -1128,8 +1129,12 @@ const _sfc_main = defineComponent({
|
||||
});
|
||||
let pagecurrent;
|
||||
const change = function(page) {
|
||||
pagecurrent = page.current;
|
||||
datalist.value = tableDataSource.value.slice(page.limit * (page.current - 1), page.limit * page.current);
|
||||
if (props.serverpage) {
|
||||
emit("change", page);
|
||||
} else {
|
||||
pagecurrent = page.current;
|
||||
datalist.value = tableDataSource.value.slice(page.limit * (page.current - 1), page.limit * page.current);
|
||||
}
|
||||
};
|
||||
const rowClick = function(data, evt) {
|
||||
emit("row", data, evt);
|
||||
|
11
lib/index.js
11
lib/index.js
@ -19398,7 +19398,8 @@ const _sfc_main$D = defineComponent({
|
||||
} },
|
||||
getRadioProps: { type: Function, default: () => {
|
||||
} },
|
||||
download: { default: "" }
|
||||
download: { default: "" },
|
||||
serverpage: { type: Boolean, default: false }
|
||||
},
|
||||
emits: [
|
||||
"change",
|
||||
@ -19575,8 +19576,12 @@ const _sfc_main$D = defineComponent({
|
||||
});
|
||||
let pagecurrent;
|
||||
const change3 = function(page) {
|
||||
pagecurrent = page.current;
|
||||
datalist.value = tableDataSource.value.slice(page.limit * (page.current - 1), page.limit * page.current);
|
||||
if (props.serverpage) {
|
||||
emit("change", page);
|
||||
} else {
|
||||
pagecurrent = page.current;
|
||||
datalist.value = tableDataSource.value.slice(page.limit * (page.current - 1), page.limit * page.current);
|
||||
}
|
||||
};
|
||||
const rowClick = function(data, evt) {
|
||||
emit("row", data, evt);
|
||||
|
@ -53,6 +53,7 @@ export interface TableProps {
|
||||
getCheckboxProps?: Function;
|
||||
getRadioProps?: Function;
|
||||
download?: string;
|
||||
serverpage?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<TableProps>(), {
|
||||
@ -72,12 +73,13 @@ const props = withDefaults(defineProps<TableProps>(), {
|
||||
rowStyle: "",
|
||||
cellStyle: "",
|
||||
defaultExpandAll: false,
|
||||
spanMethod: () => {},
|
||||
spanMethod: () => { },
|
||||
expandKeys: () => [],
|
||||
loading: false,
|
||||
getCheckboxProps: () => {},
|
||||
getRadioProps: () => {},
|
||||
getCheckboxProps: () => { },
|
||||
getRadioProps: () => { },
|
||||
download: "",
|
||||
serverpage: false
|
||||
});
|
||||
|
||||
const emit = defineEmits([
|
||||
@ -356,12 +358,16 @@ watch(
|
||||
);
|
||||
let pagecurrent: number;
|
||||
const change = function (page: any) {
|
||||
// emit("change", page);
|
||||
pagecurrent = page.current;
|
||||
datalist.value = tableDataSource.value.slice(
|
||||
page.limit * (page.current - 1),
|
||||
page.limit * page.current
|
||||
);
|
||||
if (props.serverpage) {
|
||||
emit("change", page);
|
||||
} else {
|
||||
pagecurrent = page.current;
|
||||
datalist.value = tableDataSource.value.slice(
|
||||
page.limit * (page.current - 1),
|
||||
page.limit * page.current
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const rowClick = function (data: any, evt: MouseEvent) {
|
||||
@ -830,50 +836,27 @@ window.addEventListener("click", heddin);
|
||||
</div>
|
||||
<div v-if="defaultToolbar" class="layui-table-tool-self">
|
||||
<!-- 筛选 -->
|
||||
<lay-dropdown
|
||||
v-if="showToolbar('filter')"
|
||||
updateAtScroll
|
||||
:style="toolbarStyle('filter')"
|
||||
>
|
||||
<lay-dropdown v-if="showToolbar('filter')" updateAtScroll :style="toolbarStyle('filter')">
|
||||
<div class="layui-inline" title="筛选" lay-event>
|
||||
<i class="layui-icon layui-icon-slider"></i>
|
||||
</div>
|
||||
<template #content>
|
||||
<div class="layui-table-tool-checkbox">
|
||||
<lay-checkbox
|
||||
v-for="column in tableHeadColumns[0]"
|
||||
v-model="tableColumnKeys"
|
||||
skin="primary"
|
||||
:disabled="column.children"
|
||||
:key="column.key"
|
||||
:value="column.key"
|
||||
>{{ column.title }}</lay-checkbox
|
||||
>
|
||||
<lay-checkbox v-for="column in tableHeadColumns[0]" v-model="tableColumnKeys" skin="primary"
|
||||
:disabled="column.children" :key="column.key" :value="column.key">{{ column.title }}</lay-checkbox>
|
||||
</div>
|
||||
</template>
|
||||
</lay-dropdown>
|
||||
|
||||
<!-- 导出 -->
|
||||
<div
|
||||
v-if="showToolbar('export')"
|
||||
class="layui-inline"
|
||||
title="导出"
|
||||
lay-event
|
||||
:style="toolbarStyle('export')"
|
||||
@click="exportData()"
|
||||
>
|
||||
<div v-if="showToolbar('export')" class="layui-inline" title="导出" lay-event :style="toolbarStyle('export')"
|
||||
@click="exportData()">
|
||||
<i class="layui-icon layui-icon-export"></i>
|
||||
</div>
|
||||
|
||||
<!-- 打印 -->
|
||||
<div
|
||||
v-if="showToolbar('print')"
|
||||
:style="toolbarStyle('print')"
|
||||
class="layui-inline"
|
||||
title="打印"
|
||||
lay-event
|
||||
@click="print()"
|
||||
>
|
||||
<div v-if="showToolbar('print')" :style="toolbarStyle('print')" class="layui-inline" title="打印" lay-event
|
||||
@click="print()">
|
||||
<i class="layui-icon layui-icon-print"></i>
|
||||
</div>
|
||||
</div>
|
||||
@ -885,47 +868,26 @@ window.addEventListener("click", heddin);
|
||||
|
||||
<div class="layui-table-box">
|
||||
<!-- 表头 -->
|
||||
<div
|
||||
class="layui-table-header"
|
||||
:style="[{ 'padding-right': `${scrollWidthCell}px` }]"
|
||||
>
|
||||
<div class="layui-table-header" :style="[{ 'padding-right': `${scrollWidthCell}px` }]">
|
||||
<div class="layui-table-header-wrapper" ref="tableHeader">
|
||||
<table
|
||||
class="layui-table"
|
||||
:lay-size="size"
|
||||
:lay-skin="skin"
|
||||
ref="tableHeaderTable"
|
||||
>
|
||||
<table class="layui-table" :lay-size="size" :lay-skin="skin" ref="tableHeaderTable">
|
||||
<colgroup>
|
||||
<template v-for="column in tableBodyColumns" :key="column">
|
||||
<template v-if="tableColumnKeys.includes(column.key)">
|
||||
<col
|
||||
:width="column.width"
|
||||
:style="{
|
||||
minWidth: column.minWidth ? column.minWidth : '50px',
|
||||
}"
|
||||
/>
|
||||
<col :width="column.width" :style="{
|
||||
minWidth: column.minWidth ? column.minWidth : '50px',
|
||||
}" />
|
||||
</template>
|
||||
</template>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<template
|
||||
v-for="(
|
||||
<template v-for="(
|
||||
tableHeadColumn, tableHeadColumnIndex
|
||||
) in tableHeadColumns"
|
||||
:key="tableHeadColumnIndex"
|
||||
>
|
||||
) in tableHeadColumns" :key="tableHeadColumnIndex">
|
||||
<tr>
|
||||
<template
|
||||
v-for="(column, columnIndex) in tableHeadColumn"
|
||||
:key="column"
|
||||
>
|
||||
<th
|
||||
v-if="tableColumnKeys.includes(column.key)"
|
||||
:colspan="column.colspan"
|
||||
:rowspan="column.rowspan"
|
||||
class="layui-table-cell"
|
||||
:class="[
|
||||
<template v-for="(column, columnIndex) in tableHeadColumn" :key="column">
|
||||
<th v-if="tableColumnKeys.includes(column.key)" :colspan="column.colspan" :rowspan="column.rowspan"
|
||||
class="layui-table-cell" :class="[
|
||||
renderFixedClassName(column, columnIndex),
|
||||
column.fixed
|
||||
? `layui-table-fixed-${column.fixed}`
|
||||
@ -939,26 +901,19 @@ window.addEventListener("click", heddin);
|
||||
column.type == 'number'
|
||||
? 'layui-table-cell-number'
|
||||
: '',
|
||||
]"
|
||||
:style="[
|
||||
{
|
||||
textAlign: column.align,
|
||||
},
|
||||
renderHeadFixedStyle(
|
||||
column,
|
||||
columnIndex,
|
||||
tableHeadColumn
|
||||
),
|
||||
]"
|
||||
>
|
||||
]" :style="[
|
||||
{
|
||||
textAlign: column.align,
|
||||
},
|
||||
renderHeadFixedStyle(
|
||||
column,
|
||||
columnIndex,
|
||||
tableHeadColumn
|
||||
),
|
||||
]">
|
||||
<template v-if="column.type == 'checkbox'">
|
||||
<lay-checkbox
|
||||
v-model="hasChecked"
|
||||
:is-indeterminate="!allChecked"
|
||||
skin="primary"
|
||||
value="all"
|
||||
@change="changeAll"
|
||||
/>
|
||||
<lay-checkbox v-model="hasChecked" :is-indeterminate="!allChecked" skin="primary" value="all"
|
||||
@change="changeAll" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<span>
|
||||
@ -970,33 +925,16 @@ window.addEventListener("click", heddin);
|
||||
</template>
|
||||
</span>
|
||||
<!-- 插槽 -->
|
||||
<span
|
||||
v-if="column.sort"
|
||||
class="layui-table-sort layui-inline"
|
||||
lay-sort
|
||||
>
|
||||
<i
|
||||
@click.stop="sortTable($event, column.key, 'asc')"
|
||||
class="layui-edge layui-table-sort-asc"
|
||||
title="升序"
|
||||
></i>
|
||||
<i
|
||||
@click.stop="
|
||||
sortTable($event, column.key, 'desc')
|
||||
"
|
||||
class="layui-edge layui-table-sort-desc"
|
||||
title="降序"
|
||||
></i>
|
||||
<span v-if="column.sort" class="layui-table-sort layui-inline" lay-sort>
|
||||
<i @click.stop="sortTable($event, column.key, 'asc')" class="layui-edge layui-table-sort-asc"
|
||||
title="升序"></i>
|
||||
<i @click.stop="
|
||||
sortTable($event, column.key, 'desc')
|
||||
" class="layui-edge layui-table-sort-desc" title="降序"></i>
|
||||
</span>
|
||||
<span
|
||||
v-if="column.soul"
|
||||
class="layui-table-sort layui-inline soul-icon"
|
||||
>
|
||||
<i
|
||||
class="soul-icon soul-box"
|
||||
:class="column.soulclass || 'soul-icon-filter'"
|
||||
@click.stop="showsoul($event, column, column.key)"
|
||||
>
|
||||
<span v-if="column.soul" class="layui-table-sort layui-inline soul-icon">
|
||||
<i class="soul-icon soul-box" :class="column.soulclass || 'soul-icon-filter'"
|
||||
@click.stop="showsoul($event, column, column.key)">
|
||||
<!-- <div v-show="column.soulshow" @click.stop="" class="soulbox">
|
||||
11111
|
||||
</div> -->
|
||||
@ -1012,61 +950,29 @@ window.addEventListener("click", heddin);
|
||||
</div>
|
||||
</div>
|
||||
<!-- 表身 -->
|
||||
<div
|
||||
class="layui-table-body layui-table-main"
|
||||
:style="{ height: height, maxHeight: maxHeight }"
|
||||
ref="tableBody"
|
||||
>
|
||||
<table
|
||||
class="layui-table"
|
||||
v-if="datalist.length > 0 && loading == false"
|
||||
:class="{ 'layui-table-even': props.even }"
|
||||
:lay-size="size"
|
||||
:lay-skin="skin"
|
||||
>
|
||||
<div class="layui-table-body layui-table-main" :style="{ height: height, maxHeight: maxHeight }" ref="tableBody">
|
||||
<table class="layui-table" v-if="datalist.length > 0 && loading == false"
|
||||
:class="{ 'layui-table-even': props.even }" :lay-size="size" :lay-skin="skin">
|
||||
<colgroup>
|
||||
<template
|
||||
v-for="(column, columnIndex) in tableBodyColumns"
|
||||
:key="columnIndex"
|
||||
>
|
||||
<template v-for="(column, columnIndex) in tableBodyColumns" :key="columnIndex">
|
||||
<template v-if="tableColumnKeys.includes(column.key)">
|
||||
<col
|
||||
:width="column.width"
|
||||
:style="{
|
||||
minWidth: column.minWidth ? column.minWidth : '50px',
|
||||
}"
|
||||
/>
|
||||
<col :width="column.width" :style="{
|
||||
minWidth: column.minWidth ? column.minWidth : '50px',
|
||||
}" />
|
||||
</template>
|
||||
</template>
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<!-- 渲染 -->
|
||||
<template v-for="(children, index) in datalist" :key="index">
|
||||
<table-row
|
||||
:id="id"
|
||||
:index="index"
|
||||
:data="children"
|
||||
:columns="tableBodyColumns"
|
||||
:indent-size="indentSize"
|
||||
:currentIndentSize="currentIndentSize"
|
||||
:tableColumnKeys="tableColumnKeys"
|
||||
:expandSpace="childrenExpandSpace"
|
||||
:expandIndex="expandIndex"
|
||||
:cellStyle="cellStyle"
|
||||
:cellClassName="cellClassName"
|
||||
:rowStyle="rowStyle"
|
||||
:rowClassName="rowClassName"
|
||||
:spanMethod="spanMethod"
|
||||
:defaultExpandAll="defaultExpandAll"
|
||||
:getCheckboxProps="getCheckboxProps"
|
||||
:getRadioProps="getRadioProps"
|
||||
v-model:expandKeys="tableExpandKeys"
|
||||
v-model:selectedKeys="tableSelectedKeys"
|
||||
v-model:selectedKey="tableSelectedKey"
|
||||
@row="rowClick"
|
||||
@row-double="rowDoubleClick"
|
||||
@row-contextmenu="rowContextmenu"
|
||||
>
|
||||
<table-row :id="id" :index="index" :data="children" :columns="tableBodyColumns" :indent-size="indentSize"
|
||||
:currentIndentSize="currentIndentSize" :tableColumnKeys="tableColumnKeys"
|
||||
:expandSpace="childrenExpandSpace" :expandIndex="expandIndex" :cellStyle="cellStyle"
|
||||
:cellClassName="cellClassName" :rowStyle="rowStyle" :rowClassName="rowClassName"
|
||||
:spanMethod="spanMethod" :defaultExpandAll="defaultExpandAll" :getCheckboxProps="getCheckboxProps"
|
||||
:getRadioProps="getRadioProps" v-model:expandKeys="tableExpandKeys"
|
||||
v-model:selectedKeys="tableSelectedKeys" v-model:selectedKey="tableSelectedKey" @row="rowClick"
|
||||
@row-double="rowDoubleClick" @row-contextmenu="rowContextmenu">
|
||||
<template v-for="name in slotsData" #[name]="{ data }">
|
||||
<slot :name="name" :data="data"></slot>
|
||||
</template>
|
||||
@ -1076,28 +982,21 @@ window.addEventListener("click", heddin);
|
||||
</table-row>
|
||||
</template>
|
||||
<tr v-if="hasTotalRow" class="layui-table-total">
|
||||
<template
|
||||
v-for="(column, columnIndex) in columns"
|
||||
:key="columnIndex"
|
||||
>
|
||||
<template v-for="(column, columnIndex) in columns" :key="columnIndex">
|
||||
<template v-if="tableColumnKeys.includes(column.key)">
|
||||
<td
|
||||
:style="[
|
||||
{
|
||||
textAlign: column.align,
|
||||
whiteSpace: column.ellipsisTooltip
|
||||
? 'nowrap'
|
||||
: 'normal',
|
||||
},
|
||||
renderFixedStyle(column, columnIndex),
|
||||
]"
|
||||
:class="[
|
||||
'layui-table-cell',
|
||||
renderFixedClassName(column, columnIndex),
|
||||
column.fixed ? `layui-table-fixed-${column.fixed}` : '',
|
||||
]"
|
||||
v-html="renderTotalRowCell(column)"
|
||||
></td>
|
||||
<td :style="[
|
||||
{
|
||||
textAlign: column.align,
|
||||
whiteSpace: column.ellipsisTooltip
|
||||
? 'nowrap'
|
||||
: 'normal',
|
||||
},
|
||||
renderFixedStyle(column, columnIndex),
|
||||
]" :class="[
|
||||
'layui-table-cell',
|
||||
renderFixedClassName(column, columnIndex),
|
||||
column.fixed ? `layui-table-fixed-${column.fixed}` : '',
|
||||
]" v-html="renderTotalRowCell(column)"></td>
|
||||
</template>
|
||||
</template>
|
||||
</tr>
|
||||
@ -1109,9 +1008,7 @@ window.addEventListener("click", heddin);
|
||||
</template>
|
||||
<template v-if="loading == true">
|
||||
<div class="layui-table-loading">
|
||||
<i
|
||||
class="layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"
|
||||
></i>
|
||||
<i class="layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@ -1120,41 +1017,17 @@ window.addEventListener("click", heddin);
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="page && page.total > 0" class="layui-table-page">
|
||||
<table-page
|
||||
:total="page.total"
|
||||
:pages="page.pages"
|
||||
:theme="page.theme"
|
||||
:limits="page.limits"
|
||||
:showSkip="page.showSkip"
|
||||
:show-page="page.showPage"
|
||||
:showRefresh="page.showRefresh"
|
||||
:showLimit="page.showLimit"
|
||||
:showCount="page.showCount"
|
||||
:count="page.count"
|
||||
v-model:current="page.current"
|
||||
v-model:limit="page.limit"
|
||||
@change="change"
|
||||
>
|
||||
<table-page :total="page.total" :pages="page.pages" :theme="page.theme" :limits="page.limits"
|
||||
:showSkip="page.showSkip" :show-page="page.showPage" :showRefresh="page.showRefresh" :showLimit="page.showLimit"
|
||||
:showCount="page.showCount" :count="page.count" v-model:current="page.current" v-model:limit="page.limit"
|
||||
@change="change">
|
||||
</table-page>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-for="(tableHeadColumn, tableHeadColumnIndex) in tableHeadColumns"
|
||||
:key="tableHeadColumnIndex"
|
||||
>
|
||||
<div v-for="(tableHeadColumn, tableHeadColumnIndex) in tableHeadColumns" :key="tableHeadColumnIndex">
|
||||
<div v-for="(column, columnIndex) in tableHeadColumn" :key="column">
|
||||
<soultable
|
||||
:top="soultop"
|
||||
:left="soulleft"
|
||||
v-show="soulkey == column.key"
|
||||
:show="soulkey == column.key"
|
||||
@asc="asc"
|
||||
@desc="desc"
|
||||
@daochu="exportData"
|
||||
:list="datalist"
|
||||
:soulkey="column.key"
|
||||
@sx="sx"
|
||||
></soultable>
|
||||
<soultable :top="soultop" :left="soulleft" v-show="soulkey == column.key" :show="soulkey == column.key" @asc="asc"
|
||||
@desc="desc" @daochu="exportData" :list="datalist" :soulkey="column.key" @sx="sx"></soultable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
154
umd/index.js
154
umd/index.js
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user