!215 会员: 会员等级功能调整

Merge pull request !215 from 疯狂的世界/member_dev
This commit is contained in:
芋道源码 2023-08-23 16:46:34 +00:00 committed by Gitee
commit 5fb5c6cbcf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 124 additions and 42 deletions

View File

@ -12,8 +12,8 @@ export interface LevelVO {
} }
// 查询会员等级列表 // 查询会员等级列表
export const getLevelPage = async (params) => { export const getLevelList = async (params) => {
return await request.get({ url: `/member/level/page`, params }) return await request.get({ url: `/member/level/list`, params })
} }
// 查询会员等级详情 // 查询会员等级详情

View File

@ -51,3 +51,8 @@ export const getUser = async (id: number) => {
export const updateUser = async (data: UserVO) => { export const updateUser = async (data: UserVO) => {
return await request.put({ url: `/member/user/update`, data }) return await request.put({ url: `/member/user/update`, data })
} }
// 修改会员用户等级
export const updateUserLevel = async (data: any) => {
return await request.put({ url: `/member/user/update-level`, data })
}

View File

@ -96,13 +96,6 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
@ -122,11 +115,8 @@ const message = useMessage() // 消息弹窗
const { t } = useI18n() // const { t } = useI18n() //
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: null, name: null,
status: null status: null
}) })
@ -136,9 +126,7 @@ const queryFormRef = ref() // 搜索的表单
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await LevelApi.getLevelPage(queryParams) list.value = await LevelApi.getLevelList(queryParams)
list.value = data.list
total.value = data.total
} finally { } finally {
loading.value = false loading.value = false
} }
@ -146,7 +134,6 @@ const getList = async () => {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.pageNo = 1
getList() getList()
} }

View File

@ -0,0 +1,101 @@
<template>
<Dialog title="修改用户等级" v-model="dialogVisible" width="600">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="用户编号" prop="id">
<el-input v-model="formData.id" placeholder="请输入用户昵称" class="!w-240px" disabled />
</el-form-item>
<el-form-item label="用户昵称" prop="nickname">
<el-input
v-model="formData.nickname"
placeholder="请输入用户昵称"
class="!w-240px"
disabled
/>
</el-form-item>
<el-form-item label="用户等级" prop="levelId">
<MemberLevelSelect v-model="formData.levelId" />
</el-form-item>
<el-form-item label="修改原因" prop="reason">
<el-input type="textarea" v-model="formData.reason" placeholder="请输入修改原因" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as UserApi from '@/api/member/user'
import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect.vue'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
id: undefined,
nickname: undefined,
levelId: undefined,
reason: undefined
})
const formRules = reactive({
reason: [{ required: true, message: '修改原因不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (id?: number) => {
dialogVisible.value = true
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await UserApi.getUser(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
await UserApi.updateUserLevel(formData.value)
message.success(t('common.updateSuccess'))
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
nickname: undefined,
levelId: undefined,
reason: undefined
}
formRef.value?.resetFields()
}
</script>

View File

@ -60,22 +60,6 @@
<el-form-item label="用户标签" prop="tagIds"> <el-form-item label="用户标签" prop="tagIds">
<MemberTagSelect v-model="formData.tagIds" show-add /> <MemberTagSelect v-model="formData.tagIds" show-add />
</el-form-item> </el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="用户等级" prop="levelId">
<MemberLevelSelect v-model="formData.levelId" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="修改原因"
prop="levelReason"
v-if="formData.levelId !== originLevelId"
>
<el-input type="text" v-model="formData.levelReason" placeholder="请输入修改原因" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="用户分组" prop="groupId"> <el-form-item label="用户分组" prop="groupId">
<MemberGroupSelect v-model="formData.groupId" /> <MemberGroupSelect v-model="formData.groupId" />
</el-form-item> </el-form-item>
@ -95,7 +79,6 @@ import * as UserApi from '@/api/member/user'
import * as AreaApi from '@/api/system/area' import * as AreaApi from '@/api/system/area'
import { defaultProps } from '@/utils/tree' import { defaultProps } from '@/utils/tree'
import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue' import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue'
import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect.vue'
import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue' import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue'
const { t } = useI18n() // const { t } = useI18n() //
@ -118,18 +101,14 @@ const formData = ref({
birthday: undefined, birthday: undefined,
mark: undefined, mark: undefined,
tagIds: [], tagIds: [],
levelId: undefined,
levelReason: undefined,
groupId: undefined groupId: undefined
}) })
const formRules = reactive({ const formRules = reactive({
mobile: [{ required: true, message: '手机号不能为空', trigger: 'blur' }], mobile: [{ required: true, message: '手机号不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }], status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
levelReason: [{ required: true, message: '修改原因不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const areaList = ref([]) // const areaList = ref([]) //
const originLevelId = ref() //
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
@ -142,7 +121,6 @@ const open = async (type: string, id?: number) => {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await UserApi.getUser(id) formData.value = await UserApi.getUser(id)
originLevelId.value = formData.value.levelId
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
@ -194,8 +172,6 @@ const resetForm = () => {
birthday: undefined, birthday: undefined,
mark: undefined, mark: undefined,
tagIds: [], tagIds: [],
levelId: undefined,
levelReason: undefined,
groupId: undefined groupId: undefined
} }
formRef.value?.resetFields() formRef.value?.resetFields()

View File

@ -109,7 +109,7 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180px" width="180px"
/> />
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center" width="140px" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button <el-button
link link
@ -119,6 +119,15 @@
> >
编辑 编辑
</el-button> </el-button>
<!-- todo 放到更多菜单中 -->
<el-button
link
type="primary"
@click="updateLevelFormRef.open(scope.row.id)"
v-hasPermi="['member:user:update-level']"
>
修改等级
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -133,6 +142,8 @@
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<UserForm ref="formRef" @success="getList" /> <UserForm ref="formRef" @success="getList" />
<!-- 修改用户等级弹窗 -->
<UpdateLevelForm ref="updateLevelFormRef" @success="getList" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
@ -142,6 +153,7 @@ import { DICT_TYPE } from '@/utils/dict'
import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue' import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue'
import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect.vue' import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect.vue'
import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue' import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue'
import UpdateLevelForm from '@/views/member/user/UpdateLevelForm.vue'
defineOptions({ name: 'MemberUser' }) defineOptions({ name: 'MemberUser' })
@ -160,6 +172,7 @@ const queryParams = reactive({
groupId: null groupId: null
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const updateLevelFormRef = ref() //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {