Files
aiot-platform-ui/apps/web-ele/src/views/system/social/client/data.ts

212 lines
4.8 KiB
TypeScript
Raw Normal View History

2025-05-11 23:16:56 +08:00
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
2025-05-11 23:16:56 +08:00
2025-09-05 12:00:24 +08:00
import {
CommonStatusEnum,
DICT_TYPE,
SystemUserSocialTypeEnum,
} from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
2025-05-11 23:16:56 +08:00
import { z } from '#/adapter/form';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'id',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'name',
label: '应用名',
component: 'Input',
componentProps: {
placeholder: '请输入应用名',
},
rules: 'required',
},
{
fieldName: 'socialType',
label: '社交平台',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE, 'number'),
},
rules: 'required',
},
{
fieldName: 'userType',
label: '用户类型',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.USER_TYPE, 'number'),
buttonStyle: 'solid',
optionType: 'button',
},
rules: 'required',
},
{
fieldName: 'clientId',
label: '客户端编号',
component: 'Input',
componentProps: {
placeholder: '请输入客户端编号,对应各平台的 appKey',
},
rules: 'required',
},
{
fieldName: 'clientSecret',
label: '客户端密钥',
component: 'Input',
componentProps: {
placeholder: '请输入客户端密钥,对应各平台的 appSecret',
},
rules: 'required',
},
{
fieldName: 'agentId',
label: 'agentId',
component: 'Input',
componentProps: {
placeholder: '授权方的网页应用 ID有则填',
},
dependencies: {
triggerFields: ['socialType'],
show: (values) =>
values.socialType === SystemUserSocialTypeEnum.WECHAT_ENTERPRISE.type,
},
},
{
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',
componentProps: {
placeholder: '请输入应用名',
clearable: true,
2025-05-11 23:16:56 +08:00
},
},
{
fieldName: 'socialType',
label: '社交平台',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE, 'number'),
placeholder: '请选择社交平台',
clearable: true,
2025-05-11 23:16:56 +08:00
},
},
{
fieldName: 'userType',
label: '用户类型',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.USER_TYPE, 'number'),
placeholder: '请选择用户类型',
clearable: true,
2025-05-11 23:16:56 +08:00
},
},
{
fieldName: 'clientId',
label: '客户端编号',
component: 'Input',
componentProps: {
placeholder: '请输入客户端编号',
clearable: true,
2025-05-11 23:16:56 +08:00
},
},
{
fieldName: 'status',
label: '状态',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
placeholder: '请选择状态',
clearable: true,
2025-05-11 23:16:56 +08:00
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
2025-05-11 23:16:56 +08:00
return [
{ type: 'checkbox', width: 40 },
2025-05-11 23:16:56 +08:00
{
field: 'id',
title: '编号',
minWidth: 100,
2025-05-11 23:16:56 +08:00
},
{
field: 'name',
title: '应用名',
minWidth: 120,
},
{
field: 'socialType',
title: '社交平台',
minWidth: 100,
2025-05-11 23:16:56 +08:00
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE },
},
},
{
field: 'userType',
title: '用户类型',
minWidth: 100,
2025-05-11 23:16:56 +08:00
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.USER_TYPE },
},
},
{
field: 'clientId',
title: '客户端编号',
minWidth: 180,
},
{
field: 'status',
title: '状态',
minWidth: 100,
2025-05-11 23:16:56 +08:00
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
},
},
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '操作',
width: 220,
2025-05-11 23:16:56 +08:00
fixed: 'right',
slots: { default: 'actions' },
2025-05-11 23:16:56 +08:00
},
];
}