|
1 | 1 | <template>
|
2 | 2 | <div class="pb-5">
|
3 |
| - <!-- <f-table |
4 |
| - :columns="table.columns" |
5 |
| - :buttons="table.buttons" |
6 |
| - :form="table.form" |
7 |
| - :settings="table.settings" |
8 |
| - :list="table.list" |
9 |
| - :filter-params="table.filterParams" |
10 |
| - :pagination="table.pagination" |
11 |
| - :id="table.id" |
12 |
| - > --> |
13 |
| - |
14 |
| - <el-input v-model="r" /> |
15 |
| - |
16 |
| - <!-- <el-select v-model="table.filterParams.gender"> |
17 |
| - <el-option value="m"> |
18 |
| - Male |
19 |
| - </el-option> |
20 |
| - </el-select> --> |
21 |
| - <!-- <f-table v-bind="table"> |
22 |
| - <template #column-created_at> |
23 |
| - <a href="https://google.com" class="underline text-primary-500" target="_blank">Haz click</a> |
24 |
| - </template> |
25 |
| - <template #column-actions-prepend> |
26 |
| - 'hello' |
27 |
| - </template> |
28 |
| - </f-table> --> |
| 3 | + <f-table v-bind="table" /> |
29 | 4 | </div>
|
30 |
| - |
31 |
| - <button @click="generate"> |
32 |
| - Generate |
33 |
| - </button> |
34 | 5 | </template>
|
35 | 6 |
|
36 | 7 | <script lang='ts' setup>
|
37 | 8 | import { FieldType, useForm, useTable } from '@fancy-crud/vue'
|
38 | 9 |
|
39 |
| -const r = ref(1) |
40 |
| -
|
41 |
| -function generate() { |
42 |
| - const form = useForm({ |
43 |
| - id: 'formulario', |
44 |
| - fields: { |
45 |
| - name: { |
46 |
| - type: FieldType.text, |
47 |
| - label: 'First name', |
48 |
| - placeholder: 'First name', |
49 |
| - wrapper: { |
50 |
| - class: 'col-span-12', |
51 |
| - }, |
52 |
| - }, |
53 |
| - gender: { |
54 |
| - type: FieldType.select, |
55 |
| - label: 'Select', |
56 |
| - optionLabel: 'label', |
57 |
| - optionValue: 'value', |
58 |
| - options: [ |
59 |
| - { label: 'Male', value: 'm' }, |
60 |
| - { label: 'Female', value: 'f' }, |
61 |
| - ], |
62 |
| - }, |
63 |
| - created_at: { |
64 |
| - type: FieldType.text, |
65 |
| - label: 'Created at', |
66 |
| - updateOnly: true, |
67 |
| - readonly: true, |
68 |
| - disabled: true, |
69 |
| - wrapper: { |
70 |
| - class: 'col-span-12', |
71 |
| - }, |
| 10 | +const form = useForm({ |
| 11 | + id: 'formulario', |
| 12 | + fields: { |
| 13 | + name: { |
| 14 | + type: FieldType.text, |
| 15 | + label: 'First name', |
| 16 | + placeholder: 'First name', |
| 17 | + wrapper: { |
| 18 | + class: 'col-span-12', |
72 | 19 | },
|
73 | 20 | },
|
74 |
| - settings: { |
75 |
| - url: 'artists/', |
76 |
| - title: '{{ Crear artista | Actualizar artista }}', |
| 21 | + gender: { |
| 22 | + type: FieldType.select, |
| 23 | + label: 'Select', |
| 24 | + optionLabel: 'label', |
| 25 | + optionValue: 'value', |
| 26 | + options: [ |
| 27 | + { label: 'Male', value: 'm' }, |
| 28 | + { label: 'Female', value: 'f' }, |
| 29 | + ], |
77 | 30 | },
|
78 |
| - responseInterceptor: { |
| 31 | + created_at: { |
| 32 | + type: FieldType.text, |
| 33 | + label: 'Created at', |
| 34 | + updateOnly: true, |
| 35 | + readonly: true, |
| 36 | + disabled: true, |
| 37 | + wrapper: { |
| 38 | + class: 'col-span-12', |
| 39 | + }, |
| 40 | + }, |
| 41 | + }, |
| 42 | + settings: { |
| 43 | + url: 'artists/', |
| 44 | + title: '{{ Crear artista | Actualizar artista }}', |
| 45 | + }, |
| 46 | + responseInterceptor: { |
79 | 47 | // 201: (formId, response) => {
|
80 | 48 | // console.log('🚀 ~ file: FTableViewer.vue:65 ~ response:', response)
|
81 | 49 | // console.log(response)
|
82 | 50 | // },
|
83 |
| - }, |
84 |
| - }) |
85 |
| -
|
86 |
| - console.log(form) |
87 |
| -} |
| 51 | + }, |
| 52 | +}) |
88 | 53 |
|
89 |
| -// const table = useTable({ |
90 |
| -// form, |
91 |
| -// columns: { |
92 |
| -// gender: { |
93 |
| -// format: (value: string) => value === 'm' ? 'Male' : 'Female', |
94 |
| -// width: 700, |
95 |
| -// }, |
96 |
| -// created_at: { |
97 |
| -// format: (value: string) => 'anything', |
98 |
| -// }, |
99 |
| -// actions: { value: 'actions', label: '', width: '200px', align: 'right' }, |
100 |
| -// }, |
101 |
| -// pagination: { |
102 |
| -// rowsPerPage: 10, |
103 |
| -// hidden: true, |
104 |
| -// }, |
105 |
| -// filterParams: { |
106 |
| -// gender: '', |
107 |
| -// }, |
108 |
| -// buttons: { |
109 |
| -// edit: { |
110 |
| -// // onClick(row) { |
111 |
| -// // console.log('🚀 ~ onClick ~ row:', row) |
112 |
| -// // }, |
113 |
| -// }, |
114 |
| -// }, |
115 |
| -// }) |
| 54 | +const table = useTable({ |
| 55 | + form, |
| 56 | + columns: { |
| 57 | + gender: { |
| 58 | + format: (value: string) => value === 'm' ? 'Male' : 'Female', |
| 59 | + width: 700, |
| 60 | + }, |
| 61 | + created_at: { |
| 62 | + format: (value: string) => 'anything', |
| 63 | + }, |
| 64 | + actions: { value: 'actions', label: '', width: '200px', align: 'right' }, |
| 65 | + }, |
| 66 | + pagination: { |
| 67 | + rowsPerPage: 10, |
| 68 | + // hidden: true, |
| 69 | + }, |
| 70 | + filterParams: { |
| 71 | + gender: '', |
| 72 | + }, |
| 73 | + buttons: { |
| 74 | + edit: { |
| 75 | + // onClick(row) { |
| 76 | + // console.log('🚀 ~ onClick ~ row:', row) |
| 77 | + // }, |
| 78 | + }, |
| 79 | + }, |
| 80 | +}) |
116 | 81 | </script>
|
0 commit comments