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 { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
postDeviceInfoArchivesDown,
|
||||
postAggregationDeviceCreateAsync,
|
||||
postAggregationDeviceDeleteAsync,
|
||||
postDeviceInfoArchivesDown,
|
||||
postDeviceInfoPage,
|
||||
postAggregationDeviceFindByIdAsync,
|
||||
} from '#/api-client';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { $t } from '#/locales';
|
||||
@ -123,11 +122,11 @@ async function submit() {
|
||||
if (!valid) return;
|
||||
|
||||
const formValues = await formApi.getValues();
|
||||
|
||||
|
||||
// 根据平台类型处理数据
|
||||
let processedFormValues = { ...formValues };
|
||||
|
||||
if (formValues.ioTPlatform === '2') {
|
||||
const processedFormValues = { ...formValues };
|
||||
|
||||
if (formValues.ioTPlatform === 2 || formValues.ioTPlatform === '2') {
|
||||
// OneNET平台
|
||||
processedFormValues.ioTPlatformAccountId = formValues.oneNETAccountId;
|
||||
processedFormValues.ioTPlatformProductId = formValues.oneNETProductId;
|
||||
@ -136,7 +135,7 @@ async function submit() {
|
||||
delete processedFormValues.oneNETProductId;
|
||||
delete processedFormValues.ctWingAccountId;
|
||||
delete processedFormValues.ctWingProductId;
|
||||
} else if (formValues.ioTPlatform === '1') {
|
||||
} else if (formValues.ioTPlatform === 1 || formValues.ioTPlatform === '1') {
|
||||
// CTWing平台
|
||||
processedFormValues.ioTPlatformAccountId = formValues.ctWingAccountId;
|
||||
processedFormValues.ioTPlatformProductId = formValues.ctWingProductId;
|
||||
@ -184,10 +183,10 @@ async function submit() {
|
||||
async function onEdit(record: any) {
|
||||
editRow.value = record;
|
||||
userModalApi.open();
|
||||
|
||||
|
||||
// 根据平台类型设置表单值
|
||||
const formValues = { ...record };
|
||||
|
||||
|
||||
if (record.ioTPlatform === 2 || record.ioTPlatform === '2') {
|
||||
// OneNET平台
|
||||
formValues.oneNETAccountId = record.ioTPlatformAccountId;
|
||||
@ -197,7 +196,7 @@ async function onEdit(record: any) {
|
||||
formValues.ctWingAccountId = record.ioTPlatformAccountId;
|
||||
formValues.ctWingProductId = record.ioTPlatformProductId;
|
||||
}
|
||||
|
||||
|
||||
editFormApi.setValues(formValues);
|
||||
}
|
||||
|
||||
@ -206,7 +205,9 @@ function onDel(row: any) {
|
||||
title: `${$t('common.confirmDelete')}${row.deviceName || row.deviceAddress} ?`,
|
||||
onOk: async () => {
|
||||
try {
|
||||
const result = await postAggregationDeviceDeleteAsync({ body: { id: row.id } });
|
||||
const result = await postAggregationDeviceDeleteAsync({
|
||||
body: { id: row.id },
|
||||
});
|
||||
if (result.data) {
|
||||
gridApi.reload();
|
||||
Message.success($t('common.deleteSuccess'));
|
||||
@ -262,23 +263,19 @@ const openAddModal = async () => {
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.add'),
|
||||
type: 'primary',
|
||||
icon: 'ant-design:plus-outlined',
|
||||
onClick: openAddModal.bind(null),
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
},
|
||||
]" />
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.add'),
|
||||
type: 'primary',
|
||||
icon: 'ant-design:plus-outlined',
|
||||
onClick: openAddModal.bind(null),
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</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 }">
|
||||
{{
|
||||
row.archiveStatus ? $t('common.Issued') : $t('common.Undistributed')
|
||||
@ -288,40 +285,54 @@ const openAddModal = async () => {
|
||||
{{ row.tripState ? $t('common.SwitchOff') : $t('common.Closing') }}
|
||||
</template>
|
||||
<template #isHaveValve="{ row }">
|
||||
<component :is="h(Tag, { color: row.haveValve ? 'green' : 'red' }, () =>
|
||||
row.haveValve ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
" />
|
||||
<component
|
||||
:is="
|
||||
h(Tag, { color: row.haveValve ? 'green' : 'red' }, () =>
|
||||
row.haveValve ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<template #isSelfDevelop="{ row }">
|
||||
<component :is="h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
|
||||
row.selfDevelop ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
" />
|
||||
<component
|
||||
:is="
|
||||
h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
|
||||
row.selfDevelop ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<template #isDynamicPassword="{ row }">
|
||||
<component :is="h(Tag, { color: row.dynamicPassword ? 'green' : 'red' }, () =>
|
||||
row.dynamicPassword ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
" />
|
||||
<component
|
||||
:is="
|
||||
h(Tag, { color: row.dynamicPassword ? 'green' : 'red' }, () =>
|
||||
row.dynamicPassword ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<template #isEnable="{ row }">
|
||||
<component :is="h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
|
||||
row.enabled ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
" />
|
||||
<component
|
||||
:is="
|
||||
h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
|
||||
row.enabled ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: onEdit.bind(null, row),
|
||||
},
|
||||
]" :drop-down-actions="[
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: onEdit.bind(null, row),
|
||||
},
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
icon: 'ant-design:delete-outlined',
|
||||
@ -346,10 +357,14 @@ const openAddModal = async () => {
|
||||
auth: ['AbpIdentity.Users.Delete'],
|
||||
onClick: archivesIssued.bind(null, row),
|
||||
},
|
||||
]" />
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</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" />
|
||||
</UserModal>
|
||||
</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'] => [
|
||||
{ title: $t('common.seq'), type: 'seq', width: 50 },
|
||||
{
|
||||
@ -134,10 +120,10 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '2'; // OneNET平台
|
||||
return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '2') {
|
||||
if (values.ioTPlatform === 2 || values.ioTPlatform === '2') {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
@ -187,15 +173,15 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '1'; // CTWing平台
|
||||
return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '1') {
|
||||
if (values.ioTPlatform === 1 || values.ioTPlatform === '1') {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
triggerFields: ['ioTPlatform'],
|
||||
triggerFields: ['ioTPlatform'], // 添加这一行,使其能够响应平台切换
|
||||
},
|
||||
componentProps: {
|
||||
api: postCtWingAccountListAsync,
|
||||
@ -206,7 +192,7 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
},
|
||||
},
|
||||
labelField: 'accountName',
|
||||
valueField: 'ctWingAccountId',
|
||||
valueField: 'accountId',
|
||||
immediate: true,
|
||||
afterFetch: (res: any) => {
|
||||
// 如果是 Axios 响应对象,提取 data
|
||||
@ -240,10 +226,16 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '2' && values.oneNETAccountId; // OneNET平台且已选择账号
|
||||
return (
|
||||
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||
values.oneNETAccountId
|
||||
); // OneNET平台且已选择账号
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '2' && values.oneNETAccountId) {
|
||||
if (
|
||||
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||
values.oneNETAccountId
|
||||
) {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
@ -297,10 +289,16 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '1' && values.ctWingAccountId; // CTWing平台且已选择账号
|
||||
return (
|
||||
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||
values.ctWingAccountId
|
||||
); // CTWing平台且已选择账号
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '1' && values.ctWingAccountId) {
|
||||
if (
|
||||
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||
values.ctWingAccountId
|
||||
) {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
@ -334,9 +332,10 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
items = data.data;
|
||||
}
|
||||
|
||||
// 为每个产品项添加组合标签
|
||||
// 为每个产品项添加组合标签,并确保产品ID是字符串类型
|
||||
return items.map((item: any) => ({
|
||||
...item,
|
||||
ioTPlatformProductId: String(item.ioTPlatformProductId || ''),
|
||||
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
||||
}));
|
||||
}
|
||||
@ -401,10 +400,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '2'; // OneNET平台
|
||||
return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '2') {
|
||||
if (values.ioTPlatform === 2 || values.ioTPlatform === '2') {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
@ -454,10 +453,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '1'; // CTWing平台
|
||||
return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '1') {
|
||||
if (values.ioTPlatform === 1 || values.ioTPlatform === '1') {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
@ -507,10 +506,16 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '2' && values.oneNETAccountId; // OneNET平台且已选择账号
|
||||
return (
|
||||
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||
values.oneNETAccountId
|
||||
); // OneNET平台且已选择账号
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '2' && values.oneNETAccountId) {
|
||||
if (
|
||||
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
||||
values.oneNETAccountId
|
||||
) {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
@ -564,10 +569,16 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return values.ioTPlatform === '1' && values.ctWingAccountId; // CTWing平台且已选择账号
|
||||
return (
|
||||
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||
values.ctWingAccountId
|
||||
); // CTWing平台且已选择账号
|
||||
},
|
||||
rules(values: any) {
|
||||
if (values.ioTPlatform === '1' && values.ctWingAccountId) {
|
||||
if (
|
||||
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
||||
values.ctWingAccountId
|
||||
) {
|
||||
return 'required';
|
||||
}
|
||||
return null;
|
||||
@ -601,9 +612,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
items = data.data;
|
||||
}
|
||||
|
||||
// 为每个产品项添加组合标签
|
||||
// 为每个产品项添加组合标签,并确保产品ID是字符串类型
|
||||
return items.map((item: any) => ({
|
||||
...item,
|
||||
ioTPlatformProductId: String(item.ioTPlatformProductId || ''),
|
||||
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
||||
}));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user