|
|
@ -1,142 +1,191 @@ |
|
|
|
import { dateUtil } from '/nerv-lib/util/date-util'; |
|
|
|
import data from './mock.json'; |
|
|
|
export const tableConfig = { |
|
|
|
title: '设备台账', |
|
|
|
// api: '/carbon_emission/device/getDeviceList',
|
|
|
|
value: data.dataSource, |
|
|
|
import { device } from '/@/api/deviceManage'; |
|
|
|
import { ref } from 'vue'; |
|
|
|
import { http } from '/nerv-lib/util'; |
|
|
|
|
|
|
|
export const tableConfig = (orgId) => { |
|
|
|
return ref({ |
|
|
|
title: '设备信息', |
|
|
|
api: device.queryDevicePage, |
|
|
|
params: { orgId }, |
|
|
|
treeConfig: { |
|
|
|
header: { |
|
|
|
icon: 'orgLink', |
|
|
|
title: '设备类别', |
|
|
|
}, |
|
|
|
params: { orgId }, |
|
|
|
dynamicParams: 'code', |
|
|
|
defaultExpandAll: true, |
|
|
|
api: () => { |
|
|
|
return new Promise((resolve) => { |
|
|
|
setTimeout(() => { |
|
|
|
resolve(data); |
|
|
|
}, 100); |
|
|
|
}); |
|
|
|
}, |
|
|
|
api: device.queryDeviceTree, |
|
|
|
fieldNames: { title: 'deviceType', key: 'code' }, |
|
|
|
formConfig: { |
|
|
|
schemas: [ |
|
|
|
{ |
|
|
|
field: 'name', |
|
|
|
field: 'deviceType', |
|
|
|
label: '设备名称', |
|
|
|
component: 'NsInput', |
|
|
|
autoSubmit: true, |
|
|
|
componentProps: { |
|
|
|
placeholder: '请输入', |
|
|
|
placeholder: '请输入设备类型', |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
params: { |
|
|
|
page: 0, |
|
|
|
pageSize: 10, |
|
|
|
}, |
|
|
|
rowSelection: null, |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
title: '设备名称', |
|
|
|
dataIndex: 'id', |
|
|
|
dataIndex: 'deviceName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备型号', |
|
|
|
dataIndex: 'deviceCode', |
|
|
|
dataIndex: 'deviceModel', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'SN码', |
|
|
|
dataIndex: 'deviceName', |
|
|
|
textNumber: 8, |
|
|
|
dataIndex: 'snCode', |
|
|
|
textNumber: 5, |
|
|
|
textEllipsis: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备一级区域', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'device1Area', |
|
|
|
textNumber: 5, |
|
|
|
textEllipsis: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备二级区域', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'device2Area', |
|
|
|
textNumber: 5, |
|
|
|
textEllipsis: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备详细位置', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'deviceAddress', |
|
|
|
textNumber: 5, |
|
|
|
textEllipsis: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备规格', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'deviceTp', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备厂商纳税人识别号', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'deviceRatepay', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备厂商', |
|
|
|
dataIndex: 'manufacturer', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '厂商联系人', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'contactPerson', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备描述', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'deviceDesc', |
|
|
|
textNumber: 5, |
|
|
|
textEllipsis: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'IP地址', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'ipAddress', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '生产日期', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'manufactureDate', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '采购日期', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'purchaseDate', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '启用日期', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'startDate', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备成本(元)', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'equipmentCost', |
|
|
|
textNumber: 6, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '使用期限', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'usagePeriod', |
|
|
|
textNumber: 4, |
|
|
|
customRender: ({ value }) => `${value}年`, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '额定功率', |
|
|
|
dataIndex: 'position', |
|
|
|
dataIndex: 'ratedPower', |
|
|
|
textNumber: 5, |
|
|
|
// customRender: ({ value }) => `${value}年`,
|
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '特殊参数', |
|
|
|
dataIndex: 'position', |
|
|
|
textNumber: 5, |
|
|
|
dataIndex: 'specialParameters', |
|
|
|
}, |
|
|
|
], |
|
|
|
|
|
|
|
formConfig: { |
|
|
|
schemas: [ |
|
|
|
{ |
|
|
|
field: 'name', |
|
|
|
field: 'deviceName', |
|
|
|
label: '设备名称', |
|
|
|
component: 'NsInput', |
|
|
|
componentProps: { |
|
|
|
placeholder: '请输入', |
|
|
|
placeholder: '请输入设备名称', |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'provider', |
|
|
|
label: '设备厂商', |
|
|
|
component: 'NsInput', |
|
|
|
field: 'areas', |
|
|
|
label: '设备区域', |
|
|
|
component: 'NsCascader', |
|
|
|
format: (record) => { |
|
|
|
console.log(record); |
|
|
|
|
|
|
|
return record?.reduce( |
|
|
|
(pre, cur) => { |
|
|
|
const len = cur?.length - 1; |
|
|
|
pre[len].push(cur[len]); |
|
|
|
return pre; |
|
|
|
}, |
|
|
|
[[], []], |
|
|
|
); |
|
|
|
}, |
|
|
|
fieldMap: ['area1', 'area2'], |
|
|
|
componentProps: { |
|
|
|
placeholder: '请输入', |
|
|
|
placeholder: '请选择设备区域', |
|
|
|
multiple: true, |
|
|
|
loadData: (selectedOptions, options) => { |
|
|
|
const targetOption = selectedOptions[selectedOptions.length - 1]; |
|
|
|
if (!selectedOptions.length) { |
|
|
|
http.post(device.dropArea, { orgId }).then((res) => { |
|
|
|
options.value = res.data?.map((item) => { |
|
|
|
return { label: item, value: item, children: [], isLeaf: false }; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
const value = targetOption?.value; |
|
|
|
if (targetOption) { |
|
|
|
targetOption.loading = true; |
|
|
|
http.post(device.dropArea, { device1Area: value, orgId }).then((res) => { |
|
|
|
targetOption.loading = false; |
|
|
|
targetOption.children = res.data?.map((item) => { |
|
|
|
return { label: item, value: item, children: [], isLeaf: true }; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'payWay', |
|
|
|
label: '设备区域', |
|
|
|
component: 'NsSelect', |
|
|
|
field: 'manufacturer', |
|
|
|
label: '设备厂商', |
|
|
|
component: 'NsInput', |
|
|
|
componentProps: { |
|
|
|
placeholder: '请选择', |
|
|
|
placeholder: '请输入设备厂商', |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
label: '全部', |
|
|
@ -149,27 +198,30 @@ export const tableConfig = { |
|
|
|
field: 'createTime', |
|
|
|
label: '生产日期', |
|
|
|
component: 'NsRangePicker', |
|
|
|
fieldMap: ['queryStartDate', 'queryEndDate'], |
|
|
|
fieldMap: ['manufactureBeginDate', 'manufactureEndDate'], |
|
|
|
componentProps: { |
|
|
|
valueFormat: 'YYYY-MM-DD', |
|
|
|
placeholder: ['设备生产开始日期', '设备生产结束日期'], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'createTime1', |
|
|
|
label: '采购日期', |
|
|
|
component: 'NsRangePicker', |
|
|
|
fieldMap: ['queryStartDate', 'queryEndDate'], |
|
|
|
fieldMap: ['purchaseBeginDate', 'purchaseEndDate'], |
|
|
|
componentProps: { |
|
|
|
valueFormat: 'YYYY-MM-DD', |
|
|
|
placeholder: ['设备采购开始日期', '设备采购结束日期'], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'createTime2', |
|
|
|
label: '启用日期', |
|
|
|
component: 'NsRangePicker', |
|
|
|
fieldMap: ['queryStartDate', 'queryEndDate'], |
|
|
|
fieldMap: ['startBeginDate', 'startEndDate'], |
|
|
|
componentProps: { |
|
|
|
valueFormat: 'YYYY-MM-DD', |
|
|
|
placeholder: ['设备启用开始日期', '设备启用结束日期'], |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
@ -177,4 +229,5 @@ export const tableConfig = { |
|
|
|
}, |
|
|
|
// pagination: { pageSizeOptions: false },
|
|
|
|
rowKey: 'uuid', |
|
|
|
}); |
|
|
|
}; |
|
|
|