/
Vuetify.vue
162 lines (156 loc) · 3.46 KB
/
Vuetify.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<script setup>
import useAdmateAdapter from '../../useAdmateAdapter'
import { API_PREFIX as urlPrefix } from '../../../mock/crud'
const {
list,
form,
getList,
c,
r,
u,
d,
updateStatus,
submitForm,
formTitle,
queryList,
listFilterRef,
formRef,
} = useAdmateAdapter({
urlPrefix,
}, {
validateListFilter: (...args) => new Promise((resolve, reject) => {
listFilterRef.value.validate(...args) ? resolve() : reject()
}),
validateFormData: (...args) => new Promise((resolve, reject) => {
formRef.value.validate(...args) ? resolve() : reject()
}),
clearValidateOfFormData: (...args) => formRef.value.resetValidation(...args),
})
</script>
<template>
<div
class="p-20px"
data-app
>
<v-form ref="listFilterRef">
<v-text-field
v-model="list.filter.name"
label="姓名"
:rules="[v => !!v || 'Name is required']"
required
class="w-220px"
style="display:inline-block !important;"
/>
<v-btn
v-if="!list.watchFilter"
class="ml-10px"
color="#2A73C5"
dark
@click="queryList"
>
查询
</v-btn>
<v-btn
class="ml-10px"
@click="() => {
listFilterRef.reset()
}"
>
重置
</v-btn>
</v-form>
<div class="flex justify-between my-10px">
<div>
<v-btn
dark
color="#2A73C5"
@click="c"
>
新增
</v-btn>
</div>
<v-pagination
v-model="list.filter.pageNo"
:length="Math.ceil(list.total / list.filter.pageSize)"
@input="queryList"
/>
</div>
<v-simple-table>
<template #default>
<thead>
<tr>
<th>
Name
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<tr
v-for="item in list.data"
:key="item.name"
>
<td>{{ item.name }}</td>
<td>
<v-btn
plain
@click="r(item)"
>
查看
</v-btn>
<v-btn
plain
@click="u(item)"
>
编辑
</v-btn>
<v-btn
plain
@click="d(item)"
>
删除
</v-btn>
</td>
</tr>
</tbody>
</template>
</v-simple-table>
<v-dialog v-model="form.show">
<v-card>
<v-card-title>
<h5>{{ formTitle }}</h5>
</v-card-title>
<v-card-text>
<v-form
ref="formRef"
:disabled="form.status === 'r' || form.submitting"
>
<v-text-field
v-model="form.data.name"
label="姓名*"
:rules="[v => !!v || 'Name is required']"
required
/>
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn @click="form.show = false">
取 消
</v-btn>
<v-btn
v-if="form.status !== 'r' && !form.loading"
dark
color="#2A73C5"
:loading="form.submitting"
@click="() => { submitForm() }"
>
确 定
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>