feat: 添加新功能
This commit is contained in:
parent
a894b1d510
commit
4185ad0d10
@ -12,11 +12,10 @@ 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 {
|
||||||
postDeviceInfoArchivesDown,
|
|
||||||
postAggregationDeviceCreateAsync,
|
postAggregationDeviceCreateAsync,
|
||||||
postAggregationDeviceDeleteAsync,
|
postAggregationDeviceDeleteAsync,
|
||||||
|
postDeviceInfoArchivesDown,
|
||||||
postDeviceInfoPage,
|
postDeviceInfoPage,
|
||||||
postAggregationDeviceFindByIdAsync,
|
|
||||||
} from '#/api-client';
|
} from '#/api-client';
|
||||||
import { TableAction } from '#/components/table-action';
|
import { TableAction } from '#/components/table-action';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@ -125,9 +124,9 @@ async function submit() {
|
|||||||
const formValues = await formApi.getValues();
|
const formValues = await formApi.getValues();
|
||||||
|
|
||||||
// 根据平台类型处理数据
|
// 根据平台类型处理数据
|
||||||
let processedFormValues = { ...formValues };
|
const processedFormValues = { ...formValues };
|
||||||
|
|
||||||
if (formValues.ioTPlatform === '2') {
|
if (formValues.ioTPlatform === 2 || formValues.ioTPlatform === '2') {
|
||||||
// OneNET平台
|
// OneNET平台
|
||||||
processedFormValues.ioTPlatformAccountId = formValues.oneNETAccountId;
|
processedFormValues.ioTPlatformAccountId = formValues.oneNETAccountId;
|
||||||
processedFormValues.ioTPlatformProductId = formValues.oneNETProductId;
|
processedFormValues.ioTPlatformProductId = formValues.oneNETProductId;
|
||||||
@ -136,7 +135,7 @@ async function submit() {
|
|||||||
delete processedFormValues.oneNETProductId;
|
delete processedFormValues.oneNETProductId;
|
||||||
delete processedFormValues.ctWingAccountId;
|
delete processedFormValues.ctWingAccountId;
|
||||||
delete processedFormValues.ctWingProductId;
|
delete processedFormValues.ctWingProductId;
|
||||||
} else if (formValues.ioTPlatform === '1') {
|
} else if (formValues.ioTPlatform === 1 || formValues.ioTPlatform === '1') {
|
||||||
// CTWing平台
|
// CTWing平台
|
||||||
processedFormValues.ioTPlatformAccountId = formValues.ctWingAccountId;
|
processedFormValues.ioTPlatformAccountId = formValues.ctWingAccountId;
|
||||||
processedFormValues.ioTPlatformProductId = formValues.ctWingProductId;
|
processedFormValues.ioTPlatformProductId = formValues.ctWingProductId;
|
||||||
@ -206,7 +205,9 @@ function onDel(row: any) {
|
|||||||
title: `${$t('common.confirmDelete')}${row.deviceName || row.deviceAddress} ?`,
|
title: `${$t('common.confirmDelete')}${row.deviceName || row.deviceAddress} ?`,
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
try {
|
try {
|
||||||
const result = await postAggregationDeviceDeleteAsync({ body: { id: row.id } });
|
const result = await postAggregationDeviceDeleteAsync({
|
||||||
|
body: { id: row.id },
|
||||||
|
});
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
gridApi.reload();
|
gridApi.reload();
|
||||||
Message.success($t('common.deleteSuccess'));
|
Message.success($t('common.deleteSuccess'));
|
||||||
@ -262,7 +263,8 @@ const openAddModal = async () => {
|
|||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<Grid>
|
<Grid>
|
||||||
<template #toolbar-actions>
|
<template #toolbar-actions>
|
||||||
<TableAction :actions="[
|
<TableAction
|
||||||
|
:actions="[
|
||||||
{
|
{
|
||||||
label: $t('common.add'),
|
label: $t('common.add'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
@ -270,15 +272,10 @@ const openAddModal = async () => {
|
|||||||
onClick: openAddModal.bind(null),
|
onClick: openAddModal.bind(null),
|
||||||
auth: ['AbpIdentity.Users.Create'],
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
},
|
},
|
||||||
]" />
|
]"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #isMeterType="{ row }">
|
|
||||||
{{ meterTypeOptions[row.meterType - 1]?.label }}
|
|
||||||
</template>
|
|
||||||
<template #isSingleRate="{ row }">
|
|
||||||
{{rateOptions.find((item) => item.value === row.singleRate)?.label}}
|
|
||||||
</template>
|
|
||||||
<template #isArchiveStatus="{ row }">
|
<template #isArchiveStatus="{ row }">
|
||||||
{{
|
{{
|
||||||
row.archiveStatus ? $t('common.Issued') : $t('common.Undistributed')
|
row.archiveStatus ? $t('common.Issued') : $t('common.Undistributed')
|
||||||
@ -288,32 +285,45 @@ const openAddModal = async () => {
|
|||||||
{{ row.tripState ? $t('common.SwitchOff') : $t('common.Closing') }}
|
{{ row.tripState ? $t('common.SwitchOff') : $t('common.Closing') }}
|
||||||
</template>
|
</template>
|
||||||
<template #isHaveValve="{ row }">
|
<template #isHaveValve="{ row }">
|
||||||
<component :is="h(Tag, { color: row.haveValve ? 'green' : 'red' }, () =>
|
<component
|
||||||
|
:is="
|
||||||
|
h(Tag, { color: row.haveValve ? 'green' : 'red' }, () =>
|
||||||
row.haveValve ? $t('common.yes') : $t('common.no'),
|
row.haveValve ? $t('common.yes') : $t('common.no'),
|
||||||
)
|
)
|
||||||
" />
|
"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #isSelfDevelop="{ row }">
|
<template #isSelfDevelop="{ row }">
|
||||||
<component :is="h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
|
<component
|
||||||
|
:is="
|
||||||
|
h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
|
||||||
row.selfDevelop ? $t('common.yes') : $t('common.no'),
|
row.selfDevelop ? $t('common.yes') : $t('common.no'),
|
||||||
)
|
)
|
||||||
" />
|
"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #isDynamicPassword="{ row }">
|
<template #isDynamicPassword="{ row }">
|
||||||
<component :is="h(Tag, { color: row.dynamicPassword ? 'green' : 'red' }, () =>
|
<component
|
||||||
|
:is="
|
||||||
|
h(Tag, { color: row.dynamicPassword ? 'green' : 'red' }, () =>
|
||||||
row.dynamicPassword ? $t('common.yes') : $t('common.no'),
|
row.dynamicPassword ? $t('common.yes') : $t('common.no'),
|
||||||
)
|
)
|
||||||
" />
|
"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #isEnable="{ row }">
|
<template #isEnable="{ row }">
|
||||||
<component :is="h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
|
<component
|
||||||
|
:is="
|
||||||
|
h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
|
||||||
row.enabled ? $t('common.yes') : $t('common.no'),
|
row.enabled ? $t('common.yes') : $t('common.no'),
|
||||||
)
|
)
|
||||||
" />
|
"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<TableAction :actions="[
|
<TableAction
|
||||||
|
:actions="[
|
||||||
{
|
{
|
||||||
label: $t('common.edit'),
|
label: $t('common.edit'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
@ -321,7 +331,8 @@ const openAddModal = async () => {
|
|||||||
auth: ['AbpIdentity.Users.Update'],
|
auth: ['AbpIdentity.Users.Update'],
|
||||||
onClick: onEdit.bind(null, row),
|
onClick: onEdit.bind(null, row),
|
||||||
},
|
},
|
||||||
]" :drop-down-actions="[
|
]"
|
||||||
|
:drop-down-actions="[
|
||||||
{
|
{
|
||||||
label: $t('common.delete'),
|
label: $t('common.delete'),
|
||||||
icon: 'ant-design:delete-outlined',
|
icon: 'ant-design:delete-outlined',
|
||||||
@ -346,10 +357,14 @@ const openAddModal = async () => {
|
|||||||
auth: ['AbpIdentity.Users.Delete'],
|
auth: ['AbpIdentity.Users.Delete'],
|
||||||
onClick: archivesIssued.bind(null, row),
|
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.id ? $t('common.edit') : $t('common.add')"
|
||||||
|
class="w-[800px]"
|
||||||
|
>
|
||||||
<component :is="editRow.id ? EditForm : AddForm" />
|
<component :is="editRow.id ? EditForm : AddForm" />
|
||||||
</UserModal>
|
</UserModal>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@ -21,20 +21,6 @@ export const querySchema = computed(() => [
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const ioTPlatformOptions = [
|
|
||||||
{
|
|
||||||
label: 'OneNET',
|
|
||||||
value: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'CTWing',
|
|
||||||
value: 2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Other',
|
|
||||||
value: 0,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||||
{ title: $t('common.seq'), type: 'seq', width: 50 },
|
{ title: $t('common.seq'), type: 'seq', width: 50 },
|
||||||
{
|
{
|
||||||
@ -134,10 +120,10 @@ export const addDeviceFormSchema: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '2'; // OneNET平台
|
return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '2') {
|
if (values.ioTPlatform === 2 || values.ioTPlatform === '2') {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -187,15 +173,15 @@ export const addDeviceFormSchema: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '1'; // CTWing平台
|
return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '1') {
|
if (values.ioTPlatform === 1 || values.ioTPlatform === '1') {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
triggerFields: ['ioTPlatform'],
|
triggerFields: ['ioTPlatform'], // 添加这一行,使其能够响应平台切换
|
||||||
},
|
},
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: postCtWingAccountListAsync,
|
api: postCtWingAccountListAsync,
|
||||||
@ -206,7 +192,7 @@ export const addDeviceFormSchema: any = computed(() => [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
labelField: 'accountName',
|
labelField: 'accountName',
|
||||||
valueField: 'ctWingAccountId',
|
valueField: 'accountId',
|
||||||
immediate: true,
|
immediate: true,
|
||||||
afterFetch: (res: any) => {
|
afterFetch: (res: any) => {
|
||||||
// 如果是 Axios 响应对象,提取 data
|
// 如果是 Axios 响应对象,提取 data
|
||||||
@ -240,10 +226,16 @@ export const addDeviceFormSchema: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '2' && values.oneNETAccountId; // OneNET平台且已选择账号
|
return (
|
||||||
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||||
|
values.oneNETAccountId
|
||||||
|
); // OneNET平台且已选择账号
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '2' && values.oneNETAccountId) {
|
if (
|
||||||
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||||
|
values.oneNETAccountId
|
||||||
|
) {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -297,10 +289,16 @@ export const addDeviceFormSchema: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '1' && values.ctWingAccountId; // CTWing平台且已选择账号
|
return (
|
||||||
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||||
|
values.ctWingAccountId
|
||||||
|
); // CTWing平台且已选择账号
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '1' && values.ctWingAccountId) {
|
if (
|
||||||
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||||
|
values.ctWingAccountId
|
||||||
|
) {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -334,9 +332,10 @@ export const addDeviceFormSchema: any = computed(() => [
|
|||||||
items = data.data;
|
items = data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为每个产品项添加组合标签
|
// 为每个产品项添加组合标签,并确保产品ID是字符串类型
|
||||||
return items.map((item: any) => ({
|
return items.map((item: any) => ({
|
||||||
...item,
|
...item,
|
||||||
|
ioTPlatformProductId: String(item.ioTPlatformProductId || ''),
|
||||||
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -401,10 +400,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '2'; // OneNET平台
|
return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '2') {
|
if (values.ioTPlatform === 2 || values.ioTPlatform === '2') {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -454,10 +453,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '1'; // CTWing平台
|
return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '1') {
|
if (values.ioTPlatform === 1 || values.ioTPlatform === '1') {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -507,10 +506,16 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '2' && values.oneNETAccountId; // OneNET平台且已选择账号
|
return (
|
||||||
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||||
|
values.oneNETAccountId
|
||||||
|
); // OneNET平台且已选择账号
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '2' && values.oneNETAccountId) {
|
if (
|
||||||
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||||
|
values.oneNETAccountId
|
||||||
|
) {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -564,10 +569,16 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
|||||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show(values: any) {
|
show(values: any) {
|
||||||
return values.ioTPlatform === '1' && values.ctWingAccountId; // CTWing平台且已选择账号
|
return (
|
||||||
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||||
|
values.ctWingAccountId
|
||||||
|
); // CTWing平台且已选择账号
|
||||||
},
|
},
|
||||||
rules(values: any) {
|
rules(values: any) {
|
||||||
if (values.ioTPlatform === '1' && values.ctWingAccountId) {
|
if (
|
||||||
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||||
|
values.ctWingAccountId
|
||||||
|
) {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -601,9 +612,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
|||||||
items = data.data;
|
items = data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为每个产品项添加组合标签
|
// 为每个产品项添加组合标签,并确保产品ID是字符串类型
|
||||||
return items.map((item: any) => ({
|
return items.map((item: any) => ({
|
||||||
...item,
|
...item,
|
||||||
|
ioTPlatformProductId: String(item.ioTPlatformProductId || ''),
|
||||||
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user