Blame view

src/views/demo/comp/desc/index.vue 1.91 KB
陈文彬 authored
1
<template>
2
  <PageWrapper title="详情组件示例">
陈文彬 authored
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    <Description
      title="基础示例"
      :collapseOptions="{ canExpand: true, helpMessage: 'help me' }"
      :column="3"
      :data="mockData"
      :schema="schema"
    />

    <Description
      class="mt-4"
      title="垂直示例"
      layout="vertical"
      :collapseOptions="{ canExpand: true, helpMessage: 'help me' }"
      :column="2"
      :data="mockData"
      :schema="schema"
    />

    <Description @register="register" class="mt-4" />
    <Description @register="register1" class="mt-4" />
23
  </PageWrapper>
陈文彬 authored
24
25
26
27
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { Description, DescItem, useDescription } from '/@/components/Description/index';
28
29
30
  import { PageWrapper } from '/@/components/Page';

  const mockData: Recordable = {
陈文彬 authored
31
32
    username: 'test',
    nickName: 'VB',
33
    age: '123',
陈文彬 authored
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
    phone: '15695909xxx',
    email: '190848757@qq.com',
    addr: '厦门市思明区',
    sex: '男',
    certy: '3504256199xxxxxxxxx',
    tag: 'orange',
  };
  const schema: DescItem[] = [
    {
      field: 'username',
      label: '用户名',
    },
    {
      field: 'nickName',
      label: '昵称',
      render: (curVal, data) => {
        return `${data.username}-${curVal}`;
      },
    },
    {
      field: 'phone',
      label: '联系电话',
    },
    {
      field: 'email',
      label: '邮箱',
    },
    {
      field: 'addr',
      label: '地址',
    },
  ];
  export default defineComponent({
67
    components: { Description, PageWrapper },
陈文彬 authored
68
69
70
71
72
73
74
    setup() {
      const [register] = useDescription({
        title: 'useDescription',
        data: mockData,
        schema: schema,
      });
Vben authored
75
      const [register1] = useDescription({
陈文彬 authored
76
77
78
79
80
        title: '无边框',
        bordered: false,
        data: mockData,
        schema: schema,
      });
81
陈文彬 authored
82
83
84
85
      return { mockData, schema, register, register1 };
    },
  });
</script>