2021-10-09 02:41:52 +00:00
|
|
|
<template>
|
2021-10-09 21:48:45 +00:00
|
|
|
<div>
|
2021-10-09 02:41:52 +00:00
|
|
|
<table class="layui-hide" id="test" lay-filter="test"></table>
|
|
|
|
<div
|
|
|
|
class="layui-form layui-border-box layui-table-view layui-table-view-1"
|
|
|
|
>
|
|
|
|
<div class="layui-table-tool">
|
|
|
|
<div class="layui-table-tool-self">
|
|
|
|
<div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS">
|
|
|
|
<i class="layui-icon layui-icon-cols"></i>
|
|
|
|
</div>
|
|
|
|
<div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT">
|
|
|
|
<i class="layui-icon layui-icon-export"></i>
|
|
|
|
</div>
|
|
|
|
<div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT">
|
|
|
|
<i class="layui-icon layui-icon-print"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="layui-table-box">
|
|
|
|
<div class="layui-table-header">
|
|
|
|
<table cellspacing="0" cellpadding="0" border="0" class="layui-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2021-10-09 21:48:45 +00:00
|
|
|
<th class="layui-table-col-special">
|
|
|
|
<div class="layui-table-cell laytable-cell-checkbox">
|
2021-10-09 02:41:52 +00:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
name="layTableCheckbox"
|
|
|
|
lay-skin="primary"
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
class="layui-unselect layui-form-checkbox"
|
|
|
|
lay-skin="primary"
|
|
|
|
>
|
|
|
|
<i class="layui-icon layui-icon-ok"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</th>
|
2021-10-09 21:48:45 +00:00
|
|
|
<th v-for="column in columns" :key="column">
|
|
|
|
<div
|
|
|
|
class="layui-table-cell"
|
|
|
|
:style="{ width: column.width }"
|
|
|
|
>
|
|
|
|
<span>{{ column.title }}</span>
|
2021-10-09 02:41:52 +00:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="layui-table-body layui-table-main">
|
|
|
|
<table cellspacing="0" cellpadding="0" border="0" class="layui-table">
|
|
|
|
<tbody>
|
2021-10-09 21:48:45 +00:00
|
|
|
<template v-for="data in dataSource" :key="data">
|
|
|
|
<tr>
|
|
|
|
<td class="layui-table-col-special">
|
|
|
|
<div class="layui-table-cell laytable-cell-checkbox">
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
name="layTableCheckbox"
|
|
|
|
lay-skin="primary"
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
class="layui-unselect layui-form-checkbox"
|
|
|
|
lay-skin="primary"
|
|
|
|
>
|
|
|
|
<i class="layui-icon layui-icon-ok"></i>
|
|
|
|
</div>
|
2021-10-09 02:41:52 +00:00
|
|
|
</div>
|
2021-10-09 21:48:45 +00:00
|
|
|
</td>
|
|
|
|
|
2021-10-10 07:22:07 +00:00
|
|
|
<template v-for="column in columns" :key="column">
|
|
|
|
|
|
|
|
<template v-if="column.customSlot">
|
|
|
|
<td>
|
|
|
|
<div
|
|
|
|
:style="{ width: column.width }"
|
|
|
|
style="padding: 0px 16px"
|
|
|
|
>
|
|
|
|
<slot :name="column.customSlot" :data="data"></slot>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template
|
|
|
|
v-else
|
|
|
|
v-for="(value, key, index) in data"
|
|
|
|
:key="index"
|
|
|
|
>
|
2021-10-09 21:48:45 +00:00
|
|
|
<td v-if="column.key == key">
|
|
|
|
<div
|
|
|
|
:style="{ width: column.width }"
|
|
|
|
style="padding: 0px 16px"
|
|
|
|
>
|
|
|
|
<span v-if="column.slot">
|
|
|
|
<slot :name="column.slot" :data="data"></slot>
|
|
|
|
</span>
|
|
|
|
<span v-else> {{ value }} </span>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</template>
|
2021-10-10 07:22:07 +00:00
|
|
|
|
2021-10-09 21:48:45 +00:00
|
|
|
</template>
|
|
|
|
</tr>
|
|
|
|
</template>
|
2021-10-09 02:41:52 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-10 16:44:00 +00:00
|
|
|
<div v-if="page" class="layui-table-page">
|
|
|
|
<lay-page :total="page.total" :limit="page.limit" @jump="change" showPage showLimit showSkip></lay-page>
|
2021-10-09 02:41:52 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script setup name="LayTable" lang="ts">
|
2021-10-09 21:48:45 +00:00
|
|
|
import { defineProps, useSlots } from 'vue'
|
2021-10-09 17:07:37 +00:00
|
|
|
|
|
|
|
const props =
|
|
|
|
defineProps<{
|
|
|
|
columns?: Object[]
|
2021-10-09 21:48:45 +00:00
|
|
|
dataSource?: Object[]
|
|
|
|
skin?: string
|
2021-10-10 16:44:00 +00:00
|
|
|
page?: Object
|
2021-10-09 17:07:37 +00:00
|
|
|
}>()
|
|
|
|
|
2021-10-10 16:44:00 +00:00
|
|
|
const emit = defineEmits(['change'])
|
|
|
|
|
2021-10-09 21:48:45 +00:00
|
|
|
const slot = useSlots()
|
|
|
|
const slots = slot.default && slot.default()
|
2021-10-10 16:44:00 +00:00
|
|
|
|
|
|
|
const change = function(page: any){
|
|
|
|
emit('change',page)
|
|
|
|
}
|
2021-10-09 21:48:45 +00:00
|
|
|
</script>
|