oneNET账号管理
This commit is contained in:
parent
7029e3777e
commit
bcc80ab751
@ -24,15 +24,15 @@ import type {
|
||||
IoTDBTreeModelDeviceDataPageAllResponse,
|
||||
IoTDBTreeModelDeviceDataPageDataInput,
|
||||
IoTErrorResponse,
|
||||
OneNETAccountCreateInput,
|
||||
OneNETAccountCreateInput,
|
||||
OneNETAccountCreateResponse,
|
||||
OneNETAccountCreateResponse,
|
||||
OneNetAccountInsertInput,
|
||||
OneNetAccountInsertResponse,
|
||||
OneNetAccountModifyInput,
|
||||
OneNetAccountModifyResponse,
|
||||
OneNetAccountDeleteInput,
|
||||
OneNETAccountDeleteResponse,
|
||||
OneNETAccountPageListInput,
|
||||
OneNETAccountPageListResult,
|
||||
OneNETProductCreateInput,
|
||||
OneNETProductCreateInput,
|
||||
OneNETProductCreateResponse,
|
||||
OneNETProductCreateResponse,
|
||||
OneNETProductPageListInput,
|
||||
OneNETProductPageListResult,
|
||||
@ -3148,7 +3148,6 @@ export const postOneNETAccountInfoPage = <ThrowOnError extends boolean = false>(
|
||||
ThrowOnError
|
||||
>({
|
||||
...options,
|
||||
...formDataBodySerializer,
|
||||
url: '/OneNETAccount/ListAsync',
|
||||
});
|
||||
};
|
||||
@ -3156,20 +3155,51 @@ export const postOneNETAccountInfoPage = <ThrowOnError extends boolean = false>(
|
||||
/**
|
||||
* OneNET 创建账号
|
||||
*/
|
||||
export const postOneNETAccountCreate = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<OneNETAccountCreateInput, ThrowOnError>,
|
||||
export const postOneNETAccountInsert = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<OneNetAccountInsertInput, ThrowOnError>,
|
||||
) => {
|
||||
return (options?.client ?? client).post<
|
||||
OneNETAccountCreateResponse,
|
||||
OneNetAccountInsertResponse,
|
||||
IoTErrorResponse,
|
||||
ThrowOnError
|
||||
>({
|
||||
...options,
|
||||
...formDataBodySerializer,
|
||||
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 产品管理
|
||||
*/
|
||||
|
||||
@ -5178,10 +5178,25 @@ export type OneNETAccountPageListResult = {
|
||||
totalCount?: number;
|
||||
};
|
||||
|
||||
export type OneNETAccountCreateInput = {
|
||||
export type OneNetAccountInsertInput = {
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
@ -52,5 +52,6 @@
|
||||
"exporting": "Exporting data...",
|
||||
"exportSuccess": "Data exported successfully",
|
||||
"exportFailed": "Data export failed",
|
||||
"getDataFailed": "Failed to get data"
|
||||
"getDataFailed": "Failed to get data",
|
||||
"PhoneNumberFormatError": "PhoneNumber Format Error"
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@
|
||||
"DeviceLastActiveTime": "设备最后活跃时间"
|
||||
},
|
||||
"OneNETManagement": {
|
||||
"AccountName": "账号名称",
|
||||
"AccountName": "账号名称",
|
||||
"PhoneNumber": "手机号码",
|
||||
"AccountAccesskey": "账户通信密钥",
|
||||
"ProductCount": "产品数量",
|
||||
|
||||
@ -53,5 +53,6 @@
|
||||
"exportSuccess": "数据导出成功",
|
||||
"exportFailed": "数据导出失败",
|
||||
"getDataFailed": "获取数据失败",
|
||||
"IsEnabled": "是否启用"
|
||||
"IsEnabled": "是否启用",
|
||||
"PhoneNumberFormatError": "手机号码格式错误"
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@ import { message as Message, Modal, Tag } from 'ant-design-vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
postMetersArchivesDown,
|
||||
postMetersCreate,
|
||||
postMetersDelete,
|
||||
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 () => {
|
||||
editRow.value = {};
|
||||
userModalApi.open();
|
||||
|
||||
@ -12,7 +12,6 @@ import { message as Message, Modal, Tag } from 'ant-design-vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
postMetersArchivesDown,
|
||||
postMetersCreate,
|
||||
postMetersDelete,
|
||||
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 () => {
|
||||
editRow.value = {};
|
||||
userModalApi.open();
|
||||
|
||||
@ -12,7 +12,9 @@ import { message as Message } from 'ant-design-vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
postOneNETAccountCreate,
|
||||
postOneNETAccountInsert,
|
||||
postOneNETAccountModify,
|
||||
postOneNETAccountDelete,
|
||||
postOneNETAccountInfoPage,
|
||||
} from '#/api-client';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
@ -115,7 +117,7 @@ const [EditForm, editFormApi] = useVbenForm({
|
||||
async function submit() {
|
||||
const isEdit = !!editRow.value.id;
|
||||
const formApi = isEdit ? editFormApi : addFormApi;
|
||||
const api = postOneNETAccountCreate;
|
||||
const api = isEdit ? postOneNETAccountInsert : postOneNETAccountModify;
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) return;
|
||||
|
||||
@ -160,6 +162,28 @@ const openAddModal = async () => {
|
||||
editRow.value = {};
|
||||
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>
|
||||
|
||||
<template>
|
||||
@ -192,30 +216,19 @@ const openAddModal = async () => {
|
||||
icon: 'ant-design:delete-outlined',
|
||||
type: 'primary',
|
||||
auth: ['AbpIdentity.Users.Delete'],
|
||||
disabled: row.productCount > 0,
|
||||
popConfirm: {
|
||||
title: $t('common.askConfirmDelete'),
|
||||
title: row.productCount > 0
|
||||
? $t('abp.OneNETManagement.CannotDeleteAccountWithProducts')
|
||||
: $t('common.askConfirmDelete'),
|
||||
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>
|
||||
</Grid>
|
||||
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||
<component :is="editRow.id ? EditForm : AddForm" />
|
||||
<UserModal :title="editRow.value?.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||
<component :is="editRow.value?.id ? EditForm : AddForm" />
|
||||
</UserModal>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@ -32,7 +32,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
minWidth: '150',
|
||||
},
|
||||
{
|
||||
field: 'accesskey',
|
||||
field: 'accountAccesskey',
|
||||
title: $t('abp.OneNETManagement.AccountAccesskey'),
|
||||
minWidth: '150',
|
||||
},
|
||||
@ -53,7 +53,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
export const addAccountFormSchema: any = computed(() => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'OneNETAccountId',
|
||||
fieldName: 'oneNETAccountId',
|
||||
label: $t('abp.OneNETManagement.OneNETAccountId'),
|
||||
rules: z.string().min(1, {
|
||||
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETAccountId')}`,
|
||||
@ -82,10 +82,10 @@ export const addAccountFormSchema: any = computed(() => [
|
||||
rules: z
|
||||
.string()
|
||||
.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), {
|
||||
message: $t('abp.OneNETManagement.PhoneNumber'),
|
||||
.refine((value) => /^1[3-9]\d{9}$/.test(value), {
|
||||
message: $t('common.PhoneNumberFormatError'),
|
||||
}),
|
||||
},
|
||||
]);
|
||||
@ -93,23 +93,37 @@ export const addAccountFormSchema: any = computed(() => [
|
||||
export const editAccountFormSchemaEdit: any = computed(() => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'meterName',
|
||||
label: $t('abp.meters.meterName'),
|
||||
fieldName: 'oneNETAccountId',
|
||||
label: $t('abp.OneNETManagement.OneNETAccountId'),
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'accountName',
|
||||
label: $t('abp.OneNETManagement.AccountName'),
|
||||
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',
|
||||
fieldName: 'meterAddress',
|
||||
label: $t('abp.meters.meterAddress'),
|
||||
fieldName: 'accountAccesskey',
|
||||
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
|
||||
.string()
|
||||
.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), {
|
||||
message: $t('abp.meters.checkmeterAddress'),
|
||||
.refine((value) => /^1[3-9]\d{9}$/.test(value), {
|
||||
message: $t('common.PhoneNumberFormatError'),
|
||||
}),
|
||||
},
|
||||
]);
|
||||
|
||||
@ -12,7 +12,6 @@ import { message as Message, Modal, Tag } from 'ant-design-vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
postMetersArchivesDown,
|
||||
postMetersCreate,
|
||||
postMetersDelete,
|
||||
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 () => {
|
||||
editRow.value = {};
|
||||
userModalApi.open();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user