2025-07-08 16:04:14 +08:00
|
|
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
|
|
|
|
|
|
|
|
|
import { computed } from 'vue';
|
|
|
|
|
|
|
|
|
|
import { z } from '@vben/common-ui';
|
|
|
|
|
|
|
|
|
|
import { $t } from '#/locales';
|
|
|
|
|
|
|
|
|
|
export const querySchema = computed(() => [
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-25 17:27:41 +08:00
|
|
|
fieldName: 'deviceAddress',
|
|
|
|
|
label: $t('abp.deviceInfos.deviceAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
export const meterTypeOptions = [
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.ElectricityMeter'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.waterMeter'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 2,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.GasMeter'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 3,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.HeatMeter'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 4,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.WaterMeterFlowmeter'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 5,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.GasMeterFlowmeter'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 6,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
export const rateOptions = [
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.MultipleRate'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.SingleRate'),
|
2025-07-08 16:04:14 +08:00
|
|
|
value: true,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
|
|
|
|
{ title: $t('common.seq'), type: 'seq', width: 50 },
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'deviceName',
|
|
|
|
|
title: $t('abp.deviceInfos.deviceName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'deviceAddress',
|
|
|
|
|
title: $t('abp.deviceInfos.deviceAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatform',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatform'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatformName',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatformDeviceOpenInfo',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformDeviceOpenInfo'),
|
|
|
|
|
minWidth: '100',
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'platformPassword',
|
|
|
|
|
title: $t('abp.deviceInfos.platformPassword'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatformProductName',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformProductName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatformAccountName',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatformResponse',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformResponse'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: $t('common.action'),
|
|
|
|
|
field: 'action',
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
width: '150',
|
|
|
|
|
slots: { default: 'action' },
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
2025-07-25 17:27:41 +08:00
|
|
|
export const addDeviceFormSchema: any = computed(() => [
|
2025-07-08 16:04:14 +08:00
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-25 17:27:41 +08:00
|
|
|
fieldName: 'deviceAddress',
|
|
|
|
|
label: $t('abp.deviceInfos.deviceAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-25 17:27:41 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-25 17:27:41 +08:00
|
|
|
fieldName: 'platformPassword',
|
|
|
|
|
label: $t('abp.deviceInfos.platformPassword'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.platformPassword')}`,
|
|
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
2025-07-25 17:27:41 +08:00
|
|
|
export const editDeviceFormSchemaEdit: any = computed(() => [
|
2025-07-08 16:04:14 +08:00
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-25 17:27:41 +08:00
|
|
|
fieldName: 'deviceAddress',
|
|
|
|
|
label: $t('abp.deviceInfos.deviceAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-25 17:27:41 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.deviceAddress')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-25 17:27:41 +08:00
|
|
|
fieldName: 'platformPassword',
|
|
|
|
|
label: $t('abp.deviceInfos.platformPassword'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.platformPassword')}`,
|
|
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Select',
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: true,
|
|
|
|
|
options: meterTypeOptions,
|
2025-07-25 17:27:41 +08:00
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.meterType')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
fieldName: 'meterType',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.meterType'),
|
2025-07-08 16:04:14 +08:00
|
|
|
rules: z
|
|
|
|
|
.number()
|
|
|
|
|
.min(1, {
|
2025-07-25 17:27:41 +08:00
|
|
|
message: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.meterType')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
})
|
|
|
|
|
.default(1),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Select',
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: true,
|
|
|
|
|
options: rateOptions,
|
2025-07-25 17:27:41 +08:00
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.singleRate')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
dependencies: {
|
|
|
|
|
show(values: any) {
|
|
|
|
|
return values.meterType === 1;
|
|
|
|
|
},
|
|
|
|
|
rules(values: any) {
|
|
|
|
|
if (values.meterType === 1) {
|
|
|
|
|
return 'required';
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
triggerFields: ['meterType'],
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'singleRate',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.singleRate'),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Switch',
|
|
|
|
|
componentProps: {
|
|
|
|
|
class: 'w-auto',
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'selfDevelop',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.selfDevelop'),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'brandType',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.brandType'),
|
2025-07-08 16:04:14 +08:00
|
|
|
rules: z.string().optional(),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Switch',
|
|
|
|
|
componentProps: {
|
|
|
|
|
class: 'w-auto',
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'dynamicPassword',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.dynamicPassword'),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'password',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.password'),
|
2025-07-08 16:04:14 +08:00
|
|
|
rules: z.string().optional(),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Switch',
|
|
|
|
|
componentProps: {
|
|
|
|
|
class: 'w-auto',
|
|
|
|
|
},
|
|
|
|
|
dependencies: {
|
|
|
|
|
show(values: any) {
|
|
|
|
|
return values.meterType === 2;
|
|
|
|
|
},
|
|
|
|
|
triggerFields: ['meterType'],
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'haveValve',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.haveValve'),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'timesA',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.timesA'),
|
2025-07-08 16:04:14 +08:00
|
|
|
componentProps: {
|
|
|
|
|
allowClear: true,
|
2025-07-25 17:27:41 +08:00
|
|
|
placeholder: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timesA')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
dependencies: {
|
|
|
|
|
show(values: any) {
|
|
|
|
|
return values.meterType === 1;
|
|
|
|
|
},
|
|
|
|
|
triggerFields: ['meterType'],
|
|
|
|
|
},
|
|
|
|
|
rules: z
|
|
|
|
|
.string({
|
2025-07-25 17:27:41 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timesA')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
})
|
|
|
|
|
.default('1'),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'timev',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.timev'),
|
2025-07-08 16:04:14 +08:00
|
|
|
componentProps: {
|
|
|
|
|
allowClear: true,
|
2025-07-25 17:27:41 +08:00
|
|
|
placeholder: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timev')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
dependencies: {
|
|
|
|
|
show(values: any) {
|
|
|
|
|
return values.meterType === 1;
|
|
|
|
|
},
|
|
|
|
|
triggerFields: ['meterType'],
|
|
|
|
|
},
|
|
|
|
|
rules: z
|
|
|
|
|
.string({
|
2025-07-25 17:27:41 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timev')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
})
|
|
|
|
|
.default('1'),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'meteringCode',
|
2025-07-25 17:27:41 +08:00
|
|
|
label: $t('abp.deviceInfos.meteringCode'),
|
2025-07-08 16:04:14 +08:00
|
|
|
componentProps: {
|
|
|
|
|
allowClear: true,
|
2025-07-25 17:27:41 +08:00
|
|
|
placeholder: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.meteringCode')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
rules: z
|
|
|
|
|
.string({
|
2025-07-25 17:27:41 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.meteringCode')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
})
|
|
|
|
|
.min(1, {
|
|
|
|
|
message: `${$t('common.MustGreaterTthan0')}`,
|
|
|
|
|
})
|
|
|
|
|
.default('1'),
|
|
|
|
|
},
|
|
|
|
|
]);
|