index.vue
5.07 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<template>
<div class="container">
<a-card class="general-card" title="查询表格">
<!-- 查询条件 -->
<a-row>
<a-col :flex="1">
<a-col :flex="1">
<a-form :model="formModel" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }"
label-align="left">
<a-row :gutter="16">
<a-col :span="8">
<a-form-item field="trueName" label="用户姓名">
<a-input v-model="formModel.trueName" placeholder="请输入用户姓名" allow-clear />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item field="phone" label="用户电话">
<a-input v-model="formModel.phone" placeholder="请输入用户电话" allow-clear />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item field="phone" label="用户电话">
<a-input v-model="formModel.phone" placeholder="请输入用户电话" allow-clear />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item field="phone" label="用户电话">
<a-input v-model="formModel.phone" placeholder="请输入用户电话" allow-clear />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item field="phone" label="用户电话">
<a-input v-model="formModel.phone" placeholder="请输入用户电话" allow-clear />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item field="phone" label="用户电话">
<a-input v-model="formModel.phone" placeholder="请输入用户电话" allow-clear />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-col>
</a-col>
<a-divider style="height: 84px" direction="vertical" />
<a-col :flex="'86px'" style="text-align: right">
<a-space direction="vertical" :size="18">
<a-button type="primary" @click="search">
<template #icon>
<icon-search />
</template>
查询
</a-button>
<a-button @click="reset">
<template #icon>
<icon-refresh />
</template>
重置
</a-button>
</a-space>
</a-col>
</a-row>
<a-divider style="margin-top: 0" />
<!-- 表格 -->
<a-table row-key="id" :loading="loading" :pagination="pagination" :columns="columns"
:data="renderData" :bordered="false" @page-change="onPageChange"></a-table>
</a-card>
</div>
</template>
<script lang="ts" setup>
import { computed, reactive, ref } from 'vue';
import useLoading from '@/hooks/loading';
import { UserEntity, UserQueryParams, queryUserList } from '@/api/pv/demo';
import { BasePagination } from '@/api/common';
//生成查询条件
const generateFormModel = () => {
return {
trueName: '',
phone: '',
};
};
const formModel = ref(generateFormModel());
//加载中
const { loading, setLoading } = useLoading(true);
//设置表格列
const columns = computed<any[]>(() => [
{
title: "编号",
dataIndex: 'id',
},
{
title: "昵称",
dataIndex: 'nickName',
},
{
title: "姓名",
dataIndex: 'trueName',
},
{
title: "手机号",
dataIndex: 'phone',
},
{
title: "注册时间",
dataIndex: 'registerTime',
},
{
title: "状态",
dataIndex: 'status',
slotName: 'status',
},
{
title: "用户地址",
dataIndex: 'address',
},
{
title: "操作",
dataIndex: 'operations',
slotName: 'operations',
}
]);
//表格数据
const renderData = ref<UserEntity[]>([]);
//表格分页参数
const pagination: any = reactive({ ...BasePagination()});
//查询方法
const search = () => {
fetchData({
...pagination,
...formModel.value,
} as unknown as UserQueryParams);
};
//重置查询
const reset = () => {
formModel.value = generateFormModel();
};
const onPageChange = (current: number) => {
fetchData({ ...pagination, current });
};
const fetchData = async (
params: UserQueryParams = { current: 1, pageSize: 20 }
) => {
setLoading(true);
try {
const { data } = await queryUserList(params);
renderData.value = data.list;
pagination.current = params.current;
pagination.total = data.total;
} catch (err) {
// you can report use errorHandler or other
} finally {
setLoading(false);
}
};
fetchData();
</script>
<style lang="less" scoped>
:deep(.arco-table-th) {
&:last-child {
.arco-table-th-item-title {
margin-left: 16px;
}
}
}
.action-icon {
margin-left: 12px;
cursor: pointer;
}
.active {
color: #0960bd;
background-color: #e3f4fc;
}
.setting {
display: flex;
align-items: center;
width: 200px;
.title {
margin-left: 12px;
cursor: pointer;
}
}
</style>