mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-08 07:31:09 +08:00
fix: 统一状态切换函数参数类型为 SwitchProps['checked']
修复多个系统管理页面及全局组件中状态切换函数参数类型不一致的问题,将原先的 `boolean` 类型统一为 `SwitchProps['checked']` 类型,确保与 antdv-next 组件库的类型定义保持一致,提高类型安全性和代码一致性。
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { SwitchProps } from 'antdv-next';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { $t } from '@vben/locales';
|
||||
@@ -21,7 +23,7 @@ interface Props {
|
||||
/**
|
||||
* 需要自己在内部处理更新的逻辑 因为status已经双向绑定了 可以直接获取
|
||||
*/
|
||||
api: (checked: boolean) => PromiseLike<void>;
|
||||
api: (checked: SwitchProps['checked']) => PromiseLike<void>;
|
||||
/**
|
||||
* 更新前是否弹窗确认
|
||||
* @default false
|
||||
@@ -32,7 +34,7 @@ interface Props {
|
||||
* @param checked 选中的值(更新后的值)
|
||||
* @default string '确认要更新状态吗?'
|
||||
*/
|
||||
confirmText?: (checked: boolean) => string;
|
||||
confirmText?: (checked: SwitchProps['checked']) => string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -53,13 +55,13 @@ const unCheckedTextComputed = computed(() => {
|
||||
return props.unCheckedText ?? $t('pages.common.disable');
|
||||
});
|
||||
|
||||
const currentChecked = defineModel<boolean>('value', {
|
||||
const currentChecked = defineModel<SwitchProps['checked']>('value', {
|
||||
default: false,
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
function confirmUpdate(checked: boolean, lastStatus: boolean) {
|
||||
function confirmUpdate(checked: SwitchProps['checked'], lastStatus: boolean) {
|
||||
const content = isFunction(props.confirmText)
|
||||
? props.confirmText(checked)
|
||||
: `确认要更新状态吗?`;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { SwitchProps } from 'antdv-next';
|
||||
|
||||
import type { VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
@@ -115,7 +117,10 @@ async function handleExport() {
|
||||
}
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
async function handleChangeStatus(checked: boolean, row: Client) {
|
||||
async function handleChangeStatus(
|
||||
checked: SwitchProps['checked'],
|
||||
row: Client,
|
||||
) {
|
||||
await clientChangeStatus({
|
||||
clientId: row.id,
|
||||
status: checked ? EnableStatus.Enable : EnableStatus.Disable,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { SwitchProps } from 'antdv-next';
|
||||
|
||||
import type { VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
@@ -101,7 +103,10 @@ function handleMultiDelete() {
|
||||
}
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
async function handleChangeStatus(checked: boolean, row: OssConfig) {
|
||||
async function handleChangeStatus(
|
||||
checked: SwitchProps['checked'],
|
||||
row: OssConfig,
|
||||
) {
|
||||
await ossConfigChangeStatus({
|
||||
ossConfigId: row.ossConfigId,
|
||||
configKey: row.configKey,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { SwitchProps } from 'antdv-next';
|
||||
|
||||
import type { VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
@@ -147,7 +149,7 @@ function handleAssignRole(record: Role) {
|
||||
router.push(`/system/role-auth/user/${record.roleId}`);
|
||||
}
|
||||
|
||||
async function handleChangeStatus(checked: boolean, row: Role) {
|
||||
async function handleChangeStatus(checked: SwitchProps['checked'], row: Role) {
|
||||
await roleChangeStatus({
|
||||
roleId: row.roleId,
|
||||
status: checked ? EnableStatus.Enable : EnableStatus.Disable,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { DropdownEmits, MenuItemType } from 'antdv-next';
|
||||
import type { DropdownEmits, MenuItemType, SwitchProps } from 'antdv-next';
|
||||
|
||||
import type { VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
@@ -164,7 +164,10 @@ function handleSyncTenantConfig() {
|
||||
});
|
||||
}
|
||||
|
||||
async function handleChangeStatus(checked: boolean, row: Tenant) {
|
||||
async function handleChangeStatus(
|
||||
checked: SwitchProps['checked'],
|
||||
row: Tenant,
|
||||
) {
|
||||
await tenantStatusChange({
|
||||
id: row.id,
|
||||
tenantId: row.tenantId,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { SwitchProps } from 'antdv-next';
|
||||
|
||||
import type { VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
@@ -124,7 +126,10 @@ const isSuperAdmin = computed(() => {
|
||||
return hasAccessByRoles(['superadmin']);
|
||||
});
|
||||
|
||||
async function handleChangeStatus(checked: boolean, row: TenantPackage) {
|
||||
async function handleChangeStatus(
|
||||
checked: SwitchProps['checked'],
|
||||
row: TenantPackage,
|
||||
) {
|
||||
await packageChangeStatus({
|
||||
packageId: row.packageId,
|
||||
status: checked ? EnableStatus.Enable : EnableStatus.Disable,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { MenuProps } from 'antdv-next';
|
||||
import type { MenuProps, SwitchProps } from 'antdv-next';
|
||||
|
||||
import type { VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
@@ -205,7 +205,7 @@ function handleMenuClick(key: string, row: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleChangeStatus(checked: boolean, row: User) {
|
||||
async function handleChangeStatus(checked: SwitchProps['checked'], row: User) {
|
||||
await userStatusChange({
|
||||
userId: row.userId,
|
||||
status: checked ? EnableStatus.Enable : EnableStatus.Disable,
|
||||
|
||||
Reference in New Issue
Block a user