Files
SaaS-lib/hx-ai-intelligent/src/view/equipmentManage/group/config.ts

968 lines
26 KiB
TypeScript
Raw Normal View History

2024-05-29 10:18:12 +08:00
import { http } from '/nerv-lib/util';
2024-08-07 11:32:44 +08:00
import { group, device } from '/@/api/deviceManage';
import { carbonEmissionFactorLibrary, quickCalculation } from '/@/api/carbonEmissionFactorLibrary';
2024-07-05 12:04:17 +08:00
import { dict } from '/@/api';
2024-08-07 11:32:44 +08:00
import { ref } from 'vue';
2024-07-11 15:53:41 +08:00
const tableCalKeyMap = [
2024-05-29 10:18:12 +08:00
{
title: '来源企业',
dataIndex: 'linkOrgName',
textEllipsis: true,
textNumber: 10,
2024-05-29 10:18:12 +08:00
},
{
title: '设备id',
textNumber: 10,
2024-05-29 10:18:12 +08:00
dataIndex: 'deviceCode',
textEllipsis: true,
2024-05-29 10:18:12 +08:00
},
{
title: '设备编号',
dataIndex: 'deviceNum',
2024-07-12 17:39:31 +08:00
textNumber: 10,
2024-05-29 10:18:12 +08:00
},
{
textNumber: 10,
2024-05-29 10:18:12 +08:00
title: '分组名称',
dataIndex: 'groupName',
2024-05-29 10:18:12 +08:00
},
{
title: '设备品牌/型号',
textNumber: 10,
dataIndex: 'deviceNameType',
2024-05-29 10:18:12 +08:00
},
{
textNumber: 10,
2024-05-29 10:18:12 +08:00
title: '设备状态',
2024-07-12 17:39:31 +08:00
dataIndex: 'deviceStatus',
customRender: ({ value }) => {
return value === '0' ? '启用' : '停用';
},
2024-05-29 10:18:12 +08:00
},
];
2024-08-07 11:32:44 +08:00
const tableCarbonKeyMap = [
{
title: '能源类型',
dataIndex: 'energyTypeName',
// textEllipsis: true,
textNumber: 5,
},
{
title: '设备名称',
textNumber: 10,
dataIndex: 'deviceName',
// textEllipsis: true,
},
{
title: '设备id',
dataIndex: 'deviceInfoCode',
textNumber: 10,
},
{
textNumber: 5,
title: '碳排因子值',
dataIndex: 'emissionFactor',
},
{
title: '设备品牌/型号',
textNumber: 10,
dataIndex: 'deviceModel',
},
{
title: '来源企业',
textNumber: 10,
dataIndex: 'manufacturer',
},
{
title: '分组名称',
textNumber: 10,
dataIndex: 'deviceNameType',
},
{
textNumber: 5,
title: '设备状态',
dataIndex: 'status',
customRender: ({ value }) => {
return value === '0' ? '启用' : '停用';
},
},
];
2024-07-11 15:53:41 +08:00
const tableKeyMap = [
2024-06-27 15:21:14 +08:00
{
title: '来源企业',
2024-07-11 15:53:41 +08:00
dataIndex: 'orgName',
2024-06-27 15:21:14 +08:00
},
{
title: '节点编号',
2024-07-11 15:53:41 +08:00
dataIndex: 'pointNum',
2024-06-27 15:21:14 +08:00
},
{
title: '节点路径',
2024-07-11 15:53:41 +08:00
dataIndex: 'routeName',
2024-06-27 15:21:14 +08:00
},
];
2024-05-29 10:18:12 +08:00
const doWnload = (url) => {
const a = document.createElement('a');
document.body.appendChild(a);
a.href = encodeURI(url);
//设置下载的文件名
// a.download = fileName.value;
//触发a标签的点击事件进行下载
a.click();
};
2024-07-05 12:04:17 +08:00
export const formSchema = [
{
field: 'isCreate',
2024-07-09 16:27:21 +08:00
component: 'NsCheck',
show: false,
},
{
field: 'isCreatSon',
component: 'NsCheck',
2024-07-05 12:04:17 +08:00
show: false,
2024-06-27 15:21:14 +08:00
},
2024-07-05 12:04:17 +08:00
{
field: 'orgId',
component: 'NsInput',
show: false,
},
2024-07-09 18:04:09 +08:00
{
field: 'energyType',
component: 'NsInput',
show: false,
},
2024-07-05 12:04:17 +08:00
{
2024-07-09 16:27:21 +08:00
field: 'id',
component: 'NsInput',
show: false,
},
{
field: 'pid',
2024-07-05 12:04:17 +08:00
component: 'NsInput',
show: false,
2024-06-27 15:21:14 +08:00
},
2024-07-05 12:04:17 +08:00
{
label: '节点名称',
field: 'pointName',
component: 'NsInput',
componentProps: {
2024-07-26 13:51:45 +08:00
placeholder: '请输入',
maxLength: 32,
2024-07-05 12:04:17 +08:00
},
rules: [
2024-06-27 15:21:14 +08:00
{
2024-07-05 12:04:17 +08:00
required: true,
message: '请输入节点名称',
2024-06-27 15:21:14 +08:00
},
2024-07-05 12:04:17 +08:00
],
},
{
label: '节点类型',
field: 'pointType',
component: 'NsSelectApi',
componentProps: {
2024-07-26 13:51:45 +08:00
placeholder: '请选择',
2024-07-09 16:27:21 +08:00
api: () => dict({ params: { dicKey: 'COUNT_POINT' } }),
// params: { dicKey: 'COUNT_POINT' },
2024-07-05 12:04:17 +08:00
immediate: true,
2024-07-09 16:27:21 +08:00
// resultField: 'data.COUNT_POINT',
2024-07-05 12:04:17 +08:00
labelField: 'cnValue',
2024-07-15 15:53:54 +08:00
valueField: 'dicKey',
2024-07-05 12:04:17 +08:00
},
rules: [
2024-06-27 15:21:14 +08:00
{
2024-07-05 12:04:17 +08:00
required: true,
message: '请输入节点类型',
2024-06-27 15:21:14 +08:00
},
],
},
2024-07-05 12:04:17 +08:00
];
2024-07-11 15:53:41 +08:00
export const editTreeConfig = (orgId) => ({
selectedKeys: ['0-0'],
defaultExpandAll: true,
api: group.queryEditGroup,
params: { orgId },
resultField: 'data.orgInfos',
fieldNames: { title: 'orgName', key: 'orgId' },
formConfig: {
schemas: [
{
field: 'orgName',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入企业名称',
},
},
],
},
});
export const editCalTreeConfig = (orgId) => ({
selectedKeys: ['0-0'],
defaultExpandAll: true,
api: group.queryEditCompute,
params: { orgId },
resultField: 'data.orgInfos',
fieldNames: { title: 'orgName', key: 'orgId' },
formConfig: {
schemas: [
{
field: 'orgName',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入企业名称',
},
},
],
},
});
2024-07-05 12:04:17 +08:00
export const treeConfig = (orgId) => {
return {
defaultExpandAll: true,
header: {
icon: 'orgLink',
title: '能耗分组',
},
params: { orgId },
2024-07-11 15:53:41 +08:00
2024-07-05 12:04:17 +08:00
api: group.queryDeviceGroupTree,
transform: (data) => {
2024-07-09 16:27:21 +08:00
return [{ pointName: '全部', id: 'all', selectable: false, children: data }];
2024-07-05 12:04:17 +08:00
},
formConfig: {
schemas: [
{
field: 'energyType',
label: '',
component: 'NsSelectApi',
autoSubmit: true,
componentProps: {
2024-07-08 17:44:07 +08:00
api: () => dict({ params: { dicKey: 'ENERGY_TYPE' } }),
// params: { dicKey: 'ENERGY_TYPE' },
2024-07-05 12:04:17 +08:00
immediate: true,
2024-07-08 17:44:07 +08:00
// resultField: 'data.ENERGY_TYPE',
2024-07-05 12:04:17 +08:00
labelField: 'cnValue',
2024-07-15 15:53:54 +08:00
valueField: 'dicKey',
2024-07-05 12:04:17 +08:00
placeholder: '请选择能耗种类',
2024-07-09 18:04:09 +08:00
autoSelectFirst: true,
2024-07-05 12:04:17 +08:00
},
},
{
field: 'pointName',
label: '',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入节点名称',
},
},
],
},
};
2024-06-27 15:21:14 +08:00
};
2024-07-11 15:53:41 +08:00
export const tableConfig = (el, elGroup, elFormula, defaultParams) => {
2024-05-29 16:29:22 +08:00
return {
2024-06-27 15:21:14 +08:00
title: '点位信息',
2024-07-11 15:53:41 +08:00
api: group.queryGroupPage,
params: defaultParams.value,
2024-05-29 16:29:22 +08:00
headerActions: [
2024-05-29 10:18:12 +08:00
{
2024-05-29 16:29:22 +08:00
label: '编辑',
2024-07-23 14:39:55 +08:00
name: 'GroupEdit',
2024-05-29 16:29:22 +08:00
type: 'primary',
2024-07-16 15:22:29 +08:00
dynamicDisabled: () => !defaultParams.value?.id,
2024-05-29 16:29:22 +08:00
handle: (a, b) => {
el.value.toggle();
2024-05-29 10:18:12 +08:00
},
},
{
2024-05-29 16:29:22 +08:00
label: '批量删除',
2024-07-23 14:39:55 +08:00
name: 'GroupDelete',
2024-05-29 16:29:22 +08:00
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
dynamicParams: { linkIds: 'linkId[]' },
confirm: true,
isClearCheck: true,
isReload: true,
api: group.delGroupList,
2024-05-29 10:18:12 +08:00
},
{
2024-05-29 16:29:22 +08:00
label: '批量导出',
2024-07-23 14:39:55 +08:00
name: 'GroupPointExports',
2024-05-29 16:29:22 +08:00
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
extra: {
xlsxMap: tableKeyMap,
xlsxName: '分组信息YYYY-MM-DD',
2024-05-29 10:18:12 +08:00
},
},
{
2024-05-29 16:29:22 +08:00
label: '批量导入',
2024-07-23 14:39:55 +08:00
name: 'GroupPointImport',
2024-05-29 16:29:22 +08:00
type: 'primary',
extra: {
// api: props.postImportApi, // 导入接口名
title: '设备信息', // 弹窗title
templateName: 'whiteListUser', // 所使用的文件名称
indexName: '设备id', // 匹配类型字段
message: [
{ label: '1、若必填项未填写则不能进行导入操作' },
{ label: `2、当重复时则更新数据。` },
{ label: '3、数据将从模版的第五行进行导入。' },
{ label: '4、文件导入勿超过5MB。' },
2024-05-29 10:18:12 +08:00
],
},
},
2024-05-29 16:29:22 +08:00
2024-05-29 10:18:12 +08:00
{
2024-05-29 16:29:22 +08:00
label: '模板下载',
2024-07-23 14:39:55 +08:00
name: 'GroupTempDownload',
2024-05-29 16:29:22 +08:00
type: 'primary',
handle: () => {
// http.get('/asset/file/whiteListUser.xlsx');
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
2024-05-29 10:18:12 +08:00
},
},
],
2024-05-29 16:29:22 +08:00
columns: tableKeyMap,
columnActions: {
title: '操作',
actions: [
{
label: '删除',
2024-07-23 14:39:55 +08:00
name: 'GroupDelete',
dynamicParams: { linkIds: 'linkId[]' },
2024-05-29 16:29:22 +08:00
confirm: true,
isClearCheck: true,
isReload: true,
api: group.delGroupList,
2024-05-29 16:29:22 +08:00
},
],
},
formConfig: {
schemas: [
{
field: 'orgName',
2024-07-15 15:53:54 +08:00
component: 'NsSelectApi',
defaultParams: defaultParams.value,
2024-05-29 16:29:22 +08:00
componentProps: {
placeholder: '请选择公司',
2024-07-15 15:53:54 +08:00
mode: 'multiple',
api: group.dropGroupFilter,
resultField: 'data',
params: { filterField: 'ORG' },
labelField: 'orgName',
valueField: 'orgId',
filterOption: (input: string, option: any) => {
return option.deviceName.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
showSearch: true,
dropdownReload: true,
allowClear: true,
2024-05-29 16:29:22 +08:00
},
},
{
field: 'pointNum',
2024-05-29 16:29:22 +08:00
component: 'NsInput',
componentProps: {
placeholder: '请输入节点编号',
2024-05-29 16:29:22 +08:00
},
},
],
},
// pagination: { pageSizeOptions: false },
rowKey: 'id',
};
};
2024-08-07 11:32:44 +08:00
export const tableConfigCal = (
el,
elGroup,
elFormula,
defaultParams,
isCarbon,
editCarbonEquipmentRef,
setFactorRef,
) => {
// 计算节点
2024-06-27 15:21:14 +08:00
return {
title: '点位信息',
2024-08-07 11:32:44 +08:00
api: isCarbon ? group.getCarbonGroupList : group.queryGroupInfoPage,
params: defaultParams.value,
2024-06-27 15:21:14 +08:00
headerActions: [
{
label: '编辑',
2024-07-23 14:39:55 +08:00
name: 'GroupPointEdit',
2024-06-27 15:21:14 +08:00
type: 'primary',
handle: (a, b) => {
2024-08-07 11:32:44 +08:00
if (isCarbon) {
editCarbonEquipmentRef.value.toggle();
} else {
el.value.toggle();
}
2024-06-27 15:21:14 +08:00
},
},
2024-08-07 11:32:44 +08:00
isCarbon
? {
label: '关联因子值',
name: 'SetFactor',
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
handle: ({ list }) => {
// 过滤出 id 大于 0 的项
const filteredList = list.filter(({ id }) => id > 0);
// 提取出 id 值
const ids = filteredList.map(({ id }) => id);
setFactorRef.value.toggle(ids);
},
}
: {},
2024-06-27 15:21:14 +08:00
{
label: '批量删除',
2024-07-23 14:39:55 +08:00
name: 'GroupPointDelete',
2024-06-27 15:21:14 +08:00
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
2024-08-07 11:32:44 +08:00
dynamicParams: isCarbon
? {
deviceInfoCodeList: 'id[]',
}
: {
ids: 'id[]',
},
confirm: true,
isReload: true,
isClearCheck: true,
2024-08-07 11:32:44 +08:00
api: isCarbon ? group.deleteCarbonDevice : group.delComputeList,
2024-06-27 15:21:14 +08:00
},
{
label: '批量导出',
2024-07-23 14:39:55 +08:00
name: 'GroupPointExports',
2024-06-27 15:21:14 +08:00
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
extra: {
xlsxMap: tableKeyMap,
xlsxName: '分组信息YYYY-MM-DD',
},
},
{
label: '批量导入',
2024-07-23 14:39:55 +08:00
name: 'GroupPointImport',
2024-06-27 15:21:14 +08:00
type: 'primary',
extra: {
// api: props.postImportApi, // 导入接口名
title: '设备信息', // 弹窗title
templateName: 'whiteListUser', // 所使用的文件名称
indexName: '设备id', // 匹配类型字段
message: [
{ label: '1、若必填项未填写则不能进行导入操作' },
{ label: `2、当重复时则更新数据。` },
{ label: '3、数据将从模版的第五行进行导入。' },
{ label: '4、文件导入勿超过5MB。' },
],
},
},
{
label: '模板下载',
2024-07-23 14:39:55 +08:00
name: 'GroupTempDownload',
2024-06-27 15:21:14 +08:00
type: 'primary',
handle: () => {
// http.get('/asset/file/whiteListUser.xlsx');
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
},
},
{
label: '批量分组',
2024-07-23 14:39:55 +08:00
name: 'GroupBatchGroup',
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
handle: ({ list }) => {
const ids = list.map(({ id }) => id);
defaultParams.value['saveDeviceInfoIds'] = ids;
elGroup.value.toggle();
},
},
{
label: '公式编辑',
2024-07-23 14:39:55 +08:00
name: 'GroupFormulaEdit',
type: 'primary',
handle: () => {
elFormula.value.toggle();
},
},
2024-06-27 15:21:14 +08:00
],
scroll: { x: 1400 },
2024-08-07 11:32:44 +08:00
columns: isCarbon ? tableCarbonKeyMap : tableCalKeyMap,
2024-06-27 15:21:14 +08:00
columnActions: {
title: '操作',
actions: [
2024-08-07 11:32:44 +08:00
{
label: '关联因子',
name: 'SetFactor',
dynamicDisabled: (record) => {
// 这里根据record的某个字段值判断是否禁用删除按钮
return record.id < 0;
},
handle: (row) => {
setFactorRef.value.toggle([row.id]);
},
},
2024-06-27 15:21:14 +08:00
{
label: '删除',
2024-07-23 14:39:55 +08:00
name: 'GroupPointDelete',
2024-08-07 11:32:44 +08:00
dynamicDisabled: (record) => {
// 这里根据record的某个字段值判断是否禁用删除按钮
return record.id < 0;
},
dynamicParams: isCarbon
? {
deviceInfoCodeList: 'id[]',
}
: {
ids: 'id[]',
},
2024-06-27 15:21:14 +08:00
confirm: true,
2024-07-11 15:53:41 +08:00
isReload: true,
isClearCheck: true,
2024-08-07 11:32:44 +08:00
api: isCarbon ? group.deleteCarbonDevice : group.delComputeList,
2024-06-27 15:21:14 +08:00
},
],
},
formConfig: {
schemas: [
{
2024-07-15 15:53:54 +08:00
field: 'orgIds',
component: 'NsSelectApi',
defaultParams: defaultParams.value,
2024-06-27 15:21:14 +08:00
componentProps: {
placeholder: '请选择公司',
2024-07-15 15:53:54 +08:00
mode: 'multiple',
api: group.dropGroupInfoFilter,
resultField: 'data',
params: { filterField: 'ORG' },
labelField: 'orgName',
valueField: 'orgId',
filterOption: (input: string, option: any) => {
return option.deviceName.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
showSearch: true,
dropdownReload: true,
allowClear: true,
2024-06-27 15:21:14 +08:00
},
},
{
field: 'deviceCode',
component: 'NsInput',
componentProps: {
placeholder: '请输入设备id',
},
},
{
field: 'deviceNum',
component: 'NsInput',
componentProps: {
placeholder: '请输入设备编号',
},
},
2024-06-27 15:21:14 +08:00
{
2024-07-15 15:53:54 +08:00
field: 'deviceStatus',
component: 'NsSelectApi',
2024-06-27 15:21:14 +08:00
componentProps: {
2024-07-15 15:53:54 +08:00
placeholder: '请选择设备状态',
api: () => dict({ params: { dicKey: 'DEVICE_STATUS' } }),
immediate: true,
labelField: 'cnValue',
valueField: 'dicKey',
},
},
{
field: 'deviceNameType',
2024-07-15 15:53:54 +08:00
component: 'NsSelectApi',
defaultParams: defaultParams.value,
componentProps: {
2024-07-15 15:53:54 +08:00
placeholder: '请选择设备型号',
api: (params: any) => {
return http.post(group.dropGroupInfoFilter, params).then((res: any) => {
const result = [...new Set(res.data)];
return { data: result };
});
},
resultField: 'data',
params: { filterField: 'DEVICE_TYPE' },
// labelField: 'orgName',
// valueField: 'orgId',
filterOption: (input: string, option: any) => {
return option.deviceName.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
showSearch: true,
dropdownReload: true,
allowClear: true,
},
},
{
field: 'provider',
component: 'NsInput',
componentProps: {
placeholder: '请输入分组名称',
2024-06-27 15:21:14 +08:00
},
},
],
},
2024-08-07 11:32:44 +08:00
pagination: isCarbon ? false : true,
2024-06-27 15:21:14 +08:00
rowKey: 'id',
2024-08-07 11:32:44 +08:00
rowSelection: { checkStrictly: false },
2024-06-27 15:21:14 +08:00
};
2024-05-29 10:18:12 +08:00
};
2024-08-07 11:32:44 +08:00
export const editCarbonEquipmentConfig = (orgId) => {
return ref({
title: '设备信息',
api: device.queryDevicePage,
params: { orgId },
treeConfig: {
header: {
icon: 'deviceType',
title: '设备类别',
},
params: { orgId },
dynamicParams: { deviceCode: 'code' },
defaultExpandAll: true,
api: device.queryDeviceTree,
fieldNames: { title: 'deviceType', key: 'code' },
formConfig: {
schemas: [
{
field: 'energyType',
label: '',
component: 'NsSelectApi',
autoSubmit: true,
componentProps: {
api: () => dict({ params: { dicKey: 'ENERGY_TYPE' } }),
// params: { dicKey: 'ENERGY_TYPE' },
immediate: true,
// resultField: 'data.ENERGY_TYPE',
labelField: 'cnValue',
valueField: 'dicKey',
placeholder: '请选择能耗种类',
autoSelectFirst: true,
},
},
{
field: 'deviceType',
label: '设备名称',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入设备类型',
},
},
],
},
},
// rowSelection: null,
rowSelection: true,
// scroll: { x: 2000 },
columns: [
{
title: '设备名称',
dataIndex: 'deviceName',
},
{
title: '设备型号',
dataIndex: 'deviceModel',
},
{
title: 'SN码',
dataIndex: 'snCode',
textNumber: 5,
textEllipsis: true,
},
{
title: '设备一级区域',
dataIndex: 'device1Area',
textWidth: 88,
// width: 130,
textEllipsis: true,
},
{
title: '设备二级区域',
dataIndex: 'device2Area',
textWidth: 88,
// width: 130,
textEllipsis: true,
},
{
title: '设备详细位置',
dataIndex: 'deviceAddress',
textNumber: 5,
textEllipsis: true,
},
],
formConfig: {
schemas: [
{
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: '请选择设备区域',
multiple: true,
loadData: (selectedOptions, options) => {
const targetOption = selectedOptions[selectedOptions.length - 1];
if (!selectedOptions.length) {
http.post(device.dropArea, { orgId, filterField: 'DEVICE_AREA' }).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, filterField: 'DEVICE_AREA' })
.then((res) => {
targetOption.loading = false;
targetOption.children = res.data?.map((item) => {
return { label: item, value: item, children: [], isLeaf: true };
});
});
}
},
},
},
{
field: 'deviceName',
label: '设备名称',
component: 'NsSelectApi',
componentProps: {
placeholder: '请选择设备名称',
api: (params) => {
return http.post(device.dropArea, params).then((res) => {
const result = res.data?.reduce((pre, cur) => {
!pre.includes(cur.deviceName) && pre.push(cur.deviceName);
return pre;
}, []);
return { data: result };
});
},
resultField: 'data',
params: { orgId, filterField: 'DEVICE_NAME_FACTORY' },
// labelField: 'deviceName',
// valueField: 'deviceName',
filterOption: (input: string, option: any) => {
return option.deviceName?.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
showSearch: true,
immediate: true,
dropdownReload: true,
allowClear: true,
},
},
],
params: {},
},
// pagination: { pageSizeOptions: false },
rowKey: 'deviceInfoCode',
});
};
export const setFactorConfig = (orgId) => {
return ref({
title: '排放因子库',
// api: carbonEmissionFactorLibrary.getTableList,
api: quickCalculation.queryCarbonEmissionPage,
params: { orgId, pageNum: 1, pageSize: 9999 },
treeConfig: {
header: {
icon: 'deviceType',
title: '因子分类',
},
params: { orgId },
dynamicParams: { energyType: 'id' },
defaultExpandAll: true,
// api: carbonEmissionFactorLibrary.getCarbonFactorTree,
api: quickCalculation.carbonQuickTree,
fieldNames: { title: 'energyType', key: 'id' },
formConfig: {
schemas: [
{
field: 'deviceType',
label: '设备名称',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入关键字',
},
},
],
},
},
// rowSelection: null,
rowSelection: { type: 'radio' },
// scroll: { x: 2000 },
columns: [
{
title: '序号',
textNumber: 2,
dataIndex: 'address',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '因子值',
dataIndex: 'emissionFactors',
textNumber: 3,
},
{
title: '计量单位',
dataIndex: 'carbonEmissionSuffix',
textNumber: 4,
textEllipsis: true,
},
{
title: '更新时间',
dataIndex: 'updateTime',
textWidth: 88,
// width: 130,
textEllipsis: true,
},
{
title: '启用时间',
dataIndex: 'startTime',
textWidth: 88,
// width: 130,
textEllipsis: true,
},
{
title: '结束时间',
dataIndex: 'endTime',
textNumber: 5,
textEllipsis: true,
},
{
title: '数据来源',
dataIndex: 'dataSources',
textNumber: 5,
textEllipsis: true,
},
],
// formConfig: {
// schemas: [
// {
// 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: '请选择设备区域',
// multiple: true,
// loadData: (selectedOptions, options) => {
// const targetOption = selectedOptions[selectedOptions.length - 1];
// if (!selectedOptions.length) {
// http.post(device.dropArea, { orgId, filterField: 'DEVICE_AREA' }).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, filterField: 'DEVICE_AREA' })
// .then((res) => {
// targetOption.loading = false;
// targetOption.children = res.data?.map((item) => {
// return { label: item, value: item, children: [], isLeaf: true };
// });
// });
// }
// },
// },
// },
// {
// field: 'deviceName',
// label: '设备名称',
// component: 'NsSelectApi',
// componentProps: {
// placeholder: '请选择设备名称',
// api: (params) => {
// return http.post(device.dropArea, params).then((res) => {
// const result = res.data?.reduce((pre, cur) => {
// !pre.includes(cur.deviceName) && pre.push(cur.deviceName);
// return pre;
// }, []);
// return { data: result };
// });
// },
// resultField: 'data',
// params: { orgId, filterField: 'DEVICE_NAME_FACTORY' },
// // labelField: 'deviceName',
// // valueField: 'deviceName',
// filterOption: (input: string, option: any) => {
// return option.deviceName?.toLowerCase().indexOf(input.toLowerCase()) >= 0;
// },
// showSearch: true,
// immediate: true,
// dropdownReload: true,
// allowClear: true,
// },
// },
// ],
// params: {},
// },
// pagination: { pageSizeOptions: false },
rowKey: 'id',
});
};