Browse Source

feat: 设备台账

main
xuziqiang 6 months ago
parent
commit
d2b0a2ca06
  1. 29
      hx-ai-intelligent/src/router/equipmentManage.ts
  2. 158
      hx-ai-intelligent/src/view/equipmentManage/ledger/config.ts
  3. 7
      hx-ai-intelligent/src/view/equipmentManage/ledger/index.vue
  4. 240
      hx-ai-intelligent/src/view/equipmentManage/ledger/mock.json
  5. 304
      lib/component/table/table.vue
  6. 23
      lib/saas/view/service/list-table.vue

29
hx-ai-intelligent/src/router/equipmentManage.ts

@ -0,0 +1,29 @@
const Base = () => import('/nerv-lib/saas/view/system/layout/content.vue');
const equipment = {
path: '/equipmentManage',
name: 'EquipmentManage',
meta: { title: '设备管理', icon: 'dicizhishou', index: 1 },
redirect: { name: 'homeIndex' },
children: [
{
path: 'ledger',
name: 'Ledger',
meta: { title: '设备台账', hideChildren: true, icon: 'dicizhishou' },
component: Base,
redirect: { name: 'LedgerIndex' },
children: [
{
path: 'index',
name: 'LedgerIndex',
component: () => import('/@/view/equipmentManage/ledger/index.vue'),
meta: {
title: '设备台账',
keepAlive: true,
backApi: [],
},
},
],
},
],
};
export default equipment;

158
hx-ai-intelligent/src/view/equipmentManage/ledger/config.ts

@ -0,0 +1,158 @@
import { dateUtil } from '/nerv-lib/util/date-util';
import { data } from './mock.json';
export const tableConfig = {
title: '设备台账',
api: '/carbon_emission/device/getDeviceList',
treeConfig: {
dynamicParams: { abc: 'title', key: 'key' },
defaultExpandAll: true,
treeData: data,
},
params: {
page: 0,
pageSize: 10,
},
rowSelection: null,
columns: [
{
title: '设备名称',
dataIndex: 'id',
},
{
title: '设备型号',
dataIndex: 'deviceCode',
},
{
title: 'SN码',
dataIndex: 'deviceName',
textNumber: 8,
textEllipsis: true,
},
{
title: '设备一级区域',
dataIndex: 'position',
},
{
title: '设备二级区域',
dataIndex: 'position',
},
{
title: '设备详细位置',
dataIndex: 'position',
},
{
title: '设备规格',
dataIndex: 'position',
},
{
title: '设备厂商纳税人识别号',
dataIndex: 'position',
},
{
title: '厂商联系人',
dataIndex: 'position',
},
{
title: '设备描述',
dataIndex: 'position',
},
{
title: 'IP地址',
dataIndex: 'position',
},
{
title: '生产日期',
dataIndex: 'position',
},
{
title: '采购日期',
dataIndex: 'position',
},
{
title: '启用日期',
dataIndex: 'position',
},
{
title: '设备成本(元)',
dataIndex: 'position',
},
{
title: '使用期限',
dataIndex: 'position',
},
{
title: '额定功率',
dataIndex: 'position',
},
{
title: '特殊参数',
dataIndex: 'position',
},
],
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',
},
},
],
params: {},
},
// pagination: { pageSizeOptions: false },
rowKey: 'uuid',
};

7
hx-ai-intelligent/src/view/equipmentManage/ledger/index.vue

@ -0,0 +1,7 @@
<template>
<ns-view-list-table v-bind="tableConfig" />
</template>
<script lang="ts" setup>
import { tableConfig } from './config';
</script>
<style lang="less" scoped></style>

240
hx-ai-intelligent/src/view/equipmentManage/ledger/mock.json

@ -0,0 +1,240 @@
{
"data":[
{
"title": "家居照明",
"key": "1",
"children": [
{
"title": "灯泡",
"key": "1-1",
"children": [
{
"title": "LED灯泡",
"key": "1-1-1",
"children": [
{
"title": "E27 LED灯泡",
"key": "1-1-1-1",
"attr": {
"瓦特": "7W",
"光通量": "500lm",
"色温": "2700K"
}
},
{
"title": "E14 小灯泡",
"key": "1-1-1-2",
"attr": {
"瓦特": "4W",
"光通量": "250lm",
"色温": "6500K"
}
}
]
},
{
"title": "节能灯",
"key": "1-1-2",
"children": [
{
"title": "E27 节能灯泡",
"key": "1-1-2-1",
"attr": {
"瓦特": "11W",
"光通量": "800lm",
"色温": "6500K"
}
}
]
}
]
},
{
"title": "灯具",
"key": "1-2",
"children": [
{
"title": "吊灯",
"key": "1-2-1",
"children": [
{
"title": "水晶吊灯",
"key": "1-2-1-1",
"attr": {
"尺寸": "Φ60cm",
"适用面积": "15-20㎡"
}
},
{
"title": "现代简约吊灯",
"key": "1-2-1-2",
"attr": {
"尺寸": "Φ52cm",
"适用面积": "10-15㎡"
}
}
]
},
{
"title": "台灯",
"key": "1-2-2",
"children": [
{
"title": "护眼台灯",
"key": "1-2-2-1",
"attr": {
"瓦特": "18W",
"调光调色": "是"
}
},
{
"title": "折叠臂台灯",
"key": "1-2-2-2",
"attr": {
"瓦特": "14W",
"调光调色": "否"
}
}
]
}
]
},
{
"title": "开关插座",
"key": "1-3",
"children": [
{
"title": "智能开关",
"key": "1-3-1",
"children": [
{
"title": "触控式智能开关",
"key": "1-3-1-1",
"attr": {
"控制方式": "触控/远程",
"兼容性": "ZigBee/WiFi"
}
}
]
},
{
"title": "插座",
"key": "1-3-2",
"children": [
{
"title": "多功能插座",
"key": "1-3-2-1",
"attr": {
"插孔类型": "2/3插",
"USB接口": "有"
}
}
]
}
]
}
]
},
{
"title": "电梯",
"key": "3",
"children": [
{
"title": "扶梯",
"key": "301"
},
{
"title": "直梯",
"key": "302"
}
]
},
{
"title": "冷源源",
"key": "4",
"children": [
{
"title": "通风及空调设备",
"key": "5",
"children": [
{
"title": "组合式空调机组",
"key": "501"
},
{
"title": "新风机组",
"key": "502"
},
{
"title": "精密空调",
"key": "503"
},
{
"title": "风机盘管",
"key": "504"
},
{
"title": "VAV",
"key": "505"
},
{
"title": "室外多联机",
"key": "506"
},
{
"title": "风幕机",
"key": "507"
},
{
"title": "球喷",
"key": "508"
},
{
"title": "送风机",
"key": "509"
},
{
"title": "排风机",
"key": "510"
},
{
"title": "排风兼排烟机",
"key": "511"
},
{
"title": "通风机",
"key": "512"
},
{
"title": "风阀",
"key": "513"
},
{
"title": "风柱式空调",
"key": "514"
}
]
}
]
},
{
"title": "照明",
"key": "6",
"children": [
{
"title": "多功能传感器",
"key": "701"
},
{
"title": "照度传感器",
"key": "702"
},
{
"title": "噪声传感器",
"key": "703"
}
]
}
]
}

304
lib/component/table/table.vue

@ -13,153 +13,159 @@
v-if="tableTitle"> v-if="tableTitle">
<ns-icon v-if="showBack" class="backIcon" name="left" />{{ tableTitle }} <ns-icon v-if="showBack" class="backIcon" name="left" />{{ tableTitle }}
</div> </div>
<!-- {{ formConfig }} --> <div class="ns-table-container">
<a-spin :spinning="tableState.loading"> <div class="ns-part-tree" v-if="!isEmpty(treeConfig)">
<div class="ns-table-search" v-if="!isEmpty(formConfig)"> <ns-tree v-if="getTreeData.length" v-bind="getTreeBindValue" @select="treeSelect" />
<ns-form
ref="formElRef"
class="ns-table-form"
:showAction="true"
v-bind="formConfig"
:expand="expand"
:showExpand="showExpand"
:model="formModel"
@finish="formFinish" />
</div> </div>
<a-row type="flex" class="ns-table-main"> <div class="ns-part-table">
<a-col :flex="getTreeWidth" v-if="!isEmpty(treeConfig)"> <a-spin :spinning="tableState.loading">
<div class="ns-table-search" v-if="!isEmpty(formConfig)">
<ns-form
ref="formElRef"
class="ns-table-form"
:showAction="true"
v-bind="formConfig"
:expand="expand"
:showExpand="showExpand"
:model="formModel"
@finish="formFinish" />
</div>
<a-row type="flex" class="ns-table-main">
<!-- <a-col :flex="getTreeWidth" v-if="!isEmpty(treeConfig)">
<ns-tree v-if="getTreeData.length" v-bind="getTreeBindValue" @select="treeSelect" /> <ns-tree v-if="getTreeData.length" v-bind="getTreeBindValue" @select="treeSelect" />
</a-col> </a-col> -->
<a-col flex="auto"> <a-col flex="auto">
<ns-table-header <ns-table-header
v-if="!isEmpty(headerActions) || tableTitle" v-if="!isEmpty(headerActions) || tableTitle"
:headerActions="headerActions" :headerActions="headerActions"
:searchData="formModel" :searchData="formModel"
:tableTitle="tableTitle" :tableTitle="tableTitle"
:data="tableState.selectedRows"> :data="tableState.selectedRows">
<template #header="data"> <template #header="data">
<slot name="header" v-bind="data || {}"></slot> <slot name="header" v-bind="data || {}"></slot>
</template> </template>
</ns-table-header> </ns-table-header>
<ns-basic-table ref="tableElRef" v-bind="getTableBindValues" :dataSource="tableData"> <ns-basic-table ref="tableElRef" v-bind="getTableBindValues" :dataSource="tableData">
<template #emptyText> <template #emptyText>
<template v-if="tableState.loadError"> <template v-if="tableState.loadError">
<div class="ns-table-content"> <div class="ns-table-content">
<div class="fetch-error"> <div class="fetch-error">
<p>{{ tableState.loadErrorMessage }}</p> <p>{{ tableState.loadErrorMessage }}</p>
<ns-button type="primary" ghost @click="reload">重新加载</ns-button></div <ns-button type="primary" ghost @click="reload">重新加载</ns-button></div
></div ></div
> >
</template> </template>
<template v-else-if="tableState.loading" <template v-else-if="tableState.loading"
><div class="ns-table-content"></div ><div class="ns-table-content"></div
></template> ></template>
<template v-else> <template v-else>
<div class="ns-table-content"> <a-empty /> </div> <div class="ns-table-content"> <a-empty /> </div>
</template> </template>
</template> </template>
<template #[item]="data" v-for="item in Object.keys($slots)" :key="item"> <template #[item]="data" v-for="item in Object.keys($slots)" :key="item">
<slot :name="item" v-bind="data || {}"></slot> <slot :name="item" v-bind="data || {}"></slot>
<template v-if="item === 'bodyCell'"> <template v-if="item === 'bodyCell'">
<template v-if="data?.column?.textEllipsis"> <template v-if="data?.column?.textEllipsis">
<span <span
class="tool-tips" class="tool-tips"
:style="{ width: `${data.column.textWidth || data.column.width}px` }"> :style="{ width: `${data.column.textWidth || data.column.width}px` }">
<ns-tooltip <ns-tooltip
placement="top" placement="top"
v-if=" v-if="
data.column.customRender data.column.customRender
? data.column.customRender(data) ? data.column.customRender(data)
: data.record[data.column.dataIndex] : data.record[data.column.dataIndex]
"> ">
<template #title> <template #title>
<span>{{ <span>{{
data.column.customRender
? data.column.customRender(data)
: data.record[data.column.dataIndex] || '-'
}}</span>
</template>
<span class="text-ellipsis">{{
data.column.customRender
? data.column.customRender(data)
: data.record[data.column.dataIndex] || '-'
}}</span>
</ns-tooltip>
<span class="text-ellipsis" v-else> - </span>
</span>
</template>
<template v-if="data.column.dataIndex === 'tableAction'">
<ns-table-action
:data="data.record"
:searchData="formModel"
:columnActions="getColumnActions" />
</template>
<template v-if="data.column.edit">
<ns-table-cell
:value="data.text"
:record="data.record"
:column="data.column"
:index="data.index" />
</template>
</template>
<template v-if="item === 'footer'">
<ns-table-footer :footerActions="footerActions" :data="ediRowData" />
</template>
</template>
<template #bodyCell="data" v-if="!Object.keys($slots).includes('bodyCell')">
<template v-if="data.column.textEllipsis">
<span
class="tool-tips"
:style="{ width: `${data.column.textWidth || data.column.width}px` }">
<ns-tooltip
placement="top"
v-if="
data.column.customRender
? data.column.customRender(data)
: data.record[data.column.dataIndex]
">
<template #title>
<span>{{
data.column.customRender
? data.column.customRender(data)
: data.record[data.column.dataIndex] || '-'
}}</span>
</template>
<span class="text-ellipsis">{{
data.column.customRender data.column.customRender
? data.column.customRender(data) ? data.column.customRender(data)
: data.record[data.column.dataIndex] || '-' : data.record[data.column.dataIndex] || '-'
}}</span> }}</span>
</template> </ns-tooltip>
<span class="text-ellipsis">{{ <span class="text-ellipsis" v-else> - </span>
data.column.customRender </span>
? data.column.customRender(data) </template>
: data.record[data.column.dataIndex] || '-' <template v-if="data.column.dataIndex === 'tableAction'">
}}</span> <ns-table-action
</ns-tooltip> :data="data.record"
<span class="text-ellipsis" v-else> - </span> :searchData="formModel"
</span> :columnActions="getColumnActions" />
</template>
<template v-if="data.column.edit">
<ns-table-cell
:value="data.text"
:record="data.record"
:column="data.column"
:index="data.index" />
</template>
</template> </template>
<template v-if="data.column.dataIndex === 'tableAction'">
<ns-table-action <template
:data="data.record" #footer
:searchData="formModel" v-if="!Object.keys($slots).includes('footer') && !isEmpty(footerActions)">
:columnActions="getColumnActions" /> <ns-table-footer :footerActions="footerActions" :data="ediRowData" />
</template>
<template v-if="data.column.edit">
<ns-table-cell
:value="data.text"
:record="data.record"
:column="data.column"
:index="data.index" />
</template> </template>
</template> </ns-basic-table>
<template v-if="item === 'footer'"> </a-col>
<ns-table-footer :footerActions="footerActions" :data="ediRowData" /> </a-row>
</template> </a-spin>
</template> </div>
</div>
<template #bodyCell="data" v-if="!Object.keys($slots).includes('bodyCell')">
<template v-if="data.column.textEllipsis">
<span
class="tool-tips"
:style="{ width: `${data.column.textWidth || data.column.width}px` }">
<ns-tooltip
placement="top"
v-if="
data.column.customRender
? data.column.customRender(data)
: data.record[data.column.dataIndex]
">
<template #title>
<span>{{
data.column.customRender
? data.column.customRender(data)
: data.record[data.column.dataIndex] || '-'
}}</span>
</template>
<span class="text-ellipsis">{{
data.column.customRender
? data.column.customRender(data)
: data.record[data.column.dataIndex] || '-'
}}</span>
</ns-tooltip>
<span class="text-ellipsis" v-else> - </span>
</span>
</template>
<template v-if="data.column.dataIndex === 'tableAction'">
<ns-table-action
:data="data.record"
:searchData="formModel"
:columnActions="getColumnActions" />
</template>
<template v-if="data.column.edit">
<ns-table-cell
:value="data.text"
:record="data.record"
:column="data.column"
:index="data.index" />
</template>
</template>
<template
#footer
v-if="!Object.keys($slots).includes('footer') && !isEmpty(footerActions)">
<ns-table-footer :footerActions="footerActions" :data="ediRowData" />
</template>
</ns-basic-table>
</a-col>
</a-row>
</a-spin>
</div> </div>
</template> </template>
@ -577,9 +583,9 @@
event: any; event: any;
}, },
) { ) {
// console.log(selectedKeys, e); console.log(selectedKeys, e);
const { dataRef } = e.selectedNodes[0].props; const { dataRef } = e.node;
treeParamsRef.value = getParams(dataRef, props.params); treeParamsRef.value = getParams(dataRef, getTreeBindValue.value.dynamicParams);
fetch({ fetch({
page: 1, page: 1,
}); });
@ -654,6 +660,20 @@
margin-left: -16px; margin-left: -16px;
cursor: pointer; cursor: pointer;
} }
.ns-table-container {
display: flex;
.ns-part-tree {
width: 300px;
padding-top: 14px;
padding-left: 8px;
overflow-y: auto;
}
.ns-part-table {
flex: 1;
min-width: 0;
}
}
.ns-table-content { .ns-table-content {
// background: #e5ebf0; // background: #e5ebf0;
margin: 16px; margin: 16px;

23
lib/saas/view/service/list-table.vue

@ -102,22 +102,31 @@
<style lang="less" scoped> <style lang="less" scoped>
// sticky // sticky
@gap: 16px;
@border-gap: @gap solid #e5ebf0;
:deep(.ns-table-container) {
border-top: @border-gap;
}
:deep(.ns-table) { :deep(.ns-table) {
.ns-part-tree {
border-right: @border-gap;
height: calc(100vh - 158px);
}
.ns-table-main { .ns-table-main {
padding: 0px 16px; padding: 0px @gap;
border-top: 16px solid #e5ebf0; border-top: @border-gap;
// margin: 16px; // margin: 16px;
// background-color: #fff; // background-color: #fff;
} }
.ns-table-search { .ns-table-search {
padding: 16px 16px 0; padding: @gap @gap 0;
// margin: 16px; // margin: 16px;
background: #fff; background: #fff;
// border-width: 16px 0 16px 0px; // border-width: 16px 0 16px 0px;
// border-color: #e5ebf0; // border-color: #e5ebf0;
// border-style: solid; // border-style: solid;
border-top: 16px solid #e5ebf0; // border-top: 16px solid #e5ebf0;
} }
.ns-table-header { .ns-table-header {
position: sticky; position: sticky;
@ -130,14 +139,14 @@
display: none !important; display: none !important;
} }
.ns-basic-table { .ns-basic-table {
padding-top: 16px; padding-top: @gap;
} }
} }
:deep(.ns-form::after) { :deep(.ns-form::after) {
background-color: #f0f2f5; background-color: #f0f2f5;
display: none; display: none;
margin: 0 16px; margin: @gap;
width: calc(100% - 32px); width: calc(100% - @gap * 2);
} }
</style> </style>

Loading…
Cancel
Save