signup.vue
4.69 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
<script setup lang="ts">
import { reactive, ref, onMounted } from "vue";
import { signupList, cancelSignup } from "@/api/event";
import { parseTime, globalFilters } from "@/utils/tool";
import { useRoute } from "vue-router";
import { refundStatus } from "./../config";
import Pagination from "@/components/Pagination/index.vue";
import { ElMessageBox, ElMessage } from "element-plus";
interface Form {
page: number;
pageSize: number;
name: string;
mobile: string;
handworkId: number | null;
}
interface Params {
total: number;
query: Form;
}
interface Data {
loading: boolean;
list: any[] | null;
params: Params;
}
let data = reactive({
list: [],
loading: false,
params: {
total: 0,
query: {
page: 1,
pageSize: 10,
name: "",
mobile: "",
handworkId: useRoute().query.id,
},
},
});
/**
* 列表
*/
const getList = async () => {
data.loading = true;
try {
const res = await signupList(data.params.query);
data.list = res?.data?.data.list;
data.params.total = res?.data?.data?.total;
} catch (e) {
console.log(e);
} finally {
data.loading = false;
}
};
/**
* 移除报名信息
*/
const handleRemove = async (obj: any) => {
ElMessageBox.confirm("确认移除吗?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning",
})
.then(async () => {
try {
let res = await cancelSignup({
signupId: obj.id,
});
if (res?.data) {
ElMessage({
type: "success",
message: "操作成功",
});
getList();
} else {
ElMessage({
type: "error",
message: "操作失败",
});
}
} catch (e) {
console.log(e);
}
})
.catch(() => {
console.log("取消");
});
};
onMounted(() => {
getList();
});
</script>
<template>
<div class="page-container">
<!-- <h1>报名信息</h1> -->
<el-row>
<el-form :inline="true" label-width="70px" @submit.native.prevent>
<el-form-item label="名称">
<el-input
v-model.trim="data.params.query.name"
placeholder="请填写名称"
maxlength="15"
@change="getList"
/>
</el-form-item>
<el-form-item label="手机号">
<el-input
v-model.trim="data.params.query.mobile"
placeholder="请填写手机号"
maxlength="15"
@change="getList"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getList">查询</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row style="padding-bottom: 20px">
<span class="tip">当前活动:【{{ useRoute().query?.eName }}】</span>
</el-row>
<el-table
:data="data.list"
style="width: 100%"
border
v-loading="data.loading"
align="center"
element-loading-text="拼命加载中"
>
<el-table-column prop="id" label="ID" align="center"></el-table-column>
<el-table-column
prop="name"
label="姓名"
align="center"
></el-table-column>
<el-table-column prop="age" label="年龄" align="center"></el-table-column>
<el-table-column
prop="mobile"
label="联系方式"
align="center"
></el-table-column>
<!-- 收费活动展示退费状态,免费活动展示报名状态 -->
<el-table-column
prop="refundStatus"
label="退费状态"
align="center"
v-if="~~useRoute().query.unitPrice > 0"
>
<template #default="scope">
{{ globalFilters(scope.row.refundStatus, refundStatus) }}
</template>
</el-table-column>
<el-table-column
prop="refundStatus"
label="报名状态"
align="center"
v-if="~~useRoute().query.unitPrice === 0"
>
<template #default="scope">
{{ ~~scope.row.refundStatus === 0 ? "已报名" : "取消报名" }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<!-- 未退费和退费失败的参与人员可以移除 -->
<el-button
type="text"
@click="handleRemove(scope.row)"
v-show="[0, 4].includes(~~scope.row.refundStatus)"
>取消报名</el-button
>
</template>
</el-table-column>
</el-table>
<Pagination
:total="data.params.total"
v-model:currentPage="data.params.query.page"
v-model:pageSize="data.params.query.pageSize"
@pageChange="getList"
></Pagination>
</div>
</template>