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', fieldName: 'deviceAddress', label: $t('abp.deviceInfos.deviceAddress'), }, ]); export const meterTypeOptions = [ { label: $t('abp.deviceInfos.ElectricityMeter'), value: 1, }, { label: $t('abp.deviceInfos.waterMeter'), value: 2, }, { label: $t('abp.deviceInfos.GasMeter'), value: 3, }, { label: $t('abp.deviceInfos.HeatMeter'), value: 4, }, { label: $t('abp.deviceInfos.WaterMeterFlowmeter'), value: 5, }, { label: $t('abp.deviceInfos.GasMeterFlowmeter'), value: 6, }, ]; export const rateOptions = [ { label: $t('abp.deviceInfos.MultipleRate'), value: false, }, { label: $t('abp.deviceInfos.SingleRate'), value: true, }, ]; export const tableSchema: any = computed((): VxeGridProps['columns'] => [ { title: $t('common.seq'), type: 'seq', width: 50 }, { field: 'deviceName', title: $t('abp.deviceInfos.deviceName'), minWidth: '150', }, { field: 'deviceAddress', title: $t('abp.deviceInfos.deviceAddress'), minWidth: '150', }, { field: 'ioTPlatform', title: $t('abp.deviceInfos.ioTPlatform'), minWidth: '150', }, { field: 'ioTPlatformName', title: $t('abp.deviceInfos.ioTPlatformName'), minWidth: '150', }, { field: 'ioTPlatformDeviceOpenInfo', title: $t('abp.deviceInfos.ioTPlatformDeviceOpenInfo'), minWidth: '100', }, { field: 'platformPassword', title: $t('abp.deviceInfos.platformPassword'), minWidth: '150', }, { field: 'ioTPlatformProductName', title: $t('abp.deviceInfos.ioTPlatformProductName'), minWidth: '150', }, { field: 'ioTPlatformAccountName', title: $t('abp.deviceInfos.ioTPlatformAccountName'), minWidth: '150', }, { field: 'ioTPlatformResponse', title: $t('abp.deviceInfos.ioTPlatformResponse'), minWidth: '150', }, { title: $t('common.action'), field: 'action', fixed: 'right', width: '150', slots: { default: 'action' }, }, ]); export const addDeviceFormSchema: any = computed(() => [ { component: 'Input', fieldName: 'deviceAddress', label: $t('abp.deviceInfos.deviceAddress'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`, }), }, { component: 'Input', fieldName: 'platformPassword', label: $t('abp.deviceInfos.platformPassword'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.platformPassword')}`, }), }, ]); export const editDeviceFormSchemaEdit: any = computed(() => [ { component: 'Input', fieldName: 'deviceAddress', label: $t('abp.deviceInfos.deviceAddress'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.deviceAddress')}`, }), }, { component: 'Input', fieldName: 'platformPassword', label: $t('abp.deviceInfos.platformPassword'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.platformPassword')}`, }), }, { component: 'Select', componentProps: { allowClear: true, options: meterTypeOptions, placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.meterType')}`, }, fieldName: 'meterType', label: $t('abp.deviceInfos.meterType'), rules: z .number() .min(1, { message: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.meterType')}`, }) .default(1), }, { component: 'Select', componentProps: { allowClear: true, options: rateOptions, placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.singleRate')}`, }, dependencies: { show(values: any) { return values.meterType === 1; }, rules(values: any) { if (values.meterType === 1) { return 'required'; } return null; }, triggerFields: ['meterType'], }, fieldName: 'singleRate', label: $t('abp.deviceInfos.singleRate'), }, { component: 'Switch', componentProps: { class: 'w-auto', }, fieldName: 'selfDevelop', label: $t('abp.deviceInfos.selfDevelop'), }, { component: 'Input', fieldName: 'brandType', label: $t('abp.deviceInfos.brandType'), rules: z.string().optional(), }, { component: 'Switch', componentProps: { class: 'w-auto', }, fieldName: 'dynamicPassword', label: $t('abp.deviceInfos.dynamicPassword'), }, { component: 'Input', fieldName: 'password', label: $t('abp.deviceInfos.password'), rules: z.string().optional(), }, { component: 'Switch', componentProps: { class: 'w-auto', }, dependencies: { show(values: any) { return values.meterType === 2; }, triggerFields: ['meterType'], }, fieldName: 'haveValve', label: $t('abp.deviceInfos.haveValve'), }, { component: 'Input', fieldName: 'timesA', label: $t('abp.deviceInfos.timesA'), componentProps: { allowClear: true, placeholder: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timesA')}`, }, dependencies: { show(values: any) { return values.meterType === 1; }, triggerFields: ['meterType'], }, rules: z .string({ message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timesA')}`, }) .default('1'), }, { component: 'Input', fieldName: 'timev', label: $t('abp.deviceInfos.timev'), componentProps: { allowClear: true, placeholder: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timev')}`, }, dependencies: { show(values: any) { return values.meterType === 1; }, triggerFields: ['meterType'], }, rules: z .string({ message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.timev')}`, }) .default('1'), }, { component: 'Input', fieldName: 'meteringCode', label: $t('abp.deviceInfos.meteringCode'), componentProps: { allowClear: true, placeholder: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.meteringCode')}`, }, rules: z .string({ message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.meteringCode')}`, }) .min(1, { message: `${$t('common.MustGreaterTthan0')}`, }) .default('1'), }, ]);