Merge remote-tracking branch 'yudao/dev' into dev
This commit is contained in:
20
apps/web-antd/src/api/member/address/index.ts
Normal file
20
apps/web-antd/src/api/member/address/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberAddressApi {
|
||||
/** 收件地址信息 */
|
||||
export interface Address {
|
||||
id?: number;
|
||||
name: string;
|
||||
mobile: string;
|
||||
areaId: number;
|
||||
detailAddress: string;
|
||||
defaultStatus: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询用户收件地址列表 */
|
||||
export function getAddressList(params: any) {
|
||||
return requestClient.get<MemberAddressApi.Address[]>('/member/address/list', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
22
apps/web-antd/src/api/member/config/index.ts
Normal file
22
apps/web-antd/src/api/member/config/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberConfigApi {
|
||||
/** 积分设置信息 */
|
||||
export interface Config {
|
||||
id?: number;
|
||||
pointTradeDeductEnable: number;
|
||||
pointTradeDeductUnitPrice: number;
|
||||
pointTradeDeductMaxPrice: number;
|
||||
pointTradeGivePoint: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询积分设置详情 */
|
||||
export function getConfig() {
|
||||
return requestClient.get<MemberConfigApi.Config>('/member/config/get');
|
||||
}
|
||||
|
||||
/** 新增修改积分设置 */
|
||||
export function saveConfig(data: MemberConfigApi.Config) {
|
||||
return requestClient.put('/member/config/save', data);
|
||||
}
|
||||
33
apps/web-antd/src/api/member/experience-record/index.ts
Normal file
33
apps/web-antd/src/api/member/experience-record/index.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberExperienceRecordApi {
|
||||
/** 会员经验记录信息 */
|
||||
export interface ExperienceRecord {
|
||||
id?: number;
|
||||
userId: number;
|
||||
bizId: string;
|
||||
bizType: number;
|
||||
title: string;
|
||||
description: string;
|
||||
experience: number;
|
||||
totalExperience: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询会员经验记录列表 */
|
||||
export function getExperienceRecordPage(params: PageParam) {
|
||||
return requestClient.get<
|
||||
PageResult<MemberExperienceRecordApi.ExperienceRecord>
|
||||
>('/member/experience-record/page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询会员经验记录详情 */
|
||||
export function getExperienceRecord(id: number) {
|
||||
return requestClient.get<MemberExperienceRecordApi.ExperienceRecord>(
|
||||
`/member/experience-record/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
50
apps/web-antd/src/api/member/group/index.ts
Normal file
50
apps/web-antd/src/api/member/group/index.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberGroupApi {
|
||||
/** 用户分组信息 */
|
||||
export interface Group {
|
||||
id?: number;
|
||||
name: string;
|
||||
remark: string;
|
||||
status: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询用户分组列表 */
|
||||
export function getGroupPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MemberGroupApi.Group>>(
|
||||
'/member/group/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询用户分组详情 */
|
||||
export function getGroup(id: number) {
|
||||
return requestClient.get<MemberGroupApi.Group>(`/member/group/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增用户分组 */
|
||||
export function createGroup(data: MemberGroupApi.Group) {
|
||||
return requestClient.post('/member/group/create', data);
|
||||
}
|
||||
|
||||
/** 查询用户分组 - 精简信息列表 */
|
||||
export function getSimpleGroupList() {
|
||||
return requestClient.get<MemberGroupApi.Group[]>(
|
||||
'/member/group/list-all-simple',
|
||||
);
|
||||
}
|
||||
|
||||
/** 修改用户分组 */
|
||||
export function updateGroup(data: MemberGroupApi.Group) {
|
||||
return requestClient.put('/member/group/update', data);
|
||||
}
|
||||
|
||||
/** 删除用户分组 */
|
||||
export function deleteGroup(id: number) {
|
||||
return requestClient.delete(`/member/group/delete?id=${id}`);
|
||||
}
|
||||
49
apps/web-antd/src/api/member/level/index.ts
Normal file
49
apps/web-antd/src/api/member/level/index.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberLevelApi {
|
||||
/** 会员等级信息 */
|
||||
export interface Level {
|
||||
id?: number;
|
||||
name: string;
|
||||
experience: number;
|
||||
value: number;
|
||||
discountPercent: number;
|
||||
icon: string;
|
||||
bgUrl: string;
|
||||
status: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询会员等级列表 */
|
||||
export function getLevelList(params: MemberLevelApi.Level) {
|
||||
return requestClient.get<MemberLevelApi.Level[]>('/member/level/list', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询会员等级详情 */
|
||||
export function getLevel(id: number) {
|
||||
return requestClient.get<MemberLevelApi.Level>(`/member/level/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 查询会员等级 - 精简信息列表 */
|
||||
export function getSimpleLevelList() {
|
||||
return requestClient.get<MemberLevelApi.Level[]>(
|
||||
'/member/level/list-all-simple',
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增会员等级 */
|
||||
export function createLevel(data: MemberLevelApi.Level) {
|
||||
return requestClient.post('/member/level/create', data);
|
||||
}
|
||||
|
||||
/** 修改会员等级 */
|
||||
export function updateLevel(data: MemberLevelApi.Level) {
|
||||
return requestClient.put('/member/level/update', data);
|
||||
}
|
||||
|
||||
/** 删除会员等级 */
|
||||
export function deleteLevel(id: number) {
|
||||
return requestClient.delete(`/member/level/delete?id=${id}`);
|
||||
}
|
||||
28
apps/web-antd/src/api/member/point/record/index.ts
Normal file
28
apps/web-antd/src/api/member/point/record/index.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberPointRecordApi {
|
||||
/** 用户积分记录信息 */
|
||||
export interface Record {
|
||||
id?: number;
|
||||
bizId: string;
|
||||
bizType: string;
|
||||
title: string;
|
||||
description: string;
|
||||
point: number;
|
||||
totalPoint: number;
|
||||
userId: number;
|
||||
createDate: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询用户积分记录列表 */
|
||||
export function getRecordPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MemberPointRecordApi.Record>>(
|
||||
'/member/point/record/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
41
apps/web-antd/src/api/member/signin/config/index.ts
Normal file
41
apps/web-antd/src/api/member/signin/config/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberSignInConfigApi {
|
||||
/** 积分签到规则信息 */
|
||||
export interface SignInConfig {
|
||||
id?: number;
|
||||
day?: number;
|
||||
point?: number;
|
||||
experience?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询积分签到规则列表 */
|
||||
export function getSignInConfigList() {
|
||||
return requestClient.get<MemberSignInConfigApi.SignInConfig[]>(
|
||||
'/member/sign-in/config/list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询积分签到规则详情 */
|
||||
export function getSignInConfig(id: number) {
|
||||
return requestClient.get<MemberSignInConfigApi.SignInConfig>(
|
||||
`/member/sign-in/config/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增积分签到规则 */
|
||||
export function createSignInConfig(data: MemberSignInConfigApi.SignInConfig) {
|
||||
return requestClient.post('/member/sign-in/config/create', data);
|
||||
}
|
||||
|
||||
/** 修改积分签到规则 */
|
||||
export function updateSignInConfig(data: MemberSignInConfigApi.SignInConfig) {
|
||||
return requestClient.put('/member/sign-in/config/update', data);
|
||||
}
|
||||
|
||||
/** 删除积分签到规则 */
|
||||
export function deleteSignInConfig(id: number) {
|
||||
return requestClient.delete(`/member/sign-in/config/delete?id=${id}`);
|
||||
}
|
||||
23
apps/web-antd/src/api/member/signin/record/index.ts
Normal file
23
apps/web-antd/src/api/member/signin/record/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberSignInRecordApi {
|
||||
/** 用户签到积分信息 */
|
||||
export interface SignInRecord {
|
||||
id?: number;
|
||||
userId: number;
|
||||
day: number;
|
||||
point: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询用户签到积分列表 */
|
||||
export function getSignInRecordPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MemberSignInRecordApi.SignInRecord>>(
|
||||
'/member/sign-in/record/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
43
apps/web-antd/src/api/member/tag/index.ts
Normal file
43
apps/web-antd/src/api/member/tag/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberTagApi {
|
||||
/** 会员标签信息 */
|
||||
export interface Tag {
|
||||
id?: number;
|
||||
name: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询会员标签列表 */
|
||||
export function getMemberTagPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MemberTagApi.Tag>>('/member/tag/page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询会员标签详情 */
|
||||
export function getMemberTag(id: number) {
|
||||
return requestClient.get<MemberTagApi.Tag>(`/member/tag/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 查询会员标签 - 精简信息列表 */
|
||||
export function getSimpleTagList() {
|
||||
return requestClient.get<MemberTagApi.Tag[]>('/member/tag/list-all-simple');
|
||||
}
|
||||
|
||||
/** 新增会员标签 */
|
||||
export function createMemberTag(data: MemberTagApi.Tag) {
|
||||
return requestClient.post('/member/tag/create', data);
|
||||
}
|
||||
|
||||
/** 修改会员标签 */
|
||||
export function updateMemberTag(data: MemberTagApi.Tag) {
|
||||
return requestClient.put('/member/tag/update', data);
|
||||
}
|
||||
|
||||
/** 删除会员标签 */
|
||||
export function deleteMemberTag(id: number) {
|
||||
return requestClient.delete(`/member/tag/delete?id=${id}`);
|
||||
}
|
||||
70
apps/web-antd/src/api/member/user/index.ts
Normal file
70
apps/web-antd/src/api/member/user/index.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MemberUserApi {
|
||||
/** 会员用户信息 */
|
||||
export interface User {
|
||||
id?: number;
|
||||
avatar?: string;
|
||||
birthday?: number;
|
||||
createTime?: number;
|
||||
loginDate?: number;
|
||||
loginIp: string;
|
||||
mark: string;
|
||||
mobile: string;
|
||||
name?: string;
|
||||
nickname?: string;
|
||||
registerIp: string;
|
||||
sex: number;
|
||||
status: number;
|
||||
areaId?: number;
|
||||
areaName?: string;
|
||||
levelName: null | string;
|
||||
point?: null | number;
|
||||
totalPoint?: null | number;
|
||||
experience?: null | number;
|
||||
}
|
||||
|
||||
/** 会员用户等级更新信息 */
|
||||
export interface UserLevelUpdate {
|
||||
id: number;
|
||||
levelId: number;
|
||||
}
|
||||
|
||||
/** 会员用户积分更新信息 */
|
||||
export interface UserPointUpdate {
|
||||
id: number;
|
||||
point: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询会员用户列表 */
|
||||
export function getUserPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MemberUserApi.User>>(
|
||||
'/member/user/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询会员用户详情 */
|
||||
export function getUser(id: number) {
|
||||
return requestClient.get<MemberUserApi.User>(`/member/user/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 修改会员用户 */
|
||||
export function updateUser(data: MemberUserApi.User) {
|
||||
return requestClient.put('/member/user/update', data);
|
||||
}
|
||||
|
||||
/** 修改会员用户等级 */
|
||||
export function updateUserLevel(data: MemberUserApi.UserLevelUpdate) {
|
||||
return requestClient.put('/member/user/update-level', data);
|
||||
}
|
||||
|
||||
/** 修改会员用户积分 */
|
||||
export function updateUserPoint(data: MemberUserApi.UserPointUpdate) {
|
||||
return requestClient.put('/member/user/update-point', data);
|
||||
}
|
||||
@@ -3,40 +3,51 @@ import type { InputProps, TextAreaProps } from 'ant-design-vue';
|
||||
|
||||
import type { FileUploadProps } from './typing';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { Col, Input, Row, Textarea } from 'ant-design-vue';
|
||||
|
||||
import FileUpload from './file-upload.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
defaultValue?: number | string;
|
||||
fileUploadProps?: FileUploadProps;
|
||||
inputProps?: InputProps;
|
||||
inputType?: 'input' | 'textarea';
|
||||
modelValue?: number | string;
|
||||
textareaProps?: TextAreaProps;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
const emits = defineEmits<{
|
||||
(e: 'change', payload: number | string): void;
|
||||
(e: 'update:value', payload: number | string): void;
|
||||
(e: 'update:modelValue', payload: number | string): void;
|
||||
}>();
|
||||
|
||||
const value = ref('');
|
||||
const modelValue = useVModel(props, 'modelValue', emits, {
|
||||
defaultValue: props.defaultValue,
|
||||
passive: true,
|
||||
});
|
||||
|
||||
function handleReturnText(text: string) {
|
||||
value.value = text;
|
||||
emit('change', value.value);
|
||||
emit('update:value', value.value);
|
||||
modelValue.value = text;
|
||||
emits('change', modelValue.value);
|
||||
emits('update:value', modelValue.value);
|
||||
emits('update:modelValue', modelValue.value);
|
||||
}
|
||||
|
||||
const inputProps = computed(() => {
|
||||
return {
|
||||
...props.inputProps,
|
||||
value: value.value,
|
||||
value: modelValue.value,
|
||||
};
|
||||
});
|
||||
|
||||
const textareaProps = computed(() => {
|
||||
return {
|
||||
...props.textareaProps,
|
||||
value: value.value,
|
||||
value: modelValue.value,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
16
apps/web-antd/src/router/routes/modules/member.ts
Normal file
16
apps/web-antd/src/router/routes/modules/member.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/member/user/detail',
|
||||
component: () => import('#/views/member/user/modules/detail.vue'),
|
||||
name: 'MemberUserDetail',
|
||||
meta: {
|
||||
title: '会员详情',
|
||||
icon: 'lucide:user',
|
||||
hideInMenu: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default routes;
|
||||
@@ -2,6 +2,7 @@
|
||||
* 下载工具模块
|
||||
* 提供多种文件格式的下载功能
|
||||
*/
|
||||
// 请使用 @vben/utils/download 代替 packages/@core/base/shared/src/utils/download.ts
|
||||
|
||||
/**
|
||||
* 图片下载配置接口
|
||||
|
||||
@@ -6,4 +6,3 @@ export * from './formatTime';
|
||||
export * from './formCreate';
|
||||
export * from './rangePickerProps';
|
||||
export * from './routerHelper';
|
||||
export * from './validator';
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// 参数校验,对标 Hutool 的 Validator 工具类
|
||||
|
||||
/** 手机号正则表达式(中国) */
|
||||
const MOBILE_REGEX = /(?:0|86|\+86)?1[3-9]\d{9}/;
|
||||
|
||||
/**
|
||||
* 验证是否为手机号码(中国)
|
||||
*
|
||||
* @param value 值
|
||||
* @returns 是否为手机号码(中国)
|
||||
*/
|
||||
export function isMobile(value?: null | string): boolean {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
return MOBILE_REGEX.test(value);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ defineExpose({
|
||||
<Button
|
||||
v-if="row.formId > 0"
|
||||
type="primary"
|
||||
@click="showFormDetail(row)"`
|
||||
@click="showFormDetail(row)"
|
||||
size="small"
|
||||
ghost
|
||||
class="ml-1"
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { CrmClueApi } from '#/api/crm/clue';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { getAreaTree } from '#/api/system/area';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -92,9 +89,10 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '地址',
|
||||
component: 'Cascader',
|
||||
component: 'ApiTreeSelect',
|
||||
componentProps: {
|
||||
api: 'getAreaTree',
|
||||
api: () => getAreaTree(),
|
||||
fieldNames: { label: 'name', value: 'id', children: 'children' },
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -162,14 +160,11 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns<T = CrmClueApi.Clue>(
|
||||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'name',
|
||||
title: '线索名称',
|
||||
minWidth: 160,
|
||||
fixed: 'left',
|
||||
slots: {
|
||||
default: 'name',
|
||||
@@ -178,7 +173,6 @@ export function useGridColumns<T = CrmClueApi.Clue>(
|
||||
{
|
||||
field: 'source',
|
||||
title: '线索来源',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE },
|
||||
@@ -187,27 +181,22 @@ export function useGridColumns<T = CrmClueApi.Clue>(
|
||||
{
|
||||
field: 'mobile',
|
||||
title: '手机',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'telephone',
|
||||
title: '电话',
|
||||
minWidth: 130,
|
||||
},
|
||||
{
|
||||
field: 'email',
|
||||
title: '邮箱',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'detailAddress',
|
||||
title: '地址',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'industryId',
|
||||
title: '客户行业',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY },
|
||||
@@ -216,7 +205,6 @@ export function useGridColumns<T = CrmClueApi.Clue>(
|
||||
{
|
||||
field: 'level',
|
||||
title: '客户级别',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL },
|
||||
@@ -225,66 +213,40 @@ export function useGridColumns<T = CrmClueApi.Clue>(
|
||||
{
|
||||
field: 'ownerUserName',
|
||||
title: '负责人',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'ownerUserDeptName',
|
||||
title: '所属部门',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'contactNextTime',
|
||||
title: '下次联系时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'contactLastTime',
|
||||
title: '最后跟进时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'creatorName',
|
||||
title: '创建人',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'operation',
|
||||
title: '操作',
|
||||
width: 130,
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
cellRender: {
|
||||
attrs: {
|
||||
nameField: 'name',
|
||||
nameTitle: '线索',
|
||||
onClick: onActionClick,
|
||||
},
|
||||
name: 'CellOperation',
|
||||
options: [
|
||||
{
|
||||
code: 'edit',
|
||||
show: hasAccessByCodes(['crm:clue:update']),
|
||||
},
|
||||
{
|
||||
code: 'delete',
|
||||
show: hasAccessByCodes(['crm:clue:delete']),
|
||||
},
|
||||
],
|
||||
},
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { CrmClueApi } from '#/api/crm/clue';
|
||||
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Download, Plus } from '@vben/icons';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteClue, exportClue, getCluePage } from '#/api/crm/clue';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { $t } from '#/locales';
|
||||
@@ -33,55 +29,43 @@ function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function onExport() {
|
||||
const data = await exportClue(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '线索.xls', source: data });
|
||||
}
|
||||
|
||||
/** 创建线索 */
|
||||
function onCreate() {
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑线索 */
|
||||
function onEdit(row: CrmClueApi.Clue) {
|
||||
function handleEdit(row: CrmClueApi.Clue) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除线索 */
|
||||
async function onDelete(row: CrmClueApi.Clue) {
|
||||
async function handleDelete(row: CrmClueApi.Clue) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||
duration: 0,
|
||||
key: 'action_process_msg',
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
try {
|
||||
await deleteClue(row.id as number);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} catch {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看线索详情 */
|
||||
function onDetail(row: CrmClueApi.Clue) {
|
||||
push({ name: 'CrmClueDetail', params: { id: row.id } });
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportClue(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '线索.xls', source: data });
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({ code, row }: OnActionClickParams<CrmClueApi.Clue>) {
|
||||
switch (code) {
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/** 查看线索详情 */
|
||||
function handleDetail(row: CrmClueApi.Clue) {
|
||||
push({ name: 'CrmClueDetail', params: { id: row.id } });
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
@@ -89,7 +73,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(onActionClick),
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
@@ -130,29 +114,54 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="线索列表">
|
||||
<template #toolbar-tools>
|
||||
<Button
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['crm:clue:create']"
|
||||
>
|
||||
<Plus class="size-5" />
|
||||
{{ $t('ui.actionTitle.create', ['线索']) }}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
class="ml-2"
|
||||
@click="onExport"
|
||||
v-access:code="['crm:clue:export']"
|
||||
>
|
||||
<Download class="size-5" />
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</Button>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['线索']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['crm:clue:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['crm:clue:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #name="{ row }">
|
||||
<Button type="link" @click="onDetail(row)">
|
||||
<Button type="link" @click="handleDetail(row)">
|
||||
{{ row.name }}
|
||||
</Button>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['crm:clue:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['crm:clue:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@@ -8,6 +8,8 @@ import { h } from 'vue';
|
||||
import { useAccess } from '@vben/access';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { getAreaTree } from '#/api/system/area';
|
||||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
@@ -47,9 +49,13 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'ownerUserId',
|
||||
label: '负责人',
|
||||
component: 'Select',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: 'getSimpleUserList',
|
||||
api: () => getSimpleUserList(),
|
||||
fieldNames: {
|
||||
label: 'nickname',
|
||||
value: 'id',
|
||||
},
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
@@ -92,9 +98,10 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '地址',
|
||||
component: 'Cascader',
|
||||
component: 'ApiTreeSelect',
|
||||
componentProps: {
|
||||
api: 'getAreaTree',
|
||||
api: () => getAreaTree(),
|
||||
fieldNames: { label: 'name', value: 'id', children: 'children' },
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ function onChangeSceneType(key: number | string) {
|
||||
<FormModal @success="onRefresh" />
|
||||
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<template #top>
|
||||
<Tabs class="border-none" @change="onChangeSceneType">
|
||||
<Tabs.TabPane tab="我负责的" key="1" />
|
||||
<Tabs.TabPane tab="我参与的" key="2" />
|
||||
|
||||
@@ -29,9 +29,9 @@ const [Form, formApi] = useVbenForm({
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 120,
|
||||
},
|
||||
// 一共2列
|
||||
wrapperClass: 'grid-cols-2',
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
|
||||
166
apps/web-antd/src/views/crm/product/data.ts
Normal file
166
apps/web-antd/src/views/crm/product/data.ts
Normal file
@@ -0,0 +1,166 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'name',
|
||||
label: '产品名称',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'no',
|
||||
label: '产品编码',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'categoryName',
|
||||
label: '产品类型',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'unit',
|
||||
label: '产品单位',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.CRM_PRODUCT_UNIT),
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'price',
|
||||
label: '价格(元)',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 2,
|
||||
step: 0.1,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Textarea',
|
||||
fieldName: 'description',
|
||||
label: '产品描述',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '上架状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.CRM_PRODUCT_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '产品名称',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '上架状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.CRM_PRODUCT_STATUS, 'number'),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '产品编号',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '产品名称',
|
||||
slots: { default: 'name' },
|
||||
},
|
||||
{
|
||||
field: 'categoryName',
|
||||
title: '产品类型',
|
||||
},
|
||||
{
|
||||
field: 'unit',
|
||||
title: '产品单位',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.CRM_PRODUCT_UNIT },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'no',
|
||||
title: '产品编码',
|
||||
},
|
||||
{
|
||||
field: 'price',
|
||||
title: '价格(元)',
|
||||
formatter: 'formatNumber',
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
title: '产品描述',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '上架状态',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.CRM_PRODUCT_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'ownerUserName',
|
||||
title: '负责人',
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'creatorName',
|
||||
title: '创建人',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,157 @@
|
||||
<script lang="ts" setup>
|
||||
import { Page } from '@vben/common-ui';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { CrmProductApi } from '#/api/crm/product';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteProduct,
|
||||
exportProduct,
|
||||
getProductPage,
|
||||
} from '#/api/crm/product';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const { push } = useRouter();
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportProduct(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '产品.xls', source: data });
|
||||
}
|
||||
|
||||
/** 打开详情 */
|
||||
function handleDetail(row: CrmProductApi.Product) {
|
||||
push({ name: 'CrmProductDetail', params: { id: row.id } });
|
||||
}
|
||||
|
||||
/** 创建产品 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑产品 */
|
||||
function handleEdit(row: CrmProductApi.Product) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除产品 */
|
||||
async function handleDelete(row: CrmProductApi.Product) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
try {
|
||||
await deleteProduct(row.id as number);
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getProductPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<CrmProductApi.Product>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="【产品】产品管理、产品分类"
|
||||
url="https://doc.iocoder.cn/crm/product/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/product/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/product/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="产品列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['产品']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['crm:product:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['crm:product:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #name="{ row }">
|
||||
<Button type="link" @click="handleDetail(row)">{{ row.name }}</Button>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['crm:product:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['crm:product:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
82
apps/web-antd/src/views/crm/product/modules/form.vue
Normal file
82
apps/web-antd/src/views/crm/product/modules/form.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CrmProductApi } from '#/api/crm/product';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createProduct, getProduct, updateProduct } from '#/api/crm/product';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<CrmProductApi.Product>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['产品'])
|
||||
: $t('ui.actionTitle.create', ['产品']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as CrmProductApi.Product;
|
||||
try {
|
||||
await (formData.value?.id ? updateProduct(data) : createProduct(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<CrmProductApi.Product>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getProduct(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[600px]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -3,7 +3,7 @@ import type { InfraApiAccessLogApi } from '#/api/infra/api-access-log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { JsonViewer, useVbenModal } from '@vben/common-ui';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { Descriptions } from 'ant-design-vue';
|
||||
@@ -71,7 +71,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
{{ formData?.requestMethod }} {{ formData?.requestUrl }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="请求参数">
|
||||
{{ formData?.requestParams }}
|
||||
<JsonViewer :value="formData?.requestParams" preview-mode />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="请求结果">
|
||||
{{ formData?.responseBody }}
|
||||
|
||||
@@ -3,10 +3,10 @@ import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { JsonViewer, useVbenModal } from '@vben/common-ui';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { Descriptions, Input } from 'ant-design-vue';
|
||||
import { Descriptions } from 'ant-design-vue';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { DICT_TYPE } from '#/utils';
|
||||
@@ -71,7 +71,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
{{ formData?.requestMethod }} {{ formData?.requestUrl }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="请求参数">
|
||||
{{ formData?.requestParams }}
|
||||
<JsonViewer :value="formData?.requestParams" preview-mode />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="异常时间">
|
||||
{{ formatDateTime(formData?.exceptionTime || '') }}
|
||||
@@ -80,11 +80,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
{{ formData?.exceptionName }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item v-if="formData?.exceptionStackTrace" label="异常堆栈">
|
||||
<Input.TextArea
|
||||
:value="formData?.exceptionStackTrace"
|
||||
:auto-size="{ maxRows: 20 }"
|
||||
readonly
|
||||
/>
|
||||
<JsonViewer :value="formData?.exceptionStackTrace" preview-mode />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理状态">
|
||||
<DictTag
|
||||
|
||||
@@ -97,7 +97,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['短信渠道']),
|
||||
label: $t('ui.actionTitle.create', ['参数列表']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['infra:config:create'],
|
||||
|
||||
@@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Modal class="w-[40%]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { Demo01ContactApi } from '#/api/infra/demo/demo01';
|
||||
|
||||
import { h, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Download, Plus, Trash2 } from '@vben/icons';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteDemo01Contact,
|
||||
deleteDemo01ContactListByIds,
|
||||
@@ -36,17 +32,17 @@ function onRefresh() {
|
||||
}
|
||||
|
||||
/** 创建示例联系人 */
|
||||
function onCreate() {
|
||||
function handleCreate() {
|
||||
formModalApi.setData({}).open();
|
||||
}
|
||||
|
||||
/** 编辑示例联系人 */
|
||||
function onEdit(row: Demo01ContactApi.Demo01Contact) {
|
||||
function handleEdit(row: Demo01ContactApi.Demo01Contact) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除示例联系人 */
|
||||
async function onDelete(row: Demo01ContactApi.Demo01Contact) {
|
||||
async function handleDelete(row: Demo01ContactApi.Demo01Contact) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
@@ -62,14 +58,14 @@ async function onDelete(row: Demo01ContactApi.Demo01Contact) {
|
||||
}
|
||||
|
||||
/** 批量删除示例联系人 */
|
||||
async function onDeleteBatch() {
|
||||
async function handleDeleteBatch() {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting'),
|
||||
duration: 0,
|
||||
key: 'action_process_msg',
|
||||
});
|
||||
try {
|
||||
await deleteDemo01ContactListByIds(deleteIds.value);
|
||||
await deleteDemo01ContactListByIds(checkedIds.value);
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
onRefresh();
|
||||
} finally {
|
||||
@@ -79,44 +75,27 @@ async function onDeleteBatch() {
|
||||
|
||||
// TODO @puhui999:方法名,改成 handleRowCheckboxChange;注释:处理选中表格行
|
||||
// TODO @puhui999:deleteIds => checkedIds;然后注释去掉?
|
||||
const deleteIds = ref<number[]>([]); // 待删除示例联系人 ID
|
||||
function setDeleteIds({
|
||||
const checkedIds = ref<number[]>([]); // 待删除示例联系人 ID
|
||||
function setCheckedIds({
|
||||
records,
|
||||
}: {
|
||||
records: Demo01ContactApi.Demo01Contact[];
|
||||
}) {
|
||||
deleteIds.value = records.map((item) => item.id);
|
||||
checkedIds.value = records.map((item) => item.id);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function onExport() {
|
||||
async function handleExport() {
|
||||
const data = await exportDemo01Contact(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '示例联系人.xls', source: data });
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
row,
|
||||
}: OnActionClickParams<Demo01ContactApi.Demo01Contact>) {
|
||||
switch (code) {
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(onActionClick),
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
@@ -142,8 +121,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
},
|
||||
} as VxeTableGridOptions<Demo01ContactApi.Demo01Contact>,
|
||||
gridEvents: {
|
||||
checkboxAll: setDeleteIds,
|
||||
checkboxChange: setDeleteIds,
|
||||
checkboxAll: setCheckedIds,
|
||||
checkboxChange: setCheckedIds,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -154,34 +133,56 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
<Grid table-title="示例联系人列表">
|
||||
<template #toolbar-tools>
|
||||
<Button
|
||||
:icon="h(Plus)"
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['infra:demo01-contact:create']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.create', ['示例联系人']) }}
|
||||
</Button>
|
||||
<Button
|
||||
:icon="h(Download)"
|
||||
type="primary"
|
||||
class="ml-2"
|
||||
@click="onExport"
|
||||
v-access:code="['infra:demo01-contact:export']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</Button>
|
||||
<Button
|
||||
:icon="h(Trash2)"
|
||||
type="primary"
|
||||
danger
|
||||
class="ml-2"
|
||||
:disabled="isEmpty(deleteIds)"
|
||||
@click="onDeleteBatch"
|
||||
v-access:code="['infra:demo01-contact:delete']"
|
||||
>
|
||||
批量删除
|
||||
</Button>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['示例联系人']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['infra:demo01-contact:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['infra:demo01-contact:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: '批量删除',
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['infra:demo01-contact:delete'],
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['infra:demo01-contact:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['infra:demo01-contact:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -1,34 +1,114 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberConfigApi } from '#/api/member/config';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { Card, message } from 'ant-design-vue';
|
||||
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getConfig, saveConfig } from '#/api/member/config';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberConfigApi.Config>();
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 所有表单项
|
||||
labelClass: 'w-2/6',
|
||||
},
|
||||
layout: 'horizontal',
|
||||
wrapperClass: 'grid-cols-1',
|
||||
actionWrapperClass: 'text-center',
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Switch',
|
||||
fieldName: 'pointTradeDeductEnable',
|
||||
label: '积分抵扣',
|
||||
help: '开启后,用户可以积分抵扣',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'pointTradeDeductUnitPrice',
|
||||
label: '积分抵扣单价',
|
||||
help: '用户每消费1元,可以抵扣多少积分',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 2,
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'pointTradeDeductMaxPrice',
|
||||
label: '积分抵扣最大值',
|
||||
help: '单次下单积分使用上限,0 不限制',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'pointTradeGivePoint',
|
||||
label: '1 元赠送多少分',
|
||||
help: '下单支付金额按比例赠送积分(实际支付 1 元赠送多少积分)',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
],
|
||||
// 提交函数
|
||||
handleSubmit: onSubmit,
|
||||
});
|
||||
|
||||
async function onSubmit() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberConfigApi.Config;
|
||||
formApi.setState({ commonConfig: { disabled: true } });
|
||||
try {
|
||||
await saveConfig(data);
|
||||
// 关闭并提示
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
formApi.setState({ commonConfig: { disabled: false } });
|
||||
}
|
||||
}
|
||||
|
||||
async function getConfigInfo() {
|
||||
try {
|
||||
const res = await getConfig();
|
||||
formData.value = res;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getConfigInfo();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员手册(功能开启)"
|
||||
url="https://doc.iocoder.cn/member/build/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/config/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/config/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<Card title="积分设置">
|
||||
<Form class="w-1/4" />
|
||||
</Card>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
88
apps/web-antd/src/views/member/group/data.ts
Normal file
88
apps/web-antd/src/views/member/group/data.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'name',
|
||||
label: '分组名称',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '分组名称',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '分组名称',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,127 @@
|
||||
<script lang="ts" setup>
|
||||
import { Page } from '@vben/common-ui';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberGroupApi } from '#/api/member/group';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteGroup, getGroupPage } from '#/api/member/group';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建分组 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑分组 */
|
||||
function handleEdit(row: MemberGroupApi.Group) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除分组 */
|
||||
async function handleDelete(row: MemberGroupApi.Group) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
try {
|
||||
await deleteGroup(row.id as number);
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getGroupPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberGroupApi.Group>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员用户、标签、分组"
|
||||
url="https://doc.iocoder.cn/member/user/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/group/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/group/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="分组列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['分组']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['member:group:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['member:group:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['member:group:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
82
apps/web-antd/src/views/member/group/modules/form.vue
Normal file
82
apps/web-antd/src/views/member/group/modules/form.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberGroupApi } from '#/api/member/group';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createGroup, getGroup, updateGroup } from '#/api/member/group';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberGroupApi.Group>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['会员分组'])
|
||||
: $t('ui.actionTitle.create', ['会员分组']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberGroupApi.Group;
|
||||
try {
|
||||
await (formData.value?.id ? updateGroup(data) : createGroup(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberGroupApi.Group>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getGroup(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[600px]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
158
apps/web-antd/src/views/member/level/data.ts
Normal file
158
apps/web-antd/src/views/member/level/data.ts
Normal file
@@ -0,0 +1,158 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'name',
|
||||
label: '等级名称',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'level',
|
||||
label: '等级',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'experience',
|
||||
label: '升级经验',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'discountPercent',
|
||||
label: '享受折扣(%)',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
max: 100,
|
||||
precision: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ImageUpload',
|
||||
fieldName: 'icon',
|
||||
label: '等级图标',
|
||||
componentProps: {
|
||||
maxSize: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ImageUpload',
|
||||
fieldName: 'backgroundUrl',
|
||||
label: '等级背景图',
|
||||
componentProps: {
|
||||
maxSize: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '等级名称',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
},
|
||||
{
|
||||
field: 'icon',
|
||||
title: '等级图标',
|
||||
cellRender: {
|
||||
name: 'CellImage',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'backgroundUrl',
|
||||
title: '等级背景图',
|
||||
cellRender: {
|
||||
name: 'CellImage',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '等级名称',
|
||||
},
|
||||
{
|
||||
field: 'level',
|
||||
title: '等级',
|
||||
},
|
||||
{
|
||||
field: 'experience',
|
||||
title: '升级经验',
|
||||
},
|
||||
{
|
||||
field: 'discountPercent',
|
||||
title: '享受折扣(%)',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,128 @@
|
||||
<script lang="ts" setup>
|
||||
import { Page } from '@vben/common-ui';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberLevelApi } from '#/api/member/level';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteLevel, getLevelList } from '#/api/member/level';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建等级 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑等级 */
|
||||
function handleEdit(row: MemberLevelApi.Level) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除等级 */
|
||||
async function handleDelete(row: MemberLevelApi.Level) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
try {
|
||||
await deleteLevel(row.id as number);
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async (_params, formValues) => {
|
||||
return await getLevelList({
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberLevelApi.Level>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员等级、积分、签到"
|
||||
url="https://doc.iocoder.cn/member/level/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/level/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/level/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="等级列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['等级']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['member:level:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['member:level:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['member:level:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
82
apps/web-antd/src/views/member/level/modules/form.vue
Normal file
82
apps/web-antd/src/views/member/level/modules/form.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberLevelApi } from '#/api/member/level';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createLevel, getLevel, updateLevel } from '#/api/member/level';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberLevelApi.Level>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['等级'])
|
||||
: $t('ui.actionTitle.create', ['等级']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberLevelApi.Level;
|
||||
try {
|
||||
await (formData.value?.id ? updateLevel(data) : createLevel(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberLevelApi.Level>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getLevel(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[600px]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
101
apps/web-antd/src/views/member/point/record/data.ts
Normal file
101
apps/web-antd/src/views/member/point/record/data.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'nickname',
|
||||
label: '用户',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'bizType',
|
||||
label: '业务类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE, 'number'),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'title',
|
||||
label: '积分标题',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'createDate',
|
||||
label: '获得时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '获得时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'nickname',
|
||||
title: '用户',
|
||||
},
|
||||
{
|
||||
field: 'point',
|
||||
title: '获得积分',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return h(
|
||||
Tag,
|
||||
{
|
||||
class: 'mr-5px',
|
||||
color: row.point > 0 ? 'blue' : 'red',
|
||||
},
|
||||
() => (row.point > 0 ? `+${row.point}` : row.point),
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'totalPoint',
|
||||
title: '总积分',
|
||||
},
|
||||
{
|
||||
field: 'title',
|
||||
title: '标题',
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
title: '描述',
|
||||
},
|
||||
{
|
||||
field: 'bizId',
|
||||
title: '业务编码',
|
||||
},
|
||||
{
|
||||
field: 'bizType',
|
||||
title: '业务类型',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MEMBER_POINT_BIZ_TYPE },
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,46 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberPointRecordApi } from '#/api/member/point/record';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getRecordPage } from '#/api/member/point/record';
|
||||
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getRecordPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberPointRecordApi.Record>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员等级、积分、签到"
|
||||
url="https://doc.iocoder.cn/member/level/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/point/record/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/point/record/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<Grid table-title="积分记录列表" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
101
apps/web-antd/src/views/member/signin/config/data.ts
Normal file
101
apps/web-antd/src/views/member/signin/config/data.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'day',
|
||||
label: '签到天数',
|
||||
help: '只允许设置 1-7,默认签到 7 天为一个周期',
|
||||
componentProps: {
|
||||
min: 1,
|
||||
max: 7,
|
||||
precision: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'point',
|
||||
label: '获得积分',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'experience',
|
||||
label: '奖励经验',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
},
|
||||
{
|
||||
field: 'day',
|
||||
title: '签到天数',
|
||||
formatter: ({ cellValue }) => ['第', cellValue, '天'].join(' '),
|
||||
},
|
||||
{
|
||||
field: 'point',
|
||||
title: '获得积分',
|
||||
},
|
||||
{
|
||||
field: 'experience',
|
||||
title: '奖励经验',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,126 @@
|
||||
<script lang="ts" setup>
|
||||
import { Page } from '@vben/common-ui';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberSignInConfigApi } from '#/api/member/signin/config';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteSignInConfig,
|
||||
getSignInConfigList,
|
||||
} from '#/api/member/signin/config';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建签到配置 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑签到配置 */
|
||||
function handleEdit(row: MemberSignInConfigApi.SignInConfig) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除签到配置 */
|
||||
async function handleDelete(row: MemberSignInConfigApi.SignInConfig) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting'),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
try {
|
||||
await deleteSignInConfig(row.id as number);
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess'),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async () => {
|
||||
return await getSignInConfigList();
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberSignInConfigApi.SignInConfig>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员等级、积分、签到"
|
||||
url="https://doc.iocoder.cn/member/level/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/signin/config/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/signin/config/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="签到配置列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['签到配置']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['point:sign-in-config:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['point:sign-in-config:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['point:sign-in-config:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberSignInConfigApi } from '#/api/member/signin/config';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createSignInConfig,
|
||||
getSignInConfig,
|
||||
updateSignInConfig,
|
||||
} from '#/api/member/signin/config';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberSignInConfigApi.SignInConfig>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['签到配置'])
|
||||
: $t('ui.actionTitle.create', ['签到配置']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data =
|
||||
(await formApi.getValues()) as MemberSignInConfigApi.SignInConfig;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateSignInConfig(data)
|
||||
: createSignInConfig(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberSignInConfigApi.SignInConfig>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getSignInConfig(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[600px]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
73
apps/web-antd/src/views/member/signin/record/data.ts
Normal file
73
apps/web-antd/src/views/member/signin/record/data.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'nickname',
|
||||
label: '签到用户',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'day',
|
||||
label: '签到天数',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '签到时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
},
|
||||
{
|
||||
field: 'nickname',
|
||||
title: '签到用户',
|
||||
},
|
||||
{
|
||||
field: 'day',
|
||||
title: '签到天数',
|
||||
formatter: ({ cellValue }) => ['第', cellValue, '天'].join(' '),
|
||||
},
|
||||
{
|
||||
field: 'point',
|
||||
title: '获得积分',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return h(
|
||||
Tag,
|
||||
{
|
||||
class: 'mr-5px',
|
||||
color: row.point > 0 ? 'blue' : 'red',
|
||||
},
|
||||
() => (row.point > 0 ? `+${row.point}` : row.point),
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '签到时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,46 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberSignInRecordApi } from '#/api/member/signin/record';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getSignInRecordPage } from '#/api/member/signin/record';
|
||||
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSignInRecordPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberSignInRecordApi.SignInRecord>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员等级、积分、签到"
|
||||
url="https://doc.iocoder.cn/member/level/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/signin/record/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/signin/record/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<Grid table-title="签到记录列表" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
71
apps/web-antd/src/views/member/tag/data.ts
Normal file
71
apps/web-antd/src/views/member/tag/data.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'name',
|
||||
label: '标签名称',
|
||||
rules: 'required',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '标签名称',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '标签名称',
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 150,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,134 @@
|
||||
<script lang="ts" setup>
|
||||
import { Page } from '@vben/common-ui';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberTagApi } from '#/api/member/tag';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteMemberTag, getMemberTagPage } from '#/api/member/tag';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建会员标签 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑会员标签 */
|
||||
function handleEdit(row: MemberTagApi.Tag) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除会员标签 */
|
||||
async function handleDelete(row: MemberTagApi.Tag) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
try {
|
||||
await deleteMemberTag(row.id as number);
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||
key: 'action_key_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getMemberTagPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberTagApi.Tag>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员用户、标签、分组"
|
||||
url="https://doc.iocoder.cn/member/user/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/tag/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/tag/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="会员用户、标签、分组"
|
||||
url="https://doc.iocoder.cn/member/user/"
|
||||
/>
|
||||
</template>
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="会员标签列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['会员标签']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['member:tag:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['member:tag:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['member:tag:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
88
apps/web-antd/src/views/member/tag/modules/form.vue
Normal file
88
apps/web-antd/src/views/member/tag/modules/form.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberTagApi } from '#/api/member/tag';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createMemberTag,
|
||||
getMemberTag,
|
||||
updateMemberTag,
|
||||
} from '#/api/member/tag';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberTagApi.Tag>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['会员标签'])
|
||||
: $t('ui.actionTitle.create', ['会员标签']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberTagApi.Tag;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateMemberTag(data)
|
||||
: createMemberTag(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberTagApi.Tag>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getMemberTag(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[600px]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script setup lang="ts">
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
import type { PayWalletApi } from '#/api/pay/wallet/balance';
|
||||
|
||||
import { Card } from 'ant-design-vue';
|
||||
|
||||
import { useDescription } from '#/components/description';
|
||||
import { fenToYuan } from '#/utils';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
mode?: 'kefu' | 'member';
|
||||
user: MemberUserApi.User;
|
||||
wallet: PayWalletApi.WalletVO;
|
||||
}>(),
|
||||
{
|
||||
mode: 'member',
|
||||
},
|
||||
);
|
||||
|
||||
const [Description] = useDescription({
|
||||
componentProps: {
|
||||
bordered: false,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
field: 'levelName',
|
||||
label: '等级',
|
||||
content: (data) => data.levelName || '无',
|
||||
},
|
||||
{
|
||||
field: 'experience',
|
||||
label: '成长值',
|
||||
content: (data) => data.experience || 0,
|
||||
},
|
||||
{
|
||||
field: 'point',
|
||||
label: '当前积分',
|
||||
content: (data) => data.point || 0,
|
||||
},
|
||||
{
|
||||
field: 'totalPoint',
|
||||
label: '总积分',
|
||||
content: (data) => data.totalPoint || 0,
|
||||
},
|
||||
{
|
||||
field: 'balance',
|
||||
label: '当前余额',
|
||||
content: (data) => fenToYuan(data.balance || 0),
|
||||
},
|
||||
{
|
||||
field: 'totalExpense',
|
||||
label: '支出金额',
|
||||
content: (data) => fenToYuan(data.totalExpense || 0),
|
||||
},
|
||||
{
|
||||
field: 'totalRecharge',
|
||||
label: '充值金额',
|
||||
content: (data) => fenToYuan(data.totalRecharge || 0),
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card>
|
||||
<template #title>
|
||||
<slot name="title"></slot>
|
||||
</template>
|
||||
<template #extra>
|
||||
<slot name="extra"></slot>
|
||||
</template>
|
||||
<Description
|
||||
:column="mode === 'member' ? 2 : 1"
|
||||
:data="{
|
||||
...user,
|
||||
...wallet,
|
||||
}"
|
||||
/>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,87 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberAddressApi } from '#/api/member/address';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getAddressList } from '#/api/member/address';
|
||||
|
||||
const props = defineProps<{
|
||||
userId: number;
|
||||
}>();
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: [
|
||||
{
|
||||
field: 'id',
|
||||
title: '地址编号',
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '收件人名称',
|
||||
},
|
||||
{
|
||||
field: 'mobile',
|
||||
title: '手机号',
|
||||
},
|
||||
{
|
||||
field: 'areaId',
|
||||
title: '地区编码',
|
||||
},
|
||||
{
|
||||
field: 'detailAddress',
|
||||
title: '收件详细地址',
|
||||
},
|
||||
{
|
||||
field: 'defaultStatus',
|
||||
title: '是否默认',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return h(
|
||||
Tag,
|
||||
{
|
||||
class: 'mr-5px',
|
||||
color: row.defaultStatus ? 'blue' : 'red',
|
||||
},
|
||||
() => (row.defaultStatus ? '是' : '否'),
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
],
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async () => {
|
||||
return await getAddressList({
|
||||
userId: props.userId,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberAddressApi.Address>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Grid />
|
||||
</template>
|
||||
@@ -0,0 +1,68 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WalletTransactionApi } from '#/api/pay/wallet/transaction';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getTransactionPage } from '#/api/pay/wallet/transaction';
|
||||
|
||||
const props = defineProps<{
|
||||
walletId: number | undefined;
|
||||
}>();
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
},
|
||||
{
|
||||
field: 'title',
|
||||
title: '关联业务标题',
|
||||
},
|
||||
{
|
||||
field: 'price',
|
||||
title: '交易金额',
|
||||
formatter: 'formatFraction',
|
||||
},
|
||||
{
|
||||
field: 'balance',
|
||||
title: '钱包余额',
|
||||
formatter: 'formatFraction',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '交易时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
],
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
pageSize: 10,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getTransactionPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
walletId: props.walletId,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<WalletTransactionApi.Transaction>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Grid />
|
||||
</template>
|
||||
@@ -0,0 +1,96 @@
|
||||
<script setup lang="ts">
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { formatDate } from '@vben/utils';
|
||||
|
||||
import { Avatar, Card, Col, Row } from 'ant-design-vue';
|
||||
|
||||
import { useDescription } from '#/components/description';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { DICT_TYPE } from '#/utils';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{ mode?: 'kefu' | 'member'; user: MemberUserApi.User }>(),
|
||||
{
|
||||
mode: 'member',
|
||||
},
|
||||
);
|
||||
|
||||
const [Description] = useDescription({
|
||||
componentProps: {
|
||||
bordered: false,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
field: 'name',
|
||||
label: '用户名',
|
||||
},
|
||||
{
|
||||
field: 'nickname',
|
||||
label: '昵称',
|
||||
},
|
||||
{
|
||||
field: 'mobile',
|
||||
label: '手机号',
|
||||
},
|
||||
{
|
||||
field: 'sex',
|
||||
label: '性别',
|
||||
content: (data) =>
|
||||
h(DictTag, {
|
||||
type: DICT_TYPE.SYSTEM_USER_SEX,
|
||||
value: data.sex,
|
||||
}),
|
||||
},
|
||||
{
|
||||
field: 'areaName',
|
||||
label: '所在地',
|
||||
},
|
||||
{
|
||||
field: 'registerIp',
|
||||
label: '注册 IP',
|
||||
},
|
||||
{
|
||||
field: 'birthday',
|
||||
label: '生日',
|
||||
content: (data) => formatDate(data.birthday)?.toString() || '空',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '注册时间',
|
||||
content: (data) => formatDate(data.createTime)?.toString() || '空',
|
||||
},
|
||||
{
|
||||
field: 'loginDate',
|
||||
label: '最后登录时间',
|
||||
content: (data) => formatDate(data.loginDate)?.toString() || '空',
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card>
|
||||
<template #title>
|
||||
<slot name="title"></slot>
|
||||
</template>
|
||||
<template #extra>
|
||||
<slot name="extra"></slot>
|
||||
</template>
|
||||
<Row v-if="mode === 'member'" :gutter="24">
|
||||
<Col :span="4">
|
||||
<Avatar :size="140" shape="square" :src="user.avatar" />
|
||||
</Col>
|
||||
<Col :span="20">
|
||||
<Description :column="2" :data="user" />
|
||||
</Col>
|
||||
</Row>
|
||||
<template v-else-if="mode === 'kefu'">
|
||||
<Avatar :size="140" shape="square" :src="user.avatar" />
|
||||
<Description :column="1" :data="user" />
|
||||
</template>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,131 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberExperienceRecordApi } from '#/api/member/experience-record';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getExperienceRecordPage } from '#/api/member/experience-record';
|
||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
const props = defineProps<{
|
||||
userId: number;
|
||||
}>();
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: [
|
||||
{
|
||||
fieldName: 'bizType',
|
||||
label: '业务类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(
|
||||
DICT_TYPE.MEMBER_EXPERIENCE_BIZ_TYPE,
|
||||
'number',
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'title',
|
||||
label: '标题',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'createDate',
|
||||
label: '获得时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
gridOptions: {
|
||||
columns: [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '获得时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'experience',
|
||||
title: '经验',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return h(
|
||||
Tag,
|
||||
{
|
||||
class: 'mr-5px',
|
||||
color: row.experience > 0 ? 'blue' : 'red',
|
||||
},
|
||||
() =>
|
||||
row.experience > 0 ? `+${row.experience}` : row.experience,
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'totalExperience',
|
||||
title: '总经验',
|
||||
},
|
||||
{
|
||||
field: 'title',
|
||||
title: '标题',
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
title: '描述',
|
||||
},
|
||||
{
|
||||
field: 'bizId',
|
||||
title: '业务编号',
|
||||
},
|
||||
{
|
||||
field: 'bizType',
|
||||
title: '业务类型',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MEMBER_EXPERIENCE_BIZ_TYPE },
|
||||
},
|
||||
},
|
||||
],
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
pageSize: 10,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getExperienceRecordPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
userId: props.userId,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberExperienceRecordApi.ExperienceRecord>,
|
||||
separator: false,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Grid />
|
||||
</template>
|
||||
@@ -0,0 +1,74 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberPointRecordApi } from '#/api/member/point/record';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getRecordPage } from '#/api/member/point/record';
|
||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||
import { useGridColumns } from '#/views/member/point/record/data';
|
||||
|
||||
const props = defineProps<{
|
||||
userId: number;
|
||||
}>();
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: [
|
||||
{
|
||||
fieldName: 'bizType',
|
||||
label: '业务类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE, 'number'),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'title',
|
||||
label: '积分标题',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'createDate',
|
||||
label: '获得时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
pageSize: 10,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getRecordPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
userId: props.userId,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberPointRecordApi.Record>,
|
||||
separator: false,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Grid />
|
||||
</template>
|
||||
@@ -0,0 +1,65 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberSignInRecordApi } from '#/api/member/signin/record';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getSignInRecordPage } from '#/api/member/signin/record';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import { useGridColumns } from '#/views/member/signin/record/data';
|
||||
|
||||
const props = defineProps<{
|
||||
userId: number;
|
||||
}>();
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: [
|
||||
{
|
||||
fieldName: 'day',
|
||||
label: '签到天数',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '签到时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
pageSize: 10,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSignInRecordPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
userId: props.userId,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberSignInRecordApi.SignInRecord>,
|
||||
separator: false,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Grid />
|
||||
</template>
|
||||
452
apps/web-antd/src/views/member/user/data.ts
Normal file
452
apps/web-antd/src/views/member/user/data.ts
Normal file
@@ -0,0 +1,452 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { getSimpleGroupList } from '#/api/member/group';
|
||||
import { getSimpleLevelList } from '#/api/member/level';
|
||||
import { getSimpleTagList } from '#/api/member/tag';
|
||||
import { getAreaTree } from '#/api/system/area';
|
||||
import {
|
||||
CommonStatusEnum,
|
||||
convertToInteger,
|
||||
DICT_TYPE,
|
||||
formatToFraction,
|
||||
getDictOptions,
|
||||
getRangePickerDefaultProps,
|
||||
} from '#/utils';
|
||||
|
||||
/** 修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'mobile',
|
||||
label: '手机号',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE).optional(),
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'nickname',
|
||||
label: '用户昵称',
|
||||
},
|
||||
{
|
||||
component: 'ImageUpload',
|
||||
fieldName: 'avatar',
|
||||
label: '头像',
|
||||
componentProps: {
|
||||
maxSize: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'name',
|
||||
label: '真实名字',
|
||||
},
|
||||
{
|
||||
fieldName: 'sex',
|
||||
label: '用户性别',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'DatePicker',
|
||||
fieldName: 'birthday',
|
||||
label: '出生日期',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiTreeSelect',
|
||||
fieldName: 'areaId',
|
||||
label: '所在地',
|
||||
componentProps: {
|
||||
api: () => getAreaTree(),
|
||||
fieldNames: { label: 'name', value: 'id', children: 'children' },
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'tagIds',
|
||||
label: '用户标签',
|
||||
componentProps: {
|
||||
api: () => getSimpleTagList(),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
mode: 'multiple',
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'groupId',
|
||||
label: '用户分组',
|
||||
componentProps: {
|
||||
api: () => getSimpleGroupList(),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Textarea',
|
||||
fieldName: 'mark',
|
||||
label: '会员备注',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'nickname',
|
||||
label: '用户昵称',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'mobile',
|
||||
label: '手机号',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'loginDate',
|
||||
label: '登录时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '注册时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'tagIds',
|
||||
label: '用户标签',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: () => getSimpleTagList(),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
mode: 'multiple',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'levelId',
|
||||
label: '用户等级',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: () => getSimpleLevelList(),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'groupId',
|
||||
label: '用户分组',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: () => getSimpleGroupList(),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'checkbox',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: '用户编号',
|
||||
},
|
||||
{
|
||||
field: 'avatar',
|
||||
title: '头像',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return h('img', {
|
||||
src: row.avatar,
|
||||
style: { width: '40px' },
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'mobile',
|
||||
title: '手机号',
|
||||
},
|
||||
{
|
||||
field: 'nickname',
|
||||
title: '昵称',
|
||||
},
|
||||
{
|
||||
field: 'levelName',
|
||||
title: '等级',
|
||||
},
|
||||
{
|
||||
field: 'groupName',
|
||||
title: '分组',
|
||||
},
|
||||
{
|
||||
field: 'tagNames',
|
||||
title: '用户标签',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return row.tagNames?.map((tagName: string, index: number) => {
|
||||
return h(
|
||||
Tag,
|
||||
{
|
||||
key: index,
|
||||
class: 'mr-5px',
|
||||
color: 'blue',
|
||||
},
|
||||
() => tagName,
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'point',
|
||||
title: '积分',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'loginDate',
|
||||
title: '登录时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '注册时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 修改用户等级 */
|
||||
export function useLeavelFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
label: '用户编号',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'nickname',
|
||||
label: '用户昵称',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'point',
|
||||
label: '用户等级',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: () => getSimpleLevelList(),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Textarea',
|
||||
fieldName: 'reason',
|
||||
label: '修改原因',
|
||||
rules: 'required',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 修改用户余额 */
|
||||
export function useBalanceFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
label: '用户编号',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'nickname',
|
||||
label: '用户昵称',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'balance',
|
||||
label: '变动前余额(元)',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'RadioGroup',
|
||||
fieldName: 'changeType',
|
||||
label: '变动类型',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '增加', value: 1 },
|
||||
{ label: '减少', value: -1 },
|
||||
],
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'changeBalance',
|
||||
label: '变动余额(元)',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 2,
|
||||
step: 0.1,
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'balanceResult',
|
||||
label: '变动后余额(元)',
|
||||
dependencies: {
|
||||
triggerFields: ['changeBalance', 'changeType'],
|
||||
disabled: true,
|
||||
trigger(values, form) {
|
||||
form.setFieldValue(
|
||||
'balanceResult',
|
||||
formatToFraction(
|
||||
convertToInteger(values.balance) +
|
||||
convertToInteger(values.changeBalance) * values.changeType,
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 修改用户积分 */
|
||||
export function usePointFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
label: '用户编号',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'nickname',
|
||||
label: '用户昵称',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'point',
|
||||
label: '变动前积分',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'RadioGroup',
|
||||
fieldName: 'changeType',
|
||||
label: '变动类型',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '增加', value: 1 },
|
||||
{ label: '减少', value: -1 },
|
||||
],
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'changePoint',
|
||||
label: '变动积分',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'pointResult',
|
||||
label: '变动后积分',
|
||||
dependencies: {
|
||||
triggerFields: ['changePoint', 'changeType'],
|
||||
disabled: true,
|
||||
trigger(values, form) {
|
||||
form.setFieldValue(
|
||||
'pointResult',
|
||||
values.point + values.changePoint * values.changeType ||
|
||||
values.point,
|
||||
);
|
||||
},
|
||||
},
|
||||
rules: z.number().min(0),
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1,34 +1,196 @@
|
||||
<script lang="ts" setup>
|
||||
import { Page } from '@vben/common-ui';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getUserPage } from '#/api/member/user';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import BalanceForm from './modules/balance-form.vue';
|
||||
import Form from './modules/form.vue';
|
||||
import LeavelForm from './modules/leavel-form.vue';
|
||||
import PointForm from './modules/point-form.vue';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [PointFormModal, pointFormModalApi] = useVbenModal({
|
||||
connectedComponent: PointForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [BalanceFormModal, balanceFormModalApi] = useVbenModal({
|
||||
connectedComponent: BalanceForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [LeavelFormModal, leavelFormModalApi] = useVbenModal({
|
||||
connectedComponent: LeavelForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格数据 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 设置选中 ID */
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function setCheckedIds({ records }: { records: MemberUserApi.User[] }) {
|
||||
checkedIds.value = records.map((item) => item.id as number);
|
||||
}
|
||||
|
||||
/** 发送优惠券 */
|
||||
function handleSendCoupon() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑会员 */
|
||||
function handleEdit(row: MemberUserApi.User) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 修改会员等级 */
|
||||
function handleUpdateLevel(row: MemberUserApi.User) {
|
||||
leavelFormModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 修改会员积分 */
|
||||
function handleUpdatePoint(row: MemberUserApi.User) {
|
||||
pointFormModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 修改会员余额 */
|
||||
function handleUpdateBalance(row: MemberUserApi.User) {
|
||||
balanceFormModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 查看会员详情 */
|
||||
function handleViewDetail(row: MemberUserApi.User) {
|
||||
router.push({
|
||||
name: 'MemberUserDetail',
|
||||
query: {
|
||||
id: row.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 表格实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
labelField: 'checkbox',
|
||||
},
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getUserPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MemberUserApi.User>,
|
||||
gridEvents: {
|
||||
checkboxAll: setCheckedIds,
|
||||
checkboxChange: setCheckedIds,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="会员用户、标签、分组"
|
||||
url="https://doc.iocoder.cn/member/user/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/user/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/user/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="会员用户、标签、分组"
|
||||
url="https://doc.iocoder.cn/member/user/"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<FormModal @success="onRefresh" />
|
||||
<PointFormModal @success="onRefresh" />
|
||||
<BalanceFormModal @success="onRefresh" />
|
||||
<LeavelFormModal @success="onRefresh" />
|
||||
<Grid table-title="会员列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '发送优惠券',
|
||||
type: 'primary',
|
||||
icon: 'lucide:mouse-pointer-2',
|
||||
auth: ['promotion:coupon:send'],
|
||||
onClick: handleSendCoupon,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.VIEW,
|
||||
onClick: handleViewDetail.bind(null, row),
|
||||
},
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
auth: ['member:user:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '修改等级',
|
||||
type: 'link',
|
||||
auth: ['member:user:update-level'],
|
||||
onClick: handleUpdateLevel.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '修改积分',
|
||||
type: 'link',
|
||||
auth: ['member:user:update-point'],
|
||||
onClick: handleUpdatePoint.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '修改余额',
|
||||
type: 'link',
|
||||
auth: ['pay:wallet:update-balance'],
|
||||
onClick: handleUpdateBalance.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
93
apps/web-antd/src/views/member/user/modules/balance-form.vue
Normal file
93
apps/web-antd/src/views/member/user/modules/balance-form.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getUser, updateUser } from '#/api/member/user';
|
||||
import { getWallet } from '#/api/pay/wallet/balance';
|
||||
import { $t } from '#/locales';
|
||||
import { formatToFraction } from '#/utils';
|
||||
|
||||
import { useBalanceFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref({
|
||||
id: 0,
|
||||
nickname: '',
|
||||
balance: '0',
|
||||
changeBalance: 0,
|
||||
changeType: 1,
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 100,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useBalanceFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberUserApi.User;
|
||||
try {
|
||||
await updateUser(data);
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberUserApi.User>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
const user = await getUser(data.id as number);
|
||||
if (!user || !user.id) {
|
||||
return;
|
||||
}
|
||||
const wallet = await getWallet({ userId: user.id });
|
||||
formData.value.id = user.id;
|
||||
formData.value.nickname = user.nickname || '';
|
||||
formData.value.balance = formatToFraction(wallet.balance);
|
||||
formData.value.changeType = 1; // 默认增加余额
|
||||
formData.value.changeBalance = 0; // 变动余额默认0
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[30%]" :title="$t('ui.actionTitle.edit', ['用户余额'])">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
135
apps/web-antd/src/views/member/user/modules/detail.vue
Normal file
135
apps/web-antd/src/views/member/user/modules/detail.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<script setup lang="ts">
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
import type { PayWalletApi } from '#/api/pay/wallet/balance';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useTabs } from '@vben/hooks';
|
||||
|
||||
import { Button, Card, message, TabPane, Tabs } from 'ant-design-vue';
|
||||
|
||||
import { getUser } from '#/api/member/user';
|
||||
import { getWallet } from '#/api/pay/wallet/balance';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import UserAccountInfo from '../components/user-account-info.vue';
|
||||
import UserAddressList from '../components/user-address-list.vue';
|
||||
import UserBalanceList from '../components/user-balance-list.vue';
|
||||
import UserBasicInfo from '../components/user-basic-info.vue';
|
||||
import UserExperienceRecordList from '../components/user-experience-record-list.vue';
|
||||
import UserPointList from '../components/user-point-list.vue';
|
||||
import UserSignList from '../components/user-sign-list.vue';
|
||||
import Form from './form.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { closeCurrentTab, refreshTab } = useTabs();
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const userId = Number(route.query.id);
|
||||
const user = ref<MemberUserApi.User>();
|
||||
const wallet = ref<PayWalletApi.WalletVO>();
|
||||
/* 钱包初始化数据 */
|
||||
const WALLET_INIT_DATA = {
|
||||
balance: 0,
|
||||
totalExpense: 0,
|
||||
totalRecharge: 0,
|
||||
} as PayWalletApi.WalletVO;
|
||||
|
||||
async function getUserDetail() {
|
||||
if (!userId) {
|
||||
message.error('参数错误,会员编号不能为空!');
|
||||
closeCurrentTab();
|
||||
return;
|
||||
}
|
||||
user.value = await getUser(userId);
|
||||
wallet.value = (await getWallet({ userId })) || WALLET_INIT_DATA;
|
||||
}
|
||||
|
||||
function handleEdit() {
|
||||
formModalApi.setData(user.value).open();
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getUserDetail();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="refreshTab" />
|
||||
<div class="flex">
|
||||
<UserBasicInfo v-if="user" class="w-3/5" :user="user" mode="member">
|
||||
<template #title> 基本信息 </template>
|
||||
<template #extra>
|
||||
<Button type="primary" @click="handleEdit">
|
||||
{{ $t('common.edit') }}
|
||||
</Button>
|
||||
</template>
|
||||
</UserBasicInfo>
|
||||
<UserAccountInfo
|
||||
v-if="user && wallet"
|
||||
class="ml-4 w-2/5"
|
||||
:user="user"
|
||||
:wallet="wallet"
|
||||
>
|
||||
<template #title> 账户信息 </template>
|
||||
</UserAccountInfo>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<Card title="账户明细">
|
||||
<Tabs>
|
||||
<TabPane tab="积分" key="UserPointList">
|
||||
<UserPointList class="h-full" :user-id="userId" />
|
||||
</TabPane>
|
||||
<TabPane tab="签到" key="UserSignList">
|
||||
<UserSignList class="h-full" :user-id="userId" />
|
||||
</TabPane>
|
||||
<TabPane tab="成长值" key="UserExperienceRecordList">
|
||||
<UserExperienceRecordList class="h-full" :user-id="userId" />
|
||||
</TabPane>
|
||||
<TabPane tab="余额" key="UserBalanceList">
|
||||
<UserBalanceList class="h-full" :wallet-id="wallet?.id" />
|
||||
</TabPane>
|
||||
<TabPane tab="收货地址" key="UserAddressList">
|
||||
<UserAddressList class="h-full" :user-id="userId" />
|
||||
</TabPane>
|
||||
<TabPane tab="订单管理" key="UserOrderList">
|
||||
<!-- Todo: 商城模块 -->
|
||||
<div class="h-full">
|
||||
<h1>订单管理</h1>
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane tab="售后管理" key="UserAfterSaleList">
|
||||
<!-- Todo: 商城模块 -->
|
||||
<div class="h-full">
|
||||
<h1>售后管理</h1>
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane tab="收藏记录" key="UserFavoriteList">
|
||||
<!-- Todo: 商城模块 -->
|
||||
<div class="h-full">
|
||||
<h1>收藏记录</h1>
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane tab="优惠劵" key="UserCouponList">
|
||||
<!-- Todo: 商城模块 -->
|
||||
<div class="h-full">
|
||||
<h1>优惠劵</h1>
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane tab="推广用户" key="UserBrokerageList">
|
||||
<!-- Todo: 商城模块 -->
|
||||
<div class="h-full">
|
||||
<h1>推广用户</h1>
|
||||
</div>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
||||
77
apps/web-antd/src/views/member/user/modules/form.vue
Normal file
77
apps/web-antd/src/views/member/user/modules/form.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getUser, updateUser } from '#/api/member/user';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberUserApi.User>();
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberUserApi.User;
|
||||
try {
|
||||
await updateUser(data);
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberUserApi.User>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getUser(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[40%]" :title="$t('ui.actionTitle.edit', ['会员'])">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
77
apps/web-antd/src/views/member/user/modules/leavel-form.vue
Normal file
77
apps/web-antd/src/views/member/user/modules/leavel-form.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getUser, updateUser } from '#/api/member/user';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLeavelFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberUserApi.User>();
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useLeavelFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberUserApi.User;
|
||||
try {
|
||||
await updateUser(data);
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberUserApi.User>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getUser(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[30%]" :title="$t('ui.actionTitle.edit', ['用户等级'])">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
77
apps/web-antd/src/views/member/user/modules/point-form.vue
Normal file
77
apps/web-antd/src/views/member/user/modules/point-form.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MemberUserApi } from '#/api/member/user';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getUser, updateUser } from '#/api/member/user';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { usePointFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MemberUserApi.User>();
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: usePointFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MemberUserApi.User;
|
||||
try {
|
||||
await updateUser(data);
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<MemberUserApi.User>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getUser(data.id as number);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[30%]" :title="$t('ui.actionTitle.edit', ['用户积分'])">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -54,7 +54,6 @@ export function useGridColumns<T = PayAppApi.App>(
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 100,
|
||||
align: 'center',
|
||||
cellRender: {
|
||||
attrs: { beforeChange: onStatusChange },
|
||||
|
||||
@@ -100,7 +100,7 @@ function isChannelExists(channels: string[], channelCode: string) {
|
||||
}
|
||||
|
||||
async function openChannelForm(row: PayAppApi.App, payCode: string) {
|
||||
channelModalApi.setData({ id: row.id || 0, payCode }).open();
|
||||
channelModalApi.setData({ id: row.id, payCode }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
@@ -139,8 +139,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<DocAlert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
|
||||
</template>
|
||||
|
||||
<AppModal @reload="onRefresh" />
|
||||
<ChannelModal @reload="onRefresh" />
|
||||
<AppModal @success="onRefresh" />
|
||||
<ChannelModal @success="onRefresh" />
|
||||
|
||||
<Grid>
|
||||
<template #toolbar-tools>
|
||||
@@ -185,27 +185,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_APP.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_APP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.ALIPAY_APP.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_APP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -220,27 +210,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_PC.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_PC.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.ALIPAY_PC.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_PC.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -255,27 +235,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_WAP.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_WAP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.ALIPAY_WAP.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_WAP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -290,27 +260,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_QR.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_QR.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.ALIPAY_QR.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_QR.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -325,27 +285,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_BAR.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_BAR.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.ALIPAY_BAR.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.ALIPAY_BAR.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -360,27 +310,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_LITE.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_LITE.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.WX_LITE.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_LITE.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -395,27 +335,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_PUB.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_PUB.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.WX_PUB.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_PUB.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -430,27 +360,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_APP.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_APP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.WX_APP.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_APP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -465,27 +385,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_NATIVE.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_NATIVE.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.WX_NATIVE.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_NATIVE.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -500,27 +410,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_WAP.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_WAP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.WX_WAP.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_WAP.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -535,27 +435,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_BAR.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_BAR.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.WX_BAR.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WX_BAR.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -570,27 +460,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WALLET.code,
|
||||
)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WALLET.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.WALLET.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.WALLET.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
@@ -605,27 +485,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
:actions="[
|
||||
{
|
||||
type: 'primary',
|
||||
icon: 'lucide:check',
|
||||
shape: 'circle',
|
||||
ifShow: isChannelExists(
|
||||
icon: isChannelExists(row.channelCodes, PayChannelEnum.MOCK.code)
|
||||
? 'lucide:check'
|
||||
: 'lucide:x',
|
||||
danger: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.MOCK.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
PayChannelEnum.MOCK.code,
|
||||
),
|
||||
},
|
||||
{
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: 'lucide:x',
|
||||
shape: 'circle',
|
||||
ifShow: !isChannelExists(
|
||||
row.channelCodes,
|
||||
PayChannelEnum.MOCK.code,
|
||||
),
|
||||
onClick: openChannelForm.bind(
|
||||
null,
|
||||
row,
|
||||
|
||||
@@ -10,16 +10,17 @@ import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createChannel, getChannel, updateChannel } from '#/api/pay/channel';
|
||||
import { CommonStatusEnum } from '#/utils';
|
||||
|
||||
import { channelSchema } from './data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<PayChannelApi.Channel>();
|
||||
const formData = ref<any>();
|
||||
const formType = ref<string>('');
|
||||
const title = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', '应用')
|
||||
: $t('ui.actionTitle.create', '应用');
|
||||
return formData.value?.id === 0
|
||||
? $t('ui.actionTitle.create', '应用')
|
||||
: $t('ui.actionTitle.edit', '应用');
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
@@ -43,8 +44,17 @@ const [Modal, modalApi] = useVbenModal({
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as PayChannelApi.Channel;
|
||||
// 只保留表单中实际存在的字段,且值不为 undefined
|
||||
const data2 = Object.fromEntries(
|
||||
Object.entries(data).filter(([key, value]) => {
|
||||
// 检查字段是否在表单中存在,且值不为 undefined
|
||||
return key in data && value !== undefined;
|
||||
}),
|
||||
);
|
||||
const data3 = { ...formData.value, ...data2 };
|
||||
data3.config = JSON.stringify(data3.config);
|
||||
try {
|
||||
await (formData.value?.id ? updateChannel(data) : createChannel(data));
|
||||
await (data3.id ? updateChannel(data3) : createChannel(data3));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
@@ -67,18 +77,80 @@ const [Modal, modalApi] = useVbenModal({
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
formType.value = payCode;
|
||||
if (payCode.includes('alipay_')) {
|
||||
formType.value = 'alipay';
|
||||
formData.value = {
|
||||
appId: id,
|
||||
code: payCode,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: '',
|
||||
feeRate: null,
|
||||
config: {
|
||||
appId: '',
|
||||
serverUrl: null,
|
||||
signType: 'RSA2',
|
||||
mode: null,
|
||||
privateKey: '',
|
||||
alipayPublicKey: '',
|
||||
appCertContent: '',
|
||||
alipayPublicCertContent: '',
|
||||
rootCertContent: '',
|
||||
encryptType: '',
|
||||
encryptKey: '',
|
||||
},
|
||||
};
|
||||
} else if (payCode.includes('mock')) {
|
||||
formType.value = 'mock';
|
||||
formData.value = {
|
||||
appId: id,
|
||||
code: payCode,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: '',
|
||||
feeRate: 0,
|
||||
config: {
|
||||
name: 'mock-conf',
|
||||
},
|
||||
};
|
||||
} else if (payCode.includes('wallet')) {
|
||||
formType.value = 'wallet';
|
||||
formData.value = {
|
||||
appId: id,
|
||||
code: payCode,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: '',
|
||||
feeRate: 0,
|
||||
config: {
|
||||
name: 'mock-conf',
|
||||
},
|
||||
};
|
||||
} else if (payCode.includes('wx')) {
|
||||
formType.value = 'wx';
|
||||
formData.value = {
|
||||
appId: id,
|
||||
code: payCode,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
feeRate: undefined,
|
||||
remark: '',
|
||||
config: {
|
||||
appId: '',
|
||||
mchId: '',
|
||||
apiVersion: '',
|
||||
mchKey: '',
|
||||
keyContent: '',
|
||||
privateKeyContent: '',
|
||||
certSerialNo: '',
|
||||
apiV3Key: '',
|
||||
publicKeyContent: '',
|
||||
publicKeyId: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
formData.value = await getChannel(id, payCode);
|
||||
const res = await getChannel(id, payCode);
|
||||
formData.value = {
|
||||
...res,
|
||||
config: {
|
||||
...JSON.parse(res.config),
|
||||
},
|
||||
};
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
|
||||
@@ -6,541 +6,486 @@ import { InputUpload } from '#/components/upload';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
|
||||
export function channelSchema(formType: string): VbenFormSchema[] {
|
||||
switch (formType) {
|
||||
case 'alipay': {
|
||||
return [
|
||||
{
|
||||
label: '商户编号',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
if (formType.includes('alipay_')) {
|
||||
return [
|
||||
{
|
||||
label: '应用编号',
|
||||
fieldName: 'appId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
{
|
||||
label: '应用编号',
|
||||
fieldName: 'appId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道费率',
|
||||
fieldName: 'feeRate',
|
||||
component: 'InputNumber',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入渠道费率',
|
||||
addonAfter: '%',
|
||||
},
|
||||
{
|
||||
label: '渠道编码',
|
||||
fieldName: 'code',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
label: '开放平台 APPID',
|
||||
fieldName: 'config.appId',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入开放平台 APPID',
|
||||
},
|
||||
{
|
||||
label: '渠道费率',
|
||||
fieldName: 'feeRate',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入渠道费率',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道状态',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
{
|
||||
label: '开放平台 APPID',
|
||||
fieldName: 'config.appId',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入开放平台 APPID',
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
label: '网关地址',
|
||||
fieldName: 'config.serverUrl',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 'https://openapi.alipay.com/gateway.do',
|
||||
label: '线上环境',
|
||||
},
|
||||
{
|
||||
value: 'https://openapi-sandbox.dl.alipaydev.com/gateway.do',
|
||||
label: '沙箱环境',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '渠道状态',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
label: '算法类型',
|
||||
fieldName: 'config.signType',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 'RSA2',
|
||||
label: 'RSA2',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '网关地址',
|
||||
fieldName: 'config.serverUrl',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 'https://openapi.alipay.com/gateway.do',
|
||||
label: '线上环境',
|
||||
},
|
||||
{
|
||||
value: 'https://openapi-sandbox.dl.alipaydev.com/gateway.do',
|
||||
label: '沙箱环境',
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultValue: 'RSA2',
|
||||
},
|
||||
{
|
||||
label: '公钥类型',
|
||||
fieldName: 'config.mode',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 1,
|
||||
label: '公钥模式',
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: '证书模式',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '算法类型',
|
||||
fieldName: 'config.signType',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 'RSA2',
|
||||
label: 'RSA2',
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultValue: 'RSA2',
|
||||
},
|
||||
{
|
||||
label: '应用私钥',
|
||||
fieldName: 'config.privateKey',
|
||||
component: 'Textarea',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入应用私钥',
|
||||
rows: 8,
|
||||
},
|
||||
{
|
||||
label: '公钥类型',
|
||||
fieldName: 'config.mode',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 0,
|
||||
label: '公钥模式',
|
||||
},
|
||||
{
|
||||
value: 1,
|
||||
label: '证书模式',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '支付宝公钥',
|
||||
fieldName: 'config.alipayPublicKey',
|
||||
component: 'Textarea',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入支付宝公钥',
|
||||
rows: 8,
|
||||
},
|
||||
{
|
||||
label: '应用私钥',
|
||||
fieldName: 'config.privateKey',
|
||||
component: 'Textarea',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入应用私钥',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 1;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '商户公钥应用证书',
|
||||
fieldName: 'config.appCertContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: { rows: 8, placeholder: '请上传商户公钥应用证书' },
|
||||
fileUploadProps: {
|
||||
accept: ['crt'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 2;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '支付宝公钥证书',
|
||||
fieldName: 'config.alipayPublicCertContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: { rows: 8, placeholder: '请上传支付宝公钥证书' },
|
||||
fileUploadProps: {
|
||||
accept: ['crt'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 2;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '根证书',
|
||||
fieldName: 'config.rootCertContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: { rows: 8, placeholder: '请上传根证书' },
|
||||
fileUploadProps: {
|
||||
accept: ['crt'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 2;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '接口内容加密方式',
|
||||
fieldName: 'config.encryptType',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 'NONE',
|
||||
label: '无加密',
|
||||
},
|
||||
{
|
||||
value: 'AES',
|
||||
label: 'AES',
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultValue: 'NONE',
|
||||
},
|
||||
{
|
||||
label: '接口内容加密密钥',
|
||||
fieldName: 'config.encryptKey',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.encryptType === 'AES';
|
||||
},
|
||||
triggerFields: ['config.encryptType', 'encryptType', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
} else if (formType.includes('mock') || formType.includes('wallet')) {
|
||||
return [
|
||||
{
|
||||
label: '应用编号',
|
||||
fieldName: 'appId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道状态',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
label: '渠道编码',
|
||||
fieldName: 'code',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道费率',
|
||||
fieldName: 'feeRate',
|
||||
component: 'InputNumber',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入渠道费率',
|
||||
addonAfter: '%',
|
||||
},
|
||||
defaultValue: 0,
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
} else if (formType.includes('wx')) {
|
||||
return [
|
||||
{
|
||||
label: '应用编号',
|
||||
fieldName: 'appId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道编码',
|
||||
fieldName: 'code',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道费率',
|
||||
fieldName: 'feeRate',
|
||||
component: 'InputNumber',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入渠道费率',
|
||||
addonAfter: '%',
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
label: '微信 APPID',
|
||||
fieldName: 'config.appId',
|
||||
help: '前往微信商户平台[https://pay.weixin.qq.com/index.php/extend/merchant_appid/mapay_platform/account_manage]查看 APPID',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入微信 APPID',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '商户号',
|
||||
fieldName: 'config.mchId',
|
||||
help: '前往微信商户平台[https://pay.weixin.qq.com/index.php/extend/pay_setting]查看商户号',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入商户号',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道状态',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
label: 'API 版本',
|
||||
fieldName: 'config.apiVersion',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
label: 'v2',
|
||||
value: 'v2',
|
||||
},
|
||||
{
|
||||
label: 'v3',
|
||||
value: 'v3',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '商户密钥',
|
||||
fieldName: 'config.mchKey',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入商户密钥',
|
||||
},
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v2';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'apiclient_cert.p12 证书',
|
||||
fieldName: 'config.keyContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: {
|
||||
rows: 8,
|
||||
placeholder: '请上传 apiclient_cert.p12 证书',
|
||||
},
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values.config.mode !== undefined;
|
||||
},
|
||||
triggerFields: ['config'],
|
||||
fileUploadProps: {
|
||||
accept: ['p12'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v2';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
{
|
||||
label: '支付宝公钥',
|
||||
fieldName: 'config.alipayPublicKey',
|
||||
component: 'Textarea',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入支付宝公钥',
|
||||
},
|
||||
{
|
||||
label: 'API V3 密钥',
|
||||
fieldName: 'config.apiV3Key',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入 API V3 密钥',
|
||||
},
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'apiclient_key.pem 证书',
|
||||
fieldName: 'config.privateKeyContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: {
|
||||
rows: 8,
|
||||
placeholder: '请上传 apiclient_key.pem 证书',
|
||||
},
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 0;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
fileUploadProps: {
|
||||
accept: ['pem'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
{
|
||||
label: '商户公钥应用证书',
|
||||
fieldName: 'config.appCertContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: { rows: 8, placeholder: '请上传商户公钥应用证书' },
|
||||
fileUploadProps: {
|
||||
accept: ['crt'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 1;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '证书序列号',
|
||||
fieldName: 'config.certSerialNo',
|
||||
component: 'Input',
|
||||
help: '前往微信商户平台[https://pay.weixin.qq.com/index.php/core/cert/api_cert#/api-cert-manage]查看证书序列号',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入证书序列号',
|
||||
},
|
||||
{
|
||||
label: '支付宝公钥证书',
|
||||
fieldName: 'config.alipayPublicCertContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: { rows: 8, placeholder: '请上传支付宝公钥证书' },
|
||||
fileUploadProps: {
|
||||
accept: ['crt'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 1;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
{
|
||||
label: '根证书',
|
||||
fieldName: 'config.rootCertContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: { rows: 8, placeholder: '请上传根证书' },
|
||||
fileUploadProps: {
|
||||
accept: ['crt'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.mode === 1;
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
{
|
||||
label: 'public_key.pem 证书',
|
||||
fieldName: 'config.publicKeyContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: {
|
||||
rows: 8,
|
||||
placeholder: '请上传 public_key.pem 证书',
|
||||
},
|
||||
fileUploadProps: {
|
||||
accept: ['pem'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
{
|
||||
label: '接口内容加密方式',
|
||||
fieldName: 'config.encryptType',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
value: 'NONE',
|
||||
label: '无加密',
|
||||
},
|
||||
{
|
||||
value: 'AES',
|
||||
label: 'AES',
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultValue: 'NONE',
|
||||
},
|
||||
{
|
||||
label: '公钥 ID',
|
||||
fieldName: 'config.publicKeyId',
|
||||
component: 'Input',
|
||||
help: '微信支付公钥产品简介及使用说明[https://pay.weixin.qq.com/doc/v3/merchant/4012153196]',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入公钥 ID',
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
rows: 3,
|
||||
placeholder: '请输入备注',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
];
|
||||
}
|
||||
case 'mock': {
|
||||
return [
|
||||
{
|
||||
label: '商户编号',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
{
|
||||
label: '应用编号',
|
||||
fieldName: 'appId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道状态',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
label: '渠道编码',
|
||||
fieldName: 'code',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道费率',
|
||||
fieldName: 'feeRate',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入渠道费率',
|
||||
},
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
rows: 3,
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
case 'wallet': {
|
||||
return [
|
||||
{
|
||||
label: '商户编号',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '应用编号',
|
||||
fieldName: 'appId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道状态',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
label: '渠道编码',
|
||||
fieldName: 'code',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道费率',
|
||||
fieldName: 'feeRate',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入渠道费率',
|
||||
},
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
rows: 3,
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
case 'wx': {
|
||||
return [
|
||||
{
|
||||
label: '商户编号',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '应用编号',
|
||||
fieldName: 'appId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道编码',
|
||||
fieldName: 'code',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道费率',
|
||||
fieldName: 'feeRate',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入渠道费率',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '微信 APPID',
|
||||
fieldName: 'config.appId',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入微信 APPID',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '商户号',
|
||||
fieldName: 'config.mchId',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入商户号',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '渠道状态',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
label: 'API 版本',
|
||||
fieldName: 'config.apiVersion',
|
||||
component: 'RadioGroup',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
label: 'v2',
|
||||
value: 'v2',
|
||||
},
|
||||
{
|
||||
label: 'v3',
|
||||
value: 'v3',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '商户密钥',
|
||||
fieldName: 'config.mchKey',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入商户密钥',
|
||||
},
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v2';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'apiclient_cert.p12 证书',
|
||||
fieldName: 'config.keyContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: {
|
||||
rows: 8,
|
||||
placeholder: '请上传 apiclient_cert.p12 证书',
|
||||
},
|
||||
fileUploadProps: {
|
||||
accept: ['p12 '],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v2';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'API V3 密钥',
|
||||
fieldName: 'config.apiV3Key',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入 API V3 密钥',
|
||||
},
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'apiclient_key.pem 证书',
|
||||
fieldName: 'config.privateKeyContent',
|
||||
component: h(InputUpload, {
|
||||
inputType: 'textarea',
|
||||
textareaProps: {
|
||||
rows: 8,
|
||||
placeholder: '请上传 apiclient_key.pem 证书',
|
||||
},
|
||||
fileUploadProps: {
|
||||
accept: ['pem'],
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '证书序列号',
|
||||
fieldName: 'config.certSerialNo',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: '请输入证书序列号',
|
||||
},
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return values?.config?.apiVersion === 'v3';
|
||||
},
|
||||
triggerFields: ['config.mode', 'mode', 'config'],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
rows: 3,
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
default: {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
81
apps/web-antd/src/views/pay/cashier/data.ts
Normal file
81
apps/web-antd/src/views/pay/cashier/data.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import {
|
||||
SvgAlipayAppIcon,
|
||||
SvgAlipayBarIcon,
|
||||
SvgAlipayPcIcon,
|
||||
SvgAlipayQrIcon,
|
||||
SvgAlipayWapIcon,
|
||||
SvgMockIcon,
|
||||
SvgWalletIcon,
|
||||
SvgWxAppIcon,
|
||||
SvgWxBarIcon,
|
||||
SvgWxLiteIcon,
|
||||
SvgWxNativeIcon,
|
||||
SvgWxPubIcon,
|
||||
} from '@vben/icons';
|
||||
|
||||
export const channelsAlipay = [
|
||||
{
|
||||
name: '支付宝 PC 网站支付',
|
||||
icon: SvgAlipayPcIcon,
|
||||
code: 'alipay_pc',
|
||||
},
|
||||
{
|
||||
name: '支付宝 Wap 网站支付',
|
||||
icon: SvgAlipayWapIcon,
|
||||
code: 'alipay_wap',
|
||||
},
|
||||
{
|
||||
name: '支付宝 App 网站支付',
|
||||
icon: SvgAlipayAppIcon,
|
||||
code: 'alipay_app',
|
||||
},
|
||||
{
|
||||
name: '支付宝扫码支付',
|
||||
icon: SvgAlipayQrIcon,
|
||||
code: 'alipay_qr',
|
||||
},
|
||||
{
|
||||
name: '支付宝条码支付',
|
||||
icon: SvgAlipayBarIcon,
|
||||
code: 'alipay_bar',
|
||||
},
|
||||
];
|
||||
export const channelsWechat = [
|
||||
{
|
||||
name: '微信公众号支付',
|
||||
icon: SvgWxPubIcon,
|
||||
code: 'wx_pub',
|
||||
},
|
||||
{
|
||||
name: '微信小程序支付',
|
||||
icon: SvgWxLiteIcon,
|
||||
code: 'wx_lite',
|
||||
},
|
||||
{
|
||||
name: '微信 App 支付',
|
||||
icon: SvgWxAppIcon,
|
||||
code: 'wx_app',
|
||||
},
|
||||
{
|
||||
name: '微信扫码支付',
|
||||
icon: SvgWxNativeIcon,
|
||||
code: 'wx_native',
|
||||
},
|
||||
{
|
||||
name: '微信条码支付',
|
||||
icon: SvgWxBarIcon,
|
||||
code: 'wx_bar',
|
||||
},
|
||||
];
|
||||
export const channelsMock = [
|
||||
{
|
||||
name: '钱包支付',
|
||||
icon: SvgWalletIcon,
|
||||
code: 'wallet',
|
||||
},
|
||||
{
|
||||
name: '模拟支付',
|
||||
icon: SvgMockIcon,
|
||||
code: 'mock',
|
||||
},
|
||||
];
|
||||
@@ -1,7 +1,390 @@
|
||||
<script lang="ts" setup></script>
|
||||
<script setup lang="ts">
|
||||
import type { PayOrderApi } from '#/api/pay/order';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useTabs } from '@vben/hooks';
|
||||
import { formatDate } from '@vben/utils';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Input,
|
||||
message,
|
||||
QRCode,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getOrder, submitOrder } from '#/api/pay/order';
|
||||
import {
|
||||
fenToYuan,
|
||||
PayChannelEnum,
|
||||
PayDisplayModeEnum,
|
||||
PayOrderStatusEnum,
|
||||
} from '#/utils';
|
||||
|
||||
import { channelsAlipay, channelsMock, channelsWechat } from './data';
|
||||
|
||||
defineOptions({ name: 'PayCashier' });
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
showConfirmButton: false,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const { push } = useRouter(); // 路由
|
||||
const { closeCurrentTab } = useTabs();
|
||||
|
||||
const id = ref(); // 支付单号
|
||||
const title = ref('支付订单');
|
||||
const returnUrl = ref<string>(); // 支付完的回调地址
|
||||
|
||||
const payOrder = ref<PayOrderApi.Order>();
|
||||
const interval = ref<any>(undefined); // 定时任务,轮询是否完成支付
|
||||
|
||||
/** 展示形式:二维码 */
|
||||
const qrCode = ref({
|
||||
url: '',
|
||||
visible: false,
|
||||
});
|
||||
|
||||
/** 展示形式:条形码 */
|
||||
const barCode = ref({
|
||||
channelCode: '',
|
||||
value: '',
|
||||
visible: false,
|
||||
});
|
||||
|
||||
/** 获得支付信息 */
|
||||
async function getDetail() {
|
||||
// 1. 获取路由参数
|
||||
id.value = route.query.id;
|
||||
if (route.query.returnUrl) {
|
||||
returnUrl.value = decodeURIComponent(route.query.returnUrl as string);
|
||||
}
|
||||
// 1.1 未传递订单编号
|
||||
if (!id.value) {
|
||||
message.error('未传递支付单号,无法查看对应的支付信息');
|
||||
goReturnUrl('cancel');
|
||||
return;
|
||||
}
|
||||
const res = await getOrder(id.value);
|
||||
// 1.2 无法查询到支付信息
|
||||
if (!res) {
|
||||
message.error('支付订单不存在,请检查!');
|
||||
goReturnUrl('cancel');
|
||||
return;
|
||||
}
|
||||
// 1.3 如果已支付、或者已关闭,则直接跳转
|
||||
if (res.status === PayOrderStatusEnum.SUCCESS.status) {
|
||||
message.success('支付成功');
|
||||
goReturnUrl('success');
|
||||
return;
|
||||
} else if (res.status === PayOrderStatusEnum.CLOSED.status) {
|
||||
message.error('无法支付,原因:订单已关闭');
|
||||
goReturnUrl('close');
|
||||
return;
|
||||
}
|
||||
payOrder.value = res;
|
||||
}
|
||||
|
||||
function handlePay(channelCode: string) {
|
||||
switch (channelCode) {
|
||||
// 条形码支付,需要特殊处理
|
||||
case PayChannelEnum.ALIPAY_BAR.code: {
|
||||
title.value = '“支付宝”条码支付';
|
||||
barCode.value = {
|
||||
channelCode,
|
||||
value: '',
|
||||
visible: true,
|
||||
};
|
||||
modalApi.open();
|
||||
break;
|
||||
}
|
||||
case PayChannelEnum.WX_BAR.code: {
|
||||
title.value = '“微信”条码支付';
|
||||
barCode.value = {
|
||||
channelCode,
|
||||
value: '',
|
||||
visible: true,
|
||||
};
|
||||
modalApi.open();
|
||||
break;
|
||||
}
|
||||
// 微信公众号、小程序支付,无法在 PC 网页中进行
|
||||
case PayChannelEnum.WX_LITE.code: {
|
||||
message.error('微信小程序:不支持 PC 网站');
|
||||
break;
|
||||
}
|
||||
case PayChannelEnum.WX_PUB.code: {
|
||||
message.error('微信公众号支付:不支持 PC 网站');
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
submit(channelCode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function submit(channelCode: string) {
|
||||
try {
|
||||
const submitParam = {
|
||||
id: id.value,
|
||||
channelCode,
|
||||
returnUrl: location.href, // 支付成功后,支付渠道跳转回当前页;再由当前页,跳转回 {@link returnUrl} 对应的地址
|
||||
...buildSubmitParam(channelCode),
|
||||
};
|
||||
const data = await submitOrder(submitParam);
|
||||
// 直接返回已支付的情况,例如说扫码支付
|
||||
if (data.status === PayOrderStatusEnum.SUCCESS.status) {
|
||||
clearQueryInterval();
|
||||
message.success('支付成功!');
|
||||
goReturnUrl('success');
|
||||
return;
|
||||
}
|
||||
|
||||
// 展示对应的界面
|
||||
switch (data.displayMode) {
|
||||
case PayDisplayModeEnum.APP.mode: {
|
||||
displayApp(channelCode);
|
||||
break;
|
||||
}
|
||||
case PayDisplayModeEnum.QR_CODE.mode: {
|
||||
displayQrCode(channelCode, data);
|
||||
break;
|
||||
}
|
||||
case PayDisplayModeEnum.URL.mode: {
|
||||
displayUrl(data);
|
||||
break;
|
||||
}
|
||||
// No default
|
||||
}
|
||||
|
||||
// 打开轮询任务
|
||||
createQueryInterval();
|
||||
} finally {
|
||||
// message.success('支付成功!')
|
||||
}
|
||||
}
|
||||
|
||||
/** 构建提交支付的额外参数 */
|
||||
function buildSubmitParam(channelCode: string) {
|
||||
// ① 支付宝 BarCode 支付时,需要传递 authCode 条形码
|
||||
if (channelCode === PayChannelEnum.ALIPAY_BAR.code) {
|
||||
return {
|
||||
channelExtras: {
|
||||
auth_code: barCode.value.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
// ② 微信 BarCode 支付时,需要传递 authCode 条形码
|
||||
if (channelCode === PayChannelEnum.WX_BAR.code) {
|
||||
return {
|
||||
channelExtras: {
|
||||
authCode: barCode.value.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/** 提交支付后,URL 的展示形式 */
|
||||
function displayUrl(data: any) {
|
||||
location.href = data.displayContent;
|
||||
}
|
||||
|
||||
/** 提交支付后(扫码支付) */
|
||||
function displayQrCode(channelCode: string, data: any) {
|
||||
title.value = '请使用手机浏览器“扫一扫”';
|
||||
if (channelCode === PayChannelEnum.ALIPAY_WAP.code) {
|
||||
// 考虑到 WAP 测试,所以引导手机浏览器搞
|
||||
} else if (channelCode.indexOf('alipay_') === 0) {
|
||||
title.value = '请使用支付宝“扫一扫”扫码支付';
|
||||
} else if (channelCode.indexOf('wx_') === 0) {
|
||||
title.value = '请使用微信“扫一扫”扫码支付';
|
||||
}
|
||||
qrCode.value = {
|
||||
url: data.displayContent,
|
||||
visible: true,
|
||||
};
|
||||
}
|
||||
|
||||
/** 提交支付后(App) */
|
||||
function displayApp(channelCode: string) {
|
||||
if (channelCode === PayChannelEnum.ALIPAY_APP.code) {
|
||||
message.error('支付宝 App 支付:无法在网页支付!');
|
||||
}
|
||||
if (channelCode === PayChannelEnum.WX_APP.code) {
|
||||
message.error('微信 App 支付:无法在网页支付!');
|
||||
}
|
||||
}
|
||||
|
||||
/** 轮询查询任务 */
|
||||
function createQueryInterval() {
|
||||
if (interval.value) {
|
||||
return;
|
||||
}
|
||||
interval.value = setInterval(async () => {
|
||||
const data = await getOrder(id.value);
|
||||
// 已支付
|
||||
if (data.status === PayOrderStatusEnum.SUCCESS.status) {
|
||||
clearQueryInterval();
|
||||
message.success('支付成功!');
|
||||
goReturnUrl('success');
|
||||
}
|
||||
// 已取消
|
||||
if (data.status === PayOrderStatusEnum.CLOSED.status) {
|
||||
clearQueryInterval();
|
||||
message.error('支付已关闭!');
|
||||
goReturnUrl('close');
|
||||
}
|
||||
}, 1000 * 2);
|
||||
}
|
||||
|
||||
/** 清空查询任务 */
|
||||
function clearQueryInterval() {
|
||||
// 清空数据
|
||||
qrCode.value = {
|
||||
url: '',
|
||||
visible: false,
|
||||
};
|
||||
barCode.value = {
|
||||
channelCode: '',
|
||||
value: '',
|
||||
visible: false,
|
||||
};
|
||||
// 清空任务
|
||||
clearInterval(interval.value);
|
||||
interval.value = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 回到业务的 URL
|
||||
*
|
||||
* @param payResult 支付结果
|
||||
* ① success:支付成功
|
||||
* ② cancel:取消支付
|
||||
* ③ close:支付已关闭
|
||||
*/
|
||||
function goReturnUrl(payResult: string) {
|
||||
// 清理任务
|
||||
clearQueryInterval();
|
||||
|
||||
// 未配置的情况下,只能关闭
|
||||
if (!returnUrl.value) {
|
||||
closeCurrentTab();
|
||||
return;
|
||||
}
|
||||
|
||||
const url = returnUrl.value.includes('?')
|
||||
? `${returnUrl.value}&payResult=${payResult}`
|
||||
: `${returnUrl.value}?payResult=${payResult}`;
|
||||
// 如果有配置,且是 http 开头,则浏览器跳转
|
||||
if (returnUrl.value.indexOf('http') === 0) {
|
||||
location.href = url;
|
||||
} else {
|
||||
closeCurrentTab();
|
||||
push({ path: url });
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getDetail();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<h1>收银台</h1>
|
||||
</div>
|
||||
<Page auto-content-height>
|
||||
<Card class="mt-4">
|
||||
<Descriptions :column="3" :title="payOrder?.subject ?? '商品详情'">
|
||||
<Descriptions.Item label="支付单号">
|
||||
{{ payOrder?.id }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="商品标题">
|
||||
{{ payOrder?.subject }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="商品内容">
|
||||
{{ payOrder?.body }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="支付金额">
|
||||
{{ `¥${fenToYuan(payOrder?.price || 0)}` }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">
|
||||
{{ formatDate(payOrder?.createTime) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="过期时间">
|
||||
{{ formatDate(payOrder?.expireTime) }}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Card>
|
||||
<Card title="选择支付宝支付" class="mt-4">
|
||||
<div class="flex">
|
||||
<div
|
||||
class="mr-4 w-40 cursor-pointer items-center border-2 border-gray-200 pb-1 pt-4 text-center hover:border-blue-500"
|
||||
v-for="channel in channelsAlipay"
|
||||
:key="channel.code"
|
||||
@click="handlePay(channel.code)"
|
||||
>
|
||||
<div class="flex items-center justify-center">
|
||||
<component :is="channel.icon" class="h-10 w-10" />
|
||||
</div>
|
||||
<div class="mt-2 pt-1 text-center">{{ channel.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card title="选择微信支付" class="mt-4">
|
||||
<div class="flex">
|
||||
<div
|
||||
class="mr-4 w-40 cursor-pointer items-center border-2 border-gray-200 pb-1 pt-4 text-center hover:border-blue-500"
|
||||
v-for="channel in channelsWechat"
|
||||
:key="channel.code"
|
||||
@click="handlePay(channel.code)"
|
||||
>
|
||||
<div class="flex items-center justify-center">
|
||||
<component :is="channel.icon" class="h-10 w-10" />
|
||||
</div>
|
||||
<div class="mt-2 pt-1 text-center">{{ channel.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card title="选择其它支付" class="mt-4">
|
||||
<div class="flex">
|
||||
<div
|
||||
class="mr-4 w-40 cursor-pointer items-center border-2 border-gray-200 pb-1 pt-4 text-center hover:border-blue-500"
|
||||
v-for="channel in channelsMock"
|
||||
:key="channel.code"
|
||||
@click="handlePay(channel.code)"
|
||||
>
|
||||
<div class="flex items-center justify-center">
|
||||
<component :is="channel.icon" class="h-10 w-10" />
|
||||
</div>
|
||||
<div class="mt-2 pt-1 text-center">{{ channel.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Modal class="w-[40%]" :title="title">
|
||||
<QRCode v-if="qrCode.visible" :value="qrCode.url" />
|
||||
<Input
|
||||
v-if="barCode.visible"
|
||||
v-model:value="barCode.value"
|
||||
placeholder="请输入条形码"
|
||||
required
|
||||
/>
|
||||
<div class="text-right" v-if="barCode.visible">
|
||||
或使用
|
||||
<Button
|
||||
type="link"
|
||||
danger
|
||||
target="_blank"
|
||||
href="https://baike.baidu.com/item/条码支付/10711903"
|
||||
>
|
||||
(扫码枪/扫码盒)
|
||||
</Button>
|
||||
扫码
|
||||
</div>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { getAppList } from '#/api/pay/app';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils';
|
||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
@@ -54,11 +54,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'DatePicker',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
type: 'daterange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')],
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -116,7 +116,6 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
title: '支付时间',
|
||||
field: 'successTime',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
@@ -129,7 +128,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -31,8 +31,12 @@ function handleDetail(row: PayOrderApi.Order) {
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
collapsed: false,
|
||||
},
|
||||
gridOptions: {
|
||||
cellConfig: {
|
||||
height: 80,
|
||||
},
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
@@ -49,6 +53,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isCurrent: true,
|
||||
isHover: true,
|
||||
resizable: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
@@ -90,16 +97,18 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
/>
|
||||
</template>
|
||||
<template #no="{ row }">
|
||||
<p class="order-font">
|
||||
<Tag size="small" color="blue"> 商户</Tag> {{ row.merchantOrderId }}
|
||||
</p>
|
||||
<p class="order-font" v-if="row.no">
|
||||
<Tag size="small" color="orange">支付</Tag> {{ row.no }}
|
||||
</p>
|
||||
<p class="order-font" v-if="row.channelOrderNo">
|
||||
<Tag size="small" color="green">渠道</Tag>
|
||||
{{ row.channelOrderNo }}
|
||||
</p>
|
||||
<div class="flex flex-col gap-1 text-left">
|
||||
<p class="text-sm">
|
||||
<Tag size="small" color="blue"> 商户</Tag> {{ row.merchantOrderId }}
|
||||
</p>
|
||||
<p class="text-sm" v-if="row.no">
|
||||
<Tag size="small" color="orange">支付</Tag> {{ row.no }}
|
||||
</p>
|
||||
<p class="text-sm" v-if="row.channelOrderNo">
|
||||
<Tag size="small" color="green">渠道</Tag>
|
||||
{{ row.channelOrderNo }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -2,7 +2,12 @@ import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { getAppList } from '#/api/pay/app';
|
||||
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '#/utils';
|
||||
import {
|
||||
DICT_TYPE,
|
||||
getIntDictOptions,
|
||||
getRangePickerDefaultProps,
|
||||
getStrDictOptions,
|
||||
} from '#/utils';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
@@ -64,11 +69,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'DatePicker',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
type: 'daterange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')],
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -80,76 +84,41 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'payPrice',
|
||||
title: '支付金额',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'success',
|
||||
content: '¥{payPrice}',
|
||||
formatter: (value: number) => (value / 100).toFixed(2),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'refundPrice',
|
||||
title: '退款金额',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'danger',
|
||||
content: '¥{refundPrice}',
|
||||
formatter: (value: number) => (value / 100).toFixed(2),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'merchantRefundId',
|
||||
title: '退款订单号',
|
||||
minWidth: 300,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'info',
|
||||
content: '商户 {merchantRefundId}',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'channelRefundNo',
|
||||
title: '渠道退款单号',
|
||||
minWidth: 200,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'success',
|
||||
content: '{channelRefundNo}',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'payPrice',
|
||||
title: '支付金额',
|
||||
formatter: 'formatFraction',
|
||||
},
|
||||
{
|
||||
field: 'refundPrice',
|
||||
title: '退款金额',
|
||||
formatter: 'formatFraction',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '退款状态',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.PAY_REFUND_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -117,7 +117,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['短信渠道']),
|
||||
label: $t('ui.actionTitle.create', ['站内信模板']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['system:notify-template:create'],
|
||||
|
||||
@@ -31,7 +31,7 @@ const [Form, formApi] = useVbenForm({
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
labelWidth: 140,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
@@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Modal class="w-[40%]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -96,7 +96,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['短信渠道']),
|
||||
label: $t('ui.actionTitle.create', ['岗位']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['system:post:create'],
|
||||
|
||||
@@ -50,14 +50,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'apiKey',
|
||||
label: '短信 API 的账号',
|
||||
@@ -83,6 +75,14 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
placeholder: '请输入短信发送回调 URL',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -135,17 +135,14 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'signature',
|
||||
title: '短信签名',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
title: '渠道编码',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE },
|
||||
@@ -154,38 +151,32 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'status',
|
||||
title: '启用状态',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'apiKey',
|
||||
title: '短信 API 的账号',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'apiSecret',
|
||||
title: '短信 API 的密钥',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'callbackUrl',
|
||||
title: '短信发送回调 URL',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
|
||||
@@ -31,7 +31,7 @@ const [Form, formApi] = useVbenForm({
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
labelWidth: 120,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
@@ -82,7 +82,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Modal class="w-[40%]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -84,18 +84,10 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'mobile',
|
||||
title: '手机号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'templateContent',
|
||||
@@ -105,7 +97,6 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'sendStatus',
|
||||
title: '发送状态',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_SEND_STATUS },
|
||||
@@ -114,13 +105,11 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'sendTime',
|
||||
title: '发送时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'receiveStatus',
|
||||
title: '接收状态',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS },
|
||||
@@ -129,13 +118,11 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'receiveTime',
|
||||
title: '接收时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'channelCode',
|
||||
title: '短信渠道',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE },
|
||||
@@ -144,17 +131,20 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'templateId',
|
||||
title: '模板编号',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'templateType',
|
||||
title: '短信类型',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
|
||||
@@ -78,6 +78,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入模板内容',
|
||||
rows: 4,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
@@ -204,12 +205,10 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '短信类型',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE },
|
||||
@@ -218,12 +217,10 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'name',
|
||||
title: '模板名称',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
title: '模板编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'content',
|
||||
@@ -233,26 +230,18 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'status',
|
||||
title: '开启状态',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'apiTemplateId',
|
||||
title: '短信 API 的模板编号',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'channelCode',
|
||||
title: '短信渠道',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE },
|
||||
@@ -261,9 +250,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
|
||||
@@ -31,7 +31,7 @@ const [Form, formApi] = useVbenForm({
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
labelWidth: 120,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
@@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Modal class="w-[40%]" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -103,7 +103,7 @@ const buildFormSchema = () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="发送短信">
|
||||
<Modal class="w-[30%]" title="发送短信">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user