更新 #338

Merged
zwq merged 1 commits from projects/zg-zwq into projects/zg-test 2024-04-15 17:22:41 +08:00
38 changed files with 3363 additions and 490 deletions

View File

@ -0,0 +1,86 @@
/*
* @Author: zwq
* @Date: 2024-04-11 15:00:03
* @LastEditors: zwq
* @LastEditTime: 2024-04-12 10:25:30
* @Description:
*/
import request from '@/utils/request'
// 获得分页数据
export function energyQuantityManualPage(query) {
return request({
url: '/base/energy-quantity-manual/page',
method: 'get',
params: query
})
}
// 创建
export function energyQuantityManualCreate(data) {
return request({
url: '/base/energy-quantity-manual/create',
method: 'post',
data: data
})
}
// 更新
export function energyQuantityManualUpdate(data) {
return request({
url: '/base/energy-quantity-manual/update',
method: 'put',
data: data
})
}
//获得能源抄表(手动)
export function energyQuantityManualGet(query) {
return request({
url: '/base/energy-quantity-manual/get',
method: 'get',
params: query
})
}
//删除
export function energyQuantityManualDelete(query) {
return request({
url: '/base/energy-quantity-manual/delete',
method: 'delete',
params: query
})
}
//导出
export function energyQuantityManualExport(query) {
return request({
url: '/base/energy-quantity-manual/export-excel',
method: 'get',
params: query,
responseType: 'blob'
})
}
// 获得能源表名配置分页
export function energyTablePage() {
return request({
url: '/base/energy-type-meter-bind/list',
method: 'get',
})
}
// 获得能源表名配置
export function energyTableGet(query) {
return request({
url: '/base/energy-type-meter-bind/list',
method: 'get',
params: query
})
}
// 更新能源表名配置
export function energyTableUpdate(data) {
return request({
url: '/base/energy-type-meter-bind/update',
method: 'put',
data: data
})
}

75
src/api/base/material.js Normal file
View File

@ -0,0 +1,75 @@
/*
* @Author: zwq
* @Date: 2024-04-09 16:42:19
* @LastEditors: zwq
* @LastEditTime: 2024-04-10 14:33:52
* @Description:
*/
import request from '@/utils/request'
// 创建原料
export function createMaterial(data) {
return request({
url: '/base/material/create',
method: 'post',
data: data
})
}
// 更新原料
export function updateMaterial(data) {
return request({
url: '/base/material/update',
method: 'put',
data: data
})
}
// 获取code
export function getCode() {
return request({
url: '/base/material/autoCode',
method: 'POST'
})
}
// 删除原料
export function deleteMaterial(id) {
return request({
url: '/base/material/delete?id=' + id,
method: 'delete'
})
}
// 获得原料
export function getMaterial(id) {
return request({
url: '/base/material/get?id=' + id,
method: 'get'
})
}
// 获得原料分页
export function getMaterialPage(query) {
return request({
url: '/base/material/page',
method: 'get',
params: query
})
}
// 获得原料列表
export function getMaterialList() {
return request({
url: '/base/material/list',
method: 'get',
})
}
// 导出原料 Excel
export function exportMaterialExcel(query) {
return request({
url: '/base/material/export-excel',
method: 'get',
params: query,
responseType: 'blob'
})
}

View File

@ -0,0 +1,68 @@
/*
* @Author: zwq
* @Date: 2024-04-09 16:42:19
* @LastEditors: zwq
* @LastEditTime: 2024-04-10 14:31:46
* @Description:
*/
import request from '@/utils/request'
// 创建原料
export function createMaterialPricing(data) {
return request({
url: '/base/material-pricing/create',
method: 'post',
data: data
})
}
// 更新原料
export function updateMaterialPricing(data) {
return request({
url: '/base/material-pricing/update',
method: 'put',
data: data
})
}
// 获取code
export function getCode() {
return request({
url: '/base/material-pricing/autoCode',
method: 'POST'
})
}
// 删除原料
export function deleteMaterialPricing(id) {
return request({
url: '/base/material-pricing/delete?id=' + id,
method: 'delete'
})
}
// 获得原料
export function getMaterialPricing(id) {
return request({
url: '/base/material-pricing/get?id=' + id,
method: 'get'
})
}
// 获得原料分页
export function getMaterialPricingPage(query) {
return request({
url: '/base/material-pricing/page',
method: 'get',
params: query
})
}
// 导出原料 Excel
export function exportMaterialPricingExcel(query) {
return request({
url: '/base/material-pricing/export-excel',
method: 'get',
params: query,
responseType: 'blob'
})
}

View File

@ -0,0 +1,68 @@
/*
* @Author: zwq
* @Date: 2024-04-15 17:01:20
* @LastEditors: zwq
* @LastEditTime: 2024-04-15 17:05:47
* @Description:
*/
import request from '@/utils/request'
// 创建设备
export function createRawOthercostRule(data) {
return request({
url: '/monitoring/cost-othercost-rule/create',
method: 'post',
data: data
})
}
// 更新设备
export function updateRawOthercostRule(data) {
return request({
url: '/monitoring/cost-othercost-rule/update',
method: 'put',
data: data
})
}
// 删除设备
export function deleteRawOthercostRule(id) {
return request({
url: '/monitoring/cost-othercost-rule/delete?id=' + id,
method: 'delete'
})
}
// 获得设备
export function getRawOthercostRule(id) {
return request({
url: '/monitoring/cost-othercost-rule/get?id=' + id,
method: 'get'
})
}
// 获得设备分页
export function getRawOthercostRulePage(query) {
return request({
url: '/monitoring/cost-othercost-rule/page',
method: 'get',
params: query
})
}
// 导出设备 Excel
export function exportRawOthercostRuleExcel(query) {
return request({
url: '/monitoring/cost-othercost-rule/export-excel',
method: 'get',
params: query,
responseType: 'blob'
})
}
// 获得所有设备列表
export function getRawOthercostRuleAll() {
return request({
url: '/monitoring/cost-othercost-rule/listAll',
method: 'get'
})
}

View File

@ -43,6 +43,14 @@ export function getEnergyOverlimitLogPage(data) {
}) })
} }
// 获得手动抄表记录分页
export function getEnergyManualLogPage(data) {
return request({
url: '/monitoring/energy-overlimit-log/pageManual',
method: 'post',
data: data
})
}
// 导出能源超限记录 Excel // 导出能源超限记录 Excel
export function exportEnergyOverlimitLogExcel(query) { export function exportEnergyOverlimitLogExcel(query) {
return request({ return request({

83
src/filter/code-filter.js Normal file
View File

@ -0,0 +1,83 @@
/*
* @Date: 2020-12-29 16:49:28
* @LastEditors: zwq
* @LastEditTime: 2023-12-07 10:00:51
* @FilePath: \basic-admin\src\filters\basicData\index.js
* @Description:
*/
const table = {
lineStatus: {
1: '生产中',
2: '停止',
3: '未知',
},
deactivate: {
1: '启用',
0: '停用',
},
wareType: {
1: '缓存',
2: '活动',
3: '其它',
},
reportType: {
2: '日',
3: '周',
4: '月',
5: '年',
},
manual: {
1: '手动',
0: '自动',
},
}
// 日期格式化
export function parseTime(time, pattern) {
if (arguments.length === 0 || !time) {
return null
}
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
} else if (typeof time === 'string') {
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm),'');
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
}
export default function (dictTable) {
return function (val) {
return table?.[dictTable]?.[val]
}
}

122
src/mixins/basic-add.js Normal file
View File

@ -0,0 +1,122 @@
/*
* @Author: zwq
* @Date: 2022-08-24 11:19:43
* @LastEditors: zwq
* @LastEditTime: 2024-04-10 15:46:19
* @Description:
*/
import { listData } from "@/api/system/dict/data"; //数据字典接口
export default {
data() {
/* eslint-disable */
return {
urlOptions: {
createURL: '', //新增接口
updateURL: '', //编辑提交接口
infoURL: '', //编辑时获取单条数据接口
codeURL: '', //获取code接口返回结果为dataForm.code字段
optionArrUrl: [], //需要获取下拉框的方法数组
optionArr: {}, //需要获取下拉框的方法数组的返回结果
dictNameList: [], //数据字典name数组
dictArr: {}, //需要获取数据字典的方法数组的返回结果
},
visible: false,
setData: false, // 是否需要【编辑时获取单条数据接口】返回的数据操作
}
},
created() {
},
activated() {
},
methods: {
init(id) {
this.dataForm.id = id || null;
this.visible = true;
if (this.urlOptions.optionArrUrl.length > 0) {
this.getArr()
}
if (this.urlOptions.dictNameList.length > 0) {
this.getDict()
}
this.$nextTick(() => {
this.$refs["dataForm"].resetFields();
if (this.dataForm.id) {
this.urlOptions.infoURL(id).then(response => {
this.dataForm = response.data;
if (this.setData) {
this.setDataForm()
}
});
} else {
if (this.urlOptions.codeURL) {
this.getCode()
}
}
});
},
/** 获取code */
getCode() {
this.urlOptions.codeURL()
.then(({ data: res }) => {
this.dataForm.code = res;
})
.catch(() => {});
},
/** 获取下拉框数组 */
getArr() {
const params = {
pageSize: 100,
pageNo: 1,
}
this.urlOptions.optionArrUrl.forEach((item, index) => {
item(params).then(({ data: res }) => {
this.$set(this.urlOptions.optionArr, `arr${index}`, res.list)
})
.catch(() => {
});
});
},
/** 查询字典数据列表 */
getDict() {
this.urlOptions.dictNameList.forEach((item,index)=>{
const queryParams = {
pageNo: 1,
pageSize: 99,
dictType: item,
}
listData(queryParams).then(response => {
this.$set(this.urlOptions.dictArr, `dict${index}`, response.data.list)
});
})
},
// 表单提交
dataFormSubmit() {
this.$refs["dataForm"].validate((valid) => {
if (!valid) {
return false;
}
// 修改的提交
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.visible = false;
this.$emit("refreshDataList");
});
return;
}
// 添加的提交
this.urlOptions.createURL(this.dataForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
/** 清空form */
formClear() {
if (this.$refs.dataForm!==undefined) {
this.$refs.dataForm.resetFields();
}
}
}
}

128
src/mixins/basic-page.js Normal file
View File

@ -0,0 +1,128 @@
/*
* @Author: zwq
* @Date: 2022-08-24 11:19:43
* @LastEditors: zwq
* @LastEditTime: 2024-04-02 09:33:29
* @Description:
*/
export default {
data() {
/* eslint-disable */
return {
urlOptions: {
getDataListURL: '', //获取table接口
deleteURL: '', //删除接口
exportURL: '' //导出接口
},
tableData: [], //table数据
listQuery: { //分页
pageSize: 10,
pageNo: 1,
total: 1,
},
exportLoading: false, //导出完成的加载状态是否开启
dataListLoading: false, //获取table的加载状态是否开启
addOrEditTitle: '', //dialog的title
addOrUpdateVisible: false, //dialog状态
}
},
created() {
},
mounted() {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.list;
this.listQuery.total = response.data.total;
this.dataListLoading = false;
});
},
// 每页数
sizeChangeHandle(val) {
this.listQuery.pageSize = val;
this.listQuery.pageNo = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.listQuery.pageNo = val;
this.getDataList();
},
// 新增
addOrUpdateHandle(id) {
this.addOrEditTitle = "新增";
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id);
});
},
//tableBtn点击
handleClick(val) {
if (val.type === "edit") {
this.addOrUpdateVisible = true;
this.addOrEditTitle = "编辑";
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id);
});
} else if (val.type === "delete") {
this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex)
} else {
this.otherMethods(val)
}
},
// 删除
deleteHandle(id, name, index) {
this.$confirm(`是否确认删除${name ? '名称为"' + name + '"' : '序号为"' + index + '"'}的数据项?`, "系统提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.urlOptions.deleteURL(id).then(({ data }) => {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.getDataList();
},
});
});
})
.catch(() => { });
},
// dialog取消
handleCancel() {
this.$refs.addOrUpdate.formClear()
this.addOrUpdateVisible = false
this.addOrEditTitle = ''
},
// dialog确定
handleConfirm() {
this.$refs.addOrUpdate.dataFormSubmit()
},
// dialog的父组件方法this.$emit("refreshDataList");
successSubmit() {
this.handleCancel()
this.getDataList()
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = { ...this.queryParams };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出所有数据项?').then(() => {
this.exportLoading = true;
return this.urlOptions.exportURL(params);
}).then(response => {
this.$download.excel(response, '报表.xls');
this.exportLoading = false;
}).catch(() => { });
}
}
}

View File

@ -0,0 +1,20 @@
export default {
data() {
return {
tableH: this.tableHeight(260),
};
},
created() {
this.tableH = this?.heightNum ? this.tableHeight(this.heightNum) : this.tableHeight(260);
window.addEventListener('resize', this._setTableHeight);
},
destroyed() {
window.removeEventListener('resize', this._setTableHeight);
},
methods: {
_setTableHeight() {
this.tableH = this?.heightNum ? this.tableHeight(this.heightNum) : this.tableHeight(260);
// this.tableH = this.tableHeight(260);
},
},
};

View File

@ -70,17 +70,17 @@ export const constantRoutes = [
hidden: true hidden: true
}, },
{ {
path: '/', path: "",
component: Layout, component: Layout,
redirect: 'core/base/factory', redirect: "index",
// children: [{ children: [
// path: 'index', {
// redirect: 'core/base/factory', path: "index",
// component: (resolve) => require(['@/views/index'], resolve), component: (resolve) => require(["@/views/index"], resolve),
// name: '首页', name: "首页",
// meta: { title: '首页', icon: 'dashboard', affix: true } meta: { title: "首页", icon: "dashboard", affix: true },
// } },
// ] ],
}, },
{ {
path: '/user', path: '/user',

View File

@ -48,6 +48,50 @@ export function parseTime(time, pattern) {
return time_str return time_str
} }
// 日期格式化(仅适用表格)
export function parseTimeTable(pattern) {
return function(time){
if (arguments.length === 0 || !time) {
return null
}
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
} else if (typeof time === 'string') {
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm),'');
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
}
}
// 表单重置 // 表单重置
export function resetForm(refName) { export function resetForm(refName) {
if (this.$refs[refName]) { if (this.$refs[refName]) {

View File

@ -0,0 +1,94 @@
<!--
* @Author: zwq
* @Date: 2023-08-01 13:52:10
* @LastEditors: zwq
* @LastEditTime: 2024-04-10 09:30:06
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
v-if="visible"
@keyup.enter.native="dataFormSubmit()"
label-width="100px"
label-position="top">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="原料名称" prop="name">
<el-input v-model="dataForm.name" clearable
placeholder="请输入原料名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料等级" prop="level">
<el-input v-model="dataForm.level" clearable
placeholder="请输入原料等级" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料编码" prop="code">
<el-input v-model="dataForm.code" readonly />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="单位" prop="unit">
<el-select
v-model="dataForm.unit"
filterable
clearable
:style="{ width: '100%' }"
placeholder="请选择单位">
<el-option
v-for="item in urlOptions.dictArr.dict0"
:key="item.id"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import basicAdd from '@/mixins/basic-add';
import {
createMaterial,
updateMaterial,
getMaterial,
getCode
} from '@/api/base/material';
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
createURL: createMaterial,
updateURL: updateMaterial,
infoURL: getMaterial,
codeURL: getCode, //codedataForm.code
dictNameList: ['unit_dict'], //name
},
dataForm: {
id: undefined,
code: '',
name: '',
unit: '',
level: '',
},
dataRule: {
name: [
{ required: true, message: '原料不能为空', trigger: 'blur' },
],
code: [{ required: true, message: '编码不能为空', trigger: 'blur' }],
},
};
},
created() {},
methods: {
},
};
</script>

View File

@ -0,0 +1,180 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<!-- 列表 -->
<base-table
v-loading="dataListLoading"
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:table-data="tableData">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="90"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" />
<!-- 对话框(添加 / 修改) -->
<base-dialog
:dialogTitle="addOrEditTitle"
:dialogVisible="addOrUpdateVisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
width="40%">
<add-or-update
ref="addOrUpdate"
@refreshDataList="successSubmit"></add-or-update>
</base-dialog>
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import basicPage from '@/mixins/basic-page';
import { parseTime } from '@/filter/code-filter';
import { publicFormatter } from "@/utils/dict";
import {
deleteMaterial,
getMaterialPage,
} from '@/api/base/material';
const tableProps = [
{
prop: 'createTime',
label: '添加时间',
filter: parseTime,
minWidth: 150
},
{
prop: 'name',
label: '原料名称',
},
{
prop: 'code',
label: '原料编码',
width: 180,
},
{
prop: 'unit',
label: '单位',
filter: publicFormatter('unit_dict'),
},
];
export default {
mixins: [basicPage],
data() {
return {
urlOptions: {
getDataListURL: getMaterialPage,
deleteURL: deleteMaterial,
},
tableProps,
tableBtn: [
this.$auth.hasPermi(`base:material:update`)
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi(`base:material:delete`)
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableData: [],
formConfig: [
{
type: 'input',
label: '原料名称',
placeholder: '原料名称',
param: 'name'
},
{
type: 'input',
label: '原料编码',
placeholder: '原料编码',
param: 'code'
},
{
type: this.$auth.hasPermi('base:material:query')
? 'button'
: '',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type:
this.$auth.hasPermi('base:material:create') &&
this.$auth.hasPermi('base:material:query')
? 'separate'
: '',
},
{
type: this.$auth.hasPermi('base:material:create')
? 'button'
: '',
btnName: '新增',
name: 'add',
color: 'success',
plain: true,
},
],
};
},
components: {
AddOrUpdate,
},
created() {
},
methods: {
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.name = val.name;
this.listQuery.code = val.code;
this.getDataList();
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 20,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
case 'add':
this.addOrEditTitle = '新增';
this.addOrUpdateVisible = true;
this.addOrUpdateHandle();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
},
};
</script>

View File

@ -0,0 +1,156 @@
<!--
* @Author: zwq
* @Date: 2023-08-01 13:52:10
* @LastEditors: zwq
* @LastEditTime: 2024-04-11 09:05:16
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
v-if="visible"
@keyup.enter.native="dataFormSubmit()"
label-width="100px"
label-position="top">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="原料名称" prop="materialId">
<el-select
v-model="dataForm.materialId"
filterable
@change="setCode"
:style="{ width: '100%' }"
placeholder="请选择原料名称">
<el-option
v-for="item in MaterialList"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料编码" prop="code">
<el-input v-model="dataForm.code" clearable readonly />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="生效开始时间" prop="startTime">
<el-date-picker
v-model="dataForm.startTime"
type="date"
value-format="timestamp"
:style="{ width: '100%' }"
placeholder="选择开始时间"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="生效结束时间" prop="endTime">
<el-date-picker
v-model="dataForm.endTime"
type="date"
value-format="timestamp"
:style="{ width: '100%' }"
placeholder="选择结束时间"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="单价" prop="price">
<el-input-number
:min="0"
style="width: 75%"
v-model="dataForm.price"
clearable
placeholder="请输入允许留存时间" />
{{ unit }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="remark">
<el-input
v-model="dataForm.remark"
clearable
placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import basicAdd from '@/mixins/basic-add';
import {
createMaterialPricing,
updateMaterialPricing,
getMaterialPricing,
} from '@/api/base/materialPricing';
import { getMaterialPage } from '@/api/base/material';
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
createURL: createMaterialPricing,
updateURL: updateMaterialPricing,
infoURL: getMaterialPricing,
optionArrUrl: [getMaterialPage], //
dictNameList: ['unit_dict'], //name
},
dataForm: {
id: null,
code: '',
materialId: '',
price: '',
startTime: new Date().getTime(),
endTime: null,
remark: '',
},
setData: true,
MaterialList: [],
unit: '元/吨',
dataRule: {
materialId: [
{ required: true, message: '原料不能为空', trigger: 'blur' },
],
price: [{ required: true, message: '单价不能为空', trigger: 'blur' }],
startTime: [
{
required: true,
message: '生效开始时间不能为空',
trigger: 'change',
},
],
},
};
},
created() {},
methods: {
getArr() {
getMaterialPage({ pageSize: 100, pageNo: 1 }).then((response) => {
this.MaterialList = response.data.list;
});
},
setDataForm() {
if (this.MaterialList.length > 0) {
this.setCode();
} else {
setTimeout(this.setCode(), 1000);
}
},
setCode() {
this.MaterialList.forEach((item) => {
if (item.id === this.dataForm.materialId) {
this.dataForm.code = item.code;
this.unit =
'元/' +
this.urlOptions.dictArr.dict0.find((d) => d.value === item.unit)
.label;
}
});
},
},
};
</script>

View File

@ -0,0 +1,23 @@
<!--
* @Author: zwq
* @Date: 2023-12-05 13:45:59
* @LastEditors: zwq
* @LastEditTime: 2024-04-10 15:20:11
* @Description
-->
<template>
<div>
<span>{{ parseTime(injectData.startTime,'{y}年{m}月{d}日') + '-' + (parseTime(injectData.endTime)?parseTime(injectData.endTime,'{y}年{m}月{d}日'):'永久') }}</span>
</div>
</template>
<script>
export default {
name: '',
props: {
injectData: {
type: Object,
default: () => ({}),
},
},
};
</script>

View File

@ -0,0 +1,182 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<!-- 列表 -->
<base-table
v-loading="dataListLoading"
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:table-data="tableData">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="90"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" />
<!-- 对话框(添加 / 修改) -->
<base-dialog
:dialogTitle="addOrEditTitle"
:dialogVisible="addOrUpdateVisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
width="40%">
<add-or-update
ref="addOrUpdate"
@refreshDataList="successSubmit"></add-or-update>
</base-dialog>
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import connectTime from './connectTime';
import basicPage from '@/mixins/basic-page';
import { parseTime } from '@/filter/code-filter';
import {
deleteMaterialPricing,
getMaterialPricingPage,
} from '@/api/base/materialPricing';
import { getMaterialPage } from '@/api/base/material';
const tableProps = [
{
prop: 'name',
label: '原料名称',
},
{
prop: 'code',
label: '原料编码',
width: 180,
},
{
prop: 'price',
label: '单价(元/吨)',
align: 'right',
},
{
prop: 'createTime',
label: '生效时间',
width: 235,
subcomponent: connectTime,
},
{
prop: 'remark',
label: '备注',
},
];
export default {
mixins: [basicPage],
data() {
return {
urlOptions: {
getDataListURL: getMaterialPricingPage,
deleteURL: deleteMaterialPricing,
},
tableProps,
tableBtn: [
this.$auth.hasPermi(`base:material-pricing:update`)
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi(`base:material-pricing:delete`)
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableData: [],
formConfig: [
{
type: 'select',
label: '原料名称',
selectOptions: [],
param: 'name',
filterable: true,
},
{
type: this.$auth.hasPermi('base:material-pricing:query')
? 'button'
: '',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type:
this.$auth.hasPermi('base:material-pricing:create') &&
this.$auth.hasPermi('base:material-pricing:query')
? 'separate'
: '',
},
{
type: this.$auth.hasPermi('base:material-pricing:create')
? 'button'
: '',
btnName: '新增',
name: 'add',
color: 'success',
plain: true,
},
],
};
},
components: {
AddOrUpdate,
},
created() {
getMaterialPage({ pageSize: 100, pageNo: 1 }).then((response) => {
this.formConfig[0].selectOptions = response.data.list;
});
},
methods: {
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.materialId = val.name;
this.getDataList();
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 20,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
case 'add':
this.addOrEditTitle = '新增';
this.addOrUpdateVisible = true;
this.addOrUpdateHandle();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
},
};
</script>

View File

@ -1,8 +1,8 @@
<!-- <!--
* @Author: zwq * @Author: zwq
* @Date: 2023-08-01 13:52:10 * @Date: 2023-08-01 13:52:10
* @LastEditors: DY * @LastEditors: zwq
* @LastEditTime: 2023-09-21 15:45:07 * @LastEditTime: 2024-04-10 16:31:51
* @Description: * @Description:
--> -->
<template> <template>
@ -65,6 +65,21 @@
placeholder="请输入额外编码" /> placeholder="请输入额外编码" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item prop="pdType" label="产线类型">
<el-select
v-model="dataForm.pdType"
filterable
clearable
placeholder="请选择产线类型">
<el-option
v-for="item in pdTypeArr"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input <el-input
@ -120,7 +135,18 @@ export default {
externalCode: undefined, externalCode: undefined,
remark: undefined, remark: undefined,
description: undefined, description: undefined,
pdType: undefined,
}, },
pdTypeArr: [
{
id: 0,
name: '深加工'
},
{
id: 1,
name: '原片'
}
],
dataRule: { dataRule: {
code: [ code: [
{ required: true, message: '产线编码不能为空', trigger: 'blur' }, { required: true, message: '产线编码不能为空', trigger: 'blur' },

View File

@ -13,7 +13,7 @@
<method-btn <method-btn
v-if="tableBtn.length" v-if="tableBtn.length"
slot="handleBtn" slot="handleBtn"
:width="120" :width="90"
label="操作" label="操作"
:method-list="tableBtn" :method-list="tableBtn"
@clickBtn="handleClick" /> @clickBtn="handleClick" />
@ -52,7 +52,8 @@ import {
const tableProps = [ const tableProps = [
{ {
prop: 'code', prop: 'code',
label: '产线编码' label: '产线编码',
width: 160,
}, },
{ {
prop: 'name', prop: 'name',
@ -66,6 +67,11 @@ const tableProps = [
prop: 'externalCode', prop: 'externalCode',
label: '额外编码' label: '额外编码'
}, },
{
prop: 'pdType',
label: '产线类型',
filter: codeFilter('pdType'),
},
{ {
prop: 'status', prop: 'status',
label: '当前状态', label: '当前状态',
@ -73,16 +79,19 @@ const tableProps = [
}, },
{ {
prop: 'description', prop: 'description',
label: '描述' label: '描述',
showOverflowtooltip: true,
}, },
{ {
prop: 'remark', prop: 'remark',
label: '备注' label: '备注',
showOverflowtooltip: true,
}, },
{ {
prop: 'createTime', prop: 'createTime',
label: '创建时间', label: '创建时间',
filter: parseTime filter: parseTime,
width: 160,
}, },
]; ];

View File

@ -17,7 +17,11 @@ const table = {
1: '日', 1: '日',
2: '周', 2: '周',
3: '月' 3: '月'
} },
pdType: {
1: '原片',
0: '深加工',
},
} }
// 日期格式化 // 日期格式化

View File

@ -0,0 +1,134 @@
<!--
* @Author: zwq
* @Date: 2023-08-01 13:52:10
* @LastEditors: zwq
* @LastEditTime: 2024-03-21 15:59:26
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
v-if="visible"
@keyup.enter.native="dataFormSubmit()"
label-width="100px"
label-position="top">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="原料名称" prop="materialId">
<el-select
v-model="dataForm.materialId"
filterable
clearable
@change="setCode"
:style="{ width: '100%' }"
placeholder="请选择原料名称">
<el-option
v-for="item in MaterialList"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料等级" prop="grade">
<el-select
v-model="dataForm.grade"
filterable
clearable
:style="{ width: '100%' }"
placeholder="请选择原料等级">
<el-option
v-for="item in urlOptions.dictList.dict0"
:key="item.id"
:label="item.label"
:value="parseInt(item.value)"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料编码" prop="code">
<el-input v-model="dataForm.code" clearable readonly />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="单价" prop="price">
<el-input-number
:min="0"
style="width: 80%"
v-model="dataForm.price"
clearable
placeholder="请输入允许留存时间" />
(/)
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="生效开始时间" prop="enabledTime">
<el-date-picker
v-model="dataForm.enabledTime"
type="datetime"
value-format="timestamp"
:style="{ width: '100%' }"
placeholder="选择开始时间"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="生效结束时间" prop="disabledTime">
<el-date-picker
v-model="dataForm.disabledTime"
type="datetime"
value-format="timestamp"
:style="{ width: '100%' }"
placeholder="选择结束时间"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="remark">
<el-input
v-model="dataForm.remark"
clearable
placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import basicAdd from '@/mixins/basic-add';
import {
updateRawOthercostRule,
getRawOthercostRule,
} from '@/api/cost/rawOthercostRule';
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
updateURL: updateRawOthercostRule,
infoURL: getRawOthercostRule,
},
dataForm: {
id: undefined,
code: '',
materialId: '',
price: '',
grade: '',
remark: '',
},
dataRule: {
materialId: [
{ required: true, message: '原料不能为空', trigger: 'change' },
],
price: [{ required: true, message: '单价不能为空', trigger: 'blur' }],
},
};
},
created() {},
methods: {
},
};
</script>

View File

@ -0,0 +1,94 @@
<template>
<div class="app-container">
<!-- 列表 -->
<base-table
v-loading="dataListLoading"
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:max-height="tableH"
:table-data="tableData">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="80"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" />
<!-- 对话框(添加 / 修改) -->
<base-dialog
:dialogTitle="addOrEditTitle"
:dialogVisible="addOrUpdateVisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
width="40%">
<add-or-update
ref="addOrUpdate"
@refreshDataList="successSubmit"></add-or-update>
</base-dialog>
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import basicPage from '@/mixins/basic-page';
import typeRule from './typeRule';
import {
getRawOthercostRulePage,
} from '@/api/cost/rawOthercostRule';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
const tableProps = [
{
prop: 'name',
label: '成本名称',
},
{
prop: 'type',
label: '自动计算方式',
width: 220,
subcomponent: typeRule,
},
{
prop: 'remark',
label: '备注',
},
];
export default {
mixins: [basicPage,tableHeightMixin],
data() {
return {
urlOptions: {
getDataListURL: getRawOthercostRulePage,
deleteURL: deleteCostMaterialSet,
},
tableProps,
tableBtn: [
this.$auth.hasPermi(`extend:cost-material-set:update`)
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
].filter((v) => v),
tableData: [],
};
},
components: {
AddOrUpdate,
},
created() {
},
methods: {
},
};
</script>

View File

@ -0,0 +1,31 @@
<!--
* @Author: zwq
* @Date: 2023-12-05 13:45:59
* @LastEditors: zwq
* @LastEditTime: 2024-04-15 17:12:03
* @Description
-->
<template>
<div>
<span>
{{
injectData.type == 1
? `每天等价,${injectData.price}`
: injectData.type == 2
? `总价${injectData.price}元,年折旧率${injectData.ratio}%,折旧年限${injectData.timeLimit}`
: '-'
}}
</span>
</div>
</template>
<script>
export default {
name: '',
props: {
injectData: {
type: Object,
default: () => ({}),
},
},
};
</script>

View File

@ -2,14 +2,17 @@
<div class="app-container contrastAnalysisBox" id="contrastAnalysisBox"> <div class="app-container contrastAnalysisBox" id="contrastAnalysisBox">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<search-area :isFold="isFold" @submit="getList"/> <search-area :isFold="isFold" @submit="getList"/>
<el-tabs v-model="activeName" @tab-click="switchChart" v-show='chartData.length'> <div v-show="chartData.length">
<el-tab-pane label="柱状图" name="bar"> <bar-chart
<bar-chart ref="analysisBarChart" :chartData="chartData" :timeDim="timeDim" /> ref="analysisBarChart"
</el-tab-pane> :chartData="chartData"
<el-tab-pane label="折线图" name="line"> :timeDim="timeDim" />
<line-chart ref="analysisLineChart" :chartData="chartData" :timeDim="timeDim"/> <base-table
</el-tab-pane> :table-props="tableProps"
</el-tabs> :table-data="list"
:max-height="tableH"
class="contrast-out-table" />
</div>
<!-- 没有数据 --> <!-- 没有数据 -->
<div class="no-data-bg" v-show='!chartData.length'></div> <div class="no-data-bg" v-show='!chartData.length'></div>
</div> </div>
@ -18,17 +21,22 @@
import { getCompare } from "@/api/analysis/energyAnalysis" import { getCompare } from "@/api/analysis/energyAnalysis"
import SearchArea from "./components/searchArea" import SearchArea from "./components/searchArea"
import BarChart from "./components/barChart" import BarChart from "./components/barChart"
import LineChart from "./components/lineChart" import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
import FileSaver from 'file-saver';
import * as XLSX from 'xlsx/xlsx.mjs';
// import moment from 'moment' // import moment from 'moment'
export default { export default {
name: 'ContrastAnalysis', name: 'ContrastAnalysis',
components: { SearchArea, BarChart, LineChart }, components: { SearchArea, BarChart },
mixins: [tableHeightMixin],
data() { data() {
return { return {
isFold: false, isFold: false,
activeName: 'bar', chartData: [],
chartData: [], timeDim: '',
timeDim: '' tableProps: [],
list: [],
tableH: this.tableHeight(250) / 2,
} }
}, },
mounted() { mounted() {
@ -40,28 +48,69 @@ export default {
this.isFold = this.searchBarWidth('contrastAnalysisBox', 1310) this.isFold = this.searchBarWidth('contrastAnalysisBox', 1310)
}, },
methods: { methods: {
_setTableHeight() {
this.tableH = this.tableHeight(250) / 2;
},
getList(params) { getList(params) {
this.timeDim = params.timeDim this.timeDim = params.timeDim
getCompare({ ...params }).then((res) => { getCompare({ ...params }).then((res) => {
console.log(res) if (res.code === 0) {
if (res.code === 0) { this.getTableList(res.data || []);
this.chartData = res.data || [] this.chartData = res.data || [];
} else { } else {
this.chartData = [] this.chartData = []
} }
}) })
}, },
switchChart() { getTableList(arr) {
if (this.activeName === 'bar') { this.tableProps = [];
this.$nextTick((res) => { this.list = [];
this.$refs.analysisBarChart.getChart() let tempX = [];
}) let timeArr = arr[0].trendRespVOList || [];
} else { this.list = timeArr.map((item) => {
this.$nextTick((res) => { return { time: item.time };
this.$refs.analysisLineChart.getChart() });
}) for (let i = 0; i < arr.length; i++) {
} let obj = {};
} obj.prop = arr[i].objId;
obj.label = arr[i].objName;
obj.minWidth = 100;
tempX.push(obj);
let tiemList = arr[i].trendRespVOList;
for (let j = 0; j < tiemList.length; j++) {
this.list[j][arr[i].objId] = tiemList[j].useNum
? tiemList[j].useNum.toFixed(2)
: null;
}
}
this.tableProps = [{ prop: 'time', label: '时间' }].concat(tempX);
},
//
exportExl() {
if (this.list.length > 0) {
var wb = XLSX.utils.table_to_book(
document.querySelector('.contrast-out-table')
);
let fileName = '对比分析.xlsx';
var wbout = XLSX.write(wb, {
bookType: 'xlsx',
bookSST: true,
type: 'array',
});
try {
FileSaver.saveAs(
new Blob([wbout], { type: 'application/octet-stream' }),
fileName
);
this.$message.success('导出成功');
} catch (e) {
if (typeof console !== 'undefined') console.log(e, wbout);
}
return wbout;
} else {
this.$modal.msgWarning('暂无数据导出');
}
},
} }
} }
</script> </script>
@ -93,4 +142,4 @@ export default {
color: rgba(0, 0, 0, 0.45); color: rgba(0, 0, 0, 0.45);
} }
} }
</style> </style>

View File

@ -128,7 +128,18 @@
</div> </div>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" size="small" @click="search">查询</el-button> <el-button type="primary" size="small" @click="search('search')">查询</el-button>
<!-- <span
class="separateStyle"
v-hasPermi="['analysis:energy-analysis:query']"></span>
<el-button
v-hasPermi="['analysis:energy-analysis:query']"
type="primary"
size="small"
plain
@click="search('exportBtn')">
导出
</el-button> -->
</el-form-item> </el-form-item>
</el-form> </el-form>
<span v-if="isFold" class="foldClass" @click='switchMode'> <span v-if="isFold" class="foldClass" @click='switchMode'>
@ -288,7 +299,7 @@ export default {
} }
}, },
// //
search() { search(val) {
if (!this.queryParams.energyTypeId) { if (!this.queryParams.energyTypeId) {
this.$modal.msgError('请选择能源类型') this.$modal.msgError('请选择能源类型')
return false return false
@ -358,7 +369,11 @@ export default {
} }
this.queryParams.startTime = this.queryParams.startTime + '' this.queryParams.startTime = this.queryParams.startTime + ''
this.queryParams.endTime = this.queryParams.endTime + '' this.queryParams.endTime = this.queryParams.endTime + ''
this.$emit('submit', this.queryParams) if (val === 'search') {
this.$emit('submit', this.queryParams);
} else {
this.$emit('export', this.queryParams);
}
}, },
transformTime(timeStamp) {// transformTime(timeStamp) {//
let year = moment(timeStamp).format('YYYY') let year = moment(timeStamp).format('YYYY')
@ -435,4 +450,4 @@ export default {
height: 45px; height: 45px;
overflow: hidden; overflow: hidden;
} }
</style> </style>

View File

@ -1,34 +1,43 @@
<!--
* @Author: zwq
* @Date: 2024-03-27 15:49:55
* @LastEditors: zwq
* @LastEditTime: 2024-04-15 15:47:17
* @Description:
-->
<template> <template>
<div class="app-container trendAnalysisBox" id="trendAnalysisBox"> <div class="app-container trendAnalysisBox" id="trendAnalysisBox">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<search-area :isFold="isFold" @submit="getList"/> <search-area :isFold="isFold" @submit="getList" @export="exportExl"/>
<el-tabs v-model="activeName" @tab-click="switchChart" v-show='chartData.length'> <div v-show="chartData.length">
<el-tab-pane label="柱状图" name="bar"> <base-table
<bar-chart ref="analysisBarChart" :chartData="chartData" :timeDim="timeDim"/> :table-props="tableProps"
</el-tab-pane> :table-data="list"
<el-tab-pane label="折线图" name="line"> class="trend-out-table" />
<line-chart ref="analysisLineChart" :chartData="chartData" :timeDim="timeDim"/> <line-chart
</el-tab-pane> ref="analysisLineChart"
</el-tabs> :chartData="chartData"
:timeDim="timeDim" />
</div>
<!-- 没有数据 --> <!-- 没有数据 -->
<div class="no-data-bg" v-show='!chartData.length'></div> <div class="no-data-bg" v-show='!chartData.length'></div>
</div> </div>
</template> </template>
<script> <script>
import { getEnergyTrend } from "@/api/analysis/energyAnalysis" import { getEnergyTrend, exportTrend } from "@/api/analysis/energyAnalysis"
import SearchArea from "./components/searchArea" import SearchArea from "./components/searchArea"
import BarChart from "./components/barChart"
import LineChart from "./components/lineChart" import LineChart from "./components/lineChart"
// import moment from 'moment' // import moment from 'moment'
export default { export default {
name: 'TrendAnalysis', name: 'TrendAnalysis',
components: { SearchArea, BarChart, LineChart }, components: { SearchArea, LineChart },
data() { data() {
return { return {
isFold: false, isFold: false,
activeName: 'bar',
chartData: [], chartData: [],
timeDim: '' timeDim: '',
tableProps: [],
list: [],
} }
}, },
mounted() { mounted() {
@ -43,52 +52,51 @@ export default {
this.timeDim = params.timeDim this.timeDim = params.timeDim
getEnergyTrend({ ...params }).then((res) => { getEnergyTrend({ ...params }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.chartData = res.data this.getTableList(res.data || []);
this.chartData = res.data || [];
} else { } else {
this.chartData = [] this.chartData = []
} }
}) })
}, },
switchChart() { getTableList(arr) {
if (this.activeName === 'bar') { this.tableProps = [];
this.$nextTick((res) => { this.list = [];
this.$refs.analysisBarChart.getChart() let tempX = [];
}) let listObj = { useNum: '消耗量' }; //
} else { for (let i = 0; i < arr.length; i++) {
this.$nextTick((res) => { let obj = {};
this.$refs.analysisLineChart.getChart() if (this.timeDim === '3') {
}) let fName = arr[i].time.slice(0, 4);
} let lName = arr[i].time.slice(4, 6);
} obj.label = fName + ' 第 ' + lName + ' 周';
} else {
obj.label = arr[i].time;
}
obj.prop = arr[i].time;
obj.minWidth = 100;
tempX.push(obj);
listObj[arr[i].time] = arr[i].useNum || null;
}
this.tableProps = [{ prop: 'useNum', label: '时间' }].concat(tempX);
this.list.push(listObj);
},
// excel
exportExl(params) {
exportTrend({ ...params })
.then((response) => {
this.$download.excel(response, '走势分析.xls');
this.$message.success('导出成功');
})
.catch(() => {});
},
} }
} }
</script> </script>
<style lang='scss'> <style lang='scss'>
.trendAnalysisBox { .trendAnalysisBox {
.el-tabs__nav::after { .trend-out-table {
content: ""; margin-bottom: 15px;
position: absolute; }
left: 0;
bottom: 0;
width: 100%;
height: 2px;
background-color: #e4e7ed;
/* z-index: 1; */
}
.el-tabs__nav-wrap::after {
width: 0;
}
.el-tabs__item {
padding: 0 10px;
}
.el-tabs__item:hover {
color: rgba(0, 0, 0, 0.85);
}
.el-tabs__item.is-active {
color: rgba(0, 0, 0, 0.85);
}
.el-tabs__item {
color: rgba(0, 0, 0, 0.45);
}
} }
</style> </style>

View File

@ -16,7 +16,6 @@
v-model="objIds" v-model="objIds"
:options="objList" :options="objList"
:props="{ checkStrictly: true, value: 'id', label: 'name' }" :props="{ checkStrictly: true, value: 'id', label: 'name' }"
popper-class="cascaderParent"
@change="selectObj" @change="selectObj"
clearable></el-cascader> clearable></el-cascader>
</el-form-item> </el-form-item>
@ -141,4 +140,4 @@ export default {
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio { .cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
display: none; display: none;
} }
</style> </style>

View File

@ -66,7 +66,7 @@ const tableProps = [
label: '对象备注' label: '对象备注'
}, },
{ {
prop: 'plcTableName', prop: 'plcTableName',
label: '关联表名' label: '关联表名'
}, },
{ {
@ -193,7 +193,6 @@ export default {
}); });
}, },
handleClick(val) { handleClick(val) {
console.log(val)
switch (val.type) { switch (val.type) {
case 'edit': case 'edit':
this.addOrEditTitle = '编辑' this.addOrEditTitle = '编辑'

View File

@ -0,0 +1,141 @@
<template>
<div class="energyQuantityManualAddTable">
<el-table
:data="renderData"
border
style="width: 100%"
:header-cell-style="{
background: '#F2F4F9',
color: '#606266',
}">
<el-table-column prop="meter" label="表名*">
<template slot-scope="scope">
<div class="tableInner">
<el-select
v-model="scope.row.meter"
placeholder="请选择"
style="width: 100%"
:disabled="isEdit"
@change="changeSelect(scope.row, 'meter')">
<el-option
v-for="item in tableNameList"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</div>
</template>
</el-table-column>
<el-table-column prop="readingQuantity" label="抄表数*">
<template slot-scope="scope">
<div class="tableInner">
<el-input-number
v-model="scope.row.readingQuantity"
:min="0"
:max="999999999"
style="width: 100%"
:controls="false"
@change="changeInput(scope.row, 'readingQuantity')"
:precision="2"></el-input-number>
</div>
</template>
</el-table-column>
</el-table>
<el-button
v-show="!isEdit"
class="addButton"
icon="el-icon-plus"
@click="emitButtonClick">
新增
</el-button>
</div>
</template>
<script>
export default {
name: 'AddTable',
props: {
tableData: {
type: Array,
required: true,
default: () => {
return [];
},
},
tableNameList: {
type: Array,
required: true,
default: () => {
return [];
},
},
isEdit: {
type: Boolean,
default: false,
},
},
data() {
return {};
},
computed: {
renderData() {
return this.tableData.map((item, index) => {
return {
...item,
_pageIndex: index + 1,
};
});
},
},
methods: {
emitButtonClick() {
this.$emit('emitButtonClick');
},
changeInput(val1, val2) {
val1.prop = val2;
this.$emit('emitFun', val1);
},
changeSelect(val1, val2) {
val1.prop = val2;
this.$emit('emitFun', val1);
},
},
};
</script>
<style lang="scss" scoped>
.energyQuantityManualAddTable {
.el-table .el-table__cell {
padding: 0;
height: 35px;
}
.addButton {
width: 100%;
height: 35px;
border-top: none;
color: #0b58ff;
border-color: #ebeef5;
border-radius: 0;
}
.addButton:hover {
color: #0b58ff;
border-color: #ebeef5;
background-color: #fff;
}
.addButton:focus {
border-color: #ebeef5;
background-color: #fff;
}
.tableInner .el-input__inner {
border: none;
padding: 0;
height: 33px;
}
}
</style>
<style lang="scss">
.energyQuantityManualAddTable {
.el-table .el-table__cell {
padding: 0;
height: 35px;
}
}
</style>

View File

@ -0,0 +1,215 @@
<template>
<el-form
ref="energyQuantityManualForm"
:rules="rules"
label-width="90px"
:model="form">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="能源类型" prop="energyTypeId">
<el-select
v-model="form.energyTypeId"
placeholder="请选择"
style="width: 100%"
@change="selEnergyType"
:disabled="isEdit"
filterable>
<el-option
v-for="item in this.energyTypeList"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="抄表日期" prop="recordTime">
<el-date-picker
v-model="form.recordTime"
type="date"
format="yyyy-MM-dd"
value-format="timestamp"
placeholder="选择日期"
style="width: 100%"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<add-table
:table-data="tableData"
:table-name-list="tableNameList"
:isEdit="isEdit"
@emitFun="inputChange"
@emitButtonClick="emitButtonClick" />
</el-col>
</el-row>
</el-form>
</template>
<script>
import {
energyQuantityManualCreate,
energyQuantityManualUpdate,
energyQuantityManualGet,
} from '@/api/base/energyQuantityManual';
import moment from 'moment';
import AddTable from './AddTable';
import { energyTableGet } from '@/api/base/energyQuantityManual';
export default {
name: 'EnergyQuantityManualAdd',
props: {
energyTypeList: {
type: Array,
required: true,
default: () => {
return [];
},
},
},
data() {
return {
tableData: [],
tableNameList: [], //list
addButtonShow: '新增',
form: {
id: '',
energyTypeId: '',
unit: '',
recordTime: '',
},
rules: {
energyTypeId: [
{ required: true, message: '能源类型不能为空', trigger: 'change' },
],
recordTime: [
{ required: true, message: '抄表日期不能为空', trigger: 'change' },
],
},
isEdit: false,
meterArr: [],
};
},
components: { AddTable },
methods: {
init(params) {
this.form.recordTime = moment().valueOf();
this.meterArr = this.getDictDatas('meter');
if (params.type === 'add') {
this.isEdit = false;
} else if (params.type === 'meterReading') {
this.isEdit = false;
this.form.energyTypeId = params.energyTypeId;
this.selEnergyType(this.form.energyTypeId);
let obj = {};
obj.meter = params.meter + '';
obj.readingQuantity = 0;
this.tableData.push(obj);
} else {
this.isEdit = true;
this.form.id = params.id;
this.addButtonShow = '';
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;
let obj = {};
obj.meter = res.data.meter ? res.data.meter + '' : '';
obj.readingQuantity = res.data.readingQuantity;
this.tableData.push(obj);
}
});
}
},
inputChange(val) {
this.tableData[val._pageIndex - 1][val.prop] = val[val.prop];
},
emitButtonClick() {
if (!this.form.energyTypeId) {
this.$modal.msgWarning('请先选择能源类型');
return false;
}
let obj = {};
obj.meter = '';
obj.readingQuantity = 0;
this.tableData.push(obj);
},
selEnergyType(id) {
//
this.tableData = [];
this.tableNameList = [];
energyTableGet({ energyTypeId: id }).then((res) => {
if (res.data.length === 0) {
this.$modal.msgWarning(
'当前能源类型暂无配置表名,请先到《表名配置》页面配置'
);
return;
}
res.data[0].meters.forEach((meter) => {
this.tableNameList.push(this.meterArr.find((i) => i.value === meter));
});
});
},
submitForm() {
this.$refs['energyQuantityManualForm'].validate((valid) => {
if (valid) {
//
if (this.tableData.length === 0) {
this.$modal.msgError('抄表数据不能为空');
return false;
} else {
for (let item of this.tableData) {
if (
!item.meter ||
(!item.readingQuantity && item.readingQuantity !== 0)
) {
this.$modal.msgError('抄表数据有空值,请检查');
return false;
}
}
}
if (this.isEdit) {
//
energyQuantityManualUpdate({
id: this.form.id,
recordTime: this.form.recordTime,
readingQuantity: this.tableData[0].readingQuantity,
}).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit');
}
});
} else {
let obj = {};
this.tableData.forEach((item) => {
obj[item.meter] = item.readingQuantity;
});
energyQuantityManualCreate({
energyTypeId: this.form.energyTypeId,
recordTime: this.form.recordTime,
meters: obj,
}).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit');
}
});
}
} else {
return false;
}
});
},
formClear() {
this.$refs.energyQuantityManualForm.resetFields();
this.form.unit = '';
this.isEdit = false;
this.addButtonShow = '新增';
this.tableData = [];
},
},
};
</script>

View File

@ -0,0 +1,332 @@
<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"
@selection-change="selectChange">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="120"
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-quantity-manual-add
ref="energyQuantityManualAdd"
:energyTypeList="energyTypeList"
@successSubmit="successSubmit" />
</base-dialog>
</div>
</template>
<script>
import {
energyQuantityManualPage,
energyQuantityManualDelete,
energyQuantityManualExport,
} from '@/api/base/energyQuantityManual';
import { getEnergyTypeListAll } from '@/api/base/energyType';
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',
label: '能源类型',
minWidth: 110,
showOverflowtooltip: true,
},
{
prop: 'unit',
label: '单位',
filter: publicFormatter('unit_dict'),
minWidth: 110,
},
{
prop: 'meter',
label: '能源表名',
filter: publicFormatter('meter'),
minWidth: 110,
showOverflowtooltip: true,
},
{
prop: 'recordTime',
label: '抄表日期',
filter: parseTimeTable('{y}-{m}-{d}'),
minWidth: 110,
},
{
prop: 'readingQuantity',
label: '抄表值',
},
{
prop: 'usingQuantity',
label: '差值',
},
];
export default {
name: 'EnergyQuantityManual',
data() {
return {
formConfig: [
{
type: 'select',
label: '能源类型',
labelField: 'name',
selectOptions: [],
param: 'energyTypeId',
filterable: true,
},
{
type: 'datePicker',
label: '抄表日期',
dateType: 'daterange',
format: 'yyyy-MM-dd',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
valueFormat:"yyyy-MM-dd HH:mm:ss",
param: 'timeVal',
defaultSelect: [],
},
{
type: this.$auth.hasPermi('base:energy-quantity-manual:query')
? 'button'
: '',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: this.$auth.hasPermiOr([
'base:energy-quantity-manual:export',
'base:energy-quantity-manual:create',
])
? 'separate'
: '',
},
// {
// type: this.$auth.hasPermi('base:energy-quantity-manual:export')
// ? 'button'
// : '',
// btnName: '',
// name: 'export',
// color: 'primary',
// plain: true,
// },
{
type: this.$auth.hasPermi('base:energy-quantity-manual:create')
? 'button'
: '',
btnName: '新增',
name: 'add',
color: 'success',
plain: true,
},
],
tableProps,
//
total: 0,
//
list: [],
tableBtn: [
this.$auth.hasPermiAnd([
'base:energy-quantity-manual:query',
'base:energy-quantity-manual:create',
])
? {
type: 'meterReading',
btnName: '抄表',
}
: undefined,
this.$auth.hasPermiAnd([
'base:energy-quantity-manual:update',
'base:energy-quantity-manual:query',
])
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi('base:energy-quantity-manual:delete')
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
//
queryParams: {
pageNo: 1,
pageSize: 20,
energyTypeId: '',
startTime: '',
endTime: '',
},
energyTypeList: [],
exportList: [],
addOrEditTitle: '',
centervisible: false,
};
},
components: { EnergyQuantityManualAdd },
mixins: [tableHeightMixin],
created() {
let end = moment().format('YYYY-MM-DD 23:59:59').valueOf();
let start = moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00').valueOf();
this.formConfig[1].defaultSelect = [start, end];
this.queryParams.startTime = start;
this.queryParams.endTime = end;
this.getList();
this.getTypeList();
},
methods: {
buttonClick(val) {
console.log(val.timeVal)
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].substr(0, 10) + " 23:59:59"
: null;
switch (val.btnName) {
case 'search':
this.getList();
break;
case 'add':
this.addOrEditTitle = '新增';
this.centervisible = true;
let params = {};
params.type = 'add';
this.$nextTick(() => {
this.$refs.energyQuantityManualAdd.init(params);
});
break;
default:
this.$modal
.confirm('是否确认导出')
.then(() => {
return energyQuantityManualExport({
energyTypeId: this.queryParams.energyTypeId,
startTime: this.queryParams.startTime,
endTime: this.queryParams.endTime,
});
})
.then((response) => {
this.$download.excel(response, '能源报表.xls');
})
.catch(() => {});
}
},
/** 查询列表 */
getList() {
energyQuantityManualPage(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;
},
handleClick(val) {
console.log(val);
switch (val.type) {
case 'edit':
this.addOrEditTitle = '编辑';
this.centervisible = true;
let paramA = {};
paramA.type = 'edit';
paramA.id = val.data.id;
this.$nextTick(() => {
this.$refs.energyQuantityManualAdd.init(paramA);
});
break;
case 'meterReading':
this.addOrEditTitle = '新增';
this.centervisible = true;
let paramB = {};
paramB.type = 'meterReading';
paramB.energyTypeId = val.data.energyTypeId;
paramB.meter = val.data.meter;
this.$nextTick(() => {
this.$refs.energyQuantityManualAdd.init(paramB);
});
break;
default:
this.handleDelete(val.data);
}
},
//
handleCancel() {
this.$refs.energyQuantityManualAdd.formClear();
this.centervisible = false;
this.addOrEditTitle = '';
},
handleConfirm() {
this.$refs.energyQuantityManualAdd.submitForm();
},
successSubmit() {
this.handleCancel();
this.getList();
},
/** 删除按钮操作 */
handleDelete(row) {
console.log(row.id);
this.$modal
.confirm('是否确认删除能源类型为"' + row.energyType + '"的数据项?')
.then(function () {
return energyQuantityManualDelete({ id: row.id });
})
.then(() => {
this.queryParams.pageNo = 1;
this.getList();
this.$modal.msgSuccess('删除成功');
})
.catch(() => {});
},
},
};
</script>

View File

@ -163,7 +163,6 @@ export default {
}) })
}, },
selectChange(val) { selectChange(val) {
console.log(val)
this.exportList = val this.exportList = val
}, },
// //

View File

@ -0,0 +1,85 @@
<!--
* @Author: zwq
* @Date: 2024-04-11 14:57:57
* @LastEditors: zwq
* @LastEditTime: 2024-04-12 08:53:41
* @Description:
-->
<template>
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
<el-form-item label="能源类型" prop="energyType">
<el-input v-model="form.energyType"></el-input>
</el-form-item>
<el-form-item label="能源表名" prop="meters">
<el-select
v-model="form.meters"
placeholder="请选择"
style="width: 100%"
:multiple="true"
filterable>
<el-option
v-for="dict in getDictDatas('meter')"
:key="dict.id"
:label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
</el-form>
</template>
<script>
import {
energyTableGet,
energyTableUpdate,
} from '@/api/base/energyQuantityManual';
export default {
name: 'TableNameConfigUpdate',
data() {
return {
form: {
energyType: '',
energyTypeId: '',
meters: [],
},
rules: {
meters: [
{ required: true, message: '能源表名不能为空', trigger: 'change' },
],
},
};
},
methods: {
init(id) {
energyTableGet({ energyTypeId: id }).then((res) => {
if (res.data.length > 0) {
this.form.energyType = res.data[0].energyType || '';
this.form.energyTypeId = res.data[0].energyTypeId || '';
this.form.meters =
res.data[0].meters &&
res.data[0].meters.map((item) => {
return item;
});
}
});
},
submitForm() {
this.$refs['form'].validate((valid) => {
if (valid) {
//
energyTableUpdate({ ...this.form }).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit');
}
});
}
});
},
formClear() {
this.form.energyType = '';
this.form.energyTypeId = '';
this.form.meters = [];
this.isEdit = false;
},
},
};
</script>

View File

@ -0,0 +1,118 @@
<template>
<div class="app-container">
<!-- 列表 -->
<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>
<!-- 新增 -->
<base-dialog
dialogTitle="编辑"
:dialogVisible="centervisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel">
<table-name-config-update
ref="tableNameConfigU"
@successSubmit="successSubmit" />
</base-dialog>
</div>
</template>
<script>
import { energyTablePage } from '@/api/base/energyQuantityManual';
import tableNameConfigUpdate from './components/tableNameConfigUpdate.vue';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
const tableProps = [
{
prop: 'energyType',
label: '能源类型',
width: 200,
},
{
prop: 'tableName',
label: '能源表名',
},
];
export default {
name: 'TableNameConfig',
components: { tableNameConfigUpdate },
data() {
return {
tableProps,
tableBtn: [
this.$auth.hasPermiAnd(['base:energy-table:update'])
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
].filter((v) => v),
list: [],
queryParams: {
pageNo: 1,
pageSize: 100,
},
heightNum: 165,
centervisible: false,
meterArr: [],
};
},
mixins: [tableHeightMixin],
created() {
this.meterArr = this.getDictDatas('meter');
this.$nextTick(() => {
this.getList();
});
},
methods: {
getList() {
energyTablePage().then((res) => {
let temp = res.data || [];
this.list = temp.map((item) => {
let meters = [];
item.meters.forEach((meter) => {
meters.push(
this.meterArr.find((i) =>
i.value === meter
).label
);
});
return {
energyType: item.energyType,
energyTypeId: item.energyTypeId,
tableName: meters.join('、'),
};
});
});
},
handleClick(val) {
console.log('编辑');
this.centervisible = true;
this.$nextTick(() => {
this.$refs.tableNameConfigU.init(val.data.energyTypeId);
});
},
handleCancel() {
this.$refs.tableNameConfigU.formClear();
this.centervisible = false;
},
handleConfirm() {
this.$refs.tableNameConfigU.submitForm();
},
successSubmit() {
this.handleCancel();
this.getList();
},
},
};
</script>

View File

@ -1,3 +1,10 @@
<!--
* @Author: zwq
* @Date: 2024-03-27 15:49:55
* @LastEditors: zwq
* @LastEditTime: 2024-04-12 15:16:48
* @Description:
-->
<template> <template>
<div class="tableInner"> <div class="tableInner">
<el-input-number v-model="list[itemProp]" @blur="changeInput" :min="0" :max="100000000" style="width: 100%" :controls='false'></el-input-number> <el-input-number v-model="list[itemProp]" @blur="changeInput" :min="0" :max="100000000" style="width: 100%" :controls='false'></el-input-number>

View File

@ -1,3 +1,10 @@
<!--
* @Author: zwq
* @Date: 2024-03-27 15:49:55
* @LastEditors: zwq
* @LastEditTime: 2024-04-12 15:16:56
* @Description:
-->
<template> <template>
<div class="tableInner"> <div class="tableInner">
<el-time-picker <el-time-picker

View File

@ -1,237 +1,360 @@
<template> <template>
<el-form ref="form" :rules="rules" label-width="110px" :model="form"> <el-form ref="form" :rules="rules" label-width="110px" :model="form">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="监控对象" prop="objectId"> <el-form-item label="抄表方式" prop="manual">
<el-cascader <el-select
style='width: 100%;' v-model="form.manual"
v-model="objIds" placeholder="请选择"
:options="objList" style="width: 100%"
:props="{ checkStrictly: true, value: 'id', label: 'name' }" @change="changeMethod,$forceUpdate">
popper-class="cascaderParent" <el-option
@change="selectObj" v-for="item in manualArr"
clearable></el-cascader> :key="item.value"
</el-form-item> :label="item.label"
</el-col> :value="item.value"></el-option>
<el-col :span="12"> </el-select>
<el-form-item label="能源类型" prop="energyTypeId"> </el-form-item>
<el-select v-model="form.energyTypeId" placeholder="请选择" style="width: 100%;" @change="toggleType"> </el-col>
<el-option <el-col :span="12" v-if="form.manual == 0">
v-for="item in this.energyTypeList" <el-form-item label="监控对象" prop="objectId">
:key="item.id" <el-cascader
:label="item.name" style="width: 100%"
:value="item.id"> v-model="objIds"
</el-option> :options="objList"
</el-select> :props="{ checkStrictly: true, value: 'id', label: 'name' }"
</el-form-item> @change="selectObj"
</el-col> clearable></el-cascader>
</el-row> </el-form-item>
<el-row> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="监控模式" prop="type"> <el-form-item label="监控能源类型" prop="energyTypeId">
<el-select v-model="form.type" placeholder="请选择" style="width: 100%;" @change="typeChange"> <el-select
<el-option label="合并" :value= "1" ></el-option> v-model="form.energyTypeId"
<el-option label="详细" :value= "2" ></el-option> placeholder="请选择"
</el-select> style="width: 100%"
</el-form-item> filterable
</el-col> @change="toggleType">
<el-col :span="12"> <el-option
<el-form-item label="监控详细参数" prop="type" v-if="form.type === 2"> v-for="item in this.energyTypeList"
<el-select v-model="form.plcParamId" placeholder="请选择" style="width: 100%;" @change="selectDetail"> :key="item.id"
<el-option :label="item.name"
v-for="item in detailList" :value="item.id"></el-option>
:key="item.id" </el-select>
:label="item.name" </el-form-item>
:value="item.id"> </el-col>
</el-option> <el-col :span="12" v-if="form.manual == 1">
</el-select> <el-form-item label="能源表名" prop="meter">
</el-form-item> <el-select
</el-col> v-model="form.meter"
</el-row> placeholder="请选择"
<el-row> style="width: 100%"
<el-col :span="12"> @change="$forceUpdate()">
<el-form-item label="指标类型" prop="limitType"> <el-option
<el-select v-model="form.limitType" placeholder="请选择" style="width: 100%;"> v-for="item in tableNameList"
<el-option :key="item.value"
v-for="item in getDictDatas(DICT_TYPE.MONITOR_INDEX_TYPE)" :label="item.label"
:key="item.value" :value="item.value"></el-option>
:label="item.label" </el-select>
:value="item.value"> </el-form-item>
</el-option> </el-col>
</el-select> <el-col :span="12" v-if="form.manual == 0">
</el-form-item> <el-form-item label="监控模式" prop="type">
</el-col> <el-select
<el-col :span="12"> v-model="form.type"
<el-form-item label="消耗量阈值" prop="limitValue"> placeholder="请选择"
<el-input-number v-model="form.limitValue" :min="0" :max="10000000000000000" style="width: 100%;"></el-input-number> style="width: 100%"
</el-form-item> @change="typeChange">
</el-col> <el-option label="合并" :value="1"></el-option>
</el-row> <el-option label="详细" :value="2"></el-option>
</el-form> </el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.manual == 0">
<el-form-item label="监控详细参数" prop="type" v-if="form.type === 2">
<el-select
v-model="form.plcParamId"
placeholder="请选择"
style="width: 100%"
@change="selectDetail">
<el-option
v-for="item in detailList"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="指标类型" prop="limitType">
<el-select
v-model="form.limitType"
placeholder="请选择"
style="width: 100%"
:disabled="form.manual == 1"
@change="$forceUpdate()">
<el-option
v-for="item in getDictDatas(DICT_TYPE.MONITOR_INDEX_TYPE)"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="消耗量阈值">
<el-input-number
v-model="form.downValue"
placeholder="最小值"
:max="9999999"
style="width: 50%"></el-input-number>
<el-input-number
v-model="form.upValue"
placeholder="最大值"
:max="9999999"
style="width: 50%"></el-input-number>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template> </template>
<script> <script>
import { getEnergyLimit, updateEnergyLimit, createEnergyLimit, getEnergyParamList } from '@/api/monitoring/energyLimit' import {
getEnergyLimit,
updateEnergyLimit,
createEnergyLimit,
getEnergyParamList,
} from '@/api/monitoring/energyLimit';
import { energyTableGet } from '@/api/base/energyQuantityManual';
export default { export default {
name: 'energyLimitAdd', name: 'energyLimitAdd',
props: { props: {
energyTypeList: { energyTypeList: {
type: Array, type: Array,
required: true, required: true,
default: () => { default: () => {
return [] return [];
} },
}, },
objList: { objList: {
type: Array, type: Array,
default: () => [] default: () => [],
} },
}, },
data() { data() {
return { return {
form: { form: {
id: '', id: '',
objectId: '', manual: '0',
objectType: '', objectId: '',
energyTypeId: '', objectType: '',
type: '', energyTypeId: '',
plcParamId: '', type: '',
limitType: '', plcParamId: '',
limitValue: '' limitType: '',
}, downValue: 0,
objIds: [],// upValue: 0,
isEdit: false, // meter: '',
rules: { },
objectId: [{ required: true, message: '对象不能为空', trigger: 'change' }], objIds: [], //
energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }], tableNameList: [],
type: [{ required: true, message: '监控模式不能为空', trigger: 'change' }] isEdit: false, //
}, manualArr: [
detailList: [] {
} value: '1',
}, label: '手动',
methods: { },
init(id) { {
if (id) { value: '0',
this.isEdit = true label: '自动',
this.form.id = id },
getEnergyLimit( id ).then((res) => { ],
if (res.code === 0) { rules: {
this.form = res.data manual: [
this.form.plcParamId = res.data.plcParamId || '' { required: true, message: '抄表方式不能为空', trigger: 'change' },
this.form.limitType = this.form.limitType ? this.form.limitType + '' : '' ],
this.objIds = this.changeDetSelect(this.form.objectId, this.objList) objectId: [
if (this.form.type === 2) { { required: true, message: '监控对象不能为空', trigger: 'change' },
this.getDetailList() ],
} energyTypeId: [
} { required: true, message: '能源类型不能为空', trigger: 'change' },
}) ],
} else { type: [
this.isEdit = false { required: true, message: '监控模式不能为空', trigger: 'change' },
this.form.id = '' ],
} limitType: [
}, { required: true, message: '指标类型不能为空', trigger: 'change' },
// ],
getDetailList() { },
getEnergyParamList({ detailList: [],
objId: this.form.objectId, meterArr: [],
energyTypeId: this.form.energyTypeId };
}).then((res) => { },
if (res.code === 0) { methods: {
this.detailList = res.data init(id) {
} else { this.meterArr = this.getDictDatas('meter');
this.detailList = [] if (id) {
} this.isEdit = true;
}) this.form.id = id;
}, getEnergyLimit(id).then((res) => {
typeChange(val) { if (res.code === 0) {
console.log(this.form) this.form = res.data;
this.form.plcParamId = '' this.form.plcParamId = res.data.plcParamId || '';
if (val === 2) { this.form.meter = this.form.meter ? this.form.meter + '' : '';
if (this.form.objectId && this.form.energyTypeId) { this.form.manual =
this.getDetailList() this.form.manual >= 0 ? this.form.manual + '' : '';
} this.form.limitType = this.form.limitType
} ? this.form.limitType + ''
}, : '';
toggleType() { this.objIds = this.changeDetSelect(
if (this.form.energyTypeId && this.form.type) { this.form.objectId,
this.getDetailList() this.objList
this.form.plcParamId = '' );
} if (this.form.type === 2) {
}, this.getDetailList();
// }
changeDetSelect(key, treeData) { if (this.form.energyTypeId) {
let arr = [] // this.getTableNameList(this.form.energyTypeId);
let returnArr = [] // }
let depth = 0 // }
// });
function childrenEach(childrendData, depthN) { } else {
for (var j = 0; j < childrendData.length; j++) { this.isEdit = false;
depth = depthN this.form.id = '';
arr[depthN] = childrendData[j].id }
if (childrendData[j].id == key) { },
returnArr = arr.slice(0, depthN + 1) //
break changeMethod() {
} else { if (this.form.manual === '1') {
if (childrendData[j].children) { this.form.limitType = '2';
depth++ } else {
childrenEach(childrendData[j].children, depth) this.form.limitType = '';
} }
} },
} //
return returnArr getDetailList() {
} getEnergyParamList({
return childrenEach(treeData, depth) objId: this.form.objectId,
}, energyTypeId: this.form.energyTypeId,
selectObj(val) { }).then((res) => {
this.form.objectId = val[val.length-1] if (res.code === 0) {
this.form.objectType = val.length-1 this.detailList = res.data;
if (this.form.energyTypeId && this.form.type) { } else {
this.getDetailList() this.detailList = [];
this.form.plcParamId = '' }
} });
}, },
selectDetail() { typeChange(val) {
this.$forceUpdate() this.form.plcParamId = '';
}, if (val === 2) {
submitForm() { if (this.form.objectId && this.form.energyTypeId) {
this.$refs['form'].validate((valid) => { this.getDetailList();
if (valid) { }
if (this.form.type === 2 && !this.form.plcParamId) { }
this.$modal.msgError("监控模式为详细时,详细参数为必填"); },
return false toggleType() {
} if (this.form.energyTypeId && this.form.manual == 1) {
// this.form.limitType = Number(this.form.limitType) this.form.meter = '';
if (this.isEdit) { this.getTableNameList(this.form.energyTypeId);
// }
updateEnergyLimit({...this.form}).then((res) => { },
if (res.code === 0) { // list
this.$modal.msgSuccess("操作成功"); getTableNameList(id) {
this.$emit('successSubmit') //
} this.tableNameList = [];
}) energyTableGet({ energyTypeId: id }).then((res) => {
} else { if (res.data.length === 0) {
createEnergyLimit({...this.form}).then((res) => { this.$modal.msgWarning(
if (res.code === 0) { '当前能源类型暂无配置表名,请先到《表名配置》页面配置'
this.$modal.msgSuccess("操作成功"); );
this.$emit('successSubmit') return;
} }
}) res.data[0].meters.forEach((meter) => {
} this.tableNameList.push(this.meterArr.find((i) => i.value === meter));
} else { });
return false });
} },
}) //
}, changeDetSelect(key, treeData) {
formClear() { let arr = []; //
this.$refs.form.resetFields() let returnArr = []; //
this.objIds = '' let depth = 0; //
this.detailList = [] //
this.isEdit = false function childrenEach(childrendData, depthN) {
} for (var j = 0; j < childrendData.length; j++) {
} depth = depthN;
} arr[depthN] = childrendData[j].id;
if (childrendData[j].id == key) {
returnArr = arr.slice(0, depthN + 1);
break;
} else {
if (childrendData[j].children) {
depth++;
childrenEach(childrendData[j].children, depth);
}
}
}
return returnArr;
}
return childrenEach(treeData, depth);
},
selectObj(val) {
this.form.objectId = val[val.length - 1];
this.form.objectType = val.length;
if (this.form.energyTypeId && this.form.type) {
this.getDetailList();
this.form.plcParamId = '';
}
},
selectDetail() {
this.$forceUpdate();
},
submitForm() {
this.$refs['form'].validate((valid) => {
if (valid) {
if (this.form.type === 2 && !this.form.plcParamId) {
this.$modal.msgError('监控模式为详细时,详细参数为必填');
return false;
}
if (this.form.downValue && this.form.upValue) {
if (this.form.downValue > this.form.upValue) {
this.$modal.msgError('消耗量阈值,最小值不能大于最大值');
return false;
}
}
this.form.downValue = this.form.downValue || 0;
this.form.upValue = this.form.upValue || 0;
if (this.isEdit) {
//
updateEnergyLimit({ ...this.form }).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit');
}
});
} else {
createEnergyLimit({ ...this.form }).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit');
}
});
}
} else {
return false;
}
});
},
formClear() {
this.$refs.form.resetFields();
this.form.type = '';
this.form.plcParamId = '';
this.form.downValue = null;
this.form.upValue = null;
this.objIds = '';
this.detailList = [];
this.isEdit = false;
},
},
};
</script> </script>
<style>
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
display: none;
}
</style>

View File

@ -49,15 +49,33 @@ import { getEnergyTypeListAll } from "@/api/base/energyType";
import { getTree } from '@/api/base/factory' import { getTree } from '@/api/base/factory'
import { publicFormatter } from '@/utils/dict' import { publicFormatter } from '@/utils/dict'
import EnergyLimitAdd from './components/energyLimitAdd' import EnergyLimitAdd from './components/energyLimitAdd'
import codeFilter from '@/filter/code-filter';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
const tableProps = [ const tableProps = [
{
prop: 'manual',
label: '抄表方式',
filter: codeFilter('manual'),
},
{ {
prop: 'objName', prop: 'objName',
label: '监控对象' label: '监控对象'
}, },
{ {
prop: 'objectType', prop: 'objCode',
label: '对象备注', label: '对象编码',
filter: publicFormatter('object_type') minWidth: 140,
showOverflowtooltip: true,
},
// {
// prop: 'objectType',
// label: '',
// filter: publicFormatter('object_type')
// },
{
prop: 'meter',
label: '能源表名',
filter: publicFormatter('meter'),
}, },
{ {
prop: 'energyType', prop: 'energyType',
@ -85,6 +103,7 @@ const tableProps = [
export default { export default {
name: "EnergyLimit", name: "EnergyLimit",
components: { EnergyLimitAdd }, components: { EnergyLimitAdd },
mixins: [tableHeightMixin],
data() { data() {
return { return {
formConfig: [ formConfig: [
@ -159,9 +178,6 @@ export default {
}; };
}, },
created() { created() {
window.addEventListener('resize', () => {
this.tableH = this.tableHeight(260)
})
this.getList(); this.getList();
this.getTypeList() this.getTypeList()
// //
@ -200,6 +216,15 @@ export default {
item.type = i.label item.type = i.label
} }
}) })
if (item.downValue && item.upValue) {
item.limitValue = item.downValue + '-' + item.upValue;
} else if (item.downValue) {
item.limitValue = '最小值' + item.downValue;
} else if (item.upValue) {
item.limitValue = '最大值' + item.upValue;
} else {
item.limitValue = '-';
}
}) })
this.list = arr this.list = arr
this.total = response.data.total; this.total = response.data.total;
@ -232,7 +257,7 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$modal.confirm('是否确认删除监控对象为"' + row.objName + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除第"' + row._pageInde + '"的数据项?').then(function() {
return deleteEnergyLimit(row.id); return deleteEnergyLimit(row.id);
}).then(() => { }).then(() => {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;

View File

@ -1,152 +1,268 @@
<template> <template>
<div class="app-container"> <div class="app-container energyOverlimitLog">
<!-- 搜索工作栏 -->
<!-- 搜索工作栏 --> <search-bar
<search-bar :formConfigs="formConfig"
:formConfigs="formConfig" ref="searchBarForm"
ref="searchBarForm" @headBtnClick="buttonClick" />
@headBtnClick="buttonClick" <el-tabs
/> v-model="activeName"
<!-- 列表 --> @tab-click="toggleTab">
<base-table <el-tab-pane
:page="queryParams.pageNo" label="自动抄表"
:limit="queryParams.pageSize" name="auto"></el-tab-pane>
:table-props="tableProps" <el-tab-pane
:table-data="list" label="手动抄表"
:max-height="tableH" name="manual"></el-tab-pane>
/> </el-tabs>
<pagination <!-- 列表 -->
:page.sync="queryParams.pageNo" <div v-if="activeName === 'auto'">
:limit.sync="queryParams.pageSize" <base-table
:total="total" :page="queryParams.pageNo"
@pagination="getList" :limit="queryParams.pageSize"
/> :table-props="tableProps"
</div> :table-data="list"
:max-height="tableH" />
</div>
<div v-if="activeName === 'manual'">
<base-table
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps2"
:table-data="list2"
:max-height="tableH" />
</div>
<pagination
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
:total="total"
@pagination="getList" />
</div>
</template> </template>
<script> <script>
import { getEnergyOverlimitLogPage } from "@/api/monitoring/energyOverlimitLog"; import { getEnergyOverlimitLogPage,getEnergyManualLogPage } from '@/api/monitoring/energyOverlimitLog';
import { getEnergyTypeListAll } from "@/api/base/energyType"; import { getEnergyTypeListAll } from '@/api/base/energyType';
import { publicFormatter } from '@/utils/dict' import { publicFormatter } from '@/utils/dict';
import { parseTime } from '@/utils/ruoyi';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
const tableProps = [ const tableProps = [
{ {
prop: 'objName', prop: 'objName',
label: '监控对象' label: '监控对象',
}, },
{ {
prop: 'objRemark', prop: 'objCode',
label: '对象备注' label: '对象编码',
}, },
{ {
prop: 'energyType', prop: 'energyType',
label: '能源类型' label: '能源类型',
}, },
{ {
prop: 'type', prop: 'type',
label: '监控模式' label: '监控模式',
}, },
{ {
prop: 'paramName', prop: 'paramName',
label: '监控参数' label: '监控参数',
}, },
{ {
prop: 'limitType', prop: 'limitType',
label: '指标类型', label: '指标类型',
filter: publicFormatter('monitor_index_type') filter: publicFormatter('monitor_index_type'),
}, },
{ {
prop: 'realityValue', prop: 'realityValue',
label: '实际值' label: '实际值',
}, },
{ {
prop: 'limitValue', prop: 'limitValue',
label: '阈值' label: '阈值',
}, },
{ {
prop: 'overValue', prop: 'overValue',
label: '超出值' label: '超出值',
} },
] {
prop: 'time',
label: '提醒时间',
filter: parseTime,
minWidth: 160,
},
];
const tableProps2 = [
{
prop: 'energyType',
label: '能源类型',
},
{
prop: 'limitType',
label: '指标类型',
filter: publicFormatter('monitor_index_type'),
},
{
prop: 'realityValue',
label: '实际值',
},
{
prop: 'limitValue',
label: '阈值',
},
{
prop: 'overValue',
label: '超出值',
},
{
prop: 'time',
label: '提醒时间',
filter: parseTime,
minWidth: 160,
},
];
export default { export default {
name: "EnergyOverlimitLog", name: 'EnergyOverlimitLog',
data() { mixins: [tableHeightMixin],
return { data() {
formConfig: [ return {
{ formConfig: [
type: 'select', {
label: '能源类型', type: 'select',
selectOptions: [], label: '能源类型',
param: 'energyTypeId' labelField: 'labelName',
}, selectOptions: [],
{ param: 'energyTypeId',
type: 'select', },
label: '指标类型', {
selectOptions: this.getDictDatas(this.DICT_TYPE.MONITOR_INDEX_TYPE), type: 'select',
labelField: 'label', label: '指标类型',
valueField: 'value', selectOptions: this.getDictDatas(this.DICT_TYPE.MONITOR_INDEX_TYPE),
param: 'indexType' labelField: 'label',
}, valueField: 'value',
{ param: 'indexType',
type: 'button', },
btnName: '查询', {
name: 'search', type: 'button',
color: 'primary' btnName: '查询',
} name: 'search',
], color: 'primary',
tableProps, },
tableH: this.tableHeight(260), ],
// activeName: 'auto',
total: 0, tableProps,
// tableProps2,
list: [], total: 0,
// list: [],
queryParams: { list2: [],
pageNo: 1, heightNum: 300,
pageSize: 20, //
energyTypeId: '', queryParams: {
indexType: '' pageNo: 1,
}, pageSize: 20,
typeList: [ energyTypeId: '',
{id: 1, name: '合并'}, indexType: '',
{id: 2, name: '详细'} method: '1',
] },
}; typeList: [
}, { id: 1, name: '合并' },
created() { { id: 2, name: '详细' },
window.addEventListener('resize', () => { ],
this.tableH = this.tableHeight(260) };
}) },
this.getList(); created() {
this.getTypeList() this.getList();
}, this.getTypeList();
methods: { },
buttonClick(val) { methods: {
this.queryParams.pageNo = 1; buttonClick(val) {
this.queryParams.energyTypeId = val.energyTypeId this.queryParams.pageNo = 1;
this.queryParams.indexType = val.indexType this.queryParams.energyTypeId = val.energyTypeId;
this.getList() this.queryParams.indexType = val.indexType;
}, this.getList();
/** 查询列表 */ },
getList() { /** 查询列表 */
getEnergyOverlimitLogPage(this.queryParams).then(response => { getList() {
let arr = response.data.list || []; (this.queryParams.method === '1'?getEnergyOverlimitLogPage:getEnergyManualLogPage)(this.queryParams).then((response) => {
arr&&arr.map((item) => { let arr = response.data.list || [];
this.typeList.map((i) => { arr &&
if (item.type === i.id) { arr.map((item) => {
item.type = i.name this.typeList.map((i) => {
} if (item.type === i.id) {
}) item.type = i.name;
}) }
this.list = arr });
this.total = response.data.total; if (item.downValue && item.upValue) {
}); item.limitValue = item.downValue + '-' + item.upValue;
}, } else if (item.downValue) {
getTypeList() { item.limitValue = '最小值' + item.downValue;
getEnergyTypeListAll().then((res) => { } else if (item.upValue) {
console.log(res) item.limitValue = '最大值' + item.upValue;
this.formConfig[0].selectOptions = res.data || [] } else {
}) item.limitValue = '';
} }
} });
if (this.queryParams.method === '1') {
this.list = arr;
this.list2 = [];
} else {
this.list2 = arr;
this.list1 = [];
}
this.total = response.data.total;
});
},
getTypeList() {
getEnergyTypeListAll().then((res) => {
console.log(res);
this.formConfig[0].selectOptions = res.data || [];
});
},
toggleTab() {
if (this.activeName === 'auto') {
this.queryParams.method = '1';
} else {
this.queryParams.method = '2';
}
this.queryParams.pageNo = 1;
this.getList();
},
},
}; };
</script> </script>
<style lang='scss'>
.energyOverlimitLog {
.el-tabs__nav::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 2px;
background-color: #e4e7ed;
}
.el-tabs__nav-wrap::after {
width: 0;
}
.el-tabs__item {
padding: 0 10px;
}
.el-tabs__item:hover {
color: rgba(0, 0, 0, 0.85);
}
.el-tabs__item.is-active {
color: rgba(0, 0, 0, 0.85);
}
.el-tabs__item {
color: rgba(0, 0, 0, 0.45);
}
.searchBarBox {
margin-bottom: 0;
}
}
</style>