Compare commits

...

23 Commits

Author SHA1 Message Date
00393f76c7 Merge pull request 'projects/line-new-zhp' (#469) from projects/line-new-zhp into projects/line-new
Reviewed-on: #469
2025-12-24 16:36:24 +08:00
‘937886381’
35fb0d8bfb Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-24 16:35:44 +08:00
‘937886381’
0c52306cc6 修改 2025-12-24 16:34:37 +08:00
a5fba28ff7 Merge pull request 'projects/line-new-zhp' (#468) from projects/line-new-zhp into projects/line-new
Reviewed-on: #468
2025-12-23 08:53:19 +08:00
‘937886381’
1f8b994218 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-23 08:49:07 +08:00
‘937886381’
ccfa73f3bc xiugai 2025-12-23 08:46:44 +08:00
‘937886381’
89ff79bfd7 修改 2025-12-23 08:35:46 +08:00
70a0fbb170 Merge pull request 'projects/line-new-zhp' (#466) from projects/line-new-zhp into projects/line-new
Reviewed-on: #466
2025-12-17 16:30:30 +08:00
‘937886381’
c86d94ac92 修改 2025-12-17 16:26:21 +08:00
‘937886381’
484ba6ca53 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-15 10:45:49 +08:00
‘937886381’
f403375594 修改bug 2025-12-15 10:45:06 +08:00
1cd0b13aae Merge pull request 'projects/line-new-zhp' (#463) from projects/line-new-zhp into projects/line-new
Reviewed-on: #463
2025-12-12 16:54:55 +08:00
‘937886381’
d2b0565cd1 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-12 16:53:32 +08:00
‘937886381’
7661dc5691 修改 2025-12-12 16:52:45 +08:00
1d698848c2 Merge pull request 'projects/line-new-zhp' (#461) from projects/line-new-zhp into projects/line-new
Reviewed-on: #461
2025-12-12 14:18:34 +08:00
‘937886381’
6d367b121c Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-12 14:17:56 +08:00
‘937886381’
e2385cf813 修改 2025-12-12 14:17:21 +08:00
552b1e6d6a Merge pull request '更新' (#460) from projects/line-new-zwq into projects/line-new
Reviewed-on: #460
2025-12-11 12:52:11 +08:00
zwq
4383067eb1 更新 2025-12-11 12:51:41 +08:00
f80644e07c Merge pull request 'projects/line-new-zhp' (#458) from projects/line-new-zhp into projects/line-new
Reviewed-on: #458
2025-12-09 17:03:35 +08:00
‘937886381’
1e12b653d6 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-09 16:59:54 +08:00
‘937886381’
b7ba173ca3 修改 2025-12-09 16:57:38 +08:00
c203f1e1dd Merge pull request 'projects/line-new-zhp' (#457) from projects/line-new-zhp into projects/line-new
Reviewed-on: #457
2025-12-09 13:11:32 +08:00
29 changed files with 11874 additions and 10620 deletions

View File

@@ -13,8 +13,8 @@ VUE_APP_TITLE = 智能监控分析系统
# 芋道管理系统/开发环境 # 芋道管理系统/开发环境
# VUE_APP_BASE_API = 'http://172.16.33.187:48082' # VUE_APP_BASE_API = 'http://172.16.33.187:48082'
# VUE_APP_BASE_API = 'http://line.kszny.picaiba.com' VUE_APP_BASE_API = 'http://line.kszny.picaiba.com'
VUE_APP_BASE_API = 'http://172.16.32.79:48082' # VUE_APP_BASE_API = 'http://172.16.32.79:48082'
# 路由懒加载 # 路由懒加载

BIN
dist.zip Normal file

Binary file not shown.

View File

@@ -49,7 +49,7 @@
"bpmn-js-token-simulation": "0.10.0", "bpmn-js-token-simulation": "0.10.0",
"chinese-lunar": "^0.1.4", "chinese-lunar": "^0.1.4",
"clipboard": "2.0.8", "clipboard": "2.0.8",
"code-brick-zj": "^1.0.2", "code-brick-zj": "^1.1.1",
"core-js": "^3.26.0", "core-js": "^3.26.0",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"diagram-js": "^12.3.0", "diagram-js": "^12.3.0",

View File

@@ -62,10 +62,10 @@ export function getEquipmentAll() {
export function getTree(query) { export function getTree(query) {
return request({ return request({
url: '/base/factory/getTree', url: '/base/factory/getTreeSimple',
method: 'get', method: 'get',
params: query params: query,
}) });
} }
export function getEquipmentOverall(data) { export function getEquipmentOverall(data) {

View File

@@ -102,3 +102,17 @@ export function getProcessAutoReportNew(data) {
data: data, data: data,
}); });
} }
export function getPLlistByFactory(data) {
return request({
url: 'base/production-line/listByFactory',
method: 'post',
data: data,
});
}
export function getProcessAutoReportLastGroup(data) {
return request({
url: '/monitoring/production-monitor/getProcessAutoReportLastGroup',
method: 'post',
data: data,
});
}

View File

@@ -54,7 +54,7 @@ export default {
}; };
}, },
created() { created() {
this.currentMenu = this.menus[0]; // this.currentMenu = this.menus[0];
}, },
watch: { watch: {
currentMenu(val) { currentMenu(val) {

View File

@@ -89,6 +89,31 @@ export default {
}, },
created() {}, created() {},
methods: { methods: {
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 => {
if (response.code === 1001033 || response.code === 1001034) {
return this.$modal.msgError(response.msg);
}
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
}, },
}; };
</script> </script>

View File

@@ -63,7 +63,7 @@
style="width: 75%" style="width: 75%"
v-model="dataForm.price" v-model="dataForm.price"
clearable clearable
placeholder="请输入允许留存时间" /> placeholder="请输入单价" />
{{ unit }} {{ unit }}
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -141,15 +141,40 @@ export default {
} }
}, },
setCode() { setCode() {
console.log('this.MaterialList', this.urlOptions.dictArr.dict0);
this.MaterialList.forEach((item) => { this.MaterialList.forEach((item) => {
if (item.id === this.dataForm.materialId) { if (item.id === this.dataForm.materialId) {
this.dataForm.code = item.code; this.dataForm.code = item.code;
this.unit = this.unit =
'元/' + '元/' +
this.urlOptions.dictArr.dict0.find((d) => d.value === item.unit) this.urlOptions.dictArr.dict0.find((d) => d.value == item.unit)
.label; .label;
} }
}); });
},
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 => {
// console.log('response',);
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
}, },
}, },
}; };

View File

@@ -64,7 +64,7 @@
<script> <script>
import eqDetail from './eq-detail'; import eqDetail from './eq-detail';
import { parseTime } from '../../mixins/code-filter'; import { parseTime } from '../../mixins/code-filter';
import { getPdList } from '@/api/core/monitoring/auto'; import { getPLlistByFactory } from '@/api/core/monitoring/auto';
import { getNewCTNow, getNewCTCharts } from '@/api/core/analysis/index'; import { getNewCTNow, getNewCTCharts } from '@/api/core/analysis/index';
import { getFactoryPage } from '@/api/core/base/factory'; import { getFactoryPage } from '@/api/core/base/factory';
// import codeFilter from '../../mixins/code-filter' // import codeFilter from '../../mixins/code-filter'
@@ -135,6 +135,8 @@ export default {
label: '工厂', label: '工厂',
selectOptions: [], selectOptions: [],
param: 'factoryId', param: 'factoryId',
collapseTags: true,
multiple: true,
onchange: true, onchange: true,
}, },
{ {
@@ -142,6 +144,7 @@ export default {
label: '产线', label: '产线',
selectOptions: [], selectOptions: [],
param: 'lineId', param: 'lineId',
collapseTags: true,
multiple: true, multiple: true,
}, },
{ {
@@ -232,9 +235,9 @@ export default {
return exportTableOut; return exportTableOut;
}, },
getPdLineList() { getPdLineList() {
getPdList().then((res) => { // getPLlistByFactory().then((res) => {
this.formConfig[1].selectOptions = res.data || []; // this.formConfig[1].selectOptions = res.data || [];
}); // });
const params = { const params = {
pageSize: 100, pageSize: 100,
pageNo: 1, pageNo: 1,
@@ -274,7 +277,7 @@ export default {
handleSearchBarChanged({ param, value }) { handleSearchBarChanged({ param, value }) {
this.listQuery.lineId = []; this.listQuery.lineId = [];
this.$refs.searchBarForm.formInline.lineId = undefined; this.$refs.searchBarForm.formInline.lineId = undefined;
getPdList(value).then((res) => { getPLlistByFactory({ factoryIds: this.$refs.searchBarForm.formInline.factoryId }).then((res) => {
this.formConfig[1].selectOptions = res.data || []; this.formConfig[1].selectOptions = res.data || [];
}); });
}, },

View File

@@ -1,56 +1,21 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<search-bar <search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<div v-if="tableData.length"> <div v-if="tableData.length">
<base-table <base-table v-loading="dataListLoading" :table-props="tableProps" :max-height="tableH" :table-data="tableData" />
v-loading="dataListLoading"
:table-props="tableProps"
:max-height="tableH"
:table-data="tableData" />
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" /> <SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
<line-chart ref="lineChart" /> <line-chart ref="lineChart" />
</div> </div>
<div v-else class="no-data-bg"></div> <div v-else class="no-data-bg"></div>
<!-- <pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" /> -->
</div> </div>
</template> </template>
<script> <script>
// import basicPage from '../../mixins/basic-page';
import { parseTime } from '../../mixins/code-filter'; import { parseTime } from '../../mixins/code-filter';
import { getYieldAnalysisPageData } from '@/api/core/analysis/index'; import { getYieldAnalysisPageData } from '@/api/core/analysis/index';
import { getProductionLinePage } from '@/api/core/base/productionLine'; import { getProductionLinePage } from '@/api/core/base/productionLine';
import lineChart from '../LineChart'; import lineChart from '../LineChart';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin'; import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
// import { getWorkshopSectionPage } from '@/api/core/base/workshopSection';
// const tableProps = [
// // {
// // prop: 'lineName',
// // label: '产线',
// // align: 'center',
// // },
// // {
// // prop: 'sum',
// // label: '合计',
// // align: 'center',
// // },
// // {
// // prop: 'dynamicValue',
// // label: 'dynamicName',
// // align: 'center',
// // children:[
// // ]
// // }
// ];
export default { export default {
components: { components: {
@@ -67,7 +32,7 @@ export default {
tableData: [], tableData: [],
listQuery: { listQuery: {
lineIds: [], lineIds: [],
time: '', time: '', // 存储时间选择器的选中值(时间戳/格式化字符串,根据接口要求调整)
}, },
dateLabelList: [], dateLabelList: [],
optionArrUrl: [getProductionLinePage], optionArrUrl: [getProductionLinePage],
@@ -75,21 +40,20 @@ export default {
{ {
type: 'datePicker', type: 'datePicker',
label: '时间', label: '时间',
dateType: 'month', dateType: 'month', // 单个月份选择
format: 'yyyy-MM', format: 'yyyy-MM', // 显示格式
valueFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss', // 绑定值的格式
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'time', param: 'time',
defaultSelect: '', // 新增:默认月份值
}, },
{ {
type: 'select', type: 'select',
label: '产线', label: '产线',
selectOptions: [], selectOptions: [],
param: 'lineIds', param: 'lineIds',
defaultSelect: [], defaultSelect: [], // 产线默认选择值(多选数组)
multiple: true, multiple: true,
collapseTags: true,
filterable: true, filterable: true,
width: 300, width: 300,
}, },
@@ -102,28 +66,60 @@ export default {
], ],
}; };
}, },
created() { mounted() {
// 1. 初始化默认当月时间
this.initDefaultMonth();
// 2. 获取产线数据
this.getArr(); this.getArr();
}, },
methods: { methods: {
/**
* 初始化默认当月时间(单个月份)
*/
initDefaultMonth() {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth(); // 月份从0开始直接使用取当月1号
// 创建当月1号0点0分0秒的日期对象
const firstDayOfMonth = new Date(year, month, 1, 0, 0, 0);
// 转换为时间戳(毫秒级)
const defaultTimeStamp = firstDayOfMonth.getTime();
// 给时间选择器赋值默认值
this.formConfig[0].defaultSelect = firstDayOfMonth;
// this.listQuery.time = defaultTimeStamp;
},
/**
* 获取产线数据
*/
getArr() { getArr() {
const params = { const params = {
page: 1, page: 1,
limit: 500, limit: 500,
}; };
this.optionArrUrl.forEach((item, index) => { // 原代码forEach遍历冗余直接调用第一个方法即可
item(params).then((response) => { this.optionArrUrl[0](params)
this.formConfig[1].selectOptions = response.data.list; .then((response) => {
// this.formConfig[0].defaultSelect = response.data.list[0].id const lineList = response.data.list;
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id) this.formConfig[1].selectOptions = lineList;
}); // 产线默认选择第一条数据(多选需用数组格式)
if (lineList.length > 0) {
const firstLineId = lineList[0].id;
this.formConfig[1].defaultSelect = [firstLineId];
// 给查询参数赋值
this.listQuery.lineIds = [firstLineId];
}
})
.catch((err) => {
console.error('获取产线数据失败:', err);
}); });
}, },
/**
* 获取产量分析数据
*/
getData() { getData() {
// this.listQuery.lineIds = ['1672847052717821953'] this.dataListLoading = true; // 开启加载状态
// this.listQuery.productId = val.productId; this.urlOptions.getDataListURL(this.listQuery)
// this.listQuery.time = '1694486098000'; .then((res) => {
this.urlOptions.getDataListURL(this.listQuery).then((res) => {
let arr = [ let arr = [
{ {
prop: 'lineName', prop: 'lineName',
@@ -142,49 +138,39 @@ export default {
children: [], children: [],
}, },
]; ];
// console.log(res.data.nameData.slice(1))
let xData = []; let xData = [];
let yAllData = []; let yAllData = [];
let lineName = []; let lineName = [];
if (res.data) { if (res.data) {
// 处理日期标签去重
let tempDateList = []; let tempDateList = [];
res.data.nameData.forEach((date) => { res.data.nameData.forEach((date) => {
tempDateList.push(date.name); tempDateList.push(date.name);
}); });
this.dateLabelList = Array.from(new Set(tempDateList)); this.dateLabelList = Array.from(new Set(tempDateList));
// 构造表头children和echarts横坐标
this.dateLabelList.forEach((item) => { this.dateLabelList.forEach((item) => {
if (item.indexOf('年') === -1) { if (item.indexOf('年') === -1) {
// 构造表头 arr[2].children.push({
const props = {
prop: item, prop: item,
label: item, label: item,
}; });
arr[2].children.push(props);
// 构造echarts横坐标
xData.push(item); xData.push(item);
} }
}); });
// res.data.nameData.slice(1).forEach(item => {
// const props = { // 构造表格数据
// 'prop': item.name,
// 'label': item.name,
// 'align': 'center'
// }
// arr[2].children.push(props)
// })
let tableDataArr = []; let tableDataArr = [];
res.data.data.forEach((item) => { res.data.data.forEach((item) => {
let obj = {}; let obj = {
(obj.lineName = item.lineName), lineName: item.lineName,
(obj.sum = item.sum), sum: item.sum,
item.data.forEach((ele, index) => { };
// console.log(ele) item.data.forEach((ele) => {
ele.children.forEach((e) => { ele.children.forEach((e) => {
console.log(e.dynamicName); obj[e.dynamicName] = e.dynamicValue;
obj['' + e.dynamicName + ''] = e.dynamicValue;
console.log(obj['' + e.dynamicName + '']);
}); });
}); });
tableDataArr.push(obj); tableDataArr.push(obj);
@@ -192,29 +178,17 @@ export default {
this.tableData = tableDataArr; this.tableData = tableDataArr;
this.tableProps = arr; this.tableProps = arr;
// let tempList = [] // 构造图表数据
// res.data.nameData.slice(1).forEach(item => {
// tempList.push(item.name)
// // arr[2].children.push(props)
// })
// xData = Array.from(new Set(tempList))
res.data.data.forEach((item) => { res.data.data.forEach((item) => {
let yData = []; let yData = [];
lineName.push(item.lineName); lineName.push(item.lineName);
// let obj = {} item.data.forEach((ele) => {
// obj.lineName = item.lineName,
// obj.sum = item.sum,
item.data.forEach((ele, index) => {
// console.log(ele)
ele.children.forEach((e) => { ele.children.forEach((e) => {
// let yData = []
yData.push(e.dynamicValue); yData.push(e.dynamicValue);
}); });
}); });
yAllData.push(yData); yAllData.push(yData);
}); });
console.log(lineName);
} else { } else {
this.tableProps = arr; this.tableProps = arr;
this.tableData = []; this.tableData = [];
@@ -222,47 +196,61 @@ export default {
yAllData = []; yAllData = [];
lineName = []; lineName = [];
} }
// res.data.data[0].data[0].children.forEach((item, index) => {
// // console.log(item) // 初始化图表
// yData.push(item.dynamicValue)
// // let data = 'data' + Number(index+1)
// // obj['' + item.dynamicName + ''] = item.dynamicValue
// })
// console.log(this.yData)
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.lineChart.initChart(xData, yAllData, lineName); this.$refs.lineChart.initChart(xData, yAllData, lineName);
}); });
// this.total = response.data.total; })
// this.dataListLoading = false; .catch((err) => {
console.error('获取产量数据失败:', err);
this.tableData = [];
})
.finally(() => {
this.dataListLoading = false; // 关闭加载状态
}); });
}, },
/**
* 搜索栏按钮点击事件
* @param {Object} val - 按钮/表单传递的参数
*/
buttonClick(val) { buttonClick(val) {
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
this.listQuery.lineIds = val.lineIds ? val.lineIds : undefined; // 处理产线参数避免undefined空值设为空数组
// this.listQuery.productId = val.productId; this.listQuery.lineIds = val.lineIds || [];
this.listQuery.time = val.time // 处理时间参数:如果是时间字符串,可转换为时间戳(根据接口要求调整)
? new Date(val.time).getTime()
: undefined;
// this.listQuery.pageNo = 1;
// this.listQuery.pageSize = 10;
if (val.time) { if (val.time) {
this.getData(); // this.listQuery.time = val.time;
// 若接口需要时间戳,取消下面注释:
this.listQuery.time = new Date(val.time).getTime();
} else { } else {
this.$message({ this.$message({
message: '请选择时间', message: '请选择时间',
type: 'warning', type: 'warning',
}); });
return;
} }
// 验证产线是否选择(可选,根据业务需求调整)
if (this.listQuery.lineIds.length === 0) {
this.$message({
message: '请选择至少一条产线',
type: 'warning',
});
return;
}
this.getData();
break; break;
case 'reset': case 'reset':
// 重置表单
this.$refs.searchBarForm.resetForm(); this.$refs.searchBarForm.resetForm();
// 恢复默认值
this.listQuery = { this.listQuery = {
pageSize: 10, lineIds: this.formConfig[1].defaultSelect || [],
pageNo: 1, time: this.formConfig[0].defaultValue || '',
total: 1,
}; };
this.getDataList();
break; break;
default: default:
console.log(val); console.log(val);

View File

@@ -71,14 +71,25 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label=" 产品工艺" prop="processType"> <el-form-item label=" 产品工艺" prop="processTypes">
<el-select multiple v-model="dataForm.processType" clearable style="width: 100%" :disabled="isdetail" <el-select :disabled="isdetail" collapse-tags multiple v-model="dataForm.processTypes" clearable
placeholder="请选择产品工艺"> style="width: 100%" placeholder="请选择产品工艺">
<el-option v-for="dict in processTypeList" :key="dict.id" :label="dict.label" :value="dict.id" /> <el-option v-for="dict in processTypeList" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<!-- <el-row :gutter="20">
<el-col :span="12">
<el-form-item label=" 基板类型" prop="typeDictValue">
<el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable
style="width: 100%" placeholder="请选择基板类型">
<el-option v-for="dict in typeList" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
</el-row> -->
</el-form> </el-form>
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true"> <small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
@@ -143,7 +154,7 @@ import {
import productAttrAdd from './attr-add'; import productAttrAdd from './attr-add';
import { parseTime } from '../../mixins/code-filter'; import { parseTime } from '../../mixins/code-filter';
import SmallTitle from './SmallTitle'; import SmallTitle from './SmallTitle';
import { listData } from "@/api/system/dict/data"; //数据字典接口
const tableBtn = [ const tableBtn = [
{ {
type: 'edit', type: 'edit',
@@ -190,29 +201,31 @@ export default {
unitDictValue: '', // 单位id unitDictValue: '', // 单位id
originalSpecifications: '', // 原片规格 originalSpecifications: '', // 原片规格
originalArea: 0, // 原片单位平方数 originalArea: 0, // 原片单位平方数
processType:undefined, processTypes: [],
typeDictValue: null,
}, },
typeList:[],
listQuery: { listQuery: {
pageSize: 10, pageSize: 10,
pageNo: 1, pageNo: 1,
total: 0, total: 0,
}, },
processTypeList: [ processTypeList: [
{ // {
id: '0', // value: '1',
label:'压花丝印' // label: '压花丝印'
}, // },
{ // {
id: '1', // value: '2',
label: '无印打孔' // label: '无印打孔'
}, // },
{ // {
id: '2', // value: '3',
label: '单层镀膜' // label: '单层镀膜'
}, { // }, {
id: '3', // value: '4',
label: '双层镀膜' // label: '双层镀膜'
} // }
], ],
dataRule: { dataRule: {
code: [ code: [
@@ -268,14 +281,37 @@ export default {
}; };
}, },
methods: { methods: {
initData() { async initData() {
this.productAttributeList.splice(0); this.productAttributeList.splice(0);
this.listQuery.total = 0; this.listQuery.total = 0;
const typeRes = await listData({
pageNo:
1,
pageSize
: 10,
dictType
: 'product_type'
})
this.typeList = typeRes.data.list
console.log('typeRes', this.typeList);
const processTypeRes = await listData({
pageNo:
1,
pageSize
: 10,
dictType
: 'process_type'
})
this.processTypeList = processTypeRes.data.list
console.log('typeRes', this.typeList);
}, },
init(id, isdetail) { init(id, isdetail) {
this.initData(); this.initData();
this.isdetail = isdetail || false; this.isdetail = isdetail || false;
this.dataForm.id = id || null; this.dataForm.id = id || null;
// this.dataForm.processTypes = [] // 清空工艺选择
this.visible = true; this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
@@ -283,8 +319,25 @@ export default {
if (this.dataForm.id) { if (this.dataForm.id) {
// 获取产品详情 // 获取产品详情
getProduct(id).then((response) => { getProduct(id).then((res) => {
this.dataForm = response.data; const resData = res.data || {};
// 逐个字段赋值(保留响应式)
this.dataForm.name = resData.name || '';
this.dataForm.code = resData.code || '';
this.dataForm.area = resData.area || 0;
this.dataForm.typeDictValue = resData.typeDictValue || null;
this.dataForm.processTime = resData.processTime || null;
this.dataForm.specifications = resData.specifications || '';
this.dataForm.unitDictValue = resData.unitDictValue || '';
this.dataForm.originalSpecifications = resData.originalSpecifications || '';
this.dataForm.originalArea = resData.originalArea || 0;
// 处理工艺列表:确保是数组,过滤空值
this.dataForm.processTypes = resData.processType
? resData.processType.split(',').filter(Boolean)
: [];
console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式
}); });
// 获取产品的属性列表 // 获取产品的属性列表
this.getList(); this.getList();
@@ -309,8 +362,7 @@ export default {
handleClick(raw) { handleClick(raw) {
if (raw.type === 'delete') { if (raw.type === 'delete') {
this.$confirm( this.$confirm(
`确定对${ `确定对${raw.data.name
raw.data.name
? '[名称=' + raw.data.name + ']' ? '[名称=' + raw.data.name + ']'
: '[序号=' + raw.data._pageIndex + ']' : '[序号=' + raw.data._pageIndex + ']'
}进行删除操作?`, }进行删除操作?`,
@@ -333,7 +385,7 @@ export default {
}); });
}); });
}) })
.catch(() => {}); .catch(() => { });
} else { } else {
this.addNew(raw.data.id); this.addNew(raw.data.id);
} }
@@ -342,6 +394,7 @@ export default {
dataFormSubmit() { dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
// 修改的提交 // 修改的提交
if (this.dataForm.id) { if (this.dataForm.id) {
updateProduct(this.dataForm).then((response) => { updateProduct(this.dataForm).then((response) => {
@@ -395,29 +448,30 @@ export default {
</script> </script>
<style scoped> <style scoped>
.drawer >>> .el-drawer { .drawer>>>.el-drawer {
border-radius: 8px 0 0 8px; border-radius: 8px 0 0 8px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.drawer >>> .el-form-item__label { .drawer>>>.el-form-item__label {
padding: 0; padding: 0;
} }
.drawer >>> .el-drawer__header { .drawer>>>.el-drawer__header {
margin: 0; margin: 0;
padding: 32px 32px 24px; padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6; border-bottom: 1px solid #dcdfe6;
} }
.drawer >>> .el-drawer__body {
.drawer>>>.el-drawer__body {
flex: 1; flex: 1;
height: 1px; height: 1px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.drawer >>> .content { .drawer>>>.content {
padding: 30px 24px; padding: 30px 24px;
flex: 1; flex: 1;
display: flex; display: flex;
@@ -425,16 +479,17 @@ export default {
/* height: 100%; */ /* height: 100%; */
} }
.drawer >>> .visual-part { .drawer>>>.visual-part {
flex: 1 auto; flex: 1 auto;
max-height: 76vh; max-height: 76vh;
overflow: hidden; overflow: hidden;
overflow-y: scroll; overflow-y: scroll;
padding-right: 10px; /* 调整滚动条样式 */ padding-right: 10px;
/* 调整滚动条样式 */
} }
.drawer >>> .el-form, .drawer>>>.el-form,
.drawer >>> .attr-list { .drawer>>>.attr-list {
padding: 0 16px; padding: 0 16px;
} }

View File

@@ -104,6 +104,10 @@ export default {
getDataListURL: getProductionLinePage, getDataListURL: getProductionLinePage,
deleteURL: deleteProductionLine, deleteURL: deleteProductionLine,
exportURL: exportProductionLineExcel, exportURL: exportProductionLineExcel,
},
listQuery: {
pageSize: 20,
pageNo:1
}, },
tableProps, tableProps,
tableBtn: [ tableBtn: [
@@ -212,7 +216,7 @@ export default {
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
this.listQuery.pageNo = 1; this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10; this.listQuery.pageSize = 20;
this.listQuery.factoryId = val.factoryId || undefined; this.listQuery.factoryId = val.factoryId || undefined;
this.listQuery.name = val.name; this.listQuery.name = val.name;
this.getDataList(); this.getDataList();
@@ -220,7 +224,7 @@ export default {
case 'reset': case 'reset':
this.$refs.searchBarForm.resetForm(); this.$refs.searchBarForm.resetForm();
this.listQuery = { this.listQuery = {
pageSize: 10, pageSize: 20,
pageNo: 1, pageNo: 1,
total: 1, total: 1,
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -101,7 +101,7 @@ const tableProps = [
}, },
{ {
prop: 'thick', prop: 'thick',
label: '玻璃度/mm' label: '玻璃度/mm'
}, },
]; ];
@@ -204,93 +204,87 @@ export default {
); );
}); });
}, },
test() {
var target = document.getElementsByClassName("right-aside")[0]
target.style.background = '#FFFFFF'
var that = this
setTimeout(() => {
html2canvas(target).then(function(canvas) {
var contentWidth = canvas.width
var contentHeight = canvas.height
// 一页pdf显示html页面生成的canvas高度
var pageHeight = contentHeight / 592.28 * 841.89
// 未生成pdf的html页面高度
var leftHeight = contentHeight
// 页面偏移
var position = 0
// a4纸的尺寸[595.28,841.89]html页面生成的canvas在pdf中图片的高度
var imgWidth = 595.28
var imgHeight = 592.28 / contentWidth * contentHeight
var pageData = canvas.toDataURL('image/jpeg', 1.0)
console.log('nihc URL', leftHeight, pageHeight)
var pdf = new jsPDF('', 'pt', 'a4')
if (leftHeight < pageHeight) {
pdf.addImage(pageData, 'JPEG', 0, 20, imgWidth, imgHeight)
} else {
while(leftHeight > 0) {
pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
leftHeight -= pageHeight
position -= 841.89
// 避免空白页
if (leftHeight > 0) {
pdf.addPage()
}
}
}
pdf.save(that.fileName + '工段统计.pdf')
})
}, 300)
},
exportECL() {
let tables = document.querySelector('.el-table').cloneNode(true)
const fix = tables.querySelector('.el-table__fixed')
const fixRight = tables.querySelector('.el-table__fixed-right')
if (fix) {
tables.removeChild(tables.querySelector('.el-table__fixed'))
}
if (fixRight) {
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
}
let exportTable = XLSX.utils.table_to_book(tables)
var exportTableOut = XLSX.write(exportTable, {
bookType: 'xlsx', bookSST: true, type: 'array'
})
// sheetjs.xlsx为导出表格的标题名称
try {
FileSaver.saveAs(new Blob([exportTableOut], {
type: 'application/octet-stream'
}), this.fileName + '工段统计.xlsx')
} catch (e) {
if (typeof console !== 'undefined') console.log(e, exportTableOut)
}
return exportTableOut
},
exportPdf() {
this.test()
setTimeout(() =>{
this.dialogVisible = false
this.showData = this.tableData
}, 600)
},
exportXlsx() { exportXlsx() {
this.exportECL() if (!this.showData.length) {
this.dialogVisible = false this.$message.warning('暂无数据可导出');
this.showData = this.tableData return;
}, }
handleClose(done) {
this.$confirm('确认关闭?') this.exportLoading = true;
.then(_ => {
done(); try {
}) // 1. 处理导出数据(格式化时间字段)
.catch(_ => {}); const exportData = this.showData.map(item => {
const formatItem = { ...item };
// 格式化时间字段
if (formatItem.startTime) formatItem.startTime = parseTime(formatItem.startTime);
if (formatItem.endTime) formatItem.endTime = parseTime(formatItem.endTime);
return formatItem;
});
// 2. 构建表头映射:{ prop: label },只保留表格配置中存在的列
const headerMap = {};
this.tableProps.forEach(col => {
if (col.prop && col.label) {
headerMap[col.prop] = col.label;
}
});
// 3. 转换数据将prop键名替换为label按tableProps顺序排列列
const formattedData = exportData.map(item => {
const newItem = {};
// 按表格配置顺序遍历列确保Excel列顺序与表格一致
this.tableProps.forEach(col => {
const prop = col.prop;
const label = col.label;
if (prop && label) {
// 处理可能的undefined值避免导出为空字符串
newItem[label] = item[prop] ?? '';
}
});
return newItem;
});
// 4. 创建工作表使用处理后的带label表头的数据
const worksheet = XLSX.utils.json_to_sheet(formattedData);
// 5. 创建工作簿并添加工作表
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, '下片日志数据');
// 6. 生成Excel文件
const excelBuffer = XLSX.write(workbook, {
bookType: 'xlsx',
type: 'array'
});
// 7. 保存文件
const blob = new Blob([excelBuffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
});
// 8. 生成文件名(包含查询条件信息)
let fileName = '下片历史';
if (this.listQuery.productionLineId) {
const lineItem = this.formConfig[0].selectOptions.find(
item => item.id === this.listQuery.productionLineId
);
if (lineItem) fileName += lineItem.name + '_';
}
if (this.listQuery.thick) {
fileName += this.listQuery.thick + '_';
}
// 添加时间戳避免文件名重复
fileName + '.xlsx';
FileSaver.saveAs(blob, fileName);
this.$message.success('导出成功');
} catch (error) {
console.error('导出失败:', error);
this.$message.error('导出失败,请重试');
} finally {
this.exportLoading = false;
}
}, },
getPdLineList() { getPdLineList() {
getPdList().then((res) => { getPdList().then((res) => {
@@ -323,7 +317,7 @@ export default {
this.getDataList(); this.getDataList();
break; break;
case 'export': case 'export':
this.handleExport(); this.exportXlsx();
break; break;
default: default:
console.log(val); console.log(val);
@@ -351,12 +345,6 @@ export default {
this.listQuery.pageNo = val; this.listQuery.pageNo = val;
this.getDataList(); this.getDataList();
}, },
handleExport() {
if (this.selectedList.length > 0) {
this.showData = this.selectedList
}
this.dialogVisible = true
}
}, },
}; };
</script> </script>

View File

@@ -358,8 +358,6 @@ export default {
handleExport() { handleExport() {
// 处理查询参数 // 处理查询参数
let params = { ...this.listQuery }; let params = { ...this.listQuery };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出下片日志?').then(() => { this.$modal.confirm('是否确认导出下片日志?').then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportDownLogData(params); return exportDownLogData(params);

File diff suppressed because it is too large Load Diff

View File

@@ -244,7 +244,10 @@ export default {
label: '统计时间', label: '统计时间',
dateType: 'week', dateType: 'week',
placeholder: '选择日期', placeholder: '选择日期',
format: 'yyyy-MM-dd', format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek', param: 'timeValWeek',
width: 250, width: 250,
@@ -453,11 +456,10 @@ export default {
item.statisticType = this.listQuery.statisticType; item.statisticType = this.listQuery.statisticType;
// 匹配产线名称 // 匹配产线名称
const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId); // const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
item.bindObjectName = targetLine ? targetLine.name : ''; // item.bindObjectName = targetLine ? targetLine.name : ''
return item; return item;
}); })
this.listQuery.total = response.data?.total || 0; this.listQuery.total = response.data?.total || 0;
}) })
.catch(err => { .catch(err => {

View File

@@ -1,423 +1,430 @@
<template> <template>
<div class="home-page"> <div class="app-container">
<div class="date-tabs"> <!-- 顶部日期&筛选栏 -->
<!-- @tab-click="handleClick" --> <el-row :gutter="20" class="top-bar">
<el-tabs v-model="activeName" @tab-click="timedayChange" :stretch="true"> <el-col :span="8">
<el-tab-pane
:label="'\u2002\u2002日\u2002\u2002'"
name="日"></el-tab-pane>
<el-tab-pane
:label="'\u2002\u2002周\u2002\u2002'"
name="周"></el-tab-pane>
<el-tab-pane
:label="'\u2002\u2002月\u2002\u2002'"
name="月"></el-tab-pane>
<el-tab-pane
:label="'\u2002\u2002年\u2002\u2002'"
name="年"></el-tab-pane>
</el-tabs>
<div class="detail">
<el-date-picker <el-date-picker
v-model="timeday" v-model="dateRange"
align="right" type="daterange"
type="date" range-separator="~"
format="yyyy-MM-dd" start-placeholder="开始日期"
valueFormat="yyyy-MM-dd" end-placeholder="结束日期"
:clearable="false" value-format="yyyy-MM-dd" />
@change="timedayChange" <el-button type="primary" style="margin-left: 10px">查询</el-button>
placeholder="选择日期"
:picker-options="pickerOptions"></el-date-picker>
</div>
</div>
<el-row class="main-top" :gutter="16">
<el-col :span="24" style="position: relative">
<div class="title">
<svg-icon icon-class="home-produce" />
<span class="title-inner">生产总成本</span>
</div>
<el-row class="box">
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.priceS }}万元</div>
<div class="unit-style">总计成本</div>
</el-col> </el-col>
<el-col :span="4" class="num-box shadow"> <el-col :span="16">
<div class="num-style">{{ homeData.matPriceS }}万元</div> <el-tag type="info" @click="changeTime('yesterday')">昨日</el-tag>
<div class="unit-style">原料成本</div> <el-tag type="info" @click="changeTime('week')">本周</el-tag>
</el-col> <el-tag type="info" @click="changeTime('month')">本月</el-tag>
<el-col :span="4" class="num-box shadow"> <el-tag type="info" @click="changeTime('year')">本年</el-tag>
<div class="num-style">{{ homeData.energyPriceS }}万元</div>
<div class="unit-style">能源成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.otherPriceS }}万元</div>
<div class="unit-style">其他成本</div>
</el-col>
<!-- <el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.ratioS }}</div>
<div class="unit-style">综合良品率/%</div>
</el-col> -->
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.areaPriceS }}</div>
<div class="unit-style">综合每平米成本</div>
</el-col> </el-col>
</el-row> </el-row>
</el-col>
<el-col :span="24" style="position: relative"> <!-- 成本概览卡片 -->
<div class="title"> <el-row :gutter="20" class="card-row">
<svg-icon icon-class="home-produce" /> <el-col :span="8">
<span class="title-inner">原片成本</span> <el-card class="cost-card">
<div class="card-title">总制造成本/平米</div>
<div class="card-content">
<div>
目标
<span class="target-val">16</span>
</div> </div>
<el-row class="box"> <div>
<el-col :span="4" class="num-box shadow"> 实际
<div class="num-style">{{ homeData.priceO }}万元</div> <span class="actual-val">12.8</span>
<div class="unit-style">原片总成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.matPriceO }}万元</div>
<div class="unit-style">原料成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.energyPriceO }}万元</div>
<div class="unit-style">能源成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.otherPriceO }}万元</div>
<div class="unit-style">其他成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.ratioO }}</div>
<div class="unit-style">原片良品率/%</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.areaPriceO }}</div>
<div class="unit-style">原片每平米成本</div>
</el-col>
</el-row>
</el-col>
<el-col :span="24" style="position: relative">
<div class="title">
<svg-icon icon-class="home-produce" />
<span class="title-inner">深加工成本</span>
</div> </div>
<el-row class="box"> <el-progress :stroke-width="13" :percentage="80" color="#42b983" />
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.priceD }}万元</div>
<div class="unit-style">深加工总成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.energyPriceD }}万元</div>
<div class="unit-style">能源成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.otherPriceD }}万元</div>
<div class="unit-style">其他成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.ratioD }}</div>
<div class="unit-style">深加工良品率/%</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.areaPriceD }}</div>
<div class="unit-style">深加工每平米成本</div>
</el-col>
</el-row>
</el-col>
</el-row>
<el-row class="main-bottom" :gutter="16" v-if="false">
<el-col :span="9">
<div class="chart-wrapper">
<line-chart :chart-data="lineChartData" />
</div>
</el-col>
<el-col :span="7">
<div class="chart-wrapper">
<pie-chart />
</div> </div>
</el-card>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<div class="chart-wrapper"> <el-card class="cost-card">
<bar-chart /> <div class="card-title">原片成本/平米</div>
<div class="card-content">
<div>
目标
<span class="target-val">16</span>
</div> </div>
<div>
实际
<span class="actual-val">12.8</span>
</div>
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
</div>
</el-card>
</el-col>
<el-col :span="8">
<el-card class="cost-card">
<div class="card-title">加工成本/平米</div>
<div class="card-content">
<div>
目标
<span class="target-val">16</span>
</div>
<div>
实际
<span class="actual-val">12.8</span>
</div>
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
</div>
</el-card>
</el-col> </el-col>
</el-row> </el-row>
<!-- 成本构成区域 -->
<el-row :gutter="20" class="composition-row">
<!-- 饼图 -->
<el-col :span="6">
<el-card class="composition-card">
<div class="card-title">成本构成</div>
<div id="costPie" class="chart" style="height: 350px"></div>
</el-card>
</el-col>
<!-- 原片/加工成本子项 -->
<el-col :span="18">
<el-card class="composition-card">
<div class="card-title">成本构成</div>
<!-- 原片成本子项 -->
<div class="sub-cost-group">
<div class="sub-cost-title">原片成本</div>
<div class="sub-cost">
<div <div
class="main-footer" v-for="(item, idx) in rawSubCosts"
style=" :key="idx"
color: #c7c7c7; class="sub-cost-div">
user-select: none; <div class="sub-cost-name">
font-size: 14px; {{ item.name }}
letter-spacing: 1px; <div class="sub-cost-val">{{ item.val }}</div>
height: 30px;
display: grid;
place-content: center;
">
&copy; 中建材智能自动化研究院有限公司
</div> </div>
<div style="text-align: center">
<el-progress
type="circle"
:percentage="89"
:width="60"
:stroke-width="10"
:show-text="false"
color="#e74c3c" />
</div>
<div class="sub-cost-name">
目标
<span class="red-text">{{ item.target }}</span>
</div>
<div class="sub-cost-name">
完成率
<span class="red-text">89%</span>
</div>
</div>
</div>
</div>
<el-divider></el-divider>
<!-- 加工成本子项 -->
<div class="sub-cost-group" style="margin-top: 20px">
<div class="sub-cost-title">加工成本</div>
<div class="sub-cost">
<div
v-for="(item, idx) in processSubCosts"
:key="idx"
class="sub-cost-div">
<div class="sub-cost-name">
{{ item.name }}
<div class="sub-cost-val">{{ item.val }}</div>
</div>
<div style="text-align: center">
<el-progress
type="circle"
:percentage="89"
:width="60"
:stroke-width="10"
:show-text="false"
color="#e74c3c" />
</div>
<div class="sub-cost-name">
目标
<span class="red-text">{{ item.target }}</span>
</div>
<div class="sub-cost-name">
完成率
<span class="red-text">89%</span>
</div>
</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
<!-- 趋势图区域 -->
<el-row :gutter="20" class="trend-row">
<!-- 总制造成本趋势 -->
<el-col :span="8">
<el-card class="trend-card">
<div class="card-title">总制造成本趋势</div>
<div id="totalTrend" class="chart" style="height: 300px"></div>
</el-card>
</el-col>
<!-- 原片/加工成本趋势 -->
<el-col :span="8">
<el-card class="trend-card">
<div class="card-title">原片/加工成本趋势</div>
<el-tabs v-model="costTab" type="card" style="margin-bottom: 10px">
<el-tab-pane label="原片成本" name="raw"></el-tab-pane>
<el-tab-pane label="加工成本" name="process"></el-tab-pane>
</el-tabs>
<div id="rawProcessTrend" class="chart" style="height: 300px"></div>
</el-card>
</el-col>
<!-- 单项成本趋势 -->
<el-col :span="8">
<el-card class="trend-card">
<div class="card-title">单项成本趋势</div>
<el-tabs v-model="itemTab" type="card" style="margin-bottom: 10px">
<el-tab-pane label="人工成本" name="labor"></el-tab-pane>
<el-tab-pane label="原料成本" name="material"></el-tab-pane>
<el-tab-pane label="制造费用" name="expense"></el-tab-pane>
<el-tab-pane label="玻璃热耗" name="heat"></el-tab-pane>
<el-tab-pane label="原片成品率" name="yield"></el-tab-pane>
</el-tabs>
<div id="itemTrend" class="chart" style="height: 300px"></div>
</el-card>
</el-col>
</el-row>
</div> </div>
</template> </template>
<script> <script>
import moment from 'moment'; import * as echarts from 'echarts';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
import LineChart from '../dashboard/LineChart';
import PieChart from '../dashboard/PieChart';
import BarChart from '../dashboard/BarChart';
import PanelGroup from '../dashboard/PanelGroup';
import { getData } from '@/api/cost/allCost';
import { getUserProfile } from '@/api/system/user';
const lineChartData = {
newVisitis: {
expectedData: [100, 120, 161, 134, 105, 160, 165],
actualData: [120, 82, 91, 154, 162, 140, 145],
},
messages: {
expectedData: [200, 192, 120, 144, 160, 130, 140],
actualData: [180, 160, 151, 106, 145, 150, 130],
},
purchases: {
expectedData: [80, 100, 121, 104, 105, 90, 100],
actualData: [120, 90, 100, 138, 142, 130, 130],
},
shoppings: {
expectedData: [130, 140, 141, 142, 145, 150, 160],
actualData: [120, 82, 91, 154, 162, 140, 130],
},
};
export default { export default {
name: 'Home', name: 'CostDashboard',
mixins: [tableHeightMixin],
components: {
LineChart,
PieChart,
PanelGroup,
BarChart,
},
computed: {
gradientBackground() {
return {
'background-image':
'linear-gradient(90deg, #f0f0f0 25%, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0) 50%, #f0f0f0 50%, #f0f0f0 75%, rgba(255, 255, 255, 0) 75%, rgba(255, 255, 255, 0))',
'background-size': '100px 100px', // 调整条纹的大小
};
},
},
data() { data() {
return { return {
activeName: '日', dateRange: ['2023-05-06', '2023-05-06'],
user: '', costTab: 'raw',
lineChartData: lineChartData.newVisitis, itemTab: 'labor',
homeData: {}, // 原片成本子项
timeday: moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD'), rawSubCosts: [
startTime: { name: '人工成本', val: 4.56, target: 4.32 },
moment(new Date()).subtract(0, 'days').format('YYYY-MM-DD') + { name: '原料成本', val: 4.56, target: 4.32 },
' 00:00:00', { name: '原片制造费用', val: 4.56, target: 4.32 },
endTime: { name: '玻璃热耗', val: 4.56, target: 4.32 },
moment(new Date()).subtract(-1, 'days').format('YYYY-MM-DD') + { name: '原片成品率', val: 4.56, target: 4.32 },
' 00:00:00',
pickerOptions: {
disabledDate(time) {
return time.getTime() + 3600 * 1000 * 24 > Date.now();
},
shortcuts: [
{
text: '今天',
onClick(picker) {
picker.$emit('pick', new Date());
},
},
{
text: '昨天',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', date);
},
},
{
text: '一周前',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', date);
},
},
], ],
}, // 加工成本子项
processSubCosts: [
{ name: '人工成本', val: 4.56, target: 4.32 },
{ name: '加工动力成本', val: 4.56, target: 4.32 },
{ name: '加工制造费用', val: 4.56, target: 4.32 },
{ name: '加工投入产出率', val: 4.56, target: 4.32 },
],
// 趋势图模拟数据
trendX: ['00:00', '01:00', '02:00'],
trendY: [20, 40, 50],
targetY: 12.54,
}; };
}, },
created() { mounted() {
}, this.initCostPie();
beforeDestroy() { this.initTotalTrend();
this.initRawProcessTrend();
this.initItemTrend();
}, },
methods: { methods: {
getData() { // 切换时间范围(示例)
let listQuery = { changeTime(type) {
//分页 // 实际项目中需根据type请求对应数据
pageSize: 10, console.log('切换时间:', type);
pageNo: 1,
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName),
startTime: this.timeday + ' 00:00:00',
};
getData(listQuery).then((response) => {
this.homeData = response.data;
for (let i in this.homeData) {
this.homeData[i] = Number(this.homeData[i]).toFixed(2);
}
});
}, },
timedayChange() { // 初始化成本构成饼图
let listQuery = { initCostPie() {
//分页 const pieChart = echarts.init(document.getElementById('costPie'));
pageSize: 10, pieChart.setOption({
pageNo: 1, tooltip: { trigger: 'item' },
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName), legend: {
startTime: this.timeday + ' 00:00:00', orient: 'horizontal', // 水平排列
}; bottom: 0, // 放在底部
getData(listQuery).then((response) => { icon: 'circle',
this.homeData = response.data; left: 'center',
for (let i in this.homeData) { formatter: function (name) {
this.homeData[i] = Number(this.homeData[i]).toFixed(2); return name;
}
});
}, },
goDetail() { },
this.$router.push({ path: 'indexDetail' }); series: [
{
type: 'pie',
data: [
{ name: '原料成本(4.2元)', value: 29.9 },
{ name: '动力成本(2.1元)', value: 24 },
{ name: '人工成本(1.5元)', value: 24 },
{ name: '辅料成本(0.5元)', value: 21.2 },
{ name: '制造费用(0.5元)', value: 21.2 },
],
label: { show: false },
labelLine: { show: false },
bottom: 10,
},
],
});
window.addEventListener('resize', () => pieChart.resize());
},
// 初始化总制造成本趋势图
initTotalTrend() {
const totalChart = echarts.init(document.getElementById('totalTrend'));
totalChart.setOption({
grid: { top: 20, bottom: 30, left: 30, right: 10 },
xAxis: { type: 'category', data: this.trendX },
yAxis: { type: 'value', min: -20, max: 60 },
series: [
{
name: '实际值',
type: 'line',
data: this.trendY,
lineStyle: { color: '#409eff' },
},
{
name: '目标值',
type: 'line',
data: [this.targetY, this.targetY, this.targetY],
lineStyle: { type: 'dashed', color: '#e6a23c' },
},
],
});
window.addEventListener('resize', () => totalChart.resize());
},
// 初始化原片/加工成本趋势图
initRawProcessTrend() {
const rpChart = echarts.init(document.getElementById('rawProcessTrend'));
rpChart.setOption({
grid: { top: 10, bottom: 20, left: 20, right: 10 },
xAxis: { type: 'category', data: this.trendX },
yAxis: { type: 'value', min: -20, max: 60 },
series: [
{
name: '实际值',
type: 'line',
data: this.trendY,
lineStyle: { color: '#409eff' },
},
{
name: '目标值',
type: 'line',
data: [this.targetY, this.targetY, this.targetY],
lineStyle: { type: 'dashed', color: '#e6a23c' },
},
],
});
window.addEventListener('resize', () => rpChart.resize());
},
// 初始化单项成本趋势图
initItemTrend() {
const itemChart = echarts.init(document.getElementById('itemTrend'));
itemChart.setOption({
grid: { top: 10, bottom: 20, left: 20, right: 10 },
xAxis: { type: 'category', data: this.trendX },
yAxis: { type: 'value', min: -20, max: 60 },
series: [
{
name: '实际值',
type: 'line',
data: this.trendY,
lineStyle: { color: '#409eff' },
},
{
name: '目标值',
type: 'line',
data: [this.targetY, this.targetY, this.targetY],
lineStyle: { type: 'dashed', color: '#e6a23c' },
},
],
});
window.addEventListener('resize', () => itemChart.resize());
}, },
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style scoped>
.home-page::before { .top-bar {
background-image: url('~@/assets/img/home-bg.png');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: rotate(180deg);
}
.date-tabs {
padding-left: 40px;
padding-top: 20px;
position: relative;
margin-bottom: 20px; margin-bottom: 20px;
} }
:deep(.date-tabs) { .card-row,
.el-tabs__header { .composition-row {
margin-bottom: 8px;
display: inline-block;
transform: translateY(-12px);
}
.el-tabs__content {
overflow: visible;
}
.el-tabs__item {
font-size: 18px;
color: #fff;
padding-left: 0 !important;
padding-right: 0 !important;
line-height: 36px !important;
height: 36px;
}
.el-tabs__item.is-active {
color: #0b58ff;
}
}
.detail {
display: inline-block;
position: absolute;
left: 260px;
top: 10px;
}
:deep(.detail) {
.el-input__inner {
background-color: transparent;
color: white;
}
}
// .current-date {
// color: #fff;
// font-size: 18px;
// position: absolute;
// left: 260px;
// top: 14px;
// }
.current-time {
color: #fff;
font-size: 18px;
position: absolute;
right: 38px;
top: 14px;
}
.main-top {
width: 100%;
padding: 0 20px 0 40px;
.title {
position: absolute;
left: 34px;
top: 20px;
width: 180px;
font-size: 32px;
z-index: 10;
.title-inner {
position: absolute;
left: 42px;
top: 5px;
font-size: calc(100vw * 20 / 1920);
}
}
.box {
background-color: #fff;
border-radius: 24px;
height: 192px;
padding: 40px 24px 32px 24px;
margin-bottom: 20px; margin-bottom: 20px;
box-shadow: 0 8px 8px 0 gray; }
.num-box { .cost-card .card-title {
height: 120px; font-size: 22px;
padding-top: 26px; font-weight: bold;
margin-bottom: 15px;
}
.cost-card .card-content {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 10px;
align-items: center;
font-size: 18px;
}
.target-val {
color: #666;
margin-left: 5px;
font-size: 20px;
}
.actual-val {
color: #42b983;
margin-left: 5px;
font-size: 20px;
}
.composition-card {
height: 480px;
}
.composition-card .card-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 15px;
}
.sub-cost {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
gap: 10px;
align-items: center;
}
.sub-cost-group .sub-cost-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}
.sub-cost-group .sub-cost-div {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
align-items: center;
border: 1px solid rgb(220, 220, 220, 0.5);
padding: 10px;
}
.sub-cost-name {
text-align: center; text-align: center;
.num-style { margin-top: 5px;
color: #000; font-size: 14px;
font-size: calc(100vw * 40 / 1920);
}
.unit-style {
color: rgba(0, 0, 0, 0.7);
font-size: calc(100vw * 18 / 1920);
}
}
.shadow {
background: linear-gradient(90deg, #ffffff 80%, #f2f4f9 100%);
}
}
} }
.main-bottom { .sub-cost-val {
width: 100%; font-size: 16px;
margin-top: 20px; font-weight: bold;
.chart-wrapper { }
margin-left: 10px; .completion {
height: 425px; text-align: center;
background: #fff; font-size: 12px;
border-radius: 5px; color: #666;
box-shadow: 0 3px 3px 0 gray; }
} .red-text {
} color: #e74c3c;
</style> }
<style lang="scss"> .trend-card {
.home-page { height: 450px;
.el-progress-bar__inner { }
background-image: url('~@/assets/img/home-progress-bg.png'); .trend-card .card-title {
background-size: cover; font-size: 16px;
} font-weight: bold;
margin-bottom: 10px;
} }
</style> </style>

View File

@@ -63,9 +63,9 @@ export default {
init(data) { init(data) {
console.log(data.paramMonitors,'data'); console.log(data.paramMonitors,'data');
this.dataForm.equipmentId = data.equipmentId || undefined; this.dataForm.equipmentId = data.equipmentId || '';
this.dataForm.equipmentName = data.equipmentName || undefined; this.dataForm.equipmentName = data.equipmentName || '';
this.dataForm.lineId = data.lineId || undefined; this.dataForm.lineId = data.lineId || '';
this.visible = true; this.visible = true;

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-dialog :visible.sync="visible" width="40%" @close="destroyAllCharts" title-class="dialog-title"> <el-dialog :visible.sync="visible" width="80%" @close="handleClose" title-class="dialog-title">
<small-title slot="title" :no-padding="true"> <small-title slot="title" :no-padding="true">
{{ dataForm.lineId + '·' + dataForm.equipmentName }} {{ dataForm.lineId + '·' + dataForm.equipmentName }}
</small-title> </small-title>
@@ -10,13 +10,11 @@
</el-tabs> </el-tabs>
<div class="content"> <div class="content">
<div class="visual-part"> <div class="visual-part">
<!-- 报警时长-柱状图 --> <div v-if="hasData" style="display: flex; justify-content: space-around; gap: 20px; padding: 10px 0;">
<div v-if="hasData"> <!-- 移除 v-if始终渲染两个图表容器 -->
<div v-show="activeLabel === 'duration'" id="barChart" style="width: 100%; height: 400px;"></div> <div id="barChart" style="width: 48%; height: 400px;"></div>
<!-- 报警次数-饼图 --> <div id="pieChart" style="width: 48%; height: 400px;"></div>
<div v-show="activeLabel === 'times'" id="pieChart" style="width: 100%; height: 400px;"></div>
</div> </div>
<!-- 无数据提示 -->
<div v-if="!hasData" class="no-data"> <div v-if="!hasData" class="no-data">
<el-empty description="暂无相关报警数据"></el-empty> <el-empty description="暂无相关报警数据"></el-empty>
</div> </div>
@@ -29,22 +27,15 @@
import { getAlarmDet } from '@/api/base/equipment'; import { getAlarmDet } from '@/api/base/equipment';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import SmallTitle from './SmallTitle'; import SmallTitle from './SmallTitle';
// import { ElEmpty } from 'element-plus';
// 图表颜色配置(统一风格)
const CHART_CONFIG = { const CHART_CONFIG = {
// 柱状图颜色
barColor: '#288AFF', barColor: '#288AFF',
// 饼图颜色(渐变色系,避免刺眼)
pieColors: [ pieColors: [
'#288AFF', '#4096FF', '#69B1FF', '#91CFFF', '#B8E0FF', '#288AFF', '#4096FF', '#69B1FF', '#91CFFF', '#B8E0FF',
'#E0F2FF', '#1890FF', '#096DD9', '#0050B3', '#003A8C' '#E0F2FF', '#1890FF', '#096DD9', '#0050B3', '#003A8C'
], ],
// 字体颜色
fontColor: '#333', fontColor: '#333',
// 浅色字体
lightFontColor: '#666', lightFontColor: '#666',
// 边框圆角
borderRadius: 4 borderRadius: 4
}; };
@@ -53,7 +44,7 @@ export default {
data() { data() {
return { return {
visible: false, visible: false,
hasData: true, // 是否有数据标识 hasData: false,
listQuery: { listQuery: {
pageNo: 1, pageNo: 1,
pageSize: 100, pageSize: 100,
@@ -82,40 +73,58 @@ export default {
color: 'primary' color: 'primary'
} }
], ],
activeLabel: 'duration', // 默认激活时长tab activeLabel: 'duration', // 默认选中「报警时长」
dataForm: { dataForm: {
equipmentId: undefined, equipmentId: undefined,
equipmentName: undefined, equipmentName: undefined,
lineId: undefined lineId: undefined
}, },
// 存储图表实例,用于销毁
chartInstances: { chartInstances: {
bar: null, bar: null,
pie: null pie: null
} },
isDomReady: false,
originData: null // 存储原始数据
}; };
}, },
mounted() { mounted() {
// 初始化默认日期(当天) this.$nextTick(() => {
this.initDefaultDate(); this.isDomReady = true;
if (this.listQuery.equipmentId) {
this.getDataList();
}
});
},
watch: {
// Tab 切换时自动刷新图表(无需额外操作,依赖 handleTabClick 触发查询)
activeLabel() {
if (this.isDomReady && this.originData) {
this.$nextTick(() => {
this.renderBothCharts(); // 切换 Tab 后重新渲染两个图表
});
}
}
}, },
methods: { methods: {
// 初始化默认日期当天零点到23:59:59
initDefaultDate() { initDefaultDate() {
const today = new Date(); const today = new Date();
const start = new Date(today.setHours(0, 0, 0, 0)).getTime(); const start = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0, 0).getTime();
const end = new Date(today.setHours(23, 59, 59, 999)).getTime(); const end = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 0).getTime();
this.formConfig[0].defaultSelect = [start, end]; this.formConfig[0].defaultSelect = [start, end];
this.listQuery.startTime = start; this.listQuery.startTime = start;
this.listQuery.endTime = end; this.listQuery.endTime = end;
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.form.timeVal = [start, end];
}
}, },
// 切换Tab时加载对应图表
handleTabClick() { handleTabClick() {
// 切换 Tab 时重新查询数据(或直接复用已有数据渲染)
this.getDataList(); this.getDataList();
}, },
// 搜索按钮点击事件
buttonClick(val) { buttonClick(val) {
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
@@ -123,43 +132,34 @@ export default {
this.listQuery.endTime = val.timeVal?.[1]; this.listQuery.endTime = val.timeVal?.[1];
this.getDataList(); this.getDataList();
break; break;
case 'link':
this.disabled = true;
this.connectSSEBatch(this.listQuery.equipmentIds);
break;
default: default:
} }
}, },
// 获取数据并渲染对应图表
async getDataList() { async getDataList() {
try { try {
// 校验必要参数
if (!this.listQuery.equipmentId) { if (!this.listQuery.equipmentId) {
console.warn('设备ID不能为空'); console.warn('设备ID不能为空');
this.hasData = false; this.hasData = false;
return; return;
} }
// 构造请求参数(移除硬编码,使用动态参数)
const queryParams = { const queryParams = {
equipmentId: this.listQuery.equipmentId, equipmentId: this.listQuery.equipmentId,
startTime: this.listQuery.startTime, startTime: this.listQuery.startTime,
endTime: this.listQuery.endTime, endTime: this.listQuery.endTime,
}; };
const res = await getAlarmDet(queryParams) const res = await getAlarmDet(queryParams);
const originData = res.data || []; const originData = res.data || [];
this.originData = originData;
this.hasData = originData.length > 0; this.hasData = originData.length > 0;
if (this.hasData) { if (this.hasData && this.isDomReady) {
// 根据当前Tab渲染对应图表 this.$nextTick(() => {
this.activeLabel === 'duration' this.renderBothCharts(); // 数据查询成功后,同时渲染两个图表
? this.renderBarChart(originData) });
: this.renderPieChart(originData);
} else { } else {
// 无数据时销毁已有图表
this.destroyAllCharts(); this.destroyAllCharts();
} }
} catch (error) { } catch (error) {
@@ -169,36 +169,62 @@ export default {
} }
}, },
// 渲染报警时长-柱状图 // 核心方法:同时渲染柱状图和饼图(根据当前 Tab 类型)
renderBarChart(originData) { renderBothCharts() {
// 先销毁原有图表 if (this.activeLabel === 'duration') {
this.destroyChart('chart'); // 报警时长:柱状图(时长排序)+ 饼图(时长占比)
this.renderBarChart('duration');
// 按报警时长降序排序 this.renderPieChart('duration');
const sortedData = [...originData].sort((a, b) => b.alarmDuration - a.alarmDuration); } else {
// 报警次数:柱状图(次数排序)+ 饼图(次数占比)
// 处理图表数据 this.renderBarChart('times');
const xData = sortedData.map(item => this.truncateText(item.alarmContent, 8)); // 文本截断最多8字 this.renderPieChart('times');
const seriesData = sortedData.map(item => item.alarmDuration); }
},
// 渲染柱状图(支持两种数据类型)
renderBarChart(type) {
this.destroyChart('bar');
const chartDom = document.getElementById('barChart'); const chartDom = document.getElementById('barChart');
this.chartInstances.bar = echarts.init(chartDom); if (!chartDom || !this.originData.length) return;
// 根据类型排序和提取数据
let sortedData, xData, seriesData, yAxisName;
if (type === 'duration') {
// 报警时长:按时长降序
sortedData = [...this.originData].sort((a, b) => b.alarmDuration - a.alarmDuration);
seriesData = sortedData.map(item => item.alarmDuration);
yAxisName = '报警时长';
} else {
// 报警次数:按次数降序
sortedData = [...this.originData].sort((a, b) => b.alarmCount - a.alarmCount);
seriesData = sortedData.map(item => item.alarmCount);
yAxisName = '报警次数';
}
xData = sortedData.map(item => this.truncateText(item.alarmContent, 8));
try {
this.chartInstances.bar = echarts.init(chartDom);
const option = { const option = {
title: {
text: `${yAxisName}统计(柱状图)`,
left: 'center',
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
},
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { type: 'shadow' }, axisPointer: { type: 'shadow' },
padding: 10, padding: 10,
textStyle: { fontSize: 11 }, textStyle: { fontSize: 11 },
// 自定义提示框内容
formatter: (params) => { formatter: (params) => {
const index = params[0].dataIndex; const index = params[0].dataIndex;
const item = sortedData[index]; const item = sortedData[index];
return ` return `
<div style="text-align: left;"> <div style="text-align: left;">
<div>${item.alarmContent}</div> <div>${item.alarmContent}</div>
<div>报警时长:${item.alarmDuration}</div> <div>${yAxisName}${type === 'duration' ? item.alarmDuration : item.alarmCount}</div>
<div>占比:${item.alarmDurationRatio.toFixed(2)}%</div> <div>占比:${type === 'duration' ? item.alarmDurationRatio.toFixed(2) : item.alarmCountRatio.toFixed(2)}%</div>
</div> </div>
`; `;
} }
@@ -206,8 +232,8 @@ export default {
grid: { grid: {
left: '5%', left: '5%',
right: '5%', right: '5%',
bottom: '18%', // 底部留足空间显示x轴标签 bottom: '18%',
top: '10%', top: '15%',
containLabel: true containLabel: true
}, },
xAxis: [ xAxis: [
@@ -217,7 +243,6 @@ export default {
axisTick: { alignWithLabel: true }, axisTick: { alignWithLabel: true },
axisLabel: { axisLabel: {
interval: 0, interval: 0,
// rotate: 35, // 标签旋转
fontSize: 12, fontSize: 12,
color: CHART_CONFIG.lightFontColor color: CHART_CONFIG.lightFontColor
}, },
@@ -227,20 +252,20 @@ export default {
yAxis: [ yAxis: [
{ {
type: 'value', type: 'value',
name: yAxisName,
nameTextStyle: { fontSize: 11, color: CHART_CONFIG.lightFontColor },
axisLabel: { axisLabel: {
fontSize: 11, fontSize: 11,
color: CHART_CONFIG.lightFontColor, color: CHART_CONFIG.lightFontColor,
// formatter: '{value}s' // 显示单位
}, },
axisLine: { lineStyle: { color: '#e8e8e8' } }, axisLine: { lineStyle: { color: '#e8e8e8' } },
splitLine: { lineStyle: { color: '#f5f5f5' } }, splitLine: { lineStyle: { color: '#f5f5f5' } },
// 扩展y轴最大值避免label超出
max: (value) => value.max * 1.2 max: (value) => value.max * 1.2
} }
], ],
series: [ series: [
{ {
name: '报警时长', name: yAxisName,
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
color: CHART_CONFIG.barColor, color: CHART_CONFIG.barColor,
@@ -249,7 +274,7 @@ export default {
shadowColor: 'rgba(40, 138, 255, 0.2)', shadowColor: 'rgba(40, 138, 255, 0.2)',
shadowOffsetY: 2 shadowOffsetY: 2
}, },
barWidth: '16', // 柱子宽度(百分比适配) barWidth: '16',
data: seriesData, data: seriesData,
label: { label: {
show: true, show: true,
@@ -257,32 +282,46 @@ export default {
distance: 6, distance: 6,
fontSize: 11, fontSize: 11,
color: CHART_CONFIG.fontColor, color: CHART_CONFIG.fontColor,
formatter: (params) => `${params.value}` // 显示单位 formatter: (params) => `${params.value}`
} }
} }
] ]
}; };
this.chartInstances.bar.setOption(option); this.chartInstances.bar.setOption(option);
// 监听窗口 resize
this.addResizeListener('bar'); this.addResizeListener('bar');
} catch (error) {
console.error(`${yAxisName}柱状图初始化失败:`, error);
setTimeout(() => this.renderBarChart(type), 200);
}
}, },
// 渲染报警次数-饼图 // 渲染饼图(支持两种数据类型)
renderPieChart(originData) { renderPieChart(type) {
// 先销毁原有图表
this.destroyChart('pie'); this.destroyChart('pie');
// 按报警次数降序排序
const sortedData = [...originData].sort((a, b) => b.alarmCount - a.alarmCount);
// 处理图表数据(合并占比过小的项为"其他"
const pieData = this.handlePieData(sortedData);
const chartDom = document.getElementById('pieChart'); const chartDom = document.getElementById('pieChart');
this.chartInstances.pie = echarts.init(chartDom); if (!chartDom || !this.originData.length) return;
// 根据类型处理饼图数据
let pieData, seriesName;
if (type === 'duration') {
// 报警时长:按时长占比处理
seriesName = '报警时长';
pieData = this.handlePieData(this.originData, 'alarmDuration', 'alarmDurationRatio');
} else {
// 报警次数:按次数占比处理
seriesName = '报警次数';
pieData = this.handlePieData(this.originData, 'alarmCount', 'alarmCountRatio');
}
try {
this.chartInstances.pie = echarts.init(chartDom);
const option = { const option = {
title: {
text: `${seriesName}统计(饼图)`,
left: 'center',
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
},
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
padding: 10, padding: 10,
@@ -291,7 +330,7 @@ export default {
return ` return `
<div style="text-align: left;"> <div style="text-align: left;">
<div>${params.name}</div> <div>${params.name}</div>
<div>报警次数:${params.value}</div> <div>${seriesName}${params.value}${type === 'duration' ? '' : '次'}</div>
<div>占比:${params.percent.toFixed(2)}%</div> <div>占比:${params.percent.toFixed(2)}%</div>
</div> </div>
`; `;
@@ -299,53 +338,49 @@ export default {
}, },
series: [ series: [
{ {
name: '报警次数', name: seriesName,
type: 'pie', type: 'pie',
radius: ['50%', '70%'], // 环形饼图 radius: ['50%', '70%'],
center: ['50%', '50%'], // 饼图居中显示 center: ['50%', '55%'],
color: CHART_CONFIG.pieColors, color: CHART_CONFIG.pieColors,
// 关键:添加外部标签和指示线
label: { label: {
show: true, // 显示标签 show: true,
position: 'outside', // 标签位置:饼图外部 position: 'outside',
distance: 15, // 标签与饼图的距离 distance: 15,
fontSize: 11, fontSize: 11,
color: CHART_CONFIG.lightFontColor, color: CHART_CONFIG.lightFontColor,
formatter: (params) => { formatter: (params) => {
// 标签内容:报警内容(截断)+ 次数 + 占比 const truncatedName = this.truncateText(params.name, 8);
const truncatedName = this.truncateText(params.name, 8); // 最多8字 return `${truncatedName}(${params.value}${type === 'duration' ? '' : '次'}, ${params.percent.toFixed(1)}%)`;
return `${truncatedName}(${params.value}次, ${params.percent.toFixed(1)}%)`;
}, },
align: 'center', align: 'center',
baseline: 'middle' baseline: 'middle'
}, },
// 指示线配置
labelLine: { labelLine: {
show: true, // 显示指示线 show: true,
length: 15, // 第一段线长度(从饼图到转折点) length: 15,
length2: 20, // 第二段线长度(从转折点到标签) length2: 20,
lineStyle: { lineStyle: {
color: '#ccc', // 指示线颜色 color: '#ccc',
width: 1, // 线宽 width: 1,
type: 'solid' // 实线 type: 'solid'
}, },
smooth: 0.2 // 指示线轻微弯曲,更美观 smooth: 0.2
}, },
data: pieData, data: pieData,
// 高亮样式hover时
emphasis: { emphasis: {
itemStyle: { itemStyle: {
shadowBlur: 10, shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.1)' shadowColor: 'rgba(0, 0, 0, 0.1)'
}, },
label: { label: {
color: CHART_CONFIG.fontColor, // 高亮时标签颜色加深 color: CHART_CONFIG.fontColor,
fontSize: 12, // 标签放大 fontSize: 12,
fontWeight: 500 fontWeight: 500
}, },
labelLine: { labelLine: {
lineStyle: { lineStyle: {
color: CHART_CONFIG.barColor, // 高亮时指示线颜色变为主色 color: CHART_CONFIG.barColor,
width: 1.5 width: 1.5
} }
} }
@@ -355,27 +390,30 @@ export default {
}; };
this.chartInstances.pie.setOption(option); this.chartInstances.pie.setOption(option);
// 监听窗口 resize
this.addResizeListener('pie'); this.addResizeListener('pie');
} catch (error) {
console.error(`${seriesName}饼图初始化失败:`, error);
setTimeout(() => this.renderPieChart(type), 200);
}
}, },
// 处理饼图数据(合并占比<5%的项)
handlePieData(data) { // 通用饼图数据处理(支持动态字段)
const threshold = 5; // 阈值5% handlePieData(data, valueKey, ratioKey) {
const threshold = 5; // 占比低于5%合并为「其他」
let otherCount = 0; let otherCount = 0;
const mainData = data.filter(item => { const mainData = data.filter(item => {
if (item.alarmCountRatio >= threshold) { if (item[ratioKey] >= threshold) {
return true; return true;
} else { } else {
otherCount += item.alarmCount; otherCount += item[valueKey];
return false; return false;
} }
}).map(item => ({ }).map(item => ({
name: item.alarmContent, name: item.alarmContent,
value: item.alarmCount, value: item[valueKey],
ratio: item.alarmCountRatio ratio: item[ratioKey]
})); }));
// 如果有"其他"项,添加到数据中
if (otherCount > 0) { if (otherCount > 0) {
mainData.push({ mainData.push({
name: '其他', name: '其他',
@@ -387,57 +425,70 @@ export default {
return mainData; return mainData;
}, },
// 文本截断(超出长度显示省略号)
truncateText(text, maxLength) { truncateText(text, maxLength) {
if (!text) return ''; if (!text) return '';
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text; return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
}, },
// 添加窗口resize监听
addResizeListener(type) { addResizeListener(type) {
const chart = this.chartInstances[type]; const chart = this.chartInstances[type];
if (chart) { if (chart) {
const resizeHandler = () => chart.resize(); const resizeHandler = () => chart.resize();
window.addEventListener('resize', resizeHandler); window.addEventListener('resize', resizeHandler);
// 存储resize处理器用于后续移除
chart.resizeHandler = resizeHandler; chart.resizeHandler = resizeHandler;
} }
}, },
// 销毁单个图表
destroyChart(type) { destroyChart(type) {
const chart = this.chartInstances[type]; const chart = this.chartInstances[type];
if (chart) { if (chart) {
// 移除resize监听
window.removeEventListener('resize', chart.resizeHandler); window.removeEventListener('resize', chart.resizeHandler);
chart.dispose(); chart.dispose();
this.chartInstances[type] = null; this.chartInstances[type] = null;
} }
}, },
// 销毁所有图表
destroyAllCharts() { destroyAllCharts() {
Object.keys(this.chartInstances).forEach(type => { Object.keys(this.chartInstances).forEach(type => {
this.destroyChart(type); this.destroyChart(type);
}); });
}, },
// 初始化弹窗数据 handleClose() {
this.destroyAllCharts();
this.formConfig[0].defaultSelect = [];
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
this.originData = null;
this.hasData = true;
if (this.$refs.searchBarForm) {
// this.$refs.searchBarForm.form.timeVal = [];
}
},
init(data) { init(data) {
this.dataForm = { this.dataForm = {
equipmentId: data.equipmentId || undefined, equipmentId: data.equipmentId || '',
equipmentName: data.equipmentName || '未知设备', equipmentName: data.equipmentName || '',
lineId: data.lineId || '未知产线' lineId: data.lineId || ''
}; };
this.activeLabel = 'duration'
this.listQuery.equipmentId = data.equipmentId || undefined; this.listQuery.equipmentId = data.equipmentId || undefined;
this.visible = true; this.visible = true;
this.originData = null;
this.hasData = false;
this.initDefaultDate();
this.$nextTick(() => { this.$nextTick(() => {
this.$nextTick(() => {
this.isDomReady = true;
this.getDataList(); this.getDataList();
}); });
});
} }
}, },
// 组件销毁时清理资源
beforeDestroy() { beforeDestroy() {
this.destroyAllCharts(); this.destroyAllCharts();
} }
@@ -445,6 +496,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
/* 保持原有样式,优化图表容器布局 */
.drawer>>>.el-drawer { .drawer>>>.el-drawer {
border-radius: 8px 0 0 8px; border-radius: 8px 0 0 8px;
display: flex; display: flex;
@@ -473,16 +525,27 @@ export default {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* height: 100%; */
} }
.drawer>>>.visual-part { .drawer>>>.visual-part {
flex: 1 auto; flex: 1 auto;
max-height: 76vh; max-height: 76vh;
overflow: hidden; overflow: hidden;
overflow-y: scroll; padding: 10px 0;
padding-right: 10px; }
/* 调整滚动条样式 */
/* 优化图表容器响应式布局 */
@media (max-width: 1200px) {
.visual-part>div {
flex-direction: column;
}
#barChart,
#pieChart {
width: 100% !important;
height: 350px !important;
margin-bottom: 20px;
}
} }
.drawer>>>.el-form, .drawer>>>.el-form,

View File

@@ -15,7 +15,7 @@
<div class="equipment-info"> <div class="equipment-info">
<div class="info"> <div class="info">
<div class="num equipment"> <div class="num equipment">
{{ countEq ? countEq : 0 }} {{ globalCount.total ? globalCount.total : 0 }}
</div> </div>
<div class="title"> <div class="title">
设备数量 设备数量
@@ -28,7 +28,7 @@
<div class="equipment-info"> <div class="equipment-info">
<div class="info"> <div class="info">
<div class="num run"> <div class="num run">
{{ countRun ? countRun : 0 }} {{ globalCount.run ? globalCount.run : 0 }}
</div> </div>
<div class="title"> <div class="title">
运行数量 运行数量
@@ -41,7 +41,7 @@
<div class="equipment-info"> <div class="equipment-info">
<div class="info"> <div class="info">
<div class="num stop"> <div class="num stop">
{{ countStop ? countStop : 0 }} {{ globalCount.stop ? globalCount.stop : 0 }}
</div> </div>
<div class="title"> <div class="title">
停机数量 停机数量
@@ -75,7 +75,7 @@
</div> </div>
<div class="eqRun"> <div class="eqRun">
<!-- 循环渲染设备列表key绑定唯一equipmentId --> <!-- 循环渲染设备列表key绑定唯一equipmentId -->
<div v-for="item in list" :key="item.equipmentId" class="eqItem" :class="{ <div v-for="item in filteredList" :key="item.equipmentId" class="eqItem" :class="{
'eq-item-disabled-false': !disabled, 'eq-item-disabled-false': !disabled,
'eq-item-disabled-true': disabled 'eq-item-disabled-true': disabled
}"> }">
@@ -166,13 +166,25 @@
</div> </div>
<div class="progress-text"> <div class="progress-text">
<!-- 运行百分比显示item.run的值 --> <!-- 运行百分比显示item.run的值增加值存在性判断 -->
<div class="run" :style="!disabled ? { color: 'rgba(180, 180, 180, 1)' } : {}"> <div class="run" :style="!disabled ? { color: 'rgba(180, 180, 180, 1)' } : {}">
运行 {{ !disabled ? '—' : `${item.run.toFixed(1)}%` }} 运行 {{
!disabled
? '—'
: (item.run !== undefined && item.run !== null && !isNaN(item.run))
? `${item.run.toFixed(1) }%`
: '—'
}}
</div> </div>
<!-- 停机百分比显示item.stop的值 --> <!-- 停机百分比显示item.stop的值增加值存在性判断 -->
<div class="stop" :style="!disabled ? { color: 'rgba(180, 180, 180, 1)' } : {}"> <div class="stop" :style="!disabled ? { color: 'rgba(180, 180, 180, 1)' } : {}">
停机 {{ !disabled ? '—' : `${item.stop.toFixed(1)}%` }} 停机 {{
!disabled
? '—'
: (item.stop !== undefined && item.stop !== null && !isNaN(item.stop))
? `${item.stop.toFixed(1) }%`
: '—'
}}
</div> </div>
</div> </div>
@@ -204,6 +216,7 @@ import {
import { getTree } from '@/api/base/equipment'; import { getTree } from '@/api/base/equipment';
import { getEquipmentTypePage } from '@/api/base/equipmentType'; import { getEquipmentTypePage } from '@/api/base/equipmentType';
import { getEquipmentOverall } from '@/api/base/equipment'; import { getEquipmentOverall } from '@/api/base/equipment';
import { getTenantId } from '@/utils/auth'
// import * as XLSX from 'xlsx'; // import * as XLSX from 'xlsx';
// import FileSaver from 'file-saver'; // import FileSaver from 'file-saver';
@@ -247,7 +260,7 @@ export default {
type: 'select', type: 'select',
label: '设备类型', label: '设备类型',
selectOptions: [], selectOptions: [],
param: 'equipmentType', param: 'equipmentTypeId',
// labelField: 'label', // labelField: 'label',
// valueField: 'label', // valueField: 'label',
}, },
@@ -256,6 +269,7 @@ export default {
label: '设备名称', label: '设备名称',
selectOptions: [], selectOptions: [],
param: 'equipmentIds', param: 'equipmentIds',
showAllLevels: false,
clearable: false, clearable: false,
cascaderProps: { cascaderProps: {
multiple: true, multiple: true,
@@ -299,6 +313,33 @@ export default {
this.getLineData() this.getLineData()
this.getDataList() this.getDataList()
}, },
computed: {
// 筛选后的列表(按 status 变化,不影响统计)
filteredList() {
if (this.status === undefined) {
return this.list; // 全部数据
}
// 只筛选列表,不改变统计
return this.list.filter(item => item.status === this.status);
},
// 全局统计(基于原始 list不随 status 变化)
globalCount() {
// 优先使用接口返回的统计数据(如果接口提供)
if (this.countEq > 0 || this.countRun > 0 || this.countStop > 0) {
return {
total: this.countEq,
run: this.countRun,
stop: this.countStop
};
}
// 接口未提供时,基于原始 list 计算(兜底方案)
return {
total: this.list.length,
run: this.list.filter(item => item.status === 0).length,
stop: this.list.filter(item => item.status === 1).length
};
}
},
methods: { methods: {
formatTime(time) { formatTime(time) {
// 处理时间戳10位秒级转13位毫秒级 // 处理时间戳10位秒级转13位毫秒级
@@ -399,9 +440,10 @@ export default {
// this.formConfig[2].selectOptions = res.data.list || []; // this.formConfig[2].selectOptions = res.data.list || [];
// }) // })
const { data } = await this.$axios('/base/factory/getTree'); const { data } = await this.$axios('/base/factory/getTree');
this.formConfig[2].selectOptions = this.transformAndRemoveLastChildren(data) this.formConfig[2].selectOptions = data
console.log('this.removeLastLevelChildren(data)', this.transformAndRemoveLastChildren(data)) // console.log('this.removeLastLevelChildren(data)', this.transformAndRemoveLastChildren(data))
}, },
// 切换按产线/按产品监控 // 切换按产线/按产品监控
// 搜索/导出按钮点击 // 搜索/导出按钮点击
@@ -417,20 +459,35 @@ export default {
break; break;
case 'link': case 'link':
this.disabled = true; this.disabled = true;
this.connectSSEBatch(this.listQuery.equipmentIds); let equipmentIds = []
let arr = []
this.list.forEach(ele => {
console.log('ele',ele);
arr.push(ele.equipmentId)
});
console.log('arr', arr);
equipmentIds = arr
this.connectSSEBatch(this.listQuery.equipmentIds.length > 0 ? this.listQuery.equipmentIds : equipmentIds);
break; break;
default: default:
} }
}, },
getDataList() { getDataList() {
if (this.disabled === true) {
this.closeAllSSE(); // 直接调用批量关闭方法
this.disabled = false;
this.isSSEConnected = false; // 重置连接状态
}
this.dataListLoading = true; this.dataListLoading = true;
this.listQuery.equipmentIds = this.searchBarData.equipmentIds || []; this.listQuery.equipmentIds = this.searchBarData.equipmentIds || [];
// this.listQuery.equipmentIds = [200301, 200302, 200303]; // this.listQuery.equipmentIds = [200301, 200302, 200303];
this.listQuery.lineId = this.searchBarData.lineId ? this.searchBarData.lineId : undefined; this.listQuery.lineId = this.searchBarData.lineId ? this.searchBarData.lineId : undefined;
this.listQuery.equipmentTypeId = this.searchBarData.equipmentTypeId ? this.searchBarData.equipmentTypeId : undefined this.listQuery.equipmentTypeId = this.searchBarData.equipmentTypeId ? this.searchBarData.equipmentTypeId : undefined
this.listQuery.status = this.status ? this.status : undefined // this.listQuery.status = this.status ? this.status : undefined
this.urlOptions.getDataListURL(this.listQuery).then(res => { this.urlOptions.getDataListURL(this.listQuery).then(res => {
this.list = res.data.dets this.list = res.data.dets
this.countEq = res.data.countEq this.countEq = res.data.countEq
@@ -460,8 +517,6 @@ export default {
} else{ } else{
this.status = undefined this.status = undefined
} }
// this.listQuery.status = this.status ? this.status : undefined
this.getDataList()
}, },
closeSSE() { closeSSE() {
this.isDestroyed = true; this.isDestroyed = true;
@@ -473,6 +528,8 @@ export default {
}, },
// 方案1箭头函数绑定 this推荐 // 方案1箭头函数绑定 this推荐
connectSSEBatch(equipmentIds) { connectSSEBatch(equipmentIds) {
console.log('equipmentIds'.equipmentIds);
this.closeAllSSE(); // 此时 this 指向组件实例 this.closeAllSSE(); // 此时 this 指向组件实例
if (!equipmentIds || equipmentIds.length === 0) { if (!equipmentIds || equipmentIds.length === 0) {
@@ -513,7 +570,7 @@ export default {
const token = getAccessToken(); const token = getAccessToken();
const headers = new Headers({ const headers = new Headers({
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
'tenant-id': store.getters.userId, 'tenant-id': getTenantId(),
'Content-Type': 'text/event-stream', 'Content-Type': 'text/event-stream',
}); });

View File

@@ -2,7 +2,7 @@
* @Author: zwq * @Author: zwq
* @Date: 2025-10-13 15:07:24 * @Date: 2025-10-13 15:07:24
* @LastEditors: zwq * @LastEditors: zwq
* @LastEditTime: 2025-12-01 14:40:46 * @LastEditTime: 2025-12-03 15:48:26
* @Description: * @Description:
--> -->
<template> <template>
@@ -826,10 +826,14 @@ export default {
}); });
checkPlan(data).then((RES) => { checkPlan(data).then((RES) => {
createStepFour(this.dataForm.id).then((res) => { createStepFour(this.dataForm.id).then((res) => {
if (res.code === 200 || res.code === 0) {
this.$modal.msgSuccess('创建计划成功'); this.$modal.msgSuccess('创建计划成功');
this.stepNum = 1; this.stepNum = 1;
this.$emit('setSN', this.stepNum); this.$emit('setSN', this.stepNum);
this.$emit('refreshDataList'); this.$emit('refreshDataList');
} else {
this.$message(res.msg);
}
}); });
}); });
return; return;

View File

@@ -2,7 +2,7 @@
* @Author: zwq * @Author: zwq
* @Date: 2021-11-18 14:16:25 * @Date: 2021-11-18 14:16:25
* @LastEditors: zwq * @LastEditors: zwq
* @LastEditTime: 2025-11-27 14:06:11 * @LastEditTime: 2025-12-11 10:47:50
* @Description: * @Description:
--> -->
<template> <template>
@@ -66,7 +66,7 @@
type="date" type="date"
placeholder="选择日期" placeholder="选择日期"
format="yyyy-MM-dd" format="yyyy-MM-dd"
value-format="--MM-dd" value-format="yyyy-MM-dd"
@blur="$forceUpdate()" @blur="$forceUpdate()"
:picker-options="pickerOptions"></el-date-picker> :picker-options="pickerOptions"></el-date-picker>
</el-form-item> </el-form-item>
@@ -81,7 +81,7 @@
v-model="dataForm.dateDayArr" v-model="dataForm.dateDayArr"
type="daterange" type="daterange"
format="yyyy-MM-dd" format="yyyy-MM-dd"
value-format="--MM-dd" value-format="yyyy-MM-dd"
range-separator="" range-separator=""
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
@@ -341,45 +341,70 @@ export default {
this.$refs['dataForm'].resetFields(); this.$refs['dataForm'].resetFields();
if (this.dataForm.id) { if (this.dataForm.id) {
getHoliday(this.dataForm.id).then((res) => { getHoliday(this.dataForm.id).then((res) => {
//设置年份,不重复的直接用返回的年份,重复的直接用当年年份
let year = new Date().getFullYear();
if (res.data.calendarType == 1 && !res.data.repeat) {
year = res.data.noRepeatYear;
} else if (res.data.calendarType == 2 && !res.data.repeat) {
year = res.data.noRepeatYearChinese;
}
this.dataForm = res.data; this.dataForm = res.data;
if ( if (
this.dataForm.dateType == 1 && this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 1 this.dataForm.calendarType == 1
) { ) {
this.dataForm.dateDay = this.dataForm.oneDay; this.dataForm.dateDay =
year + '-' + this.dataForm.oneDay.slice(-5);
} else if ( } else if (
this.dataForm.dateType == 2 && this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1 this.dataForm.calendarType == 1
) { ) {
let num = this.compareMonthDay(
this.dataForm.startDay.slice(-5),
this.dataForm.endDay.slice(-5)
);
this.dataForm.dateDayArr = [ this.dataForm.dateDayArr = [
this.dataForm.startDay, year + '-' + this.dataForm.startDay.slice(-5),
this.dataForm.endDay, (num > 0 ? year : year + 1) +
'-' +
this.dataForm.endDay.slice(-5),
]; ];
} else if ( } else if (
this.dataForm.dateType == 1 && this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2 this.dataForm.calendarType == 2
) { ) {
this.dataForm.dateDayChinese = this.dataForm.dateDayChinese =
'L' + 'L' + year + this.dataForm.oneDayChinese.slice(-6);
new Date().getFullYear() +
this.dataForm.oneDayChinese.slice(-6);
} else if ( } else if (
this.dataForm.dateType == 2 && this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2 this.dataForm.calendarType == 2
) { ) {
this.dataForm.dateDayArrChinese = [ let num = this.compareMonthDay(
'L' +
new Date().getFullYear() +
this.dataForm.startDayChinese.slice(-6), this.dataForm.startDayChinese.slice(-6),
this.dataForm.endDayChinese.slice(-6)
);
this.dataForm.dateDayArrChinese = [
'L' + year + this.dataForm.startDayChinese.slice(-6),
'L' + 'L' +
new Date().getFullYear() + (num > 0 ? year : year + 1) +
this.dataForm.endDayChinese.slice(-6), +this.dataForm.endDayChinese.slice(-6),
]; ];
} }
}); });
} }
}); });
}, },
//用于比较日期大小判断年份是否要加1
compareMonthDay(dateStr1, dateStr2) {
const [month1, day1] = dateStr1.split('-').map(Number);
const [month2, day2] = dateStr2.split('-').map(Number);
if (month1 !== month2) {
return month2 - month1;
}
return day2 - day1;
},
editHoliday() { editHoliday() {
this.detail = false; this.detail = false;
}, },
@@ -442,13 +467,16 @@ export default {
return false; return false;
} }
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) { if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
this.dataForm.oneDay = this.dataForm.dateDay; const [year, month, day] = this.dataForm.dateDay.split('-');
this.dataForm.oneDay = `--${month}-${day}`;
} else if ( } else if (
this.dataForm.dateType == 2 && this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1 this.dataForm.calendarType == 1
) { ) {
this.dataForm.startDay = this.dataForm.dateDayArr[0]; const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
this.dataForm.endDay = this.dataForm.dateDayArr[1]; this.dataForm.startDay = `--${month}-${day}`;
const [year1, month1, day1] = this.dataForm.dateDayArr[1].split('-');
this.dataForm.endDay = `--${month1}-${day1}`;
} else if ( } else if (
this.dataForm.dateType == 1 && this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2 this.dataForm.calendarType == 2
@@ -464,10 +492,35 @@ export default {
this.dataForm.endDayChinese = this.dataForm.endDayChinese =
'--' + this.dataForm.dateDayArrChinese[1].slice(-5); '--' + this.dataForm.dateDayArrChinese[1].slice(-5);
} }
if (this.dataForm.calendarType == 1 && !this.dataForm.repeat) { //是否每年重复,不重复的话需要传 年份
this.dataForm.noRepeatYear = new Date().getFullYear(); if (
} else if (this.dataForm.calendarType == 2 && !this.dataForm.repeat) { this.dataForm.dateType == 1 &&
this.dataForm.noRepeatYearChinese = new Date().getFullYear(); this.dataForm.calendarType == 1 &&
!this.dataForm.repeat
) {
const [year, month, day] = this.dataForm.dateDay.split('-');
this.dataForm.noRepeatYear = year;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1 &&
!this.dataForm.repeat
) {
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
this.dataForm.noRepeatYear = year;
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2 &&
!this.dataForm.repeat
) {
this.dataForm.noRepeatYearChinese =
this.dataForm.dateDayChinese.slice(1, 5);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2 &&
!this.dataForm.repeat
) {
this.dataForm.noRepeatYearChinese =
this.dataForm.dateDayArrChinese[0].slice(1, 5);
} }
// 修改的提交 // 修改的提交
if (this.dataForm.id) { if (this.dataForm.id) {
@@ -475,6 +528,7 @@ export default {
this.dataForm.inherited = false; this.dataForm.inherited = false;
} }
updateHoliday(this.dataForm).then((res) => { updateHoliday(this.dataForm).then((res) => {
if (res.code === 0 || res.code === 200) {
if (!res.data.updateFlag) { if (!res.data.updateFlag) {
this.$modal.msgSuccess('修改成功'); this.$modal.msgSuccess('修改成功');
this.$emit('refreshPage'); this.$emit('refreshPage');
@@ -502,11 +556,15 @@ export default {
this.$emit('refreshPage'); this.$emit('refreshPage');
}); });
} }
} else {
this.$modal.msg(res.msg);
}
}); });
return; return;
} }
// 添加的提交 // 添加的提交
createHoliday(this.dataForm).then((res) => { createHoliday(this.dataForm).then((res) => {
if (res.code === 0 || res.code === 200) {
if (!res.data.updateFlag) { if (!res.data.updateFlag) {
this.$modal.msgSuccess('新增成功'); this.$modal.msgSuccess('新增成功');
this.$emit('refreshPage'); this.$emit('refreshPage');
@@ -534,6 +592,9 @@ export default {
this.$emit('refreshPage'); this.$emit('refreshPage');
}); });
} }
} else {
this.$modal.msg(res.msg);
}
}); });
}); });
}, },

View File

@@ -210,7 +210,7 @@
</template> </template>
<script> <script>
import moment from 'moment'; import moment from 'moment';
import JDatePickerScript from './jDatePicker.js' // import JDatePickerScript from './JDatePicker.js'
export default { export default {
props: { props: {

View File

@@ -121,6 +121,7 @@ export default {
type: 'select', type: 'select',
label: '产线', label: '产线',
selectOptions: [], selectOptions: [],
multiple: true,
param: 'lineId', param: 'lineId',
}, },
{ {
@@ -134,13 +135,14 @@ export default {
label: '时间范围', label: '时间范围',
dateType: 'datetimerange', dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss', format: 'yyyy-MM-dd HH:mm:ss',
// valueFormat: 'timestamp', valueFormat: 'timestamp',
valueFormat: 'yyyy-MM-dd HH:mm:ss', // valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-', rangeSeparator: '-',
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
width: 350 width: 350,
defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
@@ -214,11 +216,55 @@ export default {
// deep: true // deep: true
// }, // },
// }, // },
created() { mounted() {
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
// 找到时间范围的配置项并赋值对应你代码中的timeVal参数
this.searchBarFormConfig[3].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
this.queryParams.startTime = startTimestamp;
this.queryParams.endTime = endTimestamp;
this.getList(); this.getList();
this.getDict() this.getDict()
}, },
methods: { methods: {
getThreeDaysAgoThisTimeToNowTimeStamps() {
const now = new Date();
// 1. 计算三天前的当前时刻使用setDate直接修改日期保留时分秒等信息
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天时分秒保持和当前一致
// 2. 获取时间戳(毫秒级和秒级)
// 开始时间戳:三天前的当前时刻
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
// 结束时间戳:当前时刻
const endTimestamp = now.getTime(); // 毫秒级
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
// 封装日期格式化函数转换为yyyy-MM-dd HH:mm:ss格式
const formatDateTime = (date) => {
const y = date.getFullYear();
// 月份是从0开始的所以要+1补零确保是两位
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
const h = String(date.getHours()).padStart(2, '0');
const min = String(date.getMinutes()).padStart(2, '0');
const s = String(date.getSeconds()).padStart(2, '0');
return `${y}-${m}-${d} ${h}:${min}:${s}`;
};
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
const endDateTimeStr = formatDateTime(now);
return {
startTimestamp, // 三天前当前时刻的毫秒级时间戳
endTimestamp, // 当前时刻的毫秒级时间戳
startTimestampSec, // 三天前当前时刻的秒级时间戳
endTimestampSec, // 当前时刻的秒级时间戳
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
};
},
getDict() { getDict() {
getPdList().then(res => { getPdList().then(res => {
this.searchBarFormConfig[1].selectOptions = res.data || []; this.searchBarFormConfig[1].selectOptions = res.data || [];

View File

@@ -150,7 +150,8 @@ export default {
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
width: 350 width: 350,
defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
@@ -226,11 +227,56 @@ export default {
// deep: true // deep: true
// }, // },
// }, // },
created() { mounted() {
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
// 找到时间范围的配置项并赋值对应你代码中的timeVal参数
this.searchBarFormConfig[2].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
this.queryParams.startTime = startTimestamp;
this.queryParams.endTime = endTimestamp;
this.getList(); this.getList();
this.getDict() this.getDict()
}, },
methods: { methods: {
getThreeDaysAgoThisTimeToNowTimeStamps() {
const now = new Date();
// 1. 计算三天前的当前时刻使用setDate直接修改日期保留时分秒等信息
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天时分秒保持和当前一致
// 2. 获取时间戳(毫秒级和秒级)
// 开始时间戳:三天前的当前时刻
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
// 结束时间戳:当前时刻
const endTimestamp = now.getTime(); // 毫秒级
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
// 封装日期格式化函数转换为yyyy-MM-dd HH:mm:ss格式
const formatDateTime = (date) => {
const y = date.getFullYear();
// 月份是从0开始的所以要+1补零确保是两位
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
const h = String(date.getHours()).padStart(2, '0');
const min = String(date.getMinutes()).padStart(2, '0');
const s = String(date.getSeconds()).padStart(2, '0');
return `${y}-${m}-${d} ${h}:${min}:${s}`;
};
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
const endDateTimeStr = formatDateTime(now);
return {
startTimestamp, // 三天前当前时刻的毫秒级时间戳
endTimestamp, // 当前时刻的毫秒级时间戳
startTimestampSec, // 三天前当前时刻的秒级时间戳
endTimestampSec, // 当前时刻的秒级时间戳
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
};
},
getDict() { getDict() {
getPdList().then(res => { getPdList().then(res => {
this.searchBarFormConfig[1].selectOptions = res.data || []; this.searchBarFormConfig[1].selectOptions = res.data || [];

View File

@@ -152,7 +152,8 @@ export default {
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
width: 350 width: 350,
defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
@@ -225,11 +226,56 @@ export default {
// deep: true // deep: true
// }, // },
// }, // },
created() { mounted() {
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
// 找到时间范围的配置项并赋值对应你代码中的timeVal参数
this.searchBarFormConfig[2].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
this.queryParams.startTime = startTimestamp;
this.queryParams.endTime = endTimestamp;
this.getList(); this.getList();
this.getDict() this.getDict()
}, },
methods: { methods: {
getThreeDaysAgoThisTimeToNowTimeStamps() {
const now = new Date();
// 1. 计算三天前的当前时刻使用setDate直接修改日期保留时分秒等信息
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天时分秒保持和当前一致
// 2. 获取时间戳(毫秒级和秒级)
// 开始时间戳:三天前的当前时刻
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
// 结束时间戳:当前时刻
const endTimestamp = now.getTime(); // 毫秒级
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
// 封装日期格式化函数转换为yyyy-MM-dd HH:mm:ss格式
const formatDateTime = (date) => {
const y = date.getFullYear();
// 月份是从0开始的所以要+1补零确保是两位
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
const h = String(date.getHours()).padStart(2, '0');
const min = String(date.getMinutes()).padStart(2, '0');
const s = String(date.getSeconds()).padStart(2, '0');
return `${y}-${m}-${d} ${h}:${min}:${s}`;
};
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
const endDateTimeStr = formatDateTime(now);
return {
startTimestamp, // 三天前当前时刻的毫秒级时间戳
endTimestamp, // 当前时刻的毫秒级时间戳
startTimestampSec, // 三天前当前时刻的秒级时间戳
endTimestampSec, // 当前时刻的秒级时间戳
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
};
},
getDict() { getDict() {
getPdList().then(res => { getPdList().then(res => {
this.searchBarFormConfig[1].selectOptions = res.data || []; this.searchBarFormConfig[1].selectOptions = res.data || [];

17160
yarn.lock

File diff suppressed because it is too large Load Diff