能源
This commit is contained in:
@@ -1,197 +1,219 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<!-- 列表 -->
|
||||
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps" :table-data="list"
|
||||
:max-height="tableH">
|
||||
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="80" label="操作" :method-list="tableBtn"
|
||||
@clickBtn="handleClick" />
|
||||
</base-table>
|
||||
<pagination :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" :total="total"
|
||||
@pagination="getList" />
|
||||
<!-- 新增 -->
|
||||
<base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="centervisible" @cancel="handleCancel"
|
||||
@confirm="handleConfirm" :before-close="handleCancel">
|
||||
<energy-plc-add ref="energyPlc" @successSubmit="successSubmit" />
|
||||
</base-dialog>
|
||||
</div>
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<search-bar
|
||||
:formConfigs="formConfig"
|
||||
ref="searchBarForm"
|
||||
@headBtnClick="buttonClick" />
|
||||
<!-- 列表 -->
|
||||
<base-table
|
||||
:page="queryParams.pageNo"
|
||||
:limit="queryParams.pageSize"
|
||||
:table-props="tableProps"
|
||||
:table-data="list"
|
||||
:max-height="tableH">
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="80"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick" />
|
||||
</base-table>
|
||||
<pagination
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
:total="total"
|
||||
@pagination="getList" />
|
||||
<!-- 新增 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="centervisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel">
|
||||
<energy-plc-add
|
||||
ref="energyPlc"
|
||||
@successSubmit="successSubmit" />
|
||||
</base-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getEnergyPlcPage, deleteEnergyPlc } from "@/api/base/energyPlc";
|
||||
// import { publicFormatter } from '@/utils/dict'
|
||||
import EnergyPlcAdd from './components/energyPlcAdd.vue'
|
||||
import { getEnergyPlcPage, deleteEnergyPlc } from '@/api/base/energyPlc';
|
||||
import EnergyPlcAdd from './components/energyPlcAdd.vue';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'plcTableName',
|
||||
label: '关联表名',
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'code',
|
||||
label: '关联表编码',
|
||||
minWidth: 150,
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '标识名',
|
||||
minWidth: 150,
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'enName',
|
||||
label: '英文标识名'
|
||||
},
|
||||
{
|
||||
prop: 'collection',
|
||||
label: '是否采集'
|
||||
},
|
||||
{
|
||||
prop: 'description',
|
||||
label: '描述',
|
||||
showOverflowtooltip: true
|
||||
}
|
||||
]
|
||||
{
|
||||
prop: 'plcTableName',
|
||||
label: '关联表名',
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
prop: 'code',
|
||||
label: '关联表编码',
|
||||
minWidth: 150,
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '标识名',
|
||||
minWidth: 150,
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
prop: 'enName',
|
||||
label: '英文标识名',
|
||||
},
|
||||
{
|
||||
prop: 'collection',
|
||||
label: '是否采集',
|
||||
},
|
||||
{
|
||||
prop: 'description',
|
||||
label: '描述',
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
];
|
||||
export default {
|
||||
name: "EnergyPlc",
|
||||
components: { EnergyPlcAdd },
|
||||
data() {
|
||||
return {
|
||||
formConfig: [
|
||||
{
|
||||
type: 'input',
|
||||
label: '标识名',
|
||||
placeholder: '标识名',
|
||||
param: 'name'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary'
|
||||
},
|
||||
{
|
||||
type: 'separate'
|
||||
},
|
||||
{
|
||||
type: this.$auth.hasPermi('base:energy-plc:create') ? 'button' : '',
|
||||
btnName: '新增',
|
||||
name: 'add',
|
||||
color: 'success',
|
||||
plain: true
|
||||
}
|
||||
],
|
||||
tableProps,
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi('base:energy-plc:update')
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '编辑'
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:energy-plc:delete')
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除'
|
||||
}
|
||||
: undefined
|
||||
].filter((v) => v),
|
||||
tableH: this.tableHeight(260),
|
||||
collectionList: [
|
||||
{ value: 0, label: '否' },
|
||||
{ value: 1, label: '是' }
|
||||
],
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 班次基础信息列表
|
||||
list: [],
|
||||
// 弹出层标题
|
||||
addOrEditTitle: "",
|
||||
// 是否显示弹出层
|
||||
centervisible: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
name: null
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
this.tableH = this.tableHeight(260)
|
||||
})
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.queryParams.pageNo = 1;
|
||||
this.queryParams.name = val.name
|
||||
this.getList()
|
||||
break
|
||||
default:
|
||||
this.addOrEditTitle = '新增'
|
||||
this.centervisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlc.init()
|
||||
})
|
||||
}
|
||||
},
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
getEnergyPlcPage(this.queryParams).then(response => {
|
||||
let arr = response.data.list || [];
|
||||
arr && arr.map(item => {
|
||||
this.collectionList.map(i => {
|
||||
if (item.collection === i.value) {
|
||||
item.collection = i.label
|
||||
}
|
||||
})
|
||||
})
|
||||
this.list = arr
|
||||
this.total = response.data.total;
|
||||
});
|
||||
},
|
||||
handleClick(val) {
|
||||
switch (val.type) {
|
||||
case 'edit':
|
||||
this.addOrEditTitle = '编辑'
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlc.init(val.data.id)
|
||||
})
|
||||
this.centervisible = true
|
||||
break
|
||||
default:
|
||||
this.handleDelete(val.data)
|
||||
}
|
||||
},
|
||||
handleCancel() {
|
||||
this.$refs.energyPlc.formClear()
|
||||
this.centervisible = false
|
||||
this.addOrEditTitle = ''
|
||||
},
|
||||
handleConfirm() {
|
||||
this.$refs.energyPlc.submitForm()
|
||||
},
|
||||
successSubmit() {
|
||||
this.handleCancel()
|
||||
this.getList()
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.$modal.confirm('是否确认删除关联表名为"' + row.name + '"的数据项?').then(function () {
|
||||
return deleteEnergyPlc(row.id);
|
||||
}).then(() => {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => { });
|
||||
}
|
||||
}
|
||||
name: 'EnergyPlc',
|
||||
components: { EnergyPlcAdd },
|
||||
mixins: [tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
formConfig: [
|
||||
{
|
||||
type: 'input',
|
||||
label: '标识名',
|
||||
placeholder: '标识名',
|
||||
param: 'name',
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
{
|
||||
type: 'separate',
|
||||
},
|
||||
{
|
||||
type: this.$auth.hasPermi('base:energy-plc:create') ? 'button' : '',
|
||||
btnName: '新增',
|
||||
name: 'add',
|
||||
color: 'success',
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
tableProps,
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi('base:energy-plc:update')
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '编辑',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:energy-plc:delete')
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
collectionList: [
|
||||
{ value: 0, label: '否' },
|
||||
{ value: 1, label: '是' },
|
||||
],
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 班次基础信息列表
|
||||
list: [],
|
||||
// 弹出层标题
|
||||
addOrEditTitle: '',
|
||||
// 是否显示弹出层
|
||||
centervisible: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
name: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.queryParams.pageNo = 1;
|
||||
this.queryParams.name = val.name;
|
||||
this.getList();
|
||||
break;
|
||||
default:
|
||||
this.addOrEditTitle = '新增';
|
||||
this.centervisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlc.init();
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
getEnergyPlcPage(this.queryParams).then((response) => {
|
||||
let arr = response.data.list || [];
|
||||
arr &&
|
||||
arr.map((item) => {
|
||||
this.collectionList.map((i) => {
|
||||
if (item.collection === i.value) {
|
||||
item.collection = i.label;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.list = arr;
|
||||
this.total = response.data.total;
|
||||
});
|
||||
},
|
||||
handleClick(val) {
|
||||
switch (val.type) {
|
||||
case 'edit':
|
||||
this.addOrEditTitle = '编辑';
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlc.init(val.data.id);
|
||||
});
|
||||
this.centervisible = true;
|
||||
break;
|
||||
default:
|
||||
this.handleDelete(val.data);
|
||||
}
|
||||
},
|
||||
handleCancel() {
|
||||
this.$refs.energyPlc.formClear();
|
||||
this.centervisible = false;
|
||||
this.addOrEditTitle = '';
|
||||
},
|
||||
handleConfirm() {
|
||||
this.$refs.energyPlc.submitForm();
|
||||
},
|
||||
successSubmit() {
|
||||
this.handleCancel();
|
||||
this.getList();
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.$modal
|
||||
.confirm('是否确认删除关联表名为"' + row.name + '"的数据项?')
|
||||
.then(function () {
|
||||
return deleteEnergyPlc(row.id);
|
||||
})
|
||||
.then(() => {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess('删除成功');
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,226 +1,258 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-drawer :title="drawerTitle" :visible.sync="visible" size="70%" @close='closeD' :show-close='false'>
|
||||
<div class="box">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="关联表名">
|
||||
<el-input v-model="plcTableName" size='small' readonly></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="对象">
|
||||
<el-input v-model="objName" size='small' readonly></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="showBtn">
|
||||
<el-button type="success" size='small' plain @click="addNew">新增</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<base-table
|
||||
:page="queryParams.pageNo"
|
||||
:limit="queryParams.pageSize"
|
||||
:table-props="tableProps"
|
||||
:table-data="tableData"
|
||||
:max-height="tableH"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<pagination
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</div>
|
||||
</el-drawer>
|
||||
<!-- 新增 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="centervisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<energy-plc-param-add ref="energyPlcParam" @successSubmit="successSubmit" />
|
||||
</base-dialog>
|
||||
</div>
|
||||
<div>
|
||||
<el-drawer
|
||||
:title="drawerTitle"
|
||||
:visible.sync="visible"
|
||||
size="70%"
|
||||
@close="closeD"
|
||||
:show-close="false">
|
||||
<div class="box">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="关联表名">
|
||||
<el-input
|
||||
v-model="plcTableName"
|
||||
size="small"
|
||||
readonly
|
||||
style="width: 250px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="对象">
|
||||
<el-input
|
||||
v-model="objName"
|
||||
size="small"
|
||||
readonly
|
||||
style="width: 250px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="showBtn">
|
||||
<el-button
|
||||
type="success"
|
||||
size="small"
|
||||
plain
|
||||
@click="addNew">
|
||||
新增
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<base-table
|
||||
:page="queryParams.pageNo"
|
||||
:limit="queryParams.pageSize"
|
||||
:table-props="tableProps"
|
||||
:table-data="tableData"
|
||||
:max-height="tableH">
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick" />
|
||||
</base-table>
|
||||
<pagination
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
:total="total"
|
||||
@pagination="getList" />
|
||||
</div>
|
||||
</el-drawer>
|
||||
<!-- 新增 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="centervisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel">
|
||||
<energy-plc-param-add
|
||||
ref="energyPlcParam"
|
||||
@successSubmit="successSubmit" />
|
||||
</base-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getEnergyPlcParamPage, deleteEnergyPlcParam } from '@/api/base/energyPlcParam'
|
||||
import EnergyPlcParamAdd from './energyPlcParamAdd'
|
||||
import { publicFormatter } from '@/utils/dict'
|
||||
import {
|
||||
getEnergyPlcParamPage,
|
||||
deleteEnergyPlcParam,
|
||||
} from '@/api/base/energyPlcParam';
|
||||
import EnergyPlcParamAdd from './energyPlcParamAdd';
|
||||
import { publicFormatter } from '@/utils/dict';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'typeId',
|
||||
label: '能源类型'
|
||||
},
|
||||
{
|
||||
prop: 'plcParamName',
|
||||
label: '参数列名'
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '参数名称'
|
||||
},
|
||||
{
|
||||
prop: 'unit',
|
||||
label: '单位',
|
||||
filter: publicFormatter('energy_unit')
|
||||
},
|
||||
{
|
||||
prop: 'collection',
|
||||
label: '是否采集'
|
||||
},
|
||||
{
|
||||
prop: 'description',
|
||||
label: '描述'
|
||||
}
|
||||
]
|
||||
{
|
||||
prop: 'typeId',
|
||||
label: '能源类型',
|
||||
filter: publicFormatter('energy_type'),
|
||||
},
|
||||
{
|
||||
prop: 'plcParamName',
|
||||
label: '参数列名',
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '参数名称',
|
||||
},
|
||||
{
|
||||
prop: 'unit',
|
||||
label: '单位',
|
||||
filter: publicFormatter('unit_dict'),
|
||||
},
|
||||
{
|
||||
prop: 'collection',
|
||||
label: '是否采集',
|
||||
},
|
||||
{
|
||||
prop: 'description',
|
||||
label: '描述',
|
||||
},
|
||||
];
|
||||
export default {
|
||||
name: 'EnergyPlcParam',
|
||||
props: {
|
||||
energyTypeList: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
drawerTitle: '',
|
||||
tableProps,
|
||||
tableData: [],
|
||||
tableBtn: [],
|
||||
tableH: this.tableHeight(115),
|
||||
total: 0,
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 30,
|
||||
connectId: null
|
||||
},
|
||||
plcTableName: '',
|
||||
objName: '',
|
||||
// 弹出层标题
|
||||
addOrEditTitle: "",
|
||||
// 是否显示弹出层
|
||||
centervisible: false,
|
||||
collectionList: [
|
||||
{value: 0,label: '否'},
|
||||
{value: 1,label: '是'}
|
||||
],
|
||||
showBtn: true
|
||||
}
|
||||
},
|
||||
components: { EnergyPlcParamAdd },
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
this.tableH = this.tableHeight(115)
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
init(data,title) {
|
||||
this.visible = true
|
||||
this.queryParams.connectId = data.id
|
||||
this.plcTableName = data.plcTableName
|
||||
this.objName = data.objName
|
||||
this.getList()
|
||||
if (title === 'detail') {
|
||||
this.drawerTitle = '查看参数'
|
||||
this.showBtn = false
|
||||
this.tableBtn = []
|
||||
} else {
|
||||
this.drawerTitle = '参数绑定'
|
||||
this.showBtn = true
|
||||
this.tableBtn = [
|
||||
{
|
||||
type: 'edit',
|
||||
btnName: '编辑'
|
||||
},
|
||||
{
|
||||
type: 'delete',
|
||||
btnName: '删除'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
getList() {
|
||||
getEnergyPlcParamPage({...this.queryParams}).then((res) => {
|
||||
let arr = res.data.list || []
|
||||
arr&&arr.map(item => {
|
||||
this.collectionList.map(i => {
|
||||
if (item.collection === i.value) {
|
||||
item.collection = i.label
|
||||
}
|
||||
})
|
||||
this.energyTypeList.map(j => {
|
||||
if (item.typeId === j.id) {
|
||||
item.typeId = j.name
|
||||
}
|
||||
})
|
||||
})
|
||||
this.tableData = arr
|
||||
this.total = res.data.total;
|
||||
})
|
||||
},
|
||||
// 新增
|
||||
addNew() {
|
||||
this.addOrEditTitle = '新增'
|
||||
this.centervisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlcParam.init({'connectId': this.queryParams.connectId, id: ''})
|
||||
})
|
||||
},
|
||||
handleCancel() {
|
||||
this.$refs.energyPlcParam.formClear()
|
||||
this.centervisible = false
|
||||
this.addOrEditTitle = ''
|
||||
},
|
||||
handleConfirm() {
|
||||
this.$refs.energyPlcParam.submitForm()
|
||||
},
|
||||
successSubmit() {
|
||||
this.handleCancel()
|
||||
this.getList()
|
||||
},
|
||||
handleClick(val) {
|
||||
console.log(val)
|
||||
switch (val.type) {
|
||||
case 'edit':
|
||||
this.addOrEditTitle = '编辑'
|
||||
this.centervisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlcParam.init({'connectId': this.queryParams.connectId, id: val.data.id})
|
||||
})
|
||||
break
|
||||
default:
|
||||
this.handleDelete(val.data)
|
||||
}
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.$modal.confirm('是否确认删除参数列名为"' + row.plcParamName + '"的数据项?').then(function() {
|
||||
return deleteEnergyPlcParam(row.id);
|
||||
}).then(() => {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
closeD() {
|
||||
this.$emit('closeDrawer')
|
||||
}
|
||||
}
|
||||
}
|
||||
name: 'EnergyPlcParam',
|
||||
props: {
|
||||
energyTypeList: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => {
|
||||
return [];
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
drawerTitle: '',
|
||||
tableProps,
|
||||
tableData: [],
|
||||
tableBtn: [],
|
||||
tableH: this.tableHeight(115),
|
||||
total: 0,
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 30,
|
||||
connectId: null,
|
||||
},
|
||||
plcTableName: '',
|
||||
objName: '',
|
||||
// 弹出层标题
|
||||
addOrEditTitle: '',
|
||||
// 是否显示弹出层
|
||||
centervisible: false,
|
||||
collectionList: [
|
||||
{ value: 0, label: '否' },
|
||||
{ value: 1, label: '是' },
|
||||
],
|
||||
showBtn: true,
|
||||
};
|
||||
},
|
||||
components: { EnergyPlcParamAdd },
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
this.tableH = this.tableHeight(115);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
init(data, title) {
|
||||
this.visible = true;
|
||||
this.queryParams.connectId = data.id;
|
||||
this.plcTableName = data.plcTableName;
|
||||
this.objName = data.objName;
|
||||
this.getList();
|
||||
if (title === 'detail') {
|
||||
this.drawerTitle = '查看参数';
|
||||
this.showBtn = false;
|
||||
this.tableBtn = [];
|
||||
} else {
|
||||
this.drawerTitle = '参数绑定';
|
||||
this.showBtn = true;
|
||||
this.tableBtn = [
|
||||
{
|
||||
type: 'edit',
|
||||
btnName: '编辑',
|
||||
},
|
||||
{
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
},
|
||||
];
|
||||
}
|
||||
},
|
||||
getList() {
|
||||
getEnergyPlcParamPage({ ...this.queryParams }).then((res) => {
|
||||
let arr = res.data.list || [];
|
||||
arr &&
|
||||
arr.map((item) => {
|
||||
this.collectionList.map((i) => {
|
||||
if (item.collection === i.value) {
|
||||
item.collection = i.label;
|
||||
}
|
||||
});
|
||||
this.energyTypeList.map((j) => {
|
||||
if (item.typeId === j.id) {
|
||||
item.typeId = j.name;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.tableData = arr;
|
||||
this.total = res.data.total;
|
||||
});
|
||||
},
|
||||
// 新增
|
||||
addNew() {
|
||||
this.addOrEditTitle = '新增';
|
||||
this.centervisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlcParam.init({
|
||||
connectId: this.queryParams.connectId,
|
||||
id: '',
|
||||
});
|
||||
});
|
||||
},
|
||||
handleCancel() {
|
||||
this.$refs.energyPlcParam.formClear();
|
||||
this.centervisible = false;
|
||||
this.addOrEditTitle = '';
|
||||
},
|
||||
handleConfirm() {
|
||||
this.$refs.energyPlcParam.submitForm();
|
||||
},
|
||||
successSubmit() {
|
||||
this.handleCancel();
|
||||
this.getList();
|
||||
},
|
||||
handleClick(val) {
|
||||
console.log(val);
|
||||
switch (val.type) {
|
||||
case 'edit':
|
||||
this.addOrEditTitle = '编辑';
|
||||
this.centervisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.energyPlcParam.init({
|
||||
connectId: this.queryParams.connectId,
|
||||
id: val.data.id,
|
||||
});
|
||||
});
|
||||
break;
|
||||
default:
|
||||
this.handleDelete(val.data);
|
||||
}
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.$modal
|
||||
.confirm('是否确认删除参数列名为"' + row.plcParamName + '"的数据项?')
|
||||
.then(function () {
|
||||
return deleteEnergyPlcParam(row.id);
|
||||
})
|
||||
.then(() => {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess('删除成功');
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
closeD() {
|
||||
this.$emit('closeDrawer');
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.box {
|
||||
padding: 0 32px;
|
||||
padding: 0 32px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -57,14 +57,18 @@ import { getTree } from '@/api/analysis/energyAnalysis';
|
||||
import { getEnergyTypeListAll } from '@/api/base/energyType';
|
||||
import EnergyPlcConnectAdd from './components/energyPlcConnectAdd';
|
||||
import EnergyPlcParam from './components/energyPlcParam';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'objName',
|
||||
label: '对象',
|
||||
minWidth: 130,
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
prop: 'objCode',
|
||||
label: '对象编码',
|
||||
minWidth: 150,
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
@@ -86,11 +90,13 @@ const tableProps = [
|
||||
{
|
||||
prop: 'varNum',
|
||||
label: '绑定参数数量',
|
||||
width: 110,
|
||||
},
|
||||
];
|
||||
export default {
|
||||
name: 'EnergyPlcConnect',
|
||||
components: { EnergyPlcConnectAdd, EnergyPlcParam },
|
||||
mixins: [tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
formConfig: [
|
||||
@@ -144,7 +150,6 @@ export default {
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
tableH: this.tableHeight(260),
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 班次基础信息列表
|
||||
@@ -165,9 +170,6 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
this.tableH = this.tableHeight(260);
|
||||
});
|
||||
this.getList();
|
||||
},
|
||||
mounted() {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<template>
|
||||
<div class="tableInner">
|
||||
<!-- <el-input v-model="list[itemProp]" @blur="changeInput" /> -->
|
||||
<el-input-number v-model="list[itemProp]" @change="changeInput" :min="0" :max="999999999" style='width: 100%;' :controls='false' :precision='2'></el-input-number>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'InputArea',
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
itemProp: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: this.injectData
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeInput() {
|
||||
console.log(this.list)
|
||||
this.$emit('emitData', this.list)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.tableInner .el-input__inner {
|
||||
border: none;
|
||||
padding: 0;
|
||||
height: 33px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,44 +0,0 @@
|
||||
<template>
|
||||
<div class="tableInner">
|
||||
<el-select v-model="list[itemProp]" placeholder="请选择" style="width: 100%;" @change="changeSelect">
|
||||
<el-option
|
||||
v-for="item in getDictDatas(DICT_TYPE.TABLE_NAME)"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'SelectArea',
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
itemProp: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: this.injectData
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeSelect() {
|
||||
console.log(this.list)
|
||||
this.$emit('emitData', this.list)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.tableInner .el-input__inner {
|
||||
border: none;
|
||||
padding: 0;
|
||||
height: 33px;
|
||||
}
|
||||
</style>
|
||||
@@ -40,18 +40,10 @@
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<add-table
|
||||
:table-props="tableProps"
|
||||
:table-data="tableData"
|
||||
:table-name-list="tableNameList"
|
||||
@emitFun="inputChange"
|
||||
@emitButtonClick="emitButtonClick" />
|
||||
<!-- <base-table
|
||||
border
|
||||
:table-props="tableProps"
|
||||
:table-data="tableData"
|
||||
:add-button-show="addButtonShow"
|
||||
@emitFun="inputChange"
|
||||
@emitButtonClick="emitButtonClick" /> -->
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
@@ -64,21 +56,7 @@ import {
|
||||
} from '@/api/base/energyQuantityManual';
|
||||
import moment from 'moment';
|
||||
import AddTable from './AddTable';
|
||||
import InputArea from './InputArea';
|
||||
import SelectArea from './SelectArea';
|
||||
import { energyTableGet } from '@/api/base/energyQuantityManual';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'tableName',
|
||||
label: '表名*',
|
||||
subcomponent: SelectArea,
|
||||
},
|
||||
{
|
||||
prop: 'readingQuantity',
|
||||
label: '抄表数*',
|
||||
subcomponent: InputArea,
|
||||
},
|
||||
];
|
||||
export default {
|
||||
name: 'EnergyQuantityManualAdd',
|
||||
props: {
|
||||
@@ -92,7 +70,6 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableProps,
|
||||
tableData: [],
|
||||
tableNameList: [], //表名list
|
||||
addButtonShow: '新增',
|
||||
@@ -122,6 +99,7 @@ export default {
|
||||
} else if (params.type === 'meterReading') {
|
||||
this.isEdit = false;
|
||||
this.form.energyTypeId = params.energyTypeId;
|
||||
this.selEnergyType(this.form.energyTypeId);
|
||||
let obj = {};
|
||||
obj.tableName = params.tableName + '';
|
||||
obj.readingQuantity = 0;
|
||||
@@ -133,6 +111,7 @@ export default {
|
||||
energyQuantityManualGet({ id: this.form.id }).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.form.energyTypeId = res.data.energyTypeId;
|
||||
this.selEnergyType(this.form.energyTypeId);
|
||||
this.form.recordTime = res.data.recordTime
|
||||
? res.data.recordTime
|
||||
: null;
|
||||
@@ -164,6 +143,11 @@ export default {
|
||||
this.tableNameList = [];
|
||||
energyTableGet({ energyTypeId: id }).then((res) => {
|
||||
this.tableNameList = res.data.tableObjs || [];
|
||||
if (this.tableNameList.length === 0) {
|
||||
this.$modal.msgWarning(
|
||||
'当前能源类型暂无配置表名,请先到《表名配置》页面配置'
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
submitForm() {
|
||||
|
||||
@@ -52,12 +52,12 @@ import { publicFormatter } from '@/utils/dict';
|
||||
import { parseTimeTable } from '@/utils/ruoyi';
|
||||
import EnergyQuantityManualAdd from './components/energyQuantityManualAdd';
|
||||
import moment from 'moment';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'energyType',
|
||||
prop: 'energyTypeLabel',
|
||||
label: '能源类型',
|
||||
minWidth: 110,
|
||||
filter: publicFormatter('energy_type'),
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
@@ -142,7 +142,6 @@ export default {
|
||||
},
|
||||
],
|
||||
tableProps,
|
||||
tableH: this.tableHeight(260),
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 班次基础信息列表
|
||||
@@ -181,10 +180,8 @@ export default {
|
||||
};
|
||||
},
|
||||
components: { EnergyQuantityManualAdd },
|
||||
mixins: [tableHeightMixin],
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
this.tableH = this.tableHeight(260);
|
||||
});
|
||||
let end = moment(moment().format('YYYY-MM-DD 23:59:59')).valueOf();
|
||||
let start = moment(
|
||||
moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')
|
||||
@@ -244,6 +241,11 @@ export default {
|
||||
? item.amount.toFixed(2)
|
||||
: ''
|
||||
: '';
|
||||
this.getDictDatas('energy_type').map((subItem) => {
|
||||
if (item.energyType === subItem.value) {
|
||||
item.energyTypeLabel = subItem.label;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.list = arr;
|
||||
this.total = response.data.total;
|
||||
@@ -305,7 +307,7 @@ export default {
|
||||
handleDelete(row) {
|
||||
console.log(row.id);
|
||||
this.$modal
|
||||
.confirm('是否确认删除能源类型为"' + row.energyType + '"的数据项?')
|
||||
.confirm('是否确认删除能源类型为"' + row.energyTypeLabel + '"的数据项?')
|
||||
.then(function () {
|
||||
return energyQuantityManualDelete({ id: row.id });
|
||||
})
|
||||
|
||||
@@ -1,220 +1,254 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<!-- 列表 -->
|
||||
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps" :table-data="list"
|
||||
:selectWidth="55" :max-height="tableH" @selection-change="selectChange" />
|
||||
<pagination :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" :total="total"
|
||||
@pagination="getList" />
|
||||
</div>
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<search-bar
|
||||
:formConfigs="formConfig"
|
||||
ref="searchBarForm"
|
||||
@headBtnClick="buttonClick" />
|
||||
<!-- 列表 -->
|
||||
<base-table
|
||||
:page="queryParams.pageNo"
|
||||
:limit="queryParams.pageSize"
|
||||
:table-props="tableProps"
|
||||
:table-data="list"
|
||||
:selectWidth="55"
|
||||
:max-height="tableH"
|
||||
@selection-change="selectChange" />
|
||||
<pagination
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
:total="total"
|
||||
@pagination="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getEnergyQuantityRealtimePage } from "@/api/base/energyQuantityRealtime"
|
||||
import { getEnergyTypeListAll } from "@/api/base/energyType"
|
||||
// import { publicFormatter } from '@/utils/dict'
|
||||
import FileSaver from "file-saver"
|
||||
import * as XLSX from 'xlsx/xlsx.mjs'
|
||||
import { getEnergyQuantityRealtimePage } from '@/api/base/energyQuantityRealtime';
|
||||
import { getEnergyTypeListAll } from '@/api/base/energyType';
|
||||
// import { publicFormatter } from '@/utils/dict';
|
||||
import FileSaver from 'file-saver';
|
||||
import * as XLSX from 'xlsx/xlsx.mjs';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'objName',
|
||||
label: '统计对象',
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'objCode',
|
||||
label: '对象编码',
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'energyTypeName',
|
||||
label: '能源类型',
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'startValue',
|
||||
label: '初始值'
|
||||
},
|
||||
{
|
||||
prop: 'endValue',
|
||||
label: '当前值'
|
||||
},
|
||||
{
|
||||
prop: 'diffValue',
|
||||
label: '差值'
|
||||
},
|
||||
{
|
||||
prop: 'amount',
|
||||
label: '金额'
|
||||
}
|
||||
]
|
||||
{
|
||||
prop: 'objName',
|
||||
label: '统计对象',
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
prop: 'objCode',
|
||||
label: '对象编码',
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
prop: 'energyTypeLabel',
|
||||
label: '能源类型',
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
prop: 'startValue',
|
||||
label: '初始值',
|
||||
},
|
||||
{
|
||||
prop: 'endValue',
|
||||
label: '当前值',
|
||||
},
|
||||
{
|
||||
prop: 'diffValue',
|
||||
label: '差值',
|
||||
},
|
||||
{
|
||||
prop: 'amount',
|
||||
label: '金额',
|
||||
},
|
||||
];
|
||||
export default {
|
||||
name: "EnergyQuantityRealtime",
|
||||
data() {
|
||||
return {
|
||||
formConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '能源类型',
|
||||
selectOptions: [],
|
||||
param: 'energyTypeId',
|
||||
filterable: true
|
||||
},
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间',
|
||||
dateType: 'datetimerange',
|
||||
format: 'yyyy-MM-dd HH:mm:ss',
|
||||
valueFormat: "timestamp",
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'timeVal',
|
||||
defaultSelect: [],
|
||||
width: 350
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary'
|
||||
},
|
||||
{
|
||||
type: 'separate'
|
||||
},
|
||||
{
|
||||
type: this.$auth.hasPermi('base:energy-quantity-realtime:export') ? 'button' : '',
|
||||
btnName: '导出',
|
||||
name: 'export',
|
||||
color: 'primary',
|
||||
plain: true
|
||||
}
|
||||
],
|
||||
tableProps,
|
||||
tableH: this.tableHeight(260),
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 班次基础信息列表
|
||||
list: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
energyTypeId: '',
|
||||
startTime: null,
|
||||
endTime: null
|
||||
},
|
||||
energyTypeList: [],
|
||||
exportList: []
|
||||
};
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
this.tableH = this.tableHeight(260)
|
||||
})
|
||||
if (location.href.indexOf('?') > 0) {
|
||||
let arr = location.href.split('?')[1].split('&')
|
||||
this.formConfig[1].defaultSelect = [arr[0].split('=')[1], arr[1].split('=')[1]]
|
||||
} else {
|
||||
this.formConfig[1].defaultSelect = [Date.now() - 7 * 24 * 3600000, Date.now()]
|
||||
}
|
||||
this.queryParams.startTime = this.formConfig[1].defaultSelect[0]
|
||||
this.queryParams.endTime = this.formConfig[1].defaultSelect[1]
|
||||
this.getList();
|
||||
this.getTypeList()
|
||||
},
|
||||
watch: {
|
||||
$route: 'initData'
|
||||
},
|
||||
methods: {
|
||||
initData(to) {
|
||||
if (to.name === 'EnergyQuantityRealtime') {
|
||||
if (location.href.indexOf('?') > 0) {
|
||||
let arr = location.href.split('?')[1].split('&')
|
||||
this.formConfig[1].defaultSelect = [arr[0].split('=')[1], arr[1].split('=')[1]]
|
||||
} else {
|
||||
this.formConfig[1].defaultSelect = [Date.now() - 7 * 24 * 3600000, Date.now()]
|
||||
}
|
||||
this.queryParams.startTime = this.formConfig[1].defaultSelect[0]
|
||||
this.queryParams.endTime = this.formConfig[1].defaultSelect[1]
|
||||
this.getList()
|
||||
}
|
||||
},
|
||||
buttonClick(val) {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.queryParams.energyTypeId = val.energyTypeId
|
||||
this.queryParams.startTime = val.timeVal ? val.timeVal[0] : null
|
||||
this.queryParams.endTime = val.timeVal ? val.timeVal[1] : null
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.getList()
|
||||
break
|
||||
default:
|
||||
this.exportTable()
|
||||
}
|
||||
},
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
getEnergyQuantityRealtimePage(this.queryParams).then(response => {
|
||||
let arr = response.data.list || []
|
||||
arr && arr.map(item => {
|
||||
item.amount = item.amount ? (!isNaN(parseFloat(item.amount)) && isFinite(item.amount) ? item.amount.toFixed(2) : '') : ''
|
||||
})
|
||||
this.list = arr
|
||||
this.total = response.data.total;
|
||||
this.exportList = []
|
||||
});
|
||||
},
|
||||
getTypeList() {
|
||||
getEnergyTypeListAll().then((res) => {
|
||||
this.formConfig[0].selectOptions = res.data || []
|
||||
this.energyTypeList = res.data || []
|
||||
})
|
||||
},
|
||||
selectChange(val) {
|
||||
console.log(val)
|
||||
this.exportList = val
|
||||
},
|
||||
// 勾选导出
|
||||
exportTable() {
|
||||
if (this.exportList.length > 0) {
|
||||
let body = this.exportList.map((x) => [
|
||||
x.objName,
|
||||
x.objCode,
|
||||
x.energyTypeName,
|
||||
x.startValue,
|
||||
x.endValue,
|
||||
x.diffValue,
|
||||
x.amount
|
||||
])
|
||||
let header = []
|
||||
this.tableProps.map((y) => {
|
||||
header.push(y.label)
|
||||
})
|
||||
body.unshift(header)
|
||||
console.log(body)
|
||||
const filename = '能源抄表.xlsx'
|
||||
const ws_name = 'Sheet1'
|
||||
const wb = XLSX.utils.book_new()
|
||||
const ws = XLSX.utils.aoa_to_sheet(body)
|
||||
XLSX.utils.book_append_sheet(wb, ws, ws_name)
|
||||
let wbout = XLSX.write(wb, {
|
||||
bookType: 'xlsx',
|
||||
bookSST: false,
|
||||
type: 'array'
|
||||
})
|
||||
FileSaver.saveAs(
|
||||
new Blob([wbout], {
|
||||
type: 'application/octet-stream'
|
||||
}),
|
||||
filename
|
||||
)
|
||||
} else {
|
||||
this.$modal.msgWarning('请勾选需要导出的数据')
|
||||
}
|
||||
}
|
||||
}
|
||||
name: 'EnergyQuantityRealtime',
|
||||
mixins: [tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
formConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '能源类型',
|
||||
labelField: 'labelName',
|
||||
selectOptions: [],
|
||||
param: 'energyTypeId',
|
||||
filterable: true,
|
||||
},
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间',
|
||||
dateType: 'datetimerange',
|
||||
format: 'yyyy-MM-dd HH:mm:ss',
|
||||
valueFormat: 'timestamp',
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'timeVal',
|
||||
defaultSelect: [],
|
||||
width: 350,
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
{
|
||||
type: 'separate',
|
||||
},
|
||||
{
|
||||
type: this.$auth.hasPermi('base:energy-quantity-realtime:export')
|
||||
? 'button'
|
||||
: '',
|
||||
btnName: '导出',
|
||||
name: 'export',
|
||||
color: 'primary',
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
tableProps,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 班次基础信息列表
|
||||
list: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
energyTypeId: '',
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
},
|
||||
energyTypeList: [],
|
||||
exportList: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if (location.href.indexOf('?') > 0) {
|
||||
let arr = location.href.split('?')[1].split('&');
|
||||
this.formConfig[1].defaultSelect = [
|
||||
arr[0].split('=')[1],
|
||||
arr[1].split('=')[1],
|
||||
];
|
||||
} else {
|
||||
this.formConfig[1].defaultSelect = [
|
||||
Date.now() - 7 * 24 * 3600000,
|
||||
Date.now(),
|
||||
];
|
||||
}
|
||||
this.queryParams.startTime = this.formConfig[1].defaultSelect[0];
|
||||
this.queryParams.endTime = this.formConfig[1].defaultSelect[1];
|
||||
this.getList();
|
||||
this.getTypeList();
|
||||
},
|
||||
watch: {
|
||||
$route: 'initData',
|
||||
},
|
||||
methods: {
|
||||
initData(to) {
|
||||
if (to.name === 'EnergyQuantityRealtime') {
|
||||
if (location.href.indexOf('?') > 0) {
|
||||
let arr = location.href.split('?')[1].split('&');
|
||||
this.formConfig[1].defaultSelect = [
|
||||
arr[0].split('=')[1],
|
||||
arr[1].split('=')[1],
|
||||
];
|
||||
} else {
|
||||
this.formConfig[1].defaultSelect = [
|
||||
Date.now() - 7 * 24 * 3600000,
|
||||
Date.now(),
|
||||
];
|
||||
}
|
||||
this.queryParams.startTime = this.formConfig[1].defaultSelect[0];
|
||||
this.queryParams.endTime = this.formConfig[1].defaultSelect[1];
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
buttonClick(val) {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.queryParams.energyTypeId = val.energyTypeId;
|
||||
this.queryParams.startTime = val.timeVal ? val.timeVal[0] : null;
|
||||
this.queryParams.endTime = val.timeVal ? val.timeVal[1] : null;
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.getList();
|
||||
break;
|
||||
default:
|
||||
this.exportTable();
|
||||
}
|
||||
},
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
getEnergyQuantityRealtimePage(this.queryParams).then((response) => {
|
||||
let arr = response.data.list || [];
|
||||
arr &&
|
||||
arr.map((item) => {
|
||||
item.amount = item.amount
|
||||
? !isNaN(parseFloat(item.amount)) && isFinite(item.amount)
|
||||
? item.amount.toFixed(2)
|
||||
: ''
|
||||
: '';
|
||||
this.getDictDatas('energy_type').map((subItem) => {
|
||||
if (item.energyTypeName === subItem.value) {
|
||||
item.energyTypeLabel = subItem.label;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.list = arr;
|
||||
this.total = response.data.total;
|
||||
this.exportList = [];
|
||||
});
|
||||
},
|
||||
getTypeList() {
|
||||
getEnergyTypeListAll().then((res) => {
|
||||
this.formConfig[0].selectOptions = res.data || [];
|
||||
this.energyTypeList = res.data || [];
|
||||
});
|
||||
},
|
||||
selectChange(val) {
|
||||
console.log(val);
|
||||
this.exportList = val;
|
||||
},
|
||||
// 勾选导出
|
||||
exportTable() {
|
||||
if (this.exportList.length > 0) {
|
||||
let body = this.exportList.map((x) => [
|
||||
x.objName,
|
||||
x.objCode,
|
||||
x.energyTypeLabel,
|
||||
x.startValue,
|
||||
x.endValue,
|
||||
x.diffValue,
|
||||
x.amount,
|
||||
]);
|
||||
let header = [];
|
||||
this.tableProps.map((y) => {
|
||||
header.push(y.label);
|
||||
});
|
||||
body.unshift(header);
|
||||
console.log(body);
|
||||
const filename = '能源抄表.xlsx';
|
||||
const ws_name = 'Sheet1';
|
||||
const wb = XLSX.utils.book_new();
|
||||
const ws = XLSX.utils.aoa_to_sheet(body);
|
||||
XLSX.utils.book_append_sheet(wb, ws, ws_name);
|
||||
let wbout = XLSX.write(wb, {
|
||||
bookType: 'xlsx',
|
||||
bookSST: false,
|
||||
type: 'array',
|
||||
});
|
||||
FileSaver.saveAs(
|
||||
new Blob([wbout], {
|
||||
type: 'application/octet-stream',
|
||||
}),
|
||||
filename
|
||||
);
|
||||
} else {
|
||||
this.$modal.msgWarning('请勾选需要导出的数据');
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -40,6 +40,7 @@ import { getEnergyTypePage, deleteEnergyType } from '@/api/base/energyType';
|
||||
import { publicFormatter } from '@/utils/dict';
|
||||
import InnerTable from './components/InnerTable';
|
||||
import EnergyTypeAdd from './components/energyTypeAdd';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'code',
|
||||
@@ -48,9 +49,8 @@ const tableProps = [
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
prop: 'energyTypeLabel',
|
||||
label: '能源类型',
|
||||
filter: publicFormatter('energy_type'),
|
||||
},
|
||||
{
|
||||
prop: 'unit',
|
||||
@@ -70,6 +70,7 @@ const tableProps = [
|
||||
export default {
|
||||
name: 'EnergyType',
|
||||
components: { EnergyTypeAdd },
|
||||
mixins: [tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
formConfig: [
|
||||
@@ -96,7 +97,7 @@ export default {
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
tableH: this.tableHeight(220),
|
||||
heightNum: 220,
|
||||
pricingMethodList: [
|
||||
{ value: 0, label: '分时间段计价' },
|
||||
{ value: 1, label: '分使用量计价' },
|
||||
@@ -118,9 +119,6 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
this.tableH = this.tableHeight(220);
|
||||
});
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
@@ -142,6 +140,11 @@ export default {
|
||||
item.pricingMethod = i.label;
|
||||
}
|
||||
});
|
||||
this.getDictDatas('energy_type').map((subItem) => {
|
||||
if (item.name === subItem.value) {
|
||||
item.energyTypeLabel = subItem.label;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.list = arr;
|
||||
this.total = response.data.total;
|
||||
@@ -174,8 +177,9 @@ export default {
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
console.log(row);
|
||||
this.$modal
|
||||
.confirm('是否确认删除能源类型为"' + row.name + '"的数据项?')
|
||||
.confirm('是否确认删除能源类型为"' + row.energyTypeLabel + '"的数据项?')
|
||||
.then(function () {
|
||||
return deleteEnergyType(row.id);
|
||||
})
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
import { energyTablePage } from '@/api/base/energyQuantityManual';
|
||||
import { publicFormatter } from '@/utils/dict';
|
||||
import tableNameConfigUpdate from './components/tableNameConfigUpdate.vue';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'energyType',
|
||||
@@ -63,10 +64,11 @@ export default {
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
},
|
||||
tableH: this.tableHeight(165),
|
||||
heightNum: 165,
|
||||
centervisible: false,
|
||||
};
|
||||
},
|
||||
mixins: [tableHeightMixin],
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user