CustomerCell.vue 2.6 KB
Newer Older
陈文彬 已提交
1 2 3 4
<template>
  <div class="p-4">
    <BasicTable @register="registerTable">
      <template #id="{ record }"> ID: {{ record.id }} </template>
V
vben 已提交
5 6 7 8
      <template #no="{ record }">
        <Tag color="green">
          {{ record.no }}
        </Tag>
陈文彬 已提交
9
      </template>
10
      <template #avatar="{ record }">
11
        <Avatar :size="60" :src="record.avatar" />
12
      </template>
13 14
      <template #img="{ text }">
        <TableImg :size="60" :simpleShow="true" :imgList="text" />
陈文彬 已提交
15
      </template>
16
      <template #imgs="{ text }"> <TableImg :size="60" :imgList="text" /> </template>
V
vben 已提交
17 18 19 20 21 22

      <template #category="{ record }">
        <Tag color="green">
          {{ record.no }}
        </Tag>
      </template>
陈文彬 已提交
23 24 25 26 27 28
    </BasicTable>
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { BasicTable, useTable, BasicColumn, TableImg } from '/@/components/Table';
29
  import { Tag, Avatar } from 'ant-design-vue';
陈文彬 已提交
30 31 32 33 34 35 36
  import { demoListApi } from '/@/api/demo/table';
  const columns: BasicColumn[] = [
    {
      title: 'ID',
      dataIndex: 'id',
      slots: { customRender: 'id' },
    },
37 38 39 40 41 42
    {
      title: '头像',
      dataIndex: 'avatar',
      width: 100,
      slots: { customRender: 'avatar' },
    },
V
vben 已提交
43 44 45 46 47
    {
      title: '分类',
      dataIndex: 'category',
      width: 80,
      align: 'center',
V
vben 已提交
48
      defaultHidden: true,
V
vben 已提交
49 50
      slots: { customRender: 'category' },
    },
陈文彬 已提交
51 52 53 54 55 56
    {
      title: '姓名',
      dataIndex: 'name',
      width: 120,
    },
    {
57
      title: '图片列表1',
58
      dataIndex: 'imgArr',
59 60
      helpMessage: ['这是简单模式的图片列表', '只会显示一张在表格中', '但点击可预览多张图片'],
      width: 140,
陈文彬 已提交
61 62
      slots: { customRender: 'img' },
    },
63 64 65 66 67 68
    {
      title: '照片列表2',
      dataIndex: 'imgs',
      width: 160,
      slots: { customRender: 'imgs' },
    },
陈文彬 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
    {
      title: '地址',
      dataIndex: 'address',
    },
    {
      title: '编号',
      dataIndex: 'no',
      slots: { customRender: 'no' },
    },
    {
      title: '开始时间',
      dataIndex: 'beginTime',
    },
    {
      title: '结束时间',
      dataIndex: 'endTime',
    },
  ];
  export default defineComponent({
88
    components: { BasicTable, TableImg, Tag, Avatar },
陈文彬 已提交
89 90 91
    setup() {
      const [registerTable] = useTable({
        title: '自定义列内容',
92
        titleHelpMessage: '表格中所有头像、图片均为mock生成,仅用于演示图片占位',
陈文彬 已提交
93 94
        api: demoListApi,
        columns: columns,
V
vben 已提交
95
        bordered: true,
V
vben 已提交
96
        showTableSetting: true,
陈文彬 已提交
97 98 99 100 101 102 103 104
      });

      return {
        registerTable,
      };
    },
  });
</script>