You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
6.2 KiB

10 months ago
import { dateUtil } from '/nerv-lib/util/date-util';
import data from './mock.json';
import { http } from '/nerv-lib/util';
import { ref } from 'vue';
const tableKeyMap = [
{
title: '来源企业',
dataIndex: 'id',
},
{
title: '设备id',
dataIndex: 'deviceCode',
},
{
title: '设备编号',
dataIndex: 'deviceName',
textNumber: 8,
textEllipsis: true,
},
{
title: '分组名称',
dataIndex: 'position',
},
{
title: '设备品牌/型号',
dataIndex: 'position',
},
{
title: '设备状态',
dataIndex: 'position',
},
];
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);
10 months ago
export const tableConfig = (el, elGroup, elFormula) => {
return {
title: '设备台账',
// api: '/carbon_emission/device/getDeviceList',
value: mockData.value,
treeConfig: {
defaultExpandAll: true,
header: {
icon: 'orgLink',
title: '分组管理',
},
10 months ago
api: () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(data);
}, 100);
});
},
formConfig: {
schemas: [
{
field: 'type',
label: '',
component: 'NsRadioGroup',
autoSubmit: true,
defaultValue: 1,
componentProps: {
options: [
{ label: '碳排', value: 1 },
{ label: '用电量', value: 2 },
{ label: '用水量', value: 3 },
{ label: '燃气量', value: 4 },
{ label: '供热量', value: 5 },
],
},
},
{
field: 'name',
label: '',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入',
},
},
],
10 months ago
},
},
10 months ago
headerActions: [
10 months ago
{
10 months ago
label: '编辑',
name: 'groupEdit',
type: 'primary',
handle: (a, b) => {
el.value.toggle();
10 months ago
},
},
{
10 months ago
label: '批量删除',
name: 'groupTemDownload',
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
handle: () => {
mockData.value.splice(0, 2);
10 months ago
},
},
{
10 months ago
label: '批量导出',
name: 'groupExports',
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
extra: {
xlsxMap: tableKeyMap,
xlsxName: '分组信息YYYY-MM-DD',
10 months ago
},
},
{
10 months ago
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。' },
10 months ago
],
},
},
10 months ago
10 months ago
{
10 months ago
label: '模板下载',
name: 'groupTemDownload',
type: 'primary',
handle: () => {
// http.get('/asset/file/whiteListUser.xlsx');
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
10 months ago
},
},
10 months ago
10 months ago
{
10 months ago
label: '批量分组',
name: 'groupTemDownload',
type: 'primary',
handle: () => {
elGroup.value.toggle();
10 months ago
},
},
{
10 months ago
label: '公式编辑',
name: 'groupTemDownload',
type: 'primary',
handle: () => {
elFormula.value.toggle();
10 months ago
},
},
],
10 months ago
columns: tableKeyMap,
columnActions: {
title: '操作',
actions: [
{
label: '删除',
name: 'FeedBackDetail',
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',
};
};
export const treeConfig = {
defaultExpandAll: true,
defaultSelectedKeys: ['A008'],
resultField: 'insertData',
api: () => {
return Promise.resolve(data);
10 months ago
},
};