-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFormDecoupled.vue
130 lines (123 loc) · 2.62 KB
/
FormDecoupled.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
<script setup>
import useAdmateAdapter from '@/utils/useAdmateAdapter'
import { toRaw } from 'vue'
import { useRouter } from 'vue-router'
import { API_PREFIX as urlPrefix } from '../../../mock/crud'
const router = useRouter()
const {
list,
listFilterRef,
form,
} = useAdmateAdapter({
axiosConfig: {
urlPrefix,
},
form: {
proxy: {
open() {
router.push({
path: '/form-page',
query: {
urlPrefix,
form: JSON.stringify(toRaw(form.value)),
},
})
},
},
},
})
</script>
<template>
<div class="p-20px">
<el-form
ref="listFilterRef"
:model="list.filter"
inline
>
<el-form-item
prop="name"
required
>
<el-input
v-model="list.filter.name"
placeholder="姓名"
/>
</el-form-item>
<el-form-item prop="status">
<el-select
v-model="list.filter.status"
placeholder="状态"
>
<el-option
v-for="(v, i) of ['停用', '启用']"
:key="i"
:label="v"
:value="v"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
v-if="!list.watchFilter"
type="primary"
@click="list.search()"
>
查询
</el-button>
<el-button
@click="list.reset()"
>
重置
</el-button>
</el-form-item>
</el-form>
<div class="flex justify-between my-10px">
<div>
<el-button
type="primary"
@click="form.create()"
>
新增
</el-button>
</div>
<el-pagination
v-model:current-page="list.filter.pageNo"
v-model:page-size="list.filter.pageSize"
:total="list.total"
@current-change="list.read()"
@size-change="list.read()"
/>
</div>
<el-table
v-loading="list.loading"
:data="list.data"
>
<el-table-column
prop="name"
label="姓名"
/>
<el-table-column label="操作">
<template #default="{ row }">
<el-button
type="text"
@click="form.read(row)"
>
查看
</el-button>
<el-button
type="text"
@click="form.update(row)"
>
编辑
</el-button>
<el-button
type="text"
@click="form.delete(row)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>