refactor(property): 重构能源管理相关页面布局
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form'
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table'
|
||||
|
||||
import { getDictOptions } from '#/utils/dict'
|
||||
import { renderDict } from '#/utils/render'
|
||||
|
||||
export function initMoalForm(type: number) {
|
||||
const modalSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '仪表名称',
|
||||
fieldName: 'meterName',
|
||||
component: 'Input',
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
label: '仪表编码',
|
||||
fieldName: 'meterCode',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '设备厂商',
|
||||
fieldName: 'factoryNo',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: type === 1 ? '设备类型(电表)' : type === 2 ? '设备类型(水表)' : '设备类型(气表)',
|
||||
fieldName: 'meterType',
|
||||
component: 'Select',
|
||||
defaultValue: type.toString(),
|
||||
disabled: true,
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.METER_TYPE 便于维护
|
||||
options: getDictOptions('meter_type'),
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
label: type === 1 ? '计量单位(度)' : type === 2 ? '计量单位(吨)' : '计量单位(立方米)',
|
||||
fieldName: 'meterUnit',
|
||||
component: 'Select',
|
||||
defaultValue: type.toString(),
|
||||
disabled: true,
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.METER_UNIT 便于维护
|
||||
options: getDictOptions('meter_unit'),
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
label: '安装位置',
|
||||
fieldName: 'installLocation',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '初始读数',
|
||||
fieldName: 'initReading',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '最大量程',
|
||||
fieldName: 'maxRang',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '通信状态',
|
||||
fieldName: 'communicationState',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.SIS_DEVICE_STATUS 便于维护
|
||||
options: getDictOptions('sis_device_status'),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '运行状态',
|
||||
fieldName: 'runningState',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.SIS_DEVICE_STATUS 便于维护
|
||||
options: getDictOptions('sis_device_status'),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Textarea',
|
||||
},
|
||||
]
|
||||
|
||||
return modalSchema
|
||||
}
|
||||
|
||||
export function initQuerySchema(type: number) {
|
||||
const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'meterName',
|
||||
label: '仪表名称',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'meterCode',
|
||||
label: '仪表编码',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
disabled: true,
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.METER_TYPE 便于维护
|
||||
options: getDictOptions('meter_type'),
|
||||
},
|
||||
defaultValue: type.toString(),
|
||||
fieldName: 'meterType',
|
||||
label: '设备类型',
|
||||
}
|
||||
]
|
||||
|
||||
return querySchema
|
||||
}
|
||||
|
||||
export function initColumns(type: number) {
|
||||
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||
const columns: VxeGridProps['columns'] = [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
title: '仪表名称',
|
||||
field: 'meterName',
|
||||
},
|
||||
{
|
||||
title: '仪表编码',
|
||||
field: 'meterCode',
|
||||
},
|
||||
{
|
||||
title: '设备厂商',
|
||||
field: 'factoryNo',
|
||||
},
|
||||
{
|
||||
title: type === 1 ? '设备类型(电表)' : type === 2 ? '设备类型(水表)' : '设备类型(气表)',
|
||||
field: 'meterType',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
// 可选从DictEnum中获取 DictEnum.METER_TYPE 便于维护
|
||||
return renderDict(row.meterType, 'meter_type')
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: type === 1 ? '计量单位(度)' : type === 2 ? '计量单位(吨)' : '计量单位(立方米)',
|
||||
field: 'meterUnit',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
// 可选从DictEnum中获取 DictEnum.METER_UNIT 便于维护
|
||||
return renderDict(row.meterUnit, 'meter_unit')
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '安装位置',
|
||||
field: 'installLocation',
|
||||
},
|
||||
{
|
||||
title: '初始读数',
|
||||
field: 'initReading',
|
||||
},
|
||||
{
|
||||
title: '最大量程',
|
||||
field: 'maxRang',
|
||||
},
|
||||
{
|
||||
title: '通信状态',
|
||||
field: 'communicationState',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
// 可选从DictEnum中获取 DictEnum.SIS_DEVICE_STATUS 便于维护
|
||||
return renderDict(row.communicationState, 'sis_device_status')
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '运行状态',
|
||||
field: 'runningState',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
// 可选从DictEnum中获取 DictEnum.SIS_DEVICE_STATUS 便于维护
|
||||
return renderDict(row.runningState, 'sis_device_status')
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
field: 'remark',
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
title: '操作',
|
||||
width: 180,
|
||||
},
|
||||
]
|
||||
return columns
|
||||
}
|
Reference in New Issue
Block a user