1
1
<template >
2
2
<ContentWrap >
3
3
<!-- 搜索工作栏 -->
4
- <el-form
5
- class =" -mb-15px"
6
- :model =" queryParams"
7
- ref =" queryFormRef"
8
- :inline =" true"
9
- label-width =" 68px"
4
+ <el-button
5
+ type =" primary"
6
+ plain
7
+ @click =" openForm('create')"
8
+ v-hasPermi =" ['point:sign-in-config:create']"
10
9
>
11
- <!-- TODO @xiaqing:搜索可以去掉,因为一共就没几条配置哈 -->
12
- <el-form-item label =" 签到天数" prop =" day" >
13
- <el-input
14
- v-model =" queryParams.day"
15
- placeholder =" 请输入签到天数"
16
- clearable
17
- @keyup.enter =" handleQuery"
18
- class =" !w-240px"
19
- />
20
- </el-form-item >
21
- <el-form-item >
22
- <el-button @click =" handleQuery" ><Icon icon =" ep:search" class =" mr-5px" /> 搜索</el-button >
23
- <el-button @click =" resetQuery" ><Icon icon =" ep:refresh" class =" mr-5px" /> 重置</el-button >
24
- <el-button
25
- type =" primary"
26
- plain
27
- @click =" openForm('create')"
28
- v-hasPermi =" ['point:sign-in-config:create']"
29
- >
30
- <Icon icon =" ep:plus" class =" mr-5px" /> 新增
31
- </el-button >
32
- <el-button
33
- type =" success"
34
- plain
35
- @click =" handleExport"
36
- :loading =" exportLoading"
37
- v-hasPermi =" ['point:sign-in-config:export']"
38
- >
39
- <!-- TODO @xiaqing:四个功能的导出都可以去掉 -->
40
- <Icon icon =" ep:download" class =" mr-5px" /> 导出
41
- </el-button >
42
- </el-form-item >
43
- </el-form >
10
+ <Icon icon =" ep:plus" class =" mr-5px" /> 新增
11
+ </el-button >
44
12
</ContentWrap >
45
13
46
14
<!-- 列表 -->
47
15
<ContentWrap >
48
16
<el-table v-loading =" loading" :data =" list" >
49
- <!-- TODO @xiaqing:展示优化下,改成第 1 天、第 2 天这种 -->
50
- <el-table-column label =" 签到天数" align =" center" prop =" day" />
17
+ <el-table-column
18
+ label =" 签到天数"
19
+ align =" center"
20
+ prop =" day"
21
+ :formatter =" (_, __, cellValue) => ['第', cellValue, '天'].join(' ')"
22
+ />
51
23
<el-table-column label =" 获得积分" align =" center" prop =" point" />
52
- <!-- TODO @xiaqing:展示一个是否开启 -->
24
+ <el-table-column label =" 是否开启" align =" center" >
25
+ <template #default =" scope " >
26
+ <div >
27
+ <el-switch
28
+ v-model =" scope.row.isEnable"
29
+ @change =" handleSwitchChange(scope.row.id, $event)"
30
+ inline-prompt
31
+ active-text =" 开启"
32
+ inactive-text =" 关闭"
33
+ />
34
+ </div >
35
+ </template >
36
+ </el-table-column >
53
37
<el-table-column label =" 操作" align =" center" >
54
38
<template #default =" scope " >
55
39
<el-button
71
55
</template >
72
56
</el-table-column >
73
57
</el-table >
74
- <!-- 分页 -->
75
- <Pagination
76
- :total =" total"
77
- v-model:page =" queryParams.pageNo"
78
- v-model:limit =" queryParams.pageSize"
79
- @pagination =" getList"
80
- />
81
58
</ContentWrap >
82
59
83
60
<!-- 表单弹窗:添加/修改 -->
84
61
<SignInConfigForm ref =" formRef" @success =" getList" />
85
62
</template >
86
63
87
64
<script lang="ts" setup>
88
- import download from ' @/utils/download'
89
65
import * as SignInConfigApi from ' @/api/point/signInConfig'
90
66
import SignInConfigForm from ' ./SignInConfigForm.vue'
67
+ import { SignInConfigVO } from ' @/api/point/signInConfig'
91
68
92
69
defineOptions ({ name: ' SignInConfig' })
93
70
94
71
const message = useMessage () // 消息弹窗
95
72
const { t } = useI18n () // 国际化
96
73
97
74
const loading = ref (true ) // 列表的加载中
98
- const total = ref (0 ) // 列表的总页数
99
75
const list = ref ([]) // 列表的数据
100
- const queryParams = reactive ({
101
- pageNo: 1 ,
102
- pageSize: 10 ,
103
- day: null
104
- })
105
- const queryFormRef = ref () // 搜索的表单
106
- const exportLoading = ref (false ) // 导出的加载中
107
76
108
- // TODO @xiaqing:可以不分页;
109
77
/** 查询列表 */
110
78
const getList = async () => {
111
79
loading .value = true
112
80
try {
113
- const data = await SignInConfigApi .getSignInConfigPage (queryParams )
114
- list . value = data . list
115
- total .value = data . total
81
+ const data = await SignInConfigApi .getSignInConfigPage ()
82
+ console . log ( data )
83
+ list .value = data
116
84
} finally {
117
85
loading .value = false
118
86
}
119
87
}
120
88
121
- /** 搜索按钮操作 */
122
- const handleQuery = () => {
123
- queryParams .pageNo = 1
124
- getList ()
125
- }
126
-
127
- /** 重置按钮操作 */
128
- const resetQuery = () => {
129
- queryFormRef .value .resetFields ()
130
- handleQuery ()
131
- }
132
-
133
89
/** 添加/修改操作 */
134
90
const formRef = ref ()
135
91
const openForm = (type : string , id ? : number ) => {
@@ -149,19 +105,16 @@ const handleDelete = async (id: number) => {
149
105
} catch {}
150
106
}
151
107
152
- /** 导出按钮操作 */
153
- const handleExport = async () => {
154
- try {
155
- // 导出的二次确认
156
- await message .exportConfirm ()
157
- // 发起导出
158
- exportLoading .value = true
159
- const data = await SignInConfigApi .exportSignInConfig (queryParams )
160
- download .excel (data , ' 积分签到规则.xls' )
161
- } catch {
162
- } finally {
163
- exportLoading .value = false
108
+ const handleSwitchChange = async (id , e ) => {
109
+ console .log (' 开关状态变更,id:' , id , ' 新状态:' , e )
110
+ // 创建对象
111
+ const signInConfig: SignInConfigVO = {
112
+ id: id ,
113
+ day: null ,
114
+ point: null ,
115
+ isEnable: e
164
116
}
117
+ await SignInConfigApi .updateSignInConfig (signInConfig )
165
118
}
166
119
167
120
/** 初始化 **/
0 commit comments