jeecg-boot-vue3/src/views/demo/document/table/CustomerCellDemo.vue

107 lines
2.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="p-4">
<BasicTable @register="registerTable">
<template #id="{ record }"> ID: {{ record.id }} </template>
<template #bodyCell="{ column, record }">
<Avatar v-if="column.key === 'avatar'" :size="60" :src="record.avatar" />
<Tag v-if="column.key === 'no'" color="green">
{{ record.no }}
</Tag>
</template>
<template #img="{ text }">
<TableImg :size="60" :simpleShow="true" :imgList="text" />
</template>
<template #imgs="{ text }"> <TableImg :size="60" :imgList="text" /> </template>
<template #category="{ record }">
<Tag color="green">
{{ record.no }}
</Tag>
</template>
</BasicTable>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { BasicTable, useTable, BasicColumn, TableImg } from '/@/components/Table';
import { Tag, Avatar } from 'ant-design-vue';
import { demoListApi } from '/@/api/demo/table';
import { useListPage } from '/@/hooks/system/useListPage';
const columns: BasicColumn[] = [
{
title: 'ID',
dataIndex: 'id',
slots: { customRender: 'id' },
},
{
title: '',
dataIndex: 'avatar',
width: 100,
},
{
title: '',
dataIndex: 'category',
width: 80,
align: 'center',
defaultHidden: true,
slots: { customRender: 'category' },
},
{
title: '',
dataIndex: 'name',
width: 120,
},
{
title: '1',
dataIndex: 'imgArr',
helpMessage: ['', '', ''],
width: 140,
slots: { customRender: 'img' },
},
{
title: '2',
dataIndex: 'imgs',
width: 160,
slots: { customRender: 'imgs' },
},
{
title: '',
dataIndex: 'address',
},
{
title: '',
dataIndex: 'no',
},
{
title: '',
dataIndex: 'beginTime',
},
{
title: '',
dataIndex: 'endTime',
},
];
export default defineComponent({
components: { BasicTable, TableImg, Tag, Avatar },
setup() {
const { tableContext } = useListPage({
tableProps: {
title: '',
titleHelpMessage: 'mock',
api: demoListApi,
columns: columns,
bordered: true,
showTableSetting: false,
showActionColumn: false,
useSearchForm: false,
},
});
//table
const [registerTable] = tableContext;
return {
registerTable,
};
},
});
</script>