code review:签到配置

This commit is contained in:
YunaiV 2023-08-20 19:26:50 +08:00
parent 4bc3f15571
commit 82628ce780
8 changed files with 28 additions and 31 deletions

View File

@ -8,7 +8,7 @@ export interface SignInConfigVO {
}
// 查询积分签到规则列表
export const getSignInConfigPage = async () => {
export const getSignInConfigList = async () => {
return await request.get({ url: `/member/point/sign-in-config/list` })
}

View File

@ -58,7 +58,7 @@
</ContentWrap>
</template>
<script lang="ts" setup>
import * as ConfigApi from '@/api/point/config'
import * as ConfigApi from '@/api/member/point/config'
defineOptions({ name: 'MemberPointConfig' })

View File

@ -25,7 +25,7 @@
class="!w-240px"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE)"
v-for="dict in getIntDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -109,9 +109,9 @@
</template>
<script lang="ts" setup>
import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as RecordApi from '@/api/point/record'
import * as RecordApi from '@/api//member/point/record'
defineOptions({ name: 'PointRecord' })

View File

@ -10,12 +10,23 @@
<el-form-item label="签到天数" prop="day">
<el-input-number v-model="formData.day" :min="1" :max="7" :precision="0" />
<el-text class="mx-1" style="margin-left: 10px" type="danger">
只允许设置1-7默认签到7天为一个周期</el-text
>
只允许设置 1-7默认签到 7 天为一个周期
</el-text>
</el-form-item>
<el-form-item label="签到分数" prop="point">
<el-input-number v-model="formData.point" :precision="0" />
</el-form-item>
<el-form-item label="开启状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
@ -24,7 +35,9 @@
</Dialog>
</template>
<script lang="ts" setup>
import * as SignInConfigApi from '@/api/point/signInConfig'
import * as SignInConfigApi from '@/api/member/signin/config'
import { CommonStatusEnum } from '@/utils/constants'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
const { t } = useI18n() //
const message = useMessage() //
@ -92,7 +105,8 @@ const resetForm = () => {
formData.value = {
id: undefined,
day: undefined,
point: undefined
point: undefined,
status: CommonStatusEnum.ENABLE
}
formRef.value?.resetFields()
}

View File

@ -21,17 +21,9 @@
:formatter="(_, __, cellValue) => ['第', cellValue, '天'].join(' ')"
/>
<el-table-column label="获得积分" align="center" prop="point" />
<el-table-column label="是否开启" align="center">
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<div>
<el-switch
v-model="scope.row.enable"
@change="handleSwitchChange(scope.row, $event)"
inline-prompt
active-text="开启"
inactive-text="关闭"
/>
</div>
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center">
@ -60,11 +52,10 @@
<!-- 表单弹窗添加/修改 -->
<SignInConfigForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
import * as SignInConfigApi from '@/api/point/signInConfig'
import * as SignInConfigApi from '@/api/member/signin/config'
import SignInConfigForm from './SignInConfigForm.vue'
import { SignInConfigVO } from '@/api/point/signInConfig'
import { DICT_TYPE } from '@/utils/dict'
defineOptions({ name: 'SignInConfig' })
@ -78,7 +69,7 @@ const list = ref([]) // 列表的数据
const getList = async () => {
loading.value = true
try {
const data = await SignInConfigApi.getSignInConfigPage()
const data = await SignInConfigApi.getSignInConfigList()
console.log(data)
list.value = data
} finally {
@ -105,14 +96,6 @@ const handleDelete = async (id: number) => {
} catch {}
}
const handleSwitchChange = async (row, e) => {
console.log('开关状态变更id:', row, '新状态:', e)
//
const signInConfig: SignInConfigVO = { enable: e }
;({ id: signInConfig.id, day: signInConfig.day, point: signInConfig.point, enable: e } = row)
await SignInConfigApi.updateSignInConfig(signInConfig)
}
/** 初始化 **/
onMounted(() => {
getList()