feat: member
							parent
							
								
									133fd07e98
								
							
						
					
					
						commit
						35c2ffd03e
					
				|  | @ -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}` }) | ||||
| } | ||||
|  | @ -15,6 +15,11 @@ export function getMemberTag(id: number) { | |||
|   return defHttp.get({ url: `/member/tag/get?id=${id}` }) | ||||
| } | ||||
| 
 | ||||
| // 查询会员标签 - 精简信息列表
 | ||||
| export function getSimpleTagList() { | ||||
|   return defHttp.get({ url: '/member/tag/list-all-simple' }) | ||||
| } | ||||
| 
 | ||||
| // 新增会员标签
 | ||||
| export function createMemberTag(data: TagVO) { | ||||
|   return defHttp.post({ url: '/member/tag/create', data }) | ||||
|  |  | |||
|  | @ -32,3 +32,8 @@ export function getUser(id: number) { | |||
| export function updateUser(data: UserVO) { | ||||
|   return defHttp.put({ url: '/member/user/update', data }) | ||||
| } | ||||
| 
 | ||||
| // 修改会员用户等级
 | ||||
| export function updateUserLevel(data: any) { | ||||
|   return defHttp.put({ url: '/member/user/update-level', data }) | ||||
| } | ||||
|  |  | |||
|  | @ -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', | ||||
|   }, | ||||
| ] | ||||
|  | @ -45,7 +45,7 @@ async function handleDelete(record: Recordable) { | |||
|   <div> | ||||
|     <BasicTable @register="registerTable"> | ||||
|       <template #toolbar> | ||||
|         <a-button v-auth="['system:notice:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> | ||||
|         <a-button v-auth="['point:sign-in-config:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> | ||||
|           {{ t('action.create') }} | ||||
|         </a-button> | ||||
|       </template> | ||||
|  | @ -53,12 +53,12 @@ async function handleDelete(record: Recordable) { | |||
|         <template v-if="column.key === 'action'"> | ||||
|           <TableAction | ||||
|             :actions="[ | ||||
|               { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:notice:update', onClick: handleEdit.bind(null, record) }, | ||||
|               { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'point:sign-in-config:update', onClick: handleEdit.bind(null, record) }, | ||||
|               { | ||||
|                 icon: IconEnum.DELETE, | ||||
|                 danger: true, | ||||
|                 label: t('action.delete'), | ||||
|                 auth: 'system:notice:delete', | ||||
|                 auth: 'point:sign-in-config:delete', | ||||
|                 popConfirm: { | ||||
|                   title: t('common.delMessage'), | ||||
|                   placement: 'left', | ||||
|  |  | |||
|  | @ -48,7 +48,7 @@ async function handleDelete(record: Recordable) { | |||
|   <div> | ||||
|     <BasicTable @register="registerTable"> | ||||
|       <template #toolbar> | ||||
|         <a-button v-auth="['system:notice:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> | ||||
|         <a-button v-auth="['member:tag:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> | ||||
|           {{ t('action.create') }} | ||||
|         </a-button> | ||||
|       </template> | ||||
|  | @ -56,12 +56,12 @@ async function handleDelete(record: Recordable) { | |||
|         <template v-if="column.key === 'action'"> | ||||
|           <TableAction | ||||
|             :actions="[ | ||||
|               { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:notice:update', onClick: handleEdit.bind(null, record) }, | ||||
|               { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'member:tag:update', onClick: handleEdit.bind(null, record) }, | ||||
|               { | ||||
|                 icon: IconEnum.DELETE, | ||||
|                 danger: true, | ||||
|                 label: t('action.delete'), | ||||
|                 auth: 'system:notice:delete', | ||||
|                 auth: 'member:tag:delete', | ||||
|                 popConfirm: { | ||||
|                   title: t('common.delMessage'), | ||||
|                   placement: 'left', | ||||
|  |  | |||
|  | @ -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> | ||||
|  | @ -1,5 +1,6 @@ | |||
| <script lang="ts" setup> | ||||
| import UserModal from './UserModal.vue' | ||||
| import UpdateLevelModal from './UpdateLevelModal.vue' | ||||
| import { columns, searchFormSchema } from './user.data' | ||||
| import { useI18n } from '@/hooks/web/useI18n' | ||||
| import { useModal } from '@/components/Modal' | ||||
|  | @ -11,8 +12,9 @@ defineOptions({ name: 'MemberUser' }) | |||
| 
 | ||||
| const { t } = useI18n() | ||||
| const [registerModal, { openModal }] = useModal() | ||||
| const [registerUpdateLevelModal, { openModal: openUpdateLevelModal }] = useModal() | ||||
| const [registerTable, { reload }] = useTable({ | ||||
|   title: '用户列表', | ||||
|   title: '会员列表', | ||||
|   api: getUserPage, | ||||
|   columns, | ||||
|   formConfig: { labelWidth: 120, schemas: searchFormSchema }, | ||||
|  | @ -20,7 +22,7 @@ const [registerTable, { reload }] = useTable({ | |||
|   showTableSetting: true, | ||||
|   showIndexColumn: false, | ||||
|   actionColumn: { | ||||
|     width: 140, | ||||
|     width: 200, | ||||
|     title: t('common.action'), | ||||
|     dataIndex: 'action', | ||||
|     fixed: 'right', | ||||
|  | @ -30,6 +32,9 @@ const [registerTable, { reload }] = useTable({ | |||
| function handleEdit(record: Recordable) { | ||||
|   openModal(true, { record, isUpdate: true }) | ||||
| } | ||||
| function updateLevelFormRef(record: Recordable) { | ||||
|   openUpdateLevelModal(true, { record, isUpdate: true }) | ||||
| } | ||||
| </script> | ||||
| 
 | ||||
| <template> | ||||
|  | @ -39,12 +44,14 @@ function handleEdit(record: Recordable) { | |||
|         <template v-if="column.key === 'action'"> | ||||
|           <TableAction | ||||
|             :actions="[ | ||||
|               { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:notice:update', onClick: handleEdit.bind(null, record) }, | ||||
|               { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'member:user:update', onClick: handleEdit.bind(null, record) }, | ||||
|               { icon: IconEnum.EDIT, label: '修改等级', auth: 'member:user:update-level', onClick: updateLevelFormRef.bind(null, record) }, | ||||
|             ]" | ||||
|           /> | ||||
|         </template> | ||||
|       </template> | ||||
|     </BasicTable> | ||||
|     <UserModal @register="registerModal" @success="reload()" /> | ||||
|     <UpdateLevelModal @register="registerUpdateLevelModal" @success="reload()" /> | ||||
|   </div> | ||||
| </template> | ||||
|  |  | |||
|  | @ -1,4 +1,6 @@ | |||
| import { getMemberTagPage } from '@/api/member/tag' | ||||
| import { getSimpleGroupList } from '@/api/member/group' | ||||
| import { getSimpleLevelList } from '@/api/member/level' | ||||
| import { getMemberTagPage, getSimpleTagList } from '@/api/member/tag' | ||||
| import { getAreaTree } from '@/api/system/area' | ||||
| import type { BasicColumn, FormSchema } from '@/components/Table' | ||||
| import { useRender } from '@/components/Table' | ||||
|  | @ -28,11 +30,16 @@ export const columns: BasicColumn[] = [ | |||
|     dataIndex: 'nickname', | ||||
|     width: 100, | ||||
|   }, | ||||
|   // {
 | ||||
|   //   title: '分组',
 | ||||
|   //   dataIndex: 'id',
 | ||||
|   //   width: 100,
 | ||||
|   // },
 | ||||
|   { | ||||
|     title: '等级', | ||||
|     dataIndex: 'levelName', | ||||
|     width: 100, | ||||
|   }, | ||||
|   { | ||||
|     title: '分组', | ||||
|     dataIndex: 'groupName', | ||||
|     width: 100, | ||||
|   }, | ||||
|   { | ||||
|     title: '用户标签', | ||||
|     dataIndex: 'tagNames', | ||||
|  | @ -41,11 +48,11 @@ export const columns: BasicColumn[] = [ | |||
|       return useRender.renderTags(text) | ||||
|     }, | ||||
|   }, | ||||
|   // {
 | ||||
|   //   title: '积分',
 | ||||
|   //   dataIndex: 'nickname',
 | ||||
|   //   width: 100,
 | ||||
|   // },
 | ||||
|   { | ||||
|     title: '积分', | ||||
|     dataIndex: 'point', | ||||
|     width: 100, | ||||
|   }, | ||||
|   { | ||||
|     title: '状态', | ||||
|     dataIndex: 'status', | ||||
|  | @ -100,7 +107,29 @@ export const searchFormSchema: FormSchema[] = [ | |||
|     field: 'tagIds', | ||||
|     component: 'ApiSelect', | ||||
|     componentProps: { | ||||
|       api: () => getMemberTagPage({}), | ||||
|       api: () => getSimpleTagList(), | ||||
|       labelField: 'name', | ||||
|       valueField: 'id', | ||||
|     }, | ||||
|     colProps: { span: 8 }, | ||||
|   }, | ||||
|   { | ||||
|     label: '用户等级', | ||||
|     field: 'levelId', | ||||
|     component: 'ApiSelect', | ||||
|     componentProps: { | ||||
|       api: () => getSimpleLevelList(), | ||||
|       labelField: 'name', | ||||
|       valueField: 'id', | ||||
|     }, | ||||
|     colProps: { span: 8 }, | ||||
|   }, | ||||
|   { | ||||
|     label: '用户分组', | ||||
|     field: 'groupId', | ||||
|     component: 'ApiSelect', | ||||
|     componentProps: { | ||||
|       api: () => getSimpleGroupList(), | ||||
|       labelField: 'name', | ||||
|       valueField: 'id', | ||||
|     }, | ||||
|  | @ -183,7 +212,17 @@ export const formSchema: FormSchema[] = [ | |||
|     field: 'tagIds', | ||||
|     component: 'ApiSelect', | ||||
|     componentProps: { | ||||
|       api: () => getMemberTagPage({}), | ||||
|       api: () => getSimpleTagList(), | ||||
|       labelField: 'name', | ||||
|       valueField: 'id', | ||||
|     }, | ||||
|   }, | ||||
|   { | ||||
|     label: '用户分组', | ||||
|     field: 'groupId', | ||||
|     component: 'ApiSelect', | ||||
|     componentProps: { | ||||
|       api: () => getSimpleGroupList(), | ||||
|       labelField: 'name', | ||||
|       valueField: 'id', | ||||
|     }, | ||||
|  | @ -194,3 +233,34 @@ export const formSchema: FormSchema[] = [ | |||
|     component: 'InputTextArea', | ||||
|   }, | ||||
| ] | ||||
| 
 | ||||
| export const updateLevelFormSchema: FormSchema[] = [ | ||||
|   { | ||||
|     label: '编号', | ||||
|     field: 'id', | ||||
|     show: false, | ||||
|     component: 'Input', | ||||
|   }, | ||||
|   { | ||||
|     label: '用户昵称', | ||||
|     field: 'nickname', | ||||
|     dynamicDisabled: true, | ||||
|     component: 'Input', | ||||
|   }, | ||||
|   { | ||||
|     label: '用户等级', | ||||
|     field: 'levelId', | ||||
|     component: 'ApiSelect', | ||||
|     componentProps: { | ||||
|       api: () => getSimpleLevelList(), | ||||
|       labelField: 'name', | ||||
|       valueField: 'id', | ||||
|     }, | ||||
|   }, | ||||
|   { | ||||
|     label: '修改原因', | ||||
|     field: 'reason', | ||||
|     required: true, | ||||
|     component: 'InputTextArea', | ||||
|   }, | ||||
| ] | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 xingyu
						xingyu