16 changed files with 704 additions and 22 deletions
@ -0,0 +1,15 @@
|
||||
import { defHttp } from '@/utils/http/axios' |
||||
|
||||
export interface AddressVO { |
||||
id: number |
||||
name: string |
||||
mobile: string |
||||
areaId: number |
||||
detailAddress: string |
||||
defaultStatus: boolean |
||||
} |
||||
|
||||
// 查询用户收件地址列表
|
||||
export function getAddressList(params) { |
||||
return defHttp.get({ url: '/member/address/list', params }) |
||||
} |
@ -0,0 +1,38 @@
|
||||
import { defHttp } from '@/utils/http/axios' |
||||
|
||||
export interface GroupVO { |
||||
id: number |
||||
name: string |
||||
remark: string |
||||
status: number |
||||
} |
||||
|
||||
// 查询用户分组列表
|
||||
export function getGroupPage(params: any) { |
||||
return defHttp.get({ url: '/member/group/page', params }) |
||||
} |
||||
|
||||
// 查询用户分组详情
|
||||
export function getGroup(id: number) { |
||||
return defHttp.get({ url: `/member/group/get?id=${id}` }) |
||||
} |
||||
|
||||
// 新增用户分组
|
||||
export function createGroup(data: GroupVO) { |
||||
return defHttp.post({ url: '/member/group/create', data }) |
||||
} |
||||
|
||||
// 查询用户分组 - 精简信息列表
|
||||
export function getSimpleGroupList() { |
||||
return defHttp.get({ url: '/member/group/list-all-simple' }) |
||||
} |
||||
|
||||
// 修改用户分组
|
||||
export function updateGroup(data: GroupVO) { |
||||
return defHttp.put({ url: '/member/group/update', data }) |
||||
} |
||||
|
||||
// 删除用户分组
|
||||
export function deleteGroup(id: number) { |
||||
return defHttp.delete({ url: `/member/group/delete?id=${id}` }) |
||||
} |
@ -0,0 +1,42 @@
|
||||
import { defHttp } from '@/utils/http/axios' |
||||
|
||||
export interface LevelVO { |
||||
id: number |
||||
name: string |
||||
experience: number |
||||
value: number |
||||
discountPercent: number |
||||
icon: string |
||||
bgUrl: string |
||||
status: number |
||||
} |
||||
|
||||
// 查询会员等级列表
|
||||
export function getLevelList(params) { |
||||
return defHttp.get({ url: '/member/level/list', params }) |
||||
} |
||||
|
||||
// 查询会员等级详情
|
||||
export function getLevel(id: number) { |
||||
return defHttp.get({ url: `/member/level/get?id=${id}` }) |
||||
} |
||||
|
||||
// 查询会员等级 - 精简信息列表
|
||||
export function getSimpleLevelList() { |
||||
return defHttp.get({ url: '/member/level/list-all-simple' }) |
||||
} |
||||
|
||||
// 新增会员等级
|
||||
export function createLevel(data: LevelVO) { |
||||
return defHttp.post({ url: '/member/level/create', data }) |
||||
} |
||||
|
||||
// 修改会员等级
|
||||
export function updateLevel(data: LevelVO) { |
||||
return defHttp.put({ url: '/member/level/update', data }) |
||||
} |
||||
|
||||
// 删除会员等级
|
||||
export function deleteLevel(id: number) { |
||||
return defHttp.delete({ url: `/member/level/delete?id=${id}` }) |
||||
} |
@ -0,0 +1,61 @@
|
||||
<script lang="ts" setup> |
||||
import { ref, unref } from 'vue' |
||||
import { formSchema } from './group.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { BasicForm, useForm } from '@/components/Form' |
||||
import { BasicModal, useModalInner } from '@/components/Modal' |
||||
import { createGroup, getGroup, updateGroup } from '@/api/member/group' |
||||
|
||||
defineOptions({ name: 'MemberGroupModal' }) |
||||
|
||||
const emit = defineEmits(['success', 'register']) |
||||
const { t } = useI18n() |
||||
const { createMessage } = useMessage() |
||||
const isUpdate = ref(true) |
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ |
||||
labelWidth: 120, |
||||
baseColProps: { span: 24 }, |
||||
schemas: formSchema, |
||||
showActionButtonGroup: false, |
||||
actionColOptions: { span: 23 }, |
||||
}) |
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { |
||||
resetFields() |
||||
setModalProps({ confirmLoading: false }) |
||||
isUpdate.value = !!data?.isUpdate |
||||
if (unref(isUpdate)) { |
||||
const res = await getGroup(data.record.id) |
||||
setFieldsValue({ ...res }) |
||||
} |
||||
}) |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
const values = await validate() |
||||
setModalProps({ confirmLoading: true }) |
||||
if (unref(isUpdate)) |
||||
await updateGroup(values) |
||||
else |
||||
await createGroup(values) |
||||
|
||||
closeModal() |
||||
emit('success') |
||||
createMessage.success(t('common.saveSuccessText')) |
||||
} |
||||
finally { |
||||
setModalProps({ confirmLoading: false }) |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" @register="registerModal" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm" /> |
||||
</BasicModal> |
||||
</template> |
@ -0,0 +1,84 @@
|
||||
import type { BasicColumn, FormSchema } from '@/components/Table' |
||||
import { useRender } from '@/components/Table' |
||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict' |
||||
|
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '编号', |
||||
dataIndex: 'id', |
||||
}, |
||||
{ |
||||
title: '名称', |
||||
dataIndex: 'name', |
||||
}, |
||||
{ |
||||
title: '备注', |
||||
dataIndex: 'remark', |
||||
}, |
||||
{ |
||||
title: '状态', |
||||
dataIndex: 'status', |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS) |
||||
}, |
||||
}, |
||||
{ |
||||
title: '创建时间', |
||||
dataIndex: 'createTime', |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDate(text) |
||||
}, |
||||
}, |
||||
] |
||||
|
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
label: '分组名称', |
||||
field: 'name', |
||||
component: 'Input', |
||||
colProps: { span: 8 }, |
||||
}, |
||||
{ |
||||
label: '创建时间', |
||||
field: 'createTime', |
||||
component: 'RangePicker', |
||||
colProps: { span: 8 }, |
||||
}, |
||||
{ |
||||
label: '状态', |
||||
field: 'status', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS), |
||||
}, |
||||
colProps: { span: 8 }, |
||||
}, |
||||
] |
||||
|
||||
export const formSchema: FormSchema[] = [ |
||||
{ |
||||
label: '编号', |
||||
field: 'id', |
||||
show: false, |
||||
component: 'Input', |
||||
}, |
||||
{ |
||||
label: '名称', |
||||
field: 'name', |
||||
required: true, |
||||
component: 'Input', |
||||
}, |
||||
{ |
||||
label: '状态', |
||||
field: 'status', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS), |
||||
}, |
||||
}, |
||||
{ |
||||
label: '备注', |
||||
field: 'remark', |
||||
component: 'InputTextArea', |
||||
}, |
||||
] |
@ -0,0 +1,50 @@
|
||||
<script lang="ts" setup> |
||||
import GroupModal from './GroupModal.vue' |
||||
import { columns, searchFormSchema } from './group.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useModal } from '@/components/Modal' |
||||
import { IconEnum } from '@/enums/appEnum' |
||||
import { BasicTable, TableAction, useTable } from '@/components/Table' |
||||
import { getGroupPage } from '@/api/member/group' |
||||
|
||||
defineOptions({ name: 'MemberGroup' }) |
||||
|
||||
const { t } = useI18n() |
||||
const [registerModal, { openModal }] = useModal() |
||||
const [registerTable, { reload }] = useTable({ |
||||
title: '会员分组', |
||||
api: getGroupPage, |
||||
columns, |
||||
formConfig: { labelWidth: 120, schemas: searchFormSchema }, |
||||
useSearchForm: true, |
||||
showTableSetting: true, |
||||
showIndexColumn: false, |
||||
actionColumn: { |
||||
width: 140, |
||||
title: t('common.action'), |
||||
dataIndex: 'action', |
||||
fixed: 'right', |
||||
}, |
||||
}) |
||||
|
||||
function handleEdit(record: Recordable) { |
||||
openModal(true, { record, isUpdate: true }) |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<div> |
||||
<BasicTable @register="registerTable"> |
||||
<template #bodyCell="{ column, record }"> |
||||
<template v-if="column.key === 'action'"> |
||||
<TableAction |
||||
:actions="[ |
||||
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'member:group:update', onClick: handleEdit.bind(null, record) }, |
||||
]" |
||||
/> |
||||
</template> |
||||
</template> |
||||
</BasicTable> |
||||
<GroupModal @register="registerModal" @success="reload()" /> |
||||
</div> |
||||
</template> |
@ -0,0 +1,61 @@
|
||||
<script lang="ts" setup> |
||||
import { ref, unref } from 'vue' |
||||
import { formSchema } from './level.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { BasicForm, useForm } from '@/components/Form' |
||||
import { BasicModal, useModalInner } from '@/components/Modal' |
||||
import { createLevel, getLevel, updateLevel } from '@/api/member/level' |
||||
|
||||
defineOptions({ name: 'MemberLevelModal' }) |
||||
|
||||
const emit = defineEmits(['success', 'register']) |
||||
const { t } = useI18n() |
||||
const { createMessage } = useMessage() |
||||
const isUpdate = ref(true) |
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ |
||||
labelWidth: 120, |
||||
baseColProps: { span: 24 }, |
||||
schemas: formSchema, |
||||
showActionButtonGroup: false, |
||||
actionColOptions: { span: 23 }, |
||||
}) |
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { |
||||
resetFields() |
||||
setModalProps({ confirmLoading: false }) |
||||
isUpdate.value = !!data?.isUpdate |
||||
if (unref(isUpdate)) { |
||||
const res = await getLevel(data.record.id) |
||||
setFieldsValue({ ...res }) |
||||
} |
||||
}) |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
const values = await validate() |
||||
setModalProps({ confirmLoading: true }) |
||||
if (unref(isUpdate)) |
||||
await updateLevel(values) |
||||
else |
||||
await createLevel(values) |
||||
|
||||
closeModal() |
||||
emit('success') |
||||
createMessage.success(t('common.saveSuccessText')) |
||||
} |
||||
finally { |
||||
setModalProps({ confirmLoading: false }) |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" @register="registerModal" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm" /> |
||||
</BasicModal> |
||||
</template> |
@ -0,0 +1,50 @@
|
||||
<script lang="ts" setup> |
||||
import LevelModal from './LevelModal.vue' |
||||
import { columns, searchFormSchema } from './level.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useModal } from '@/components/Modal' |
||||
import { IconEnum } from '@/enums/appEnum' |
||||
import { BasicTable, TableAction, useTable } from '@/components/Table' |
||||
import { getLevelList } from '@/api/member/level' |
||||
|
||||
defineOptions({ name: 'MemberLevel' }) |
||||
|
||||
const { t } = useI18n() |
||||
const [registerModal, { openModal }] = useModal() |
||||
const [registerTable, { reload }] = useTable({ |
||||
title: '会员等级列表', |
||||
api: getLevelList, |
||||
columns, |
||||
formConfig: { labelWidth: 120, schemas: searchFormSchema }, |
||||
useSearchForm: true, |
||||
showTableSetting: true, |
||||
showIndexColumn: false, |
||||
actionColumn: { |
||||
width: 140, |
||||
title: t('common.action'), |
||||
dataIndex: 'action', |
||||
fixed: 'right', |
||||
}, |
||||
}) |
||||
|
||||
function handleEdit(record: Recordable) { |
||||
openModal(true, { record, isUpdate: true }) |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<div> |
||||
<BasicTable @register="registerTable"> |
||||
<template #bodyCell="{ column, record }"> |
||||
<template v-if="column.key === 'action'"> |
||||
<TableAction |
||||
:actions="[ |
||||
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'member:level:update', onClick: handleEdit.bind(null, record) }, |
||||
]" |
||||
/> |
||||
</template> |
||||
</template> |
||||
</BasicTable> |
||||
<LevelModal @register="registerModal" @success="reload()" /> |
||||
</div> |
||||
</template> |
@ -0,0 +1,136 @@
|
||||
import type { BasicColumn, FormSchema } from '@/components/Table' |
||||
import { useRender } from '@/components/Table' |
||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict' |
||||
|
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '编号', |
||||
dataIndex: 'id', |
||||
}, |
||||
{ |
||||
title: '等级图标', |
||||
dataIndex: 'icon', |
||||
customRender: ({ text }) => { |
||||
return useRender.renderImg(text) |
||||
}, |
||||
}, |
||||
{ |
||||
title: '等级背景图', |
||||
dataIndex: 'remark', |
||||
customRender: ({ text }) => { |
||||
return useRender.renderImg(text) |
||||
}, |
||||
}, |
||||
{ |
||||
title: '等级名称', |
||||
dataIndex: 'name', |
||||
}, |
||||
{ |
||||
title: '等级', |
||||
dataIndex: 'level', |
||||
}, |
||||
{ |
||||
title: '升级经验', |
||||
dataIndex: 'experience', |
||||
}, |
||||
{ |
||||
title: '享受折扣(%)', |
||||
dataIndex: 'discountPercent', |
||||
}, |
||||
{ |
||||
title: '状态', |
||||
dataIndex: 'status', |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS) |
||||
}, |
||||
}, |
||||
{ |
||||
title: '创建时间', |
||||
dataIndex: 'createTime', |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDate(text) |
||||
}, |
||||
}, |
||||
] |
||||
|
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
label: '等级名称', |
||||
field: 'name', |
||||
component: 'Input', |
||||
colProps: { span: 8 }, |
||||
}, |
||||
{ |
||||
label: '状态', |
||||
field: 'status', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS), |
||||
}, |
||||
colProps: { span: 8 }, |
||||
}, |
||||
] |
||||
|
||||
export const formSchema: FormSchema[] = [ |
||||
{ |
||||
label: '编号', |
||||
field: 'id', |
||||
show: false, |
||||
component: 'Input', |
||||
}, |
||||
{ |
||||
label: '等级名称', |
||||
field: 'name', |
||||
required: true, |
||||
component: 'Input', |
||||
}, |
||||
{ |
||||
label: '等级', |
||||
field: 'level', |
||||
required: true, |
||||
component: 'InputNumber', |
||||
}, |
||||
{ |
||||
label: '升级经验', |
||||
field: 'experience', |
||||
required: true, |
||||
component: 'InputNumber', |
||||
}, |
||||
{ |
||||
label: '享受折扣(%)', |
||||
field: 'discountPercent', |
||||
required: true, |
||||
component: 'InputNumber', |
||||
}, |
||||
{ |
||||
label: '等级图标', |
||||
field: 'icon', |
||||
component: 'FileUpload', |
||||
componentProps: { |
||||
maxCount: 1, |
||||
fileType: 'image', |
||||
}, |
||||
}, |
||||
{ |
||||
label: '背景图', |
||||
field: 'backgroundUrl', |
||||
component: 'FileUpload', |
||||
componentProps: { |
||||
maxCount: 1, |
||||
fileType: 'image', |
||||
}, |
||||
}, |
||||
{ |
||||
label: '状态', |
||||
field: 'status', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS), |
||||
}, |
||||
}, |
||||
{ |
||||
label: '备注', |
||||
field: 'remark', |
||||
component: 'InputTextArea', |
||||
}, |
||||
] |
@ -0,0 +1,58 @@
|
||||
<script lang="ts" setup> |
||||
import { ref, unref } from 'vue' |
||||
import { updateLevelFormSchema } from './user.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { BasicForm, useForm } from '@/components/Form' |
||||
import { BasicModal, useModalInner } from '@/components/Modal' |
||||
import { getUser, updateUserLevel } from '@/api/member/user' |
||||
|
||||
defineOptions({ name: 'MemberUpdateLevelModal' }) |
||||
|
||||
const emit = defineEmits(['success', 'register']) |
||||
const { t } = useI18n() |
||||
const { createMessage } = useMessage() |
||||
const isUpdate = ref(true) |
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ |
||||
labelWidth: 120, |
||||
baseColProps: { span: 24 }, |
||||
schemas: updateLevelFormSchema, |
||||
showActionButtonGroup: false, |
||||
actionColOptions: { span: 23 }, |
||||
}) |
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { |
||||
resetFields() |
||||
setModalProps({ confirmLoading: false }) |
||||
isUpdate.value = !!data?.isUpdate |
||||
if (unref(isUpdate)) { |
||||
const res = await getUser(data.record.id) |
||||
setFieldsValue({ ...res }) |
||||
} |
||||
}) |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
const values = await validate() |
||||
setModalProps({ confirmLoading: true }) |
||||
if (unref(isUpdate)) |
||||
await updateUserLevel(values) |
||||
// else |
||||
// await createUser(values) |
||||
|
||||
closeModal() |
||||
emit('success') |
||||
createMessage.success(t('common.saveSuccessText')) |
||||
} |
||||
finally { |
||||
setModalProps({ confirmLoading: false }) |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<BasicModal v-bind="$attrs" title="修改用户等级" @register="registerModal" @ok="handleSubmit"> |
||||
<BasicForm @register="registerForm" /> |
||||
</BasicModal> |
||||
</template> |
Reference in new issue