Skip to content

Commit f310f65

Browse files
author
xiaqing
committed
会员签到针对代码格式、功能优化
1.优化todo建议 2.删除无用代码
1 parent ac0f387 commit f310f65

File tree

6 files changed

+54
-251
lines changed

6 files changed

+54
-251
lines changed

src/api/point/signInConfig/index.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import request from '@/config/axios'
22

33
export interface SignInConfigVO {
44
id: number
5-
day: number
6-
point: number
5+
day: number | null
6+
point: number | null
7+
isEnable: boolean | null
78
}
89

910
// 查询积分签到规则列表
10-
export const getSignInConfigPage = async (params) => {
11-
return await request.get({ url: `/point/sign-in-config/page`, params })
11+
export const getSignInConfigPage = async () => {
12+
return await request.get({ url: `/point/sign-in-config/list` })
1213
}
1314

1415
// 查询积分签到规则详情
@@ -30,8 +31,3 @@ export const updateSignInConfig = async (data: SignInConfigVO) => {
3031
export const deleteSignInConfig = async (id: number) => {
3132
return await request.delete({ url: `/point/sign-in-config/delete?id=` + id })
3233
}
33-
34-
// 导出积分签到规则 Excel
35-
export const exportSignInConfig = async (params) => {
36-
return await request.download({ url: `/point/sign-in-config/export-excel`, params })
37-
}

src/api/point/signInRecord/index.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,6 @@ export const getSignInRecordPage = async (params) => {
1212
return await request.get({ url: `/point/sign-in-record/page`, params })
1313
}
1414

15-
// 查询用户签到积分详情
16-
export const getSignInRecord = async (id: number) => {
17-
return await request.get({ url: `/point/sign-in-record/get?id=` + id })
18-
}
19-
20-
// 新增用户签到积分
21-
export const createSignInRecord = async (data: SignInRecordVO) => {
22-
return await request.post({ url: `/point/sign-in-record/create`, data })
23-
}
24-
25-
// 修改用户签到积分
26-
export const updateSignInRecord = async (data: SignInRecordVO) => {
27-
return await request.put({ url: `/point/sign-in-record/update`, data })
28-
}
29-
30-
// 删除用户签到积分
31-
export const deleteSignInRecord = async (id: number) => {
32-
return await request.delete({ url: `/point/sign-in-record/delete?id=` + id })
33-
}
34-
3515
// 导出用户签到积分 Excel
3616
export const exportSignInRecord = async (params) => {
3717
return await request.download({ url: `/point/sign-in-record/export-excel`, params })

src/views/member/point/record/index.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@
6969
/>
7070
</el-form-item>
7171
<el-form-item>
72-
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
73-
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
72+
<el-button @click="handleQuery">
73+
<Icon icon="ep:search" class="mr-5px" />
74+
搜索
75+
</el-button>
76+
<el-button @click="resetQuery">
77+
<Icon icon="ep:refresh" class="mr-5px" />
78+
重置
79+
</el-button>
7480
</el-form-item>
7581
</el-form>
7682
</ContentWrap>
@@ -95,7 +101,7 @@
95101
align="center"
96102
prop="type"
97103
:formatter="
98-
(a, b, c) => {
104+
(_, __, c) => {
99105
return c === '1' ? '增加' : '扣减'
100106
}
101107
"

src/views/member/signin/config/index.vue

Lines changed: 39 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,39 @@
11
<template>
22
<ContentWrap>
33
<!-- 搜索工作栏 -->
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']"
109
>
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>
4412
</ContentWrap>
4513

4614
<!-- 列表 -->
4715
<ContentWrap>
4816
<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+
/>
5123
<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>
5337
<el-table-column label="操作" align="center">
5438
<template #default="scope">
5539
<el-button
@@ -71,65 +55,37 @@
7155
</template>
7256
</el-table-column>
7357
</el-table>
74-
<!-- 分页 -->
75-
<Pagination
76-
:total="total"
77-
v-model:page="queryParams.pageNo"
78-
v-model:limit="queryParams.pageSize"
79-
@pagination="getList"
80-
/>
8158
</ContentWrap>
8259

8360
<!-- 表单弹窗:添加/修改 -->
8461
<SignInConfigForm ref="formRef" @success="getList" />
8562
</template>
8663

8764
<script lang="ts" setup>
88-
import download from '@/utils/download'
8965
import * as SignInConfigApi from '@/api/point/signInConfig'
9066
import SignInConfigForm from './SignInConfigForm.vue'
67+
import { SignInConfigVO } from '@/api/point/signInConfig'
9168
9269
defineOptions({ name: 'SignInConfig' })
9370
9471
const message = useMessage() // 消息弹窗
9572
const { t } = useI18n() // 国际化
9673
9774
const loading = ref(true) // 列表的加载中
98-
const total = ref(0) // 列表的总页数
9975
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) // 导出的加载中
10776
108-
// TODO @xiaqing:可以不分页;
10977
/** 查询列表 */
11078
const getList = async () => {
11179
loading.value = true
11280
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
11684
} finally {
11785
loading.value = false
11886
}
11987
}
12088
121-
/** 搜索按钮操作 */
122-
const handleQuery = () => {
123-
queryParams.pageNo = 1
124-
getList()
125-
}
126-
127-
/** 重置按钮操作 */
128-
const resetQuery = () => {
129-
queryFormRef.value.resetFields()
130-
handleQuery()
131-
}
132-
13389
/** 添加/修改操作 */
13490
const formRef = ref()
13591
const openForm = (type: string, id?: number) => {
@@ -149,19 +105,16 @@ const handleDelete = async (id: number) => {
149105
} catch {}
150106
}
151107
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
164116
}
117+
await SignInConfigApi.updateSignInConfig(signInConfig)
165118
}
166119
167120
/** 初始化 **/

src/views/member/signin/record/SignInRecordForm.vue

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)