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

464 lines
11 KiB
TypeScript
Raw Normal View History

2024-05-29 10:18:12 +08:00
import { dateUtil } from '/nerv-lib/util/date-util';
import data from './mock.json';
import { http } from '/nerv-lib/util';
import { ref } from 'vue';
2024-07-05 12:04:17 +08:00
import { group } from '/@/api/deviceManage';
import { dict } from '/@/api';
2024-07-11 15:53:41 +08:00
import { origanizemanage } from '/@/api/origanizemanage';
const tableCalKeyMap = [
2024-05-29 10:18:12 +08:00
{
title: '来源企业',
2024-07-11 15:53:41 +08:00
dataIndex: 'orgName',
// textEllipsis: true,
// textNumber: 4,
2024-05-29 10:18:12 +08:00
},
{
title: '设备id',
dataIndex: 'deviceCode',
},
{
title: '设备编号',
dataIndex: 'deviceName',
textNumber: 8,
textEllipsis: true,
},
{
title: '分组名称',
dataIndex: 'position',
},
{
title: '设备品牌/型号',
dataIndex: 'position',
},
{
title: '设备状态',
dataIndex: 'position',
},
];
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();
};
const mockData = ref(data.listData);
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: {
placeholder: '请输入节点名称(必填)',
},
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: {
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',
valueField: 'cnValue',
},
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: '请输入企业名称',
},
},
],
},
});
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',
valueField: 'cnValue',
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: '编辑',
name: 'groupEdit',
type: 'primary',
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-11 15:53:41 +08:00
name: 'groupBatDelete',
2024-05-29 16:29:22 +08:00
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
handle: () => {
mockData.value.splice(0, 2);
2024-05-29 10:18:12 +08:00
},
},
{
2024-05-29 16:29:22 +08:00
label: '批量导出',
name: 'groupExports',
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: '批量导入',
name: 'groupImport',
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: '模板下载',
name: 'groupTemDownload',
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
2024-05-29 10:18:12 +08:00
{
2024-05-29 16:29:22 +08:00
label: '批量分组',
2024-07-11 15:53:41 +08:00
name: 'groupBatGroup',
2024-05-29 16:29:22 +08:00
type: 'primary',
handle: () => {
elGroup.value.toggle();
2024-05-29 10:18:12 +08:00
},
},
{
2024-05-29 16:29:22 +08:00
label: '公式编辑',
2024-07-11 15:53:41 +08:00
name: 'groupFormulaEdit',
2024-05-29 16:29:22 +08:00
type: 'primary',
handle: () => {
elFormula.value.toggle();
2024-05-29 10:18:12 +08:00
},
},
],
2024-05-29 16:29:22 +08:00
columns: tableKeyMap,
columnActions: {
title: '操作',
actions: [
{
label: '删除',
2024-07-11 15:53:41 +08:00
name: 'groupDelete',
2024-05-29 16:29:22 +08:00
dynamicParams: ['uuid', 'appealType'],
confirm: true,
handle: () => {
mockData.value.splice(0, 1);
},
},
],
},
formConfig: {
schemas: [
{
field: 'name',
label: '设备名称',
component: 'NsInput',
componentProps: {
placeholder: '请输入',
},
},
{
field: 'provider',
label: '设备厂商',
component: 'NsInput',
componentProps: {
placeholder: '请输入',
},
},
{
field: 'payWay',
label: '设备区域',
component: 'NsSelect',
componentProps: {
placeholder: '请选择',
options: [
{
label: '全部',
value: '',
},
],
},
},
{
field: 'createTime',
label: '生产日期',
component: 'NsRangePicker',
fieldMap: ['queryStartDate', 'queryEndDate'],
componentProps: {
valueFormat: 'YYYY-MM-DD',
},
},
{
field: 'createTime1',
label: '采购日期',
component: 'NsRangePicker',
fieldMap: ['queryStartDate', 'queryEndDate'],
componentProps: {
valueFormat: 'YYYY-MM-DD',
},
},
{
field: 'createTime2',
label: '启用日期',
component: 'NsRangePicker',
fieldMap: ['queryStartDate', 'queryEndDate'],
componentProps: {
valueFormat: 'YYYY-MM-DD',
},
},
],
},
// pagination: { pageSizeOptions: false },
rowKey: 'id',
};
};
2024-07-11 15:53:41 +08:00
export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => {
// 分组节点
2024-06-27 15:21:14 +08:00
return {
title: '点位信息',
// api: '/carbon_emission/device/getDeviceList',
value: mockData.value,
2024-07-11 15:53:41 +08:00
params: defaultParams,
2024-06-27 15:21:14 +08:00
headerActions: [
{
label: '编辑',
name: 'groupEdit',
type: 'primary',
handle: (a, b) => {
el.value.toggle();
},
},
{
label: '批量删除',
name: 'groupTemDownload',
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
handle: () => {
mockData.value.splice(0, 2);
},
},
{
label: '批量导出',
name: 'groupExports',
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
extra: {
xlsxMap: tableKeyMap,
xlsxName: '分组信息YYYY-MM-DD',
},
},
{
label: '批量导入',
name: 'groupImport',
type: 'primary',
extra: {
// api: props.postImportApi, // 导入接口名
title: '设备信息', // 弹窗title
templateName: 'whiteListUser', // 所使用的文件名称
indexName: '设备id', // 匹配类型字段
message: [
{ label: '1、若必填项未填写则不能进行导入操作' },
{ label: `2、当重复时则更新数据。` },
{ label: '3、数据将从模版的第五行进行导入。' },
{ label: '4、文件导入勿超过5MB。' },
],
},
},
{
label: '模板下载',
name: 'groupTemDownload',
type: 'primary',
handle: () => {
// http.get('/asset/file/whiteListUser.xlsx');
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
},
},
],
columns: tableCalKeyMap,
columnActions: {
title: '操作',
actions: [
{
label: '删除',
2024-07-11 15:53:41 +08:00
name: 'groupDelete',
dynamicParams: 'id',
2024-06-27 15:21:14 +08:00
confirm: true,
2024-07-11 15:53:41 +08:00
isReload: true,
isClearCheck: true,
api: group.delGroupList,
2024-06-27 15:21:14 +08:00
},
],
},
formConfig: {
schemas: [
{
field: 'name',
label: '设备名称',
component: 'NsInput',
componentProps: {
placeholder: '请选择公司',
},
},
{
field: 'provider',
component: 'NsInput',
componentProps: {
placeholder: '请输入节点编号',
},
},
],
},
// pagination: { pageSizeOptions: false },
rowKey: 'id',
};
2024-05-29 10:18:12 +08:00
};