77 changed files with 481 additions and 543 deletions
@ -0,0 +1,49 @@ |
|||
import type { |
|||
VbenFormSchema as FormSchema, |
|||
VbenFormProps, |
|||
} from '@vben/common-ui'; |
|||
|
|||
import type { ComponentType } from './component'; |
|||
|
|||
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui'; |
|||
import { $t } from '@vben/locales'; |
|||
|
|||
async function initVbenForm() { |
|||
setupVbenForm<ComponentType>({ |
|||
config: { |
|||
// ant design vue组件库默认都是 v-model:value
|
|||
baseModelPropName: 'value', |
|||
|
|||
// 一些组件是 v-model:checked 或者 v-model:fileList
|
|||
modelPropNameMap: { |
|||
Checkbox: 'checked', |
|||
Radio: 'checked', |
|||
Switch: 'checked', |
|||
Upload: 'fileList', |
|||
}, |
|||
}, |
|||
defineRules: { |
|||
// 输入项目必填国际化适配
|
|||
required: (value, _params, ctx) => { |
|||
if (value === undefined || value === null || value.length === 0) { |
|||
return $t('ui.formRules.required', [ctx.label]); |
|||
} |
|||
return true; |
|||
}, |
|||
// 选择项目必填国际化适配
|
|||
selectRequired: (value, _params, ctx) => { |
|||
if (value === undefined || value === null) { |
|||
return $t('ui.formRules.selectRequired', [ctx.label]); |
|||
} |
|||
return true; |
|||
}, |
|||
}, |
|||
}); |
|||
} |
|||
|
|||
const useVbenForm = useForm<ComponentType>; |
|||
|
|||
export { initVbenForm, useVbenForm, z }; |
|||
|
|||
export type VbenFormSchema = FormSchema<ComponentType>; |
|||
export type { VbenFormProps }; |
|||
@ -1 +0,0 @@ |
|||
export * from './permissions'; |
|||
@ -1,4 +1,4 @@ |
|||
export * from './api'; |
|||
export * from './components'; |
|||
export * from './constants'; |
|||
export { UserLookupPermissions } from './constants/permissions'; |
|||
export * from './types'; |
|||
|
|||
@ -1 +0,0 @@ |
|||
export * from './permissions'; |
|||
@ -1,4 +1,3 @@ |
|||
export * from './api'; |
|||
export * from './components'; |
|||
export * from './constants'; |
|||
export * from './types'; |
|||
|
|||
@ -1 +0,0 @@ |
|||
export * from './permissions'; |
|||
@ -1 +0,0 @@ |
|||
export * from './permissions'; |
|||
@ -1,4 +1,3 @@ |
|||
export * from './api'; |
|||
export * from './components'; |
|||
export * from './constants'; |
|||
export * from './types'; |
|||
|
|||
@ -1 +0,0 @@ |
|||
export * from './permissions'; |
|||
@ -1,4 +1,3 @@ |
|||
export * from './api'; |
|||
export * from './components'; |
|||
export * from './constants'; |
|||
export * from './types'; |
|||
|
|||
@ -1,77 +0,0 @@ |
|||
import type { ListResultDto } from '@abp/core'; |
|||
|
|||
import type { |
|||
SettingDefinitionCreateDto, |
|||
SettingDefinitionDto, |
|||
SettingDefinitionGetListInput, |
|||
SettingDefinitionUpdateDto, |
|||
} from '../types/definitions'; |
|||
|
|||
import { requestClient } from '@abp/request'; |
|||
|
|||
/** |
|||
* 删除设置定义 |
|||
* @param name 设置名称 |
|||
*/ |
|||
export function deleteApi(name: string): Promise<void> { |
|||
return requestClient.delete( |
|||
`/api/setting-management/settings/definitions/${name}`, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 查询设置定义 |
|||
* @param name 设置名称 |
|||
* @returns 设置定义数据传输对象 |
|||
*/ |
|||
export function getApi(name: string): Promise<SettingDefinitionDto> { |
|||
return requestClient.get<SettingDefinitionDto>( |
|||
`/api/setting-management/settings/definitions/${name}`, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 查询设置定义列表 |
|||
* @param input 设置过滤条件 |
|||
* @returns 设置定义数据传输对象列表 |
|||
*/ |
|||
export function getListApi( |
|||
input?: SettingDefinitionGetListInput, |
|||
): Promise<ListResultDto<SettingDefinitionDto>> { |
|||
return requestClient.get<ListResultDto<SettingDefinitionDto>>( |
|||
`/api/setting-management/settings/definitions`, |
|||
{ |
|||
params: input, |
|||
}, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 创建设置定义 |
|||
* @param input 设置定义参数 |
|||
* @returns 设置定义数据传输对象 |
|||
*/ |
|||
export function createApi( |
|||
input: SettingDefinitionCreateDto, |
|||
): Promise<SettingDefinitionDto> { |
|||
return requestClient.post<SettingDefinitionDto>( |
|||
'/api/setting-management/settings/definitions', |
|||
input, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 更新设置定义 |
|||
* @param name 设置名称 |
|||
* @param input 设置定义参数 |
|||
* @returns 设置定义数据传输对象 |
|||
*/ |
|||
export function updateApi( |
|||
name: string, |
|||
input: SettingDefinitionUpdateDto, |
|||
): Promise<SettingDefinitionDto> { |
|||
return requestClient.put<SettingDefinitionDto>( |
|||
`/api/setting-management/settings/definitions/${name}`, |
|||
input, |
|||
); |
|||
} |
|||
@ -1,2 +1,2 @@ |
|||
export * as settingDefinitionsApi from './definitions'; |
|||
export * as settingsApi from './settings'; |
|||
export { useDefinitionsApi } from './useDefinitionsApi'; |
|||
export { useSettingsApi } from './useSettingsApi'; |
|||
|
|||
@ -1,84 +0,0 @@ |
|||
import type { ListResultDto } from '@abp/core'; |
|||
|
|||
import type { SettingGroup, SettingsUpdateInput } from '../types/settings'; |
|||
|
|||
import { requestClient } from '@abp/request'; |
|||
|
|||
/** |
|||
* 获取全局设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
export function getGlobalSettingsApi(): Promise<ListResultDto<SettingGroup>> { |
|||
return requestClient.get<ListResultDto<SettingGroup>>( |
|||
`/api/setting-management/settings/by-global`, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 设置全局设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
export function setGlobalSettingsApi( |
|||
input: SettingsUpdateInput, |
|||
): Promise<void> { |
|||
return requestClient.put( |
|||
`/api/setting-management/settings/change-global`, |
|||
input, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 获取租户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
export function getTenantSettingsApi(): Promise<ListResultDto<SettingGroup>> { |
|||
return requestClient.get<ListResultDto<SettingGroup>>( |
|||
`/api/setting-management/settings/by-current-tenant`, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 设置租户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
export function setTenantSettingsApi( |
|||
input: SettingsUpdateInput, |
|||
): Promise<void> { |
|||
return requestClient.put( |
|||
`/api/setting-management/settings/change-current-tenant`, |
|||
input, |
|||
); |
|||
} |
|||
/** |
|||
* 获取用户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
export function getUserSettingsApi(): Promise<ListResultDto<SettingGroup>> { |
|||
return requestClient.get<ListResultDto<SettingGroup>>( |
|||
`/api/setting-management/settings/by-current-user`, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 设置用户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
export function setUserSettingsApi(input: SettingsUpdateInput): Promise<void> { |
|||
return requestClient.put( |
|||
`/api/setting-management/settings/change-current-user`, |
|||
input, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 发送测试邮件 |
|||
* @param emailAddress 邮件接收方地址 |
|||
*/ |
|||
export const sendTestEmailApi = (emailAddress: string) => { |
|||
return requestClient.post( |
|||
`/api/setting-management/settings/send-test-email`, |
|||
{ |
|||
emailAddress, |
|||
}, |
|||
); |
|||
}; |
|||
@ -0,0 +1,99 @@ |
|||
import type { ListResultDto } from '@abp/core'; |
|||
|
|||
import type { |
|||
SettingDefinitionCreateDto, |
|||
SettingDefinitionDto, |
|||
SettingDefinitionGetListInput, |
|||
SettingDefinitionUpdateDto, |
|||
} from '../types'; |
|||
|
|||
import { useRequest } from '@abp/request'; |
|||
|
|||
export function useDefinitionsApi() { |
|||
const { cancel, request } = useRequest(); |
|||
/** |
|||
* 删除设置定义 |
|||
* @param name 设置名称 |
|||
*/ |
|||
function deleteApi(name: string): Promise<void> { |
|||
return request(`/api/setting-management/settings/definitions/${name}`, { |
|||
method: 'DELETE', |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 查询设置定义 |
|||
* @param name 设置名称 |
|||
* @returns 设置定义数据传输对象 |
|||
*/ |
|||
function getApi(name: string): Promise<SettingDefinitionDto> { |
|||
return request<SettingDefinitionDto>( |
|||
`/api/setting-management/settings/definitions/${name}`, |
|||
{ |
|||
method: 'GET', |
|||
}, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 查询设置定义列表 |
|||
* @param input 设置过滤条件 |
|||
* @returns 设置定义数据传输对象列表 |
|||
*/ |
|||
function getListApi( |
|||
input?: SettingDefinitionGetListInput, |
|||
): Promise<ListResultDto<SettingDefinitionDto>> { |
|||
return request<ListResultDto<SettingDefinitionDto>>( |
|||
`/api/setting-management/settings/definitions`, |
|||
{ |
|||
method: 'GET', |
|||
params: input, |
|||
}, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 创建设置定义 |
|||
* @param input 设置定义参数 |
|||
* @returns 设置定义数据传输对象 |
|||
*/ |
|||
function createApi( |
|||
input: SettingDefinitionCreateDto, |
|||
): Promise<SettingDefinitionDto> { |
|||
return request<SettingDefinitionDto>( |
|||
'/api/setting-management/settings/definitions', |
|||
{ |
|||
data: input, |
|||
method: 'POST', |
|||
}, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 更新设置定义 |
|||
* @param name 设置名称 |
|||
* @param input 设置定义参数 |
|||
* @returns 设置定义数据传输对象 |
|||
*/ |
|||
function updateApi( |
|||
name: string, |
|||
input: SettingDefinitionUpdateDto, |
|||
): Promise<SettingDefinitionDto> { |
|||
return request<SettingDefinitionDto>( |
|||
`/api/setting-management/settings/definitions/${name}`, |
|||
{ |
|||
data: input, |
|||
method: 'PUT', |
|||
}, |
|||
); |
|||
} |
|||
|
|||
return { |
|||
cancel, |
|||
createApi, |
|||
deleteApi, |
|||
getApi, |
|||
getListApi, |
|||
updateApi, |
|||
}; |
|||
} |
|||
@ -0,0 +1,103 @@ |
|||
import type { ListResultDto } from '@abp/core'; |
|||
|
|||
import type { SettingGroup, SettingsUpdateInput } from '../types'; |
|||
|
|||
import { useRequest } from '@abp/request'; |
|||
|
|||
export function useSettingsApi() { |
|||
const { cancel, request } = useRequest(); |
|||
/** |
|||
* 获取全局设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
function getGlobalSettingsApi(): Promise<ListResultDto<SettingGroup>> { |
|||
return request<ListResultDto<SettingGroup>>( |
|||
`/api/setting-management/settings/by-global`, |
|||
{ |
|||
method: 'GET', |
|||
}, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 设置全局设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
function setGlobalSettingsApi(input: SettingsUpdateInput): Promise<void> { |
|||
return request(`/api/setting-management/settings/change-global`, { |
|||
data: input, |
|||
method: 'PUT', |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 获取租户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
function getTenantSettingsApi(): Promise<ListResultDto<SettingGroup>> { |
|||
return request<ListResultDto<SettingGroup>>( |
|||
`/api/setting-management/settings/by-current-tenant`, |
|||
{ |
|||
method: 'GET', |
|||
}, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 设置租户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
function setTenantSettingsApi(input: SettingsUpdateInput): Promise<void> { |
|||
return request(`/api/setting-management/settings/change-current-tenant`, { |
|||
data: input, |
|||
method: 'PUT', |
|||
}); |
|||
} |
|||
/** |
|||
* 获取用户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
function getUserSettingsApi(): Promise<ListResultDto<SettingGroup>> { |
|||
return request<ListResultDto<SettingGroup>>( |
|||
`/api/setting-management/settings/by-current-user`, |
|||
{ |
|||
method: 'GET', |
|||
}, |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* 设置用户设置 |
|||
* @returns 设置数据传输对象列表 |
|||
*/ |
|||
function setUserSettingsApi(input: SettingsUpdateInput): Promise<void> { |
|||
return request(`/api/setting-management/settings/change-current-user`, { |
|||
data: input, |
|||
method: 'PUT', |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 发送测试邮件 |
|||
* @param emailAddress 邮件接收方地址 |
|||
*/ |
|||
const sendTestEmailApi = (emailAddress: string) => { |
|||
return request(`/api/setting-management/settings/send-test-email`, { |
|||
data: { |
|||
emailAddress, |
|||
}, |
|||
method: 'POST', |
|||
}); |
|||
}; |
|||
|
|||
return { |
|||
cancel, |
|||
getGlobalSettingsApi, |
|||
getTenantSettingsApi, |
|||
getUserSettingsApi, |
|||
sendTestEmailApi, |
|||
setGlobalSettingsApi, |
|||
setTenantSettingsApi, |
|||
setUserSettingsApi, |
|||
}; |
|||
} |
|||
@ -1 +0,0 @@ |
|||
export * from './permissions'; |
|||
@ -1,4 +1,3 @@ |
|||
export * from './api'; |
|||
export * from './components'; |
|||
export * from './constants'; |
|||
export * from './types'; |
|||
|
|||
@ -1,172 +0,0 @@ |
|||
/** |
|||
* 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用 |
|||
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用, |
|||
*/ |
|||
|
|||
import type { Component, SetupContext } from 'vue'; |
|||
|
|||
import type { BaseFormComponentType } from '@vben/common-ui'; |
|||
|
|||
import { h } from 'vue'; |
|||
|
|||
import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui'; |
|||
import { $t } from '@vben/locales'; |
|||
|
|||
import { |
|||
AutoComplete, |
|||
Button, |
|||
Checkbox, |
|||
CheckboxGroup, |
|||
DatePicker, |
|||
Divider, |
|||
Input, |
|||
InputNumber, |
|||
InputPassword, |
|||
InputSearch, |
|||
Mentions, |
|||
notification, |
|||
Radio, |
|||
RadioGroup, |
|||
RangePicker, |
|||
Rate, |
|||
Select, |
|||
Space, |
|||
Switch, |
|||
Textarea, |
|||
TimePicker, |
|||
TreeSelect, |
|||
Upload, |
|||
} from 'ant-design-vue'; |
|||
|
|||
const withDefaultPlaceholder = <T extends Component>( |
|||
component: T, |
|||
type: 'input' | 'select', |
|||
) => { |
|||
return (props: any, { attrs, slots }: Omit<SetupContext, 'expose'>) => { |
|||
const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`); |
|||
return h(component, { ...props, ...attrs, placeholder }, slots); |
|||
}; |
|||
}; |
|||
|
|||
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
|
|||
export type ComponentType = |
|||
| 'ApiSelect' |
|||
| 'ApiTreeSelect' |
|||
| 'AutoComplete' |
|||
| 'Checkbox' |
|||
| 'CheckboxGroup' |
|||
| 'DatePicker' |
|||
| 'DefaultButton' |
|||
| 'Divider' |
|||
| 'IconPicker' |
|||
| 'Input' |
|||
| 'InputNumber' |
|||
| 'InputPassword' |
|||
| 'InputSearch' |
|||
| 'Mentions' |
|||
| 'PrimaryButton' |
|||
| 'Radio' |
|||
| 'RadioGroup' |
|||
| 'RangePicker' |
|||
| 'Rate' |
|||
| 'Select' |
|||
| 'Space' |
|||
| 'Switch' |
|||
| 'Textarea' |
|||
| 'TimePicker' |
|||
| 'TreeSelect' |
|||
| 'Upload' |
|||
| BaseFormComponentType; |
|||
|
|||
async function initComponentAdapter() { |
|||
const components: Partial<Record<ComponentType, Component>> = { |
|||
// 如果你的组件体积比较大,可以使用异步加载
|
|||
// Button: () =>
|
|||
// import('xxx').then((res) => res.Button),
|
|||
ApiSelect: (props, { attrs, slots }) => { |
|||
return h( |
|||
ApiComponent, |
|||
{ |
|||
placeholder: $t('ui.placeholder.select'), |
|||
...props, |
|||
...attrs, |
|||
component: Select, |
|||
loadingSlot: 'suffixIcon', |
|||
modelPropName: 'value', |
|||
visibleEvent: 'onDropdownVisibleChange', |
|||
}, |
|||
slots, |
|||
); |
|||
}, |
|||
ApiTreeSelect: (props, { attrs, slots }) => { |
|||
return h( |
|||
ApiComponent, |
|||
{ |
|||
placeholder: $t('ui.placeholder.select'), |
|||
...props, |
|||
...attrs, |
|||
component: TreeSelect, |
|||
fieldNames: { label: 'label', value: 'value', children: 'children' }, |
|||
loadingSlot: 'suffixIcon', |
|||
modelPropName: 'value', |
|||
optionsPropName: 'treeData', |
|||
visibleEvent: 'onVisibleChange', |
|||
}, |
|||
slots, |
|||
); |
|||
}, |
|||
AutoComplete, |
|||
Checkbox, |
|||
CheckboxGroup, |
|||
DatePicker, |
|||
// 自定义默认按钮
|
|||
DefaultButton: (props, { attrs, slots }) => { |
|||
return h(Button, { ...props, attrs, type: 'default' }, slots); |
|||
}, |
|||
Divider, |
|||
IconPicker: (props, { attrs, slots }) => { |
|||
return h( |
|||
IconPicker, |
|||
{ iconSlot: 'addonAfter', inputComponent: Input, ...props, ...attrs }, |
|||
slots, |
|||
); |
|||
}, |
|||
Input: withDefaultPlaceholder(Input, 'input'), |
|||
InputNumber: withDefaultPlaceholder(InputNumber, 'input'), |
|||
InputPassword: withDefaultPlaceholder(InputPassword, 'input'), |
|||
InputSearch: withDefaultPlaceholder(InputSearch, 'input'), |
|||
Mentions: withDefaultPlaceholder(Mentions, 'input'), |
|||
// 自定义主要按钮
|
|||
PrimaryButton: (props, { attrs, slots }) => { |
|||
return h(Button, { ...props, attrs, type: 'primary' }, slots); |
|||
}, |
|||
Radio, |
|||
RadioGroup, |
|||
RangePicker, |
|||
Rate, |
|||
Select: withDefaultPlaceholder(Select, 'select'), |
|||
Space, |
|||
Switch, |
|||
Textarea: withDefaultPlaceholder(Textarea, 'input'), |
|||
TimePicker, |
|||
TreeSelect: withDefaultPlaceholder(TreeSelect, 'select'), |
|||
Upload, |
|||
}; |
|||
|
|||
// 将组件注册到全局共享状态中
|
|||
globalShareState.setComponents(components); |
|||
|
|||
// 定义全局共享状态中的消息提示
|
|||
globalShareState.defineMessage({ |
|||
// 复制成功消息提示
|
|||
copyPreferencesSuccess: (title, content) => { |
|||
notification.success({ |
|||
description: content, |
|||
message: title, |
|||
placement: 'bottomRight', |
|||
}); |
|||
}, |
|||
}); |
|||
} |
|||
|
|||
export { initComponentAdapter }; |
|||
@ -1,47 +0,0 @@ |
|||
import type { |
|||
VbenFormSchema as FormSchema, |
|||
VbenFormProps, |
|||
} from '@vben/common-ui'; |
|||
|
|||
import type { ComponentType } from './component'; |
|||
|
|||
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui'; |
|||
import { $t } from '@vben/locales'; |
|||
|
|||
setupVbenForm<ComponentType>({ |
|||
config: { |
|||
// ant design vue组件库默认都是 v-model:value
|
|||
baseModelPropName: 'value', |
|||
|
|||
// 一些组件是 v-model:checked 或者 v-model:fileList
|
|||
modelPropNameMap: { |
|||
Checkbox: 'checked', |
|||
Radio: 'checked', |
|||
Switch: 'checked', |
|||
Upload: 'fileList', |
|||
}, |
|||
}, |
|||
defineRules: { |
|||
// 输入项目必填国际化适配
|
|||
required: (value, _params, ctx) => { |
|||
if (value === undefined || value === null || value.length === 0) { |
|||
return $t('ui.formRules.required', [ctx.label]); |
|||
} |
|||
return true; |
|||
}, |
|||
// 选择项目必填国际化适配
|
|||
selectRequired: (value, _params, ctx) => { |
|||
if (value === undefined || value === null) { |
|||
return $t('ui.formRules.selectRequired', [ctx.label]); |
|||
} |
|||
return true; |
|||
}, |
|||
}, |
|||
}); |
|||
|
|||
const useVbenForm = useForm<ComponentType>; |
|||
|
|||
export { useVbenForm, z }; |
|||
|
|||
export type VbenFormSchema = FormSchema<ComponentType>; |
|||
export type { VbenFormProps }; |
|||
@ -1,4 +1,2 @@ |
|||
export * from './adapter/component'; |
|||
export * from './adapter/form'; |
|||
export * from './adapter/vxe-table'; |
|||
export * from './components'; |
|||
|
|||
Loading…
Reference in new issue