oneNET账号管理

This commit is contained in:
ChenYi 2025-07-28 11:03:35 +08:00
parent 7029e3777e
commit bcc80ab751
10 changed files with 123 additions and 99 deletions

View File

@ -24,15 +24,15 @@ import type {
IoTDBTreeModelDeviceDataPageAllResponse, IoTDBTreeModelDeviceDataPageAllResponse,
IoTDBTreeModelDeviceDataPageDataInput, IoTDBTreeModelDeviceDataPageDataInput,
IoTErrorResponse, IoTErrorResponse,
OneNETAccountCreateInput, OneNetAccountInsertInput,
OneNETAccountCreateInput, OneNetAccountInsertResponse,
OneNETAccountCreateResponse, OneNetAccountModifyInput,
OneNETAccountCreateResponse, OneNetAccountModifyResponse,
OneNetAccountDeleteInput,
OneNETAccountDeleteResponse,
OneNETAccountPageListInput, OneNETAccountPageListInput,
OneNETAccountPageListResult, OneNETAccountPageListResult,
OneNETProductCreateInput, OneNETProductCreateInput,
OneNETProductCreateInput,
OneNETProductCreateResponse,
OneNETProductCreateResponse, OneNETProductCreateResponse,
OneNETProductPageListInput, OneNETProductPageListInput,
OneNETProductPageListResult, OneNETProductPageListResult,
@ -3148,7 +3148,6 @@ export const postOneNETAccountInfoPage = <ThrowOnError extends boolean = false>(
ThrowOnError ThrowOnError
>({ >({
...options, ...options,
...formDataBodySerializer,
url: '/OneNETAccount/ListAsync', url: '/OneNETAccount/ListAsync',
}); });
}; };
@ -3156,20 +3155,51 @@ export const postOneNETAccountInfoPage = <ThrowOnError extends boolean = false>(
/** /**
* OneNET * OneNET
*/ */
export const postOneNETAccountCreate = <ThrowOnError extends boolean = false>( export const postOneNETAccountInsert = <ThrowOnError extends boolean = false>(
options?: Options<OneNETAccountCreateInput, ThrowOnError>, options?: Options<OneNetAccountInsertInput, ThrowOnError>,
) => { ) => {
return (options?.client ?? client).post< return (options?.client ?? client).post<
OneNETAccountCreateResponse, OneNetAccountInsertResponse,
IoTErrorResponse, IoTErrorResponse,
ThrowOnError ThrowOnError
>({ >({
...options, ...options,
...formDataBodySerializer,
url: '/OneNETAccount/InsertAsync', url: '/OneNETAccount/InsertAsync',
}); });
}; };
/**
* OneNET
*/
export const postOneNETAccountModify = <ThrowOnError extends boolean = false>(
options?: Options<OneNetAccountModifyInput, ThrowOnError>,
) => {
return (options?.client ?? client).post<
OneNetAccountModifyResponse,
IoTErrorResponse,
ThrowOnError
>({
...options,
url: '/OneNETAccount/ModifyAsync',
});
};
/**
* OneNET
*/
export const postOneNETAccountDelete = <ThrowOnError extends boolean = false>(
options?: Options<OneNetAccountDeleteInput, ThrowOnError>,
) => {
return (options?.client ?? client).post<
OneNETAccountDeleteResponse,
IoTErrorResponse,
ThrowOnError
>({
...options,
url: '/OneNETAccount/DeleteAsync',
});
};
/** /**
* OneNET * OneNET
*/ */

View File

@ -5178,10 +5178,25 @@ export type OneNETAccountPageListResult = {
totalCount?: number; totalCount?: number;
}; };
export type OneNETAccountCreateInput = { export type OneNetAccountInsertInput = {
body?: OneNETAccountDto; body?: OneNETAccountDto;
}; };
export type OneNETAccountCreateResponse = { export type OneNetAccountInsertResponse = {
body?: OneNETAccountDto;
};
export type OneNetAccountModifyInput = {
body?: OneNETAccountDto;
};
export type OneNetAccountModifyResponse = {
body?: OneNETAccountDto;
};
export type OneNetAccountDeleteInput = {
body?: IdInput;
};
export type OneNETAccountDeleteResponse = {
body?: OneNETAccountDto; body?: OneNETAccountDto;
}; };

View File

@ -52,5 +52,6 @@
"exporting": "Exporting data...", "exporting": "Exporting data...",
"exportSuccess": "Data exported successfully", "exportSuccess": "Data exported successfully",
"exportFailed": "Data export failed", "exportFailed": "Data export failed",
"getDataFailed": "Failed to get data" "getDataFailed": "Failed to get data",
"PhoneNumberFormatError": "PhoneNumber Format Error"
} }

View File

@ -263,7 +263,7 @@
"DeviceLastActiveTime": "设备最后活跃时间" "DeviceLastActiveTime": "设备最后活跃时间"
}, },
"OneNETManagement": { "OneNETManagement": {
"AccountName": "账号名称", "AccountName": "账号名称",
"PhoneNumber": "手机号码", "PhoneNumber": "手机号码",
"AccountAccesskey": "账户通信密钥", "AccountAccesskey": "账户通信密钥",
"ProductCount": "产品数量", "ProductCount": "产品数量",

View File

@ -53,5 +53,6 @@
"exportSuccess": "数据导出成功", "exportSuccess": "数据导出成功",
"exportFailed": "数据导出失败", "exportFailed": "数据导出失败",
"getDataFailed": "获取数据失败", "getDataFailed": "获取数据失败",
"IsEnabled": "是否启用" "IsEnabled": "是否启用",
"PhoneNumberFormatError": "手机号码格式错误"
} }

View File

@ -12,7 +12,6 @@ import { message as Message, Modal, Tag } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
postMetersArchivesDown,
postMetersCreate, postMetersCreate,
postMetersDelete, postMetersDelete,
postMetersPage, postMetersPage,
@ -186,22 +185,6 @@ const toStatusData = (row: Record<string, any>) => {
}, },
}); });
}; };
//
const archivesIssued = async (row: Record<string, any>) => {
const result = await postMetersArchivesDown({
body: {
meterAddress: row.meterAddress,
meterType: row.meterType,
focusAddress: row.focusAddress,
},
});
if (result) {
gridApi.reload();
Message.success($t('common.success'));
} else {
Message.error($t('common.error'));
}
};
const openAddModal = async () => { const openAddModal = async () => {
editRow.value = {}; editRow.value = {};
userModalApi.open(); userModalApi.open();

View File

@ -12,7 +12,6 @@ import { message as Message, Modal, Tag } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
postMetersArchivesDown,
postMetersCreate, postMetersCreate,
postMetersDelete, postMetersDelete,
postMetersPage, postMetersPage,
@ -186,22 +185,7 @@ const toStatusData = (row: Record<string, any>) => {
}, },
}); });
}; };
//
const archivesIssued = async (row: Record<string, any>) => {
const result = await postMetersArchivesDown({
body: {
meterAddress: row.meterAddress,
meterType: row.meterType,
focusAddress: row.focusAddress,
},
});
if (result) {
gridApi.reload();
Message.success($t('common.success'));
} else {
Message.error($t('common.error'));
}
};
const openAddModal = async () => { const openAddModal = async () => {
editRow.value = {}; editRow.value = {};
userModalApi.open(); userModalApi.open();

View File

@ -12,7 +12,9 @@ import { message as Message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
postOneNETAccountCreate, postOneNETAccountInsert,
postOneNETAccountModify,
postOneNETAccountDelete,
postOneNETAccountInfoPage, postOneNETAccountInfoPage,
} from '#/api-client'; } from '#/api-client';
import { TableAction } from '#/components/table-action'; import { TableAction } from '#/components/table-action';
@ -115,7 +117,7 @@ const [EditForm, editFormApi] = useVbenForm({
async function submit() { async function submit() {
const isEdit = !!editRow.value.id; const isEdit = !!editRow.value.id;
const formApi = isEdit ? editFormApi : addFormApi; const formApi = isEdit ? editFormApi : addFormApi;
const api = postOneNETAccountCreate; const api = isEdit ? postOneNETAccountInsert : postOneNETAccountModify;
const { valid } = await formApi.validate(); const { valid } = await formApi.validate();
if (!valid) return; if (!valid) return;
@ -160,6 +162,28 @@ const openAddModal = async () => {
editRow.value = {}; editRow.value = {};
userModalApi.open(); userModalApi.open();
}; };
//
async function onDel(record: any) {
if (record.productCount > 0) {
Message.warning($t('abp.OneNETManagement.CannotDeleteAccountWithProducts'));
return;
}
try {
const resp = await postOneNETAccountDelete({ body: { id: record.id } });
if (resp.data) {
Message.success($t('common.deleteSuccess'));
gridApi.reload();
} else {
Message.error($t('common.deleteFail'));
}
} catch (error) {
Message.error($t('common.deleteFail'));
}
}
</script> </script>
<template> <template>
@ -192,30 +216,19 @@ const openAddModal = async () => {
icon: 'ant-design:delete-outlined', icon: 'ant-design:delete-outlined',
type: 'primary', type: 'primary',
auth: ['AbpIdentity.Users.Delete'], auth: ['AbpIdentity.Users.Delete'],
disabled: row.productCount > 0,
popConfirm: { popConfirm: {
title: $t('common.askConfirmDelete'), title: row.productCount > 0
? $t('abp.OneNETManagement.CannotDeleteAccountWithProducts')
: $t('common.askConfirmDelete'),
confirm: onDel.bind(null, row), confirm: onDel.bind(null, row),
}, },
}, },
{
label: $t('abp.Account.pointData'),
icon: 'ant-design:profile-outlined',
type: 'primary',
auth: ['AbpIdentity.Users.Delete'],
onClick: toStatusData.bind(null, row),
},
{
label: $t('abp.Account.archivesIssued'),
icon: 'ant-design:cloud-download-outlined',
type: 'primary',
auth: ['AbpIdentity.Users.Delete'],
onClick: archivesIssued.bind(null, row),
},
]" /> ]" />
</template> </template>
</Grid> </Grid>
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]"> <UserModal :title="editRow.value?.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
<component :is="editRow.id ? EditForm : AddForm" /> <component :is="editRow.value?.id ? EditForm : AddForm" />
</UserModal> </UserModal>
</Page> </Page>
</template> </template>

View File

@ -32,7 +32,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
minWidth: '150', minWidth: '150',
}, },
{ {
field: 'accesskey', field: 'accountAccesskey',
title: $t('abp.OneNETManagement.AccountAccesskey'), title: $t('abp.OneNETManagement.AccountAccesskey'),
minWidth: '150', minWidth: '150',
}, },
@ -53,7 +53,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
export const addAccountFormSchema: any = computed(() => [ export const addAccountFormSchema: any = computed(() => [
{ {
component: 'Input', component: 'Input',
fieldName: 'OneNETAccountId', fieldName: 'oneNETAccountId',
label: $t('abp.OneNETManagement.OneNETAccountId'), label: $t('abp.OneNETManagement.OneNETAccountId'),
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETAccountId')}`, message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETAccountId')}`,
@ -82,10 +82,10 @@ export const addAccountFormSchema: any = computed(() => [
rules: z rules: z
.string() .string()
.min(1, { .min(1, {
message: `${$t('common.pleaseInput')}${$t('common.numberType')}${$t('abp.OneNETManagement.PhoneNumber')}`, message: `${$t('common.pleaseInput')}${$t('abp.OneNETManagement.PhoneNumber')}`,
}) })
.refine((value) => /^\d+$/.test(value), { .refine((value) => /^1[3-9]\d{9}$/.test(value), {
message: $t('abp.OneNETManagement.PhoneNumber'), message: $t('common.PhoneNumberFormatError'),
}), }),
}, },
]); ]);
@ -93,23 +93,37 @@ export const addAccountFormSchema: any = computed(() => [
export const editAccountFormSchemaEdit: any = computed(() => [ export const editAccountFormSchemaEdit: any = computed(() => [
{ {
component: 'Input', component: 'Input',
fieldName: 'meterName', fieldName: 'oneNETAccountId',
label: $t('abp.meters.meterName'), label: $t('abp.OneNETManagement.OneNETAccountId'),
disabled: true,
},
{
component: 'Input',
fieldName: 'accountName',
label: $t('abp.OneNETManagement.AccountName'),
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.meters.meterName')}`, message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.AccountName')}`,
}), }),
}, },
{ {
component: 'Input', component: 'Input',
fieldName: 'meterAddress', fieldName: 'accountAccesskey',
label: $t('abp.meters.meterAddress'), label: $t('abp.OneNETManagement.AccountAccesskey'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.AccountAccesskey')}`,
}),
},
{
component: 'Input',
fieldName: 'phoneNumber',
label: $t('abp.OneNETManagement.PhoneNumber'),
rules: z rules: z
.string() .string()
.min(1, { .min(1, {
message: `${$t('common.pleaseInput')}${$t('common.numberType')}${$t('abp.meters.meterAddress')}`, message: `${$t('common.pleaseInput')}${$t('abp.OneNETManagement.PhoneNumber')}`,
}) })
.refine((value) => /^\d+$/.test(value), { .refine((value) => /^1[3-9]\d{9}$/.test(value), {
message: $t('abp.meters.checkmeterAddress'), message: $t('common.PhoneNumberFormatError'),
}), }),
}, },
]); ]);

View File

@ -12,7 +12,6 @@ import { message as Message, Modal, Tag } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
postMetersArchivesDown,
postMetersCreate, postMetersCreate,
postMetersDelete, postMetersDelete,
postMetersPage, postMetersPage,
@ -186,22 +185,6 @@ const toStatusData = (row: Record<string, any>) => {
}, },
}); });
}; };
//
const archivesIssued = async (row: Record<string, any>) => {
const result = await postMetersArchivesDown({
body: {
meterAddress: row.meterAddress,
meterType: row.meterType,
focusAddress: row.focusAddress,
},
});
if (result) {
gridApi.reload();
Message.success($t('common.success'));
} else {
Message.error($t('common.error'));
}
};
const openAddModal = async () => { const openAddModal = async () => {
editRow.value = {}; editRow.value = {};
userModalApi.open(); userModalApi.open();