code review:用户详情

(cherry picked from commit 1b6c9b2e29)
This commit is contained in:
YunaiV 2023-08-26 01:59:36 +08:00 committed by shizhong
parent 19e96f1d0d
commit e97a62fe06
14 changed files with 45 additions and 147 deletions

View File

@ -10,31 +10,6 @@ export interface AddressVO {
} }
// 查询用户收件地址列表 // 查询用户收件地址列表
export const getAddressPage = async (params) => { export const getAddressList = async (params) => {
return await request.get({ url: `/member/address/page`, params }) return await request.get({ url: `/member/address/list`, params })
}
// 查询用户收件地址详情
export const getAddress = async (id: number) => {
return await request.get({ url: `/member/address/get?id=` + id })
}
// 新增用户收件地址
export const createAddress = async (data: AddressVO) => {
return await request.post({ url: `/member/address/create`, data })
}
// 修改用户收件地址
export const updateAddress = async (data: AddressVO) => {
return await request.put({ url: `/member/address/update`, data })
}
// 删除用户收件地址
export const deleteAddress = async (id: number) => {
return await request.delete({ url: `/member/address/delete?id=` + id })
}
// 导出用户收件地址 Excel
export const exportAddress = async (params) => {
return await request.download({ url: `/member/address/export-excel`, params })
} }

View File

@ -1,12 +1,10 @@
import request from '@/config/axios' import request from '@/config/axios'
export interface UserVO { export interface UserVO {
areaId: number | undefined id: number
areaName: string | undefined
avatar: string | undefined avatar: string | undefined
birthday: number | undefined birthday: number | undefined
createTime: number | undefined createTime: number | undefined
id: number
loginDate: number | undefined loginDate: number | undefined
loginIp: string loginIp: string
mark: string mark: string
@ -16,26 +14,8 @@ export interface UserVO {
registerIp: string registerIp: string
sex: number sex: number
status: number status: number
} areaId: number | undefined
areaName: string | undefined
// TODO @梦:和 UserVO 搞成一个把。
export interface UserBaseInfoVO {
id: number | undefined | null
mobile: string
password: string | null | undefined
status: number
registerIp: string | null | undefined
loginIp: string | null | undefined
loginDate: Date | null | undefined
nickname: string | null | undefined
avatar: string | null | undefined
name: string | null | undefined
sex: number
areaId: number | null | undefined
areaName: string | null | undefined
birthday: Date | null | undefined
mark: string | null | undefined
createTime: Date | null | undefined
} }
// 查询会员用户列表 // 查询会员用户列表

View File

@ -0,0 +1,3 @@
import CardTitle from './src/CardTitle.vue'
export { CardTitle }

View File

@ -1,3 +1,4 @@
import Descriptions from './src/Descriptions.vue' import Descriptions from './src/Descriptions.vue'
import DescriptionsItemLabel from './src/DescriptionsItemLabel.vue'
export { Descriptions } export { Descriptions, DescriptionsItemLabel }

View File

@ -434,7 +434,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
meta: { hidden: true }, meta: { hidden: true },
children: [ children: [
{ {
path: 'user/detail/:userId', path: 'user/detail/:id',
name: 'MemberUserDetail', name: 'MemberUserDetail',
meta: { meta: {
title: '会员详情', title: '会员详情',

View File

@ -46,11 +46,6 @@
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</template> </template>
<script lang="ts" setup>
defineComponent({
name: 'AccountInfo'
})
</script>
<style scoped lang="scss"> <style scoped lang="scss">
.cell-item { .cell-item {
display: inline; display: inline;

View File

@ -1,6 +1,6 @@
<template> <template>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="收件地址编号" align="center" prop="id" width="150px" /> <el-table-column label="地址编号" align="center" prop="id" width="150px" />
<el-table-column label="收件人名称" align="center" prop="name" width="150px" /> <el-table-column label="收件人名称" align="center" prop="name" width="150px" />
<el-table-column label="手机号" align="center" prop="mobile" width="150px" /> <el-table-column label="手机号" align="center" prop="mobile" width="150px" />
<el-table-column label="地区编码" align="center" prop="areaId" width="150px" /> <el-table-column label="地区编码" align="center" prop="areaId" width="150px" />
@ -18,21 +18,9 @@
width="180px" width="180px"
/> />
</el-table> </el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
defineComponent({
name: 'AddressList'
})
import { defineComponent } from 'vue'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as AddressApi from '@/api/member/address' import * as AddressApi from '@/api/member/address'
@ -46,25 +34,12 @@ const { userId }: { userId: number } = defineProps({
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
userId: NaN,
name: null,
mobile: null,
areaId: null,
detailAddress: null,
defaultStatus: null,
createTime: []
})
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await AddressApi.getAddressPage(queryParams) list.value = await AddressApi.getAddressList({ userId })
list.value = data.list
total.value = data.total
} finally { } finally {
loading.value = false loading.value = false
} }
@ -72,7 +47,6 @@ const getList = async () => {
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
queryParams.userId = userId
getList() getList()
}) })
</script> </script>

View File

@ -72,7 +72,7 @@
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import * as UserApi from '@/api/member/user' import * as UserApi from '@/api/member/user'
import DescriptionsItemLabel from '@/views/member/user/components/descriptions/DescriptionsItemLabel.vue' import { DescriptionsItemLabel } from '@/components/Descriptions/index'
const { user }: { user: UserApi.UserVO } = defineProps({ const { user }: { user: UserApi.UserVO } = defineProps({
user: { user: {

View File

@ -17,7 +17,7 @@
> >
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE)"
:key="dict.value as number" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
/> />
@ -67,7 +67,6 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180" width="180"
/> />
<el-table-column label="用户" align="center" prop="nickname" width="200" />
<el-table-column label="获得积分" align="center" prop="point" width="100"> <el-table-column label="获得积分" align="center" prop="point" width="100">
<template #default="scope"> <template #default="scope">
<el-tag v-if="scope.row.point > 0" class="ml-2" type="success" effect="dark"> <el-tag v-if="scope.row.point > 0" class="ml-2" type="success" effect="dark">
@ -101,8 +100,6 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as RecordApi from '@/api//member/point/record' import * as RecordApi from '@/api//member/point/record'
defineOptions({ name: 'PointList' })
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //

View File

@ -48,7 +48,6 @@
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="编号" align="center" prop="id" /> <el-table-column label="编号" align="center" prop="id" />
<el-table-column label="签到用户" align="center" prop="nickname" />
<el-table-column <el-table-column
label="签到天数" label="签到天数"
align="center" align="center"
@ -84,8 +83,6 @@
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as SignInRecordApi from '@/api/member/signin/record' import * as SignInRecordApi from '@/api/member/signin/record'
defineOptions({ name: 'SignList' })
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //

View File

@ -7,13 +7,7 @@
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
<CardTitle title="基本信息" /> <CardTitle title="基本信息" />
<el-button <el-button type="primary" size="small" text @click="openForm('update')">
v-if="user.id"
type="primary"
size="small"
text
@click="openForm('update', user.id)"
>
编辑 编辑
</el-button> </el-button>
</div> </div>
@ -26,26 +20,26 @@
<template #header> <template #header>
<CardTitle title="账户信息" /> <CardTitle title="账户信息" />
</template> </template>
<AccountInfo /> <UserAccountInfo />
</el-card> </el-card>
</el-col> </el-col>
<!-- 下边账户明细 --> <!-- 下边账户明细 -->
<!-- TODO 芋艿收货地址订单管理售后管理收藏记录优惠劵 --> <!-- TODO 芋艿订单管理售后管理收藏记录优惠劵 -->
<el-card header="账户明细" style="width: 100%; margin-top: 20px" shadow="never"> <el-card header="账户明细" style="width: 100%; margin-top: 20px" shadow="never">
<template #header> <template #header>
<CardTitle title="账户明细" /> <CardTitle title="账户明细" />
</template> </template>
<el-tabs v-model="activeName"> <el-tabs v-model="activeName">
<el-tab-pane label="积分" name="point"> <el-tab-pane label="积分" name="point">
<PointList v-if="user.id" :user-id="user.id" /> <UserPointList :user-id="id" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="签到" name="sign"> <el-tab-pane label="签到" name="sign">
<SignList v-if="user.id" :user-id="user.id" /> <UserSignList :user-id="id" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="成长值" name="third">成长值(WIP)</el-tab-pane> <el-tab-pane label="成长值" name="third">成长值(WIP)</el-tab-pane>
<el-tab-pane label="余额" name="fourth">余额(WIP)</el-tab-pane> <el-tab-pane label="余额" name="fourth">余额(WIP)</el-tab-pane>
<el-tab-pane label="收货地址" name="address"> <el-tab-pane label="收货地址" name="address">
<AddressList v-if="user.id" :user-id="user.id" /> <UserAddressList :user-id="id" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="订单管理" name="fourth">订单管理(WIP)</el-tab-pane> <el-tab-pane label="订单管理" name="fourth">订单管理(WIP)</el-tab-pane>
<el-tab-pane label="售后管理" name="fourth">售后管理(WIP)</el-tab-pane> <el-tab-pane label="售后管理" name="fourth">售后管理(WIP)</el-tab-pane>
@ -55,45 +49,33 @@
</el-card> </el-card>
</el-row> </el-row>
</div> </div>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<UserForm ref="formRef" v-if="user.id" @success="getUserData(user.id)" /> <UserForm ref="formRef" @success="getUserData(id)" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import PointList from '@/views/member/user/components/PointList.vue'
import SignList from '@/views/member/user/components/SignList.vue'
import CardTitle from '@/views/member/user/components/CardTitle.vue'
import * as UserApi from '@/api/member/user' import * as UserApi from '@/api/member/user'
import { useTagsViewStore } from '@/store/modules/tagsView'
import UserBasicInfo from './UserBasicInfo.vue'
import UserForm from '@/views/member/user/UserForm.vue' import UserForm from '@/views/member/user/UserForm.vue'
import AccountInfo from '@/views/member/user/components/AccountInfo.vue' import UserAccountInfo from './UserAccountInfo.vue'
import UserBasicInfo from '@/views/member/user/components/UserBasicInfo.vue' import UserAddressList from './UserAddressList.vue'
import AddressList from '@/views/member/user/components/AddressList.vue' import UserPointList from './UserPointList.vue'
import UserSignList from './UserSignList.vue'
import { CardTitle } from '@/components/Card/index'
defineOptions({ name: 'MemberDetail' }) defineOptions({ name: 'MemberDetail' })
const activeName = ref('point') // tabs const activeName = ref('point') // tabs
const loading = ref(true) // const loading = ref(true) //
let user = ref<UserApi.UserVO>({ let user = ref<UserApi.UserVO>({})
areaId: undefined,
avatar: undefined,
birthday: undefined,
createTime: undefined,
id: NaN,
loginDate: undefined,
loginIp: '',
mark: '',
mobile: '',
name: '',
nickname: '',
registerIp: '',
sex: 0,
status: 0,
areaName: ''
})
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
/** 获得用户 */ /** 获得用户 */
const getUserData = async (id: number) => { const getUserData = async (id: number) => {
loading.value = true loading.value = true
@ -105,21 +87,20 @@ const getUserData = async (id: number) => {
} }
/** 初始化 */ /** 初始化 */
const { push, currentRoute } = useRouter() //
const { delView } = useTagsViewStore() //
const route = useRoute() const route = useRoute()
const router = useRouter() const id = route.params.id as number
const member_id = Number(route.params.userId as string)
onMounted(() => { onMounted(() => {
if (!member_id) { if (!id) {
// TODO
ElMessage.warning('参数错误,会员编号不能为空!') ElMessage.warning('参数错误,会员编号不能为空!')
router.back() delView(unref(currentRoute))
return return
} }
getUserData(member_id) getUserData(id)
}) })
</script> </script>
<style scoped lang="css"> <style scoped lang="css">
/** TODO 这 3 个 css 貌似没用? */
.detail-info-item:first-child { .detail-info-item:first-child {
padding-left: 0 !important; padding-left: 0 !important;
} }

View File

@ -109,15 +109,9 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180px" width="180px"
/> />
<el-table-column label="操作" align="center" width="140px" fixed="right"> <el-table-column label="操作" align="center" width="180px" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button <el-button link type="primary" @click="openDetail(scope.row.id)">详情</el-button>
link
type="primary"
@click="goMemberDetail(scope.row.id)"
>
详情
</el-button>
<el-button <el-button
link link
type="primary" type="primary"
@ -204,9 +198,10 @@ const resetQuery = () => {
handleQuery() handleQuery()
} }
/** 打开会员详情 */
const { push } = useRouter() const { push } = useRouter()
const goMemberDetail = (id: number) => { const openDetail = (id: number) => {
push({ name: 'MemberUserDetail', params: { member_id: id } }) push({ name: 'MemberUserDetail', params: { id } })
} }
/** 初始化 **/ /** 初始化 **/