Compare commits
17 Commits
552b1e6d6a
...
projects/l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51e1ef8501 | ||
|
|
35fb0d8bfb | ||
|
|
0c52306cc6 | ||
| a5fba28ff7 | |||
|
|
1f8b994218 | ||
|
|
ccfa73f3bc | ||
|
|
89ff79bfd7 | ||
| 70a0fbb170 | |||
|
|
c86d94ac92 | ||
|
|
484ba6ca53 | ||
|
|
f403375594 | ||
| 1cd0b13aae | |||
|
|
d2b0565cd1 | ||
|
|
7661dc5691 | ||
| 1d698848c2 | |||
|
|
6d367b121c | ||
|
|
e2385cf813 |
4
.env.dev
4
.env.dev
@@ -13,8 +13,8 @@ VUE_APP_TITLE = 智能监控分析系统
|
||||
|
||||
# 芋道管理系统/开发环境
|
||||
# VUE_APP_BASE_API = 'http://172.16.33.187:48082'
|
||||
# VUE_APP_BASE_API = 'http://line.kszny.picaiba.com'
|
||||
VUE_APP_BASE_API = 'http://172.16.32.79:48082'
|
||||
VUE_APP_BASE_API = 'http://line.kszny.picaiba.com'
|
||||
# VUE_APP_BASE_API = 'http://172.16.32.79:48082'
|
||||
|
||||
|
||||
# 路由懒加载
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
"bpmn-js-token-simulation": "0.10.0",
|
||||
"chinese-lunar": "^0.1.4",
|
||||
"clipboard": "2.0.8",
|
||||
"code-brick-zj": "^1.0.2",
|
||||
"code-brick-zj": "^1.1.1",
|
||||
"core-js": "^3.26.0",
|
||||
"crypto-js": "^4.0.0",
|
||||
"diagram-js": "^12.3.0",
|
||||
|
||||
@@ -62,10 +62,10 @@ export function getEquipmentAll() {
|
||||
|
||||
export function getTree(query) {
|
||||
return request({
|
||||
url: '/base/factory/getTree',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
url: '/base/factory/getTreeSimple',
|
||||
method: 'get',
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
export function getEquipmentOverall(data) {
|
||||
|
||||
@@ -102,3 +102,17 @@ export function getProcessAutoReportNew(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,
|
||||
});
|
||||
}
|
||||
|
||||
25
src/api/monitoring/eqParamAlarmLog.js
Normal file
25
src/api/monitoring/eqParamAlarmLog.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getEquipmentAlarmLogPage(query) {
|
||||
return request({
|
||||
url: '/monitoring/equipment-param-alarm-log/page',
|
||||
method: 'get',
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
export function getEqList(query) {
|
||||
return request({
|
||||
url: '/base/equipment/listByLine',
|
||||
method: 'get',
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
export function getLineList(query) {
|
||||
return request({
|
||||
url: '/base/production-line/listAll',
|
||||
method: 'get',
|
||||
// params: query,
|
||||
});
|
||||
}
|
||||
@@ -54,7 +54,7 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.currentMenu = this.menus[0];
|
||||
// this.currentMenu = this.menus[0];
|
||||
},
|
||||
watch: {
|
||||
currentMenu(val) {
|
||||
|
||||
@@ -88,7 +88,32 @@ export default {
|
||||
};
|
||||
},
|
||||
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>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
style="width: 75%"
|
||||
v-model="dataForm.price"
|
||||
clearable
|
||||
placeholder="请输入允许留存时间" />
|
||||
placeholder="请输入单价" />
|
||||
{{ unit }}
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -140,17 +140,42 @@ export default {
|
||||
setTimeout(this.setCode(), 1000);
|
||||
}
|
||||
},
|
||||
setCode() {
|
||||
setCode() {
|
||||
console.log('this.MaterialList', this.urlOptions.dictArr.dict0);
|
||||
|
||||
this.MaterialList.forEach((item) => {
|
||||
if (item.id === this.dataForm.materialId) {
|
||||
this.dataForm.code = item.code;
|
||||
this.unit =
|
||||
'元/' +
|
||||
this.urlOptions.dictArr.dict0.find((d) => d.value === item.unit)
|
||||
this.urlOptions.dictArr.dict0.find((d) => d.value == item.unit)
|
||||
.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");
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -128,7 +128,7 @@ export default {
|
||||
this.tableData = response.data;
|
||||
this.dataListLoading = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
handleClick(val) {
|
||||
const data = {
|
||||
...this.time,
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<script>
|
||||
import eqDetail from './eq-detail';
|
||||
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 { getFactoryPage } from '@/api/core/base/factory';
|
||||
// import codeFilter from '../../mixins/code-filter'
|
||||
@@ -134,14 +134,17 @@ export default {
|
||||
type: 'select',
|
||||
label: '工厂',
|
||||
selectOptions: [],
|
||||
param: 'factoryId',
|
||||
param: 'factoryId',
|
||||
collapseTags: true,
|
||||
multiple: true,
|
||||
onchange: true,
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '产线',
|
||||
selectOptions: [],
|
||||
param: 'lineId',
|
||||
param: 'lineId',
|
||||
collapseTags: true,
|
||||
multiple: true,
|
||||
},
|
||||
{
|
||||
@@ -232,9 +235,9 @@ export default {
|
||||
return exportTableOut;
|
||||
},
|
||||
getPdLineList() {
|
||||
getPdList().then((res) => {
|
||||
this.formConfig[1].selectOptions = res.data || [];
|
||||
});
|
||||
// getPLlistByFactory().then((res) => {
|
||||
// this.formConfig[1].selectOptions = res.data || [];
|
||||
// });
|
||||
const params = {
|
||||
pageSize: 100,
|
||||
pageNo: 1,
|
||||
@@ -274,7 +277,7 @@ export default {
|
||||
handleSearchBarChanged({ param, value }) {
|
||||
this.listQuery.lineId = [];
|
||||
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 || [];
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,273 +1,261 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<search-bar
|
||||
:formConfigs="formConfig"
|
||||
ref="searchBarForm"
|
||||
@headBtnClick="buttonClick" />
|
||||
<div v-if="tableData.length">
|
||||
<base-table
|
||||
v-loading="dataListLoading"
|
||||
:table-props="tableProps"
|
||||
:max-height="tableH"
|
||||
:table-data="tableData" />
|
||||
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
|
||||
<line-chart ref="lineChart" />
|
||||
</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 class="app-container">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<div v-if="tableData.length">
|
||||
<base-table v-loading="dataListLoading" :table-props="tableProps" :max-height="tableH" :table-data="tableData" />
|
||||
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
|
||||
<line-chart ref="lineChart" />
|
||||
</div>
|
||||
<div v-else class="no-data-bg"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import basicPage from '../../mixins/basic-page';
|
||||
import { parseTime } from '../../mixins/code-filter';
|
||||
import { getYieldAnalysisPageData } from '@/api/core/analysis/index';
|
||||
import { getProductionLinePage } from '@/api/core/base/productionLine';
|
||||
import lineChart from '../LineChart';
|
||||
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 {
|
||||
components: {
|
||||
lineChart,
|
||||
},
|
||||
mixins: [tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: getYieldAnalysisPageData,
|
||||
},
|
||||
tableProps: [],
|
||||
dataListLoading: false,
|
||||
tableData: [],
|
||||
listQuery: {
|
||||
lineIds: [],
|
||||
time: '',
|
||||
},
|
||||
dateLabelList: [],
|
||||
optionArrUrl: [getProductionLinePage],
|
||||
formConfig: [
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间',
|
||||
dateType: 'month',
|
||||
format: 'yyyy-MM',
|
||||
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'time',
|
||||
components: {
|
||||
lineChart,
|
||||
},
|
||||
mixins: [tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: getYieldAnalysisPageData,
|
||||
},
|
||||
tableProps: [],
|
||||
dataListLoading: false,
|
||||
tableData: [],
|
||||
listQuery: {
|
||||
lineIds: [],
|
||||
time: '', // 存储时间选择器的选中值(时间戳/格式化字符串,根据接口要求调整)
|
||||
},
|
||||
dateLabelList: [],
|
||||
optionArrUrl: [getProductionLinePage],
|
||||
formConfig: [
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间',
|
||||
dateType: 'month', // 单个月份选择
|
||||
format: 'yyyy-MM', // 显示格式
|
||||
valueFormat: 'yyyy-MM-dd HH:mm:ss', // 绑定值的格式
|
||||
param: 'time',
|
||||
defaultSelect: '', // 新增:默认月份值
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '产线',
|
||||
selectOptions: [],
|
||||
param: 'lineIds',
|
||||
defaultSelect: [],
|
||||
defaultSelect: [], // 产线默认选择值(多选数组)
|
||||
multiple: true,
|
||||
collapseTags: true,
|
||||
filterable: true,
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getArr();
|
||||
},
|
||||
methods: {
|
||||
getArr() {
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 500,
|
||||
};
|
||||
this.optionArrUrl.forEach((item, index) => {
|
||||
item(params).then((response) => {
|
||||
this.formConfig[1].selectOptions = response.data.list;
|
||||
// this.formConfig[0].defaultSelect = response.data.list[0].id
|
||||
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id)
|
||||
});
|
||||
});
|
||||
},
|
||||
getData() {
|
||||
// this.listQuery.lineIds = ['1672847052717821953']
|
||||
// this.listQuery.productId = val.productId;
|
||||
// this.listQuery.time = '1694486098000';
|
||||
this.urlOptions.getDataListURL(this.listQuery).then((res) => {
|
||||
let arr = [
|
||||
{
|
||||
prop: 'lineName',
|
||||
label: '产线',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
prop: 'sum',
|
||||
label: '合计[片]',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
prop: res.data ? res.data.nameData[0].name : undefined,
|
||||
label: res.data ? res.data.nameData[0].name : undefined,
|
||||
align: 'center',
|
||||
children: [],
|
||||
},
|
||||
];
|
||||
// console.log(res.data.nameData.slice(1))
|
||||
let xData = [];
|
||||
let yAllData = [];
|
||||
let lineName = [];
|
||||
if (res.data) {
|
||||
let tempDateList = [];
|
||||
res.data.nameData.forEach((date) => {
|
||||
tempDateList.push(date.name);
|
||||
});
|
||||
this.dateLabelList = Array.from(new Set(tempDateList));
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// 1. 初始化默认当月时间
|
||||
this.initDefaultMonth();
|
||||
// 2. 获取产线数据
|
||||
this.getArr();
|
||||
},
|
||||
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() {
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 500,
|
||||
};
|
||||
// 原代码forEach遍历冗余,直接调用第一个方法即可
|
||||
this.optionArrUrl[0](params)
|
||||
.then((response) => {
|
||||
const lineList = response.data.list;
|
||||
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() {
|
||||
this.dataListLoading = true; // 开启加载状态
|
||||
this.urlOptions.getDataListURL(this.listQuery)
|
||||
.then((res) => {
|
||||
let arr = [
|
||||
{
|
||||
prop: 'lineName',
|
||||
label: '产线',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
prop: 'sum',
|
||||
label: '合计[片]',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
prop: res.data ? res.data.nameData[0].name : undefined,
|
||||
label: res.data ? res.data.nameData[0].name : undefined,
|
||||
align: 'center',
|
||||
children: [],
|
||||
},
|
||||
];
|
||||
|
||||
this.dateLabelList.forEach((item) => {
|
||||
if (item.indexOf('年') === -1) {
|
||||
// 构造表头
|
||||
const props = {
|
||||
prop: item,
|
||||
label: item,
|
||||
};
|
||||
arr[2].children.push(props);
|
||||
let xData = [];
|
||||
let yAllData = [];
|
||||
let lineName = [];
|
||||
if (res.data) {
|
||||
// 处理日期标签去重
|
||||
let tempDateList = [];
|
||||
res.data.nameData.forEach((date) => {
|
||||
tempDateList.push(date.name);
|
||||
});
|
||||
this.dateLabelList = Array.from(new Set(tempDateList));
|
||||
|
||||
// 构造echarts横坐标
|
||||
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 = [];
|
||||
res.data.data.forEach((item) => {
|
||||
let obj = {};
|
||||
(obj.lineName = item.lineName),
|
||||
(obj.sum = item.sum),
|
||||
item.data.forEach((ele, index) => {
|
||||
// console.log(ele)
|
||||
ele.children.forEach((e) => {
|
||||
console.log(e.dynamicName);
|
||||
obj['' + e.dynamicName + ''] = e.dynamicValue;
|
||||
console.log(obj['' + e.dynamicName + '']);
|
||||
});
|
||||
});
|
||||
tableDataArr.push(obj);
|
||||
});
|
||||
this.tableData = tableDataArr;
|
||||
this.tableProps = arr;
|
||||
// 构造表头children和echarts横坐标
|
||||
this.dateLabelList.forEach((item) => {
|
||||
if (item.indexOf('年') === -1) {
|
||||
arr[2].children.push({
|
||||
prop: item,
|
||||
label: item,
|
||||
});
|
||||
xData.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
// let tempList = []
|
||||
// res.data.nameData.slice(1).forEach(item => {
|
||||
// tempList.push(item.name)
|
||||
// // arr[2].children.push(props)
|
||||
// })
|
||||
// xData = Array.from(new Set(tempList))
|
||||
// 构造表格数据
|
||||
let tableDataArr = [];
|
||||
res.data.data.forEach((item) => {
|
||||
let obj = {
|
||||
lineName: item.lineName,
|
||||
sum: item.sum,
|
||||
};
|
||||
item.data.forEach((ele) => {
|
||||
ele.children.forEach((e) => {
|
||||
obj[e.dynamicName] = e.dynamicValue;
|
||||
});
|
||||
});
|
||||
tableDataArr.push(obj);
|
||||
});
|
||||
this.tableData = tableDataArr;
|
||||
this.tableProps = arr;
|
||||
|
||||
res.data.data.forEach((item) => {
|
||||
let yData = [];
|
||||
lineName.push(item.lineName);
|
||||
// let obj = {}
|
||||
// obj.lineName = item.lineName,
|
||||
// obj.sum = item.sum,
|
||||
item.data.forEach((ele, index) => {
|
||||
// console.log(ele)
|
||||
ele.children.forEach((e) => {
|
||||
// let yData = []
|
||||
yData.push(e.dynamicValue);
|
||||
});
|
||||
});
|
||||
yAllData.push(yData);
|
||||
});
|
||||
console.log(lineName);
|
||||
} else {
|
||||
this.tableProps = arr;
|
||||
this.tableData = [];
|
||||
xData = [];
|
||||
yAllData = [];
|
||||
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.$refs.lineChart.initChart(xData, yAllData, lineName);
|
||||
});
|
||||
// this.total = response.data.total;
|
||||
// this.dataListLoading = false;
|
||||
});
|
||||
},
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.listQuery.lineIds = val.lineIds ? val.lineIds : undefined;
|
||||
// this.listQuery.productId = val.productId;
|
||||
this.listQuery.time = val.time
|
||||
? new Date(val.time).getTime()
|
||||
: undefined;
|
||||
// this.listQuery.pageNo = 1;
|
||||
// this.listQuery.pageSize = 10;
|
||||
if (val.time) {
|
||||
this.getData();
|
||||
} else {
|
||||
this.$message({
|
||||
message: '请选择时间',
|
||||
type: 'warning',
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'reset':
|
||||
this.$refs.searchBarForm.resetForm();
|
||||
this.listQuery = {
|
||||
pageSize: 10,
|
||||
pageNo: 1,
|
||||
total: 1,
|
||||
};
|
||||
this.getDataList();
|
||||
break;
|
||||
default:
|
||||
console.log(val);
|
||||
}
|
||||
},
|
||||
},
|
||||
// 构造图表数据
|
||||
res.data.data.forEach((item) => {
|
||||
let yData = [];
|
||||
lineName.push(item.lineName);
|
||||
item.data.forEach((ele) => {
|
||||
ele.children.forEach((e) => {
|
||||
yData.push(e.dynamicValue);
|
||||
});
|
||||
});
|
||||
yAllData.push(yData);
|
||||
});
|
||||
} else {
|
||||
this.tableProps = arr;
|
||||
this.tableData = [];
|
||||
xData = [];
|
||||
yAllData = [];
|
||||
lineName = [];
|
||||
}
|
||||
|
||||
// 初始化图表
|
||||
this.$nextTick(() => {
|
||||
this.$refs.lineChart.initChart(xData, yAllData, lineName);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('获取产量数据失败:', err);
|
||||
this.tableData = [];
|
||||
})
|
||||
.finally(() => {
|
||||
this.dataListLoading = false; // 关闭加载状态
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 搜索栏按钮点击事件
|
||||
* @param {Object} val - 按钮/表单传递的参数
|
||||
*/
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
// 处理产线参数(避免undefined,空值设为空数组)
|
||||
this.listQuery.lineIds = val.lineIds || [];
|
||||
// 处理时间参数:如果是时间字符串,可转换为时间戳(根据接口要求调整)
|
||||
if (val.time) {
|
||||
// this.listQuery.time = val.time;
|
||||
// 若接口需要时间戳,取消下面注释:
|
||||
this.listQuery.time = new Date(val.time).getTime();
|
||||
} else {
|
||||
this.$message({
|
||||
message: '请选择时间',
|
||||
type: 'warning',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证产线是否选择(可选,根据业务需求调整)
|
||||
if (this.listQuery.lineIds.length === 0) {
|
||||
this.$message({
|
||||
message: '请选择至少一条产线',
|
||||
type: 'warning',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.getData();
|
||||
break;
|
||||
case 'reset':
|
||||
// 重置表单
|
||||
this.$refs.searchBarForm.resetForm();
|
||||
// 恢复默认值
|
||||
this.listQuery = {
|
||||
lineIds: this.formConfig[1].defaultSelect || [],
|
||||
time: this.formConfig[0].defaultValue || '',
|
||||
};
|
||||
break;
|
||||
default:
|
||||
console.log(val);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -80,6 +80,16 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</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>
|
||||
|
||||
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
|
||||
@@ -131,160 +141,184 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
deleteProductAttr,
|
||||
getProductAttrPage,
|
||||
deleteProductAttr,
|
||||
getProductAttrPage,
|
||||
} from '@/api/core/base/productAttr';
|
||||
|
||||
import {
|
||||
createProduct,
|
||||
updateProduct,
|
||||
getProduct,
|
||||
getCode,
|
||||
createProduct,
|
||||
updateProduct,
|
||||
getProduct,
|
||||
getCode,
|
||||
} from '@/api/core/base/product';
|
||||
import productAttrAdd from './attr-add';
|
||||
import { parseTime } from '../../mixins/code-filter';
|
||||
import SmallTitle from './SmallTitle';
|
||||
|
||||
import { listData } from "@/api/system/dict/data"; //数据字典接口
|
||||
const tableBtn = [
|
||||
{
|
||||
type: 'edit',
|
||||
btnName: '编辑',
|
||||
},
|
||||
{
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
},
|
||||
{
|
||||
type: 'edit',
|
||||
btnName: '编辑',
|
||||
},
|
||||
{
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
},
|
||||
];
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '添加时间',
|
||||
filter: parseTime,
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '属性名',
|
||||
},
|
||||
{
|
||||
prop: 'value',
|
||||
label: '属性值',
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '添加时间',
|
||||
filter: parseTime,
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '属性名',
|
||||
},
|
||||
{
|
||||
prop: 'value',
|
||||
label: '属性值',
|
||||
},
|
||||
];
|
||||
|
||||
export default {
|
||||
components: { productAttrAdd, SmallTitle },
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
addOrUpdateVisible: false,
|
||||
tableBtn,
|
||||
tableProps,
|
||||
productAttributeList: [],
|
||||
dataForm: {
|
||||
id: null,
|
||||
name: '', // 产品名称
|
||||
code: '', // 产品编码
|
||||
area: 0, // 深加工单位平方数(float only)
|
||||
typeDictValue: null, // 产品类型id
|
||||
processTime: null, // 单位产品用时 (s)
|
||||
specifications: '', // 深加工规格
|
||||
unitDictValue: '', // 单位id
|
||||
originalSpecifications: '', // 原片规格
|
||||
components: { productAttrAdd, SmallTitle },
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
addOrUpdateVisible: false,
|
||||
tableBtn,
|
||||
tableProps,
|
||||
productAttributeList: [],
|
||||
dataForm: {
|
||||
id: null,
|
||||
name: '', // 产品名称
|
||||
code: '', // 产品编码
|
||||
area: 0, // 深加工单位平方数(float only)
|
||||
typeDictValue: null, // 产品类型id
|
||||
processTime: null, // 单位产品用时 (s)
|
||||
specifications: '', // 深加工规格
|
||||
unitDictValue: '', // 单位id
|
||||
originalSpecifications: '', // 原片规格
|
||||
originalArea: 0, // 原片单位平方数
|
||||
processTypes: [],
|
||||
},
|
||||
listQuery: {
|
||||
pageSize: 10,
|
||||
pageNo: 1,
|
||||
total: 0,
|
||||
typeDictValue: null,
|
||||
},
|
||||
typeList:[],
|
||||
listQuery: {
|
||||
pageSize: 10,
|
||||
pageNo: 1,
|
||||
total: 0,
|
||||
},
|
||||
processTypeList: [
|
||||
{
|
||||
value: '1',
|
||||
label:'压花丝印'
|
||||
},
|
||||
{
|
||||
value: '2',
|
||||
label: '无印打孔'
|
||||
},
|
||||
{
|
||||
value: '3',
|
||||
label: '单层镀膜'
|
||||
}, {
|
||||
value: '4',
|
||||
label: '双层镀膜'
|
||||
}
|
||||
// {
|
||||
// value: '1',
|
||||
// label: '压花丝印'
|
||||
// },
|
||||
// {
|
||||
// value: '2',
|
||||
// label: '无印打孔'
|
||||
// },
|
||||
// {
|
||||
// value: '3',
|
||||
// label: '单层镀膜'
|
||||
// }, {
|
||||
// value: '4',
|
||||
// label: '双层镀膜'
|
||||
// }
|
||||
],
|
||||
dataRule: {
|
||||
code: [
|
||||
{
|
||||
required: true,
|
||||
message: '产品编码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
// {
|
||||
// type: 'number',
|
||||
// message: '产品编码为数字类型',
|
||||
// trigger: 'blur',
|
||||
// transfom: 'val => Number(val)',
|
||||
// },
|
||||
],
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '产品名称不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
typeDictValue: [
|
||||
{
|
||||
required: true,
|
||||
message: '产品类型不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
area: [
|
||||
{
|
||||
type: 'number',
|
||||
message: '请输入正确的数值',
|
||||
trigger: 'change',
|
||||
transform: (val) => Number(val),
|
||||
},
|
||||
],
|
||||
processTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '完成单位产品用时不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
message: '请输入正确的数值',
|
||||
trigger: 'blur',
|
||||
transform: (val) => Number(val),
|
||||
},
|
||||
],
|
||||
},
|
||||
isdetail: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
initData() {
|
||||
this.productAttributeList.splice(0);
|
||||
this.listQuery.total = 0;
|
||||
},
|
||||
init(id, isdetail) {
|
||||
this.initData();
|
||||
this.isdetail = isdetail || false;
|
||||
dataRule: {
|
||||
code: [
|
||||
{
|
||||
required: true,
|
||||
message: '产品编码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
// {
|
||||
// type: 'number',
|
||||
// message: '产品编码为数字类型',
|
||||
// trigger: 'blur',
|
||||
// transfom: 'val => Number(val)',
|
||||
// },
|
||||
],
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '产品名称不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
typeDictValue: [
|
||||
{
|
||||
required: true,
|
||||
message: '产品类型不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
area: [
|
||||
{
|
||||
type: 'number',
|
||||
message: '请输入正确的数值',
|
||||
trigger: 'change',
|
||||
transform: (val) => Number(val),
|
||||
},
|
||||
],
|
||||
processTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '完成单位产品用时不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
message: '请输入正确的数值',
|
||||
trigger: 'blur',
|
||||
transform: (val) => Number(val),
|
||||
},
|
||||
],
|
||||
},
|
||||
isdetail: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async initData() {
|
||||
this.productAttributeList.splice(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) {
|
||||
this.initData();
|
||||
this.isdetail = isdetail || false;
|
||||
this.dataForm.id = id || null;
|
||||
// this.dataForm.processTypes = [] // 清空工艺选择
|
||||
this.visible = true;
|
||||
this.visible = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields();
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields();
|
||||
|
||||
if (this.dataForm.id) {
|
||||
// 获取产品详情
|
||||
if (this.dataForm.id) {
|
||||
// 获取产品详情
|
||||
getProduct(id).then((res) => {
|
||||
const resData = res.data || {};
|
||||
// 逐个字段赋值(保留响应式)
|
||||
@@ -305,161 +339,163 @@ export default {
|
||||
|
||||
console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式
|
||||
});
|
||||
// 获取产品的属性列表
|
||||
this.getList();
|
||||
} else {
|
||||
getCode().then((res) => {
|
||||
this.dataForm.code = res.data;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取产品的属性列表
|
||||
this.getList();
|
||||
} else {
|
||||
getCode().then((res) => {
|
||||
this.dataForm.code = res.data;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getList() {
|
||||
// 获取产品的属性列表
|
||||
getProductAttrPage({
|
||||
...this.listQuery,
|
||||
productId: this.dataForm.id,
|
||||
}).then((response) => {
|
||||
this.productAttributeList = response.data.list;
|
||||
this.listQuery.total = response.data.total;
|
||||
});
|
||||
},
|
||||
handleClick(raw) {
|
||||
if (raw.type === 'delete') {
|
||||
this.$confirm(
|
||||
`确定对${
|
||||
raw.data.name
|
||||
? '[名称=' + raw.data.name + ']'
|
||||
: '[序号=' + raw.data._pageIndex + ']'
|
||||
}进行删除操作?`,
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
deleteProductAttr(raw.data.id).then(({ data }) => {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getList();
|
||||
},
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
} else {
|
||||
this.addNew(raw.data.id);
|
||||
}
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
getList() {
|
||||
// 获取产品的属性列表
|
||||
getProductAttrPage({
|
||||
...this.listQuery,
|
||||
productId: this.dataForm.id,
|
||||
}).then((response) => {
|
||||
this.productAttributeList = response.data.list;
|
||||
this.listQuery.total = response.data.total;
|
||||
});
|
||||
},
|
||||
handleClick(raw) {
|
||||
if (raw.type === 'delete') {
|
||||
this.$confirm(
|
||||
`确定对${raw.data.name
|
||||
? '[名称=' + raw.data.name + ']'
|
||||
: '[序号=' + raw.data._pageIndex + ']'
|
||||
}进行删除操作?`,
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
deleteProductAttr(raw.data.id).then(({ data }) => {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getList();
|
||||
},
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => { });
|
||||
} else {
|
||||
this.addNew(raw.data.id);
|
||||
}
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
// 修改的提交
|
||||
if (this.dataForm.id) {
|
||||
updateProduct(this.dataForm).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功');
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
createProduct(this.dataForm).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功');
|
||||
this.$confirm(`是否新增产品属性?`, '系统提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
// 修改的提交
|
||||
if (this.dataForm.id) {
|
||||
updateProduct(this.dataForm).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功');
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
createProduct(this.dataForm).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功');
|
||||
this.$confirm(`是否新增产品属性?`, '系统提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
this.dataForm.id = response.data
|
||||
this.addNew();
|
||||
})
|
||||
.catch(() => {
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
goEdit() {
|
||||
this.isdetail = false;
|
||||
},
|
||||
// 新增 / 修改
|
||||
addNew(id) {
|
||||
if (this.dataForm.id) {
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
});
|
||||
} else {
|
||||
this.$message('请先创建产品!');
|
||||
}
|
||||
},
|
||||
goback() {
|
||||
this.$emit('refreshDataList');
|
||||
this.visible = false;
|
||||
this.initData();
|
||||
},
|
||||
},
|
||||
this.addNew();
|
||||
})
|
||||
.catch(() => {
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
goEdit() {
|
||||
this.isdetail = false;
|
||||
},
|
||||
// 新增 / 修改
|
||||
addNew(id) {
|
||||
if (this.dataForm.id) {
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
});
|
||||
} else {
|
||||
this.$message('请先创建产品!');
|
||||
}
|
||||
},
|
||||
goback() {
|
||||
this.$emit('refreshDataList');
|
||||
this.visible = false;
|
||||
this.initData();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.drawer >>> .el-drawer {
|
||||
border-radius: 8px 0 0 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.drawer>>>.el-drawer {
|
||||
border-radius: 8px 0 0 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.drawer >>> .el-form-item__label {
|
||||
padding: 0;
|
||||
.drawer>>>.el-form-item__label {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.drawer >>> .el-drawer__header {
|
||||
margin: 0;
|
||||
padding: 32px 32px 24px;
|
||||
border-bottom: 1px solid #dcdfe6;
|
||||
}
|
||||
.drawer >>> .el-drawer__body {
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.drawer>>>.el-drawer__header {
|
||||
margin: 0;
|
||||
padding: 32px 32px 24px;
|
||||
border-bottom: 1px solid #dcdfe6;
|
||||
}
|
||||
|
||||
.drawer >>> .content {
|
||||
padding: 30px 24px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
/* height: 100%; */
|
||||
.drawer>>>.el-drawer__body {
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.drawer >>> .visual-part {
|
||||
flex: 1 auto;
|
||||
max-height: 76vh;
|
||||
overflow: hidden;
|
||||
overflow-y: scroll;
|
||||
padding-right: 10px; /* 调整滚动条样式 */
|
||||
.drawer>>>.content {
|
||||
padding: 30px 24px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
/* height: 100%; */
|
||||
}
|
||||
|
||||
.drawer >>> .el-form,
|
||||
.drawer >>> .attr-list {
|
||||
padding: 0 16px;
|
||||
.drawer>>>.visual-part {
|
||||
flex: 1 auto;
|
||||
max-height: 76vh;
|
||||
overflow: hidden;
|
||||
overflow-y: scroll;
|
||||
padding-right: 10px;
|
||||
/* 调整滚动条样式 */
|
||||
}
|
||||
|
||||
.drawer>>>.el-form,
|
||||
.drawer>>>.attr-list {
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.drawer-body__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 18px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -104,7 +104,11 @@ export default {
|
||||
getDataListURL: getProductionLinePage,
|
||||
deleteURL: deleteProductionLine,
|
||||
exportURL: exportProductionLineExcel,
|
||||
},
|
||||
},
|
||||
listQuery: {
|
||||
pageSize: 20,
|
||||
pageNo:1
|
||||
},
|
||||
tableProps,
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi(`base:production-line:update`)
|
||||
@@ -212,7 +216,7 @@ export default {
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.listQuery.pageNo = 1;
|
||||
this.listQuery.pageSize = 10;
|
||||
this.listQuery.pageSize = 20;
|
||||
this.listQuery.factoryId = val.factoryId || undefined;
|
||||
this.listQuery.name = val.name;
|
||||
this.getDataList();
|
||||
@@ -220,7 +224,7 @@ export default {
|
||||
case 'reset':
|
||||
this.$refs.searchBarForm.resetForm();
|
||||
this.listQuery = {
|
||||
pageSize: 10,
|
||||
pageSize: 20,
|
||||
pageNo: 1,
|
||||
total: 1,
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,7 +101,7 @@ const tableProps = [
|
||||
},
|
||||
{
|
||||
prop: 'thick',
|
||||
label: '玻璃长度/mm'
|
||||
label: '玻璃厚度/mm'
|
||||
},
|
||||
];
|
||||
|
||||
@@ -204,94 +204,88 @@ 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)
|
||||
exportXlsx() {
|
||||
if (!this.showData.length) {
|
||||
this.$message.warning('暂无数据可导出');
|
||||
return;
|
||||
}
|
||||
return exportTableOut
|
||||
},
|
||||
exportPdf() {
|
||||
this.test()
|
||||
setTimeout(() =>{
|
||||
this.dialogVisible = false
|
||||
this.showData = this.tableData
|
||||
}, 600)
|
||||
|
||||
},
|
||||
exportXlsx() {
|
||||
this.exportECL()
|
||||
this.dialogVisible = false
|
||||
this.showData = this.tableData
|
||||
},
|
||||
handleClose(done) {
|
||||
this.$confirm('确认关闭?')
|
||||
.then(_ => {
|
||||
done();
|
||||
})
|
||||
.catch(_ => {});
|
||||
},
|
||||
this.exportLoading = true;
|
||||
|
||||
try {
|
||||
// 1. 处理导出数据(格式化时间字段)
|
||||
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() {
|
||||
getPdList().then((res) => {
|
||||
this.formConfig[0].selectOptions = res.data || []
|
||||
@@ -323,7 +317,7 @@ export default {
|
||||
this.getDataList();
|
||||
break;
|
||||
case 'export':
|
||||
this.handleExport();
|
||||
this.exportXlsx();
|
||||
break;
|
||||
default:
|
||||
console.log(val);
|
||||
@@ -351,12 +345,6 @@ export default {
|
||||
this.listQuery.pageNo = val;
|
||||
this.getDataList();
|
||||
},
|
||||
handleExport() {
|
||||
if (this.selectedList.length > 0) {
|
||||
this.showData = this.selectedList
|
||||
}
|
||||
this.dialogVisible = true
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -358,8 +358,6 @@ export default {
|
||||
handleExport() {
|
||||
// 处理查询参数
|
||||
let params = { ...this.listQuery };
|
||||
params.pageNo = undefined;
|
||||
params.pageSize = undefined;
|
||||
this.$modal.confirm('是否确认导出下片日志?').then(() => {
|
||||
this.exportLoading = true;
|
||||
return exportDownLogData(params);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -244,7 +244,10 @@ export default {
|
||||
label: '统计时间',
|
||||
dateType: 'week',
|
||||
placeholder: '选择日期',
|
||||
format: 'yyyy-MM-dd',
|
||||
format: 'yyyy 第 WW 周',
|
||||
pickerOptions: {
|
||||
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天(0=周日,1=周一,依此类推)
|
||||
},
|
||||
valueFormat: 'yyyy-MM-dd',
|
||||
param: 'timeValWeek',
|
||||
width: 250,
|
||||
@@ -453,11 +456,10 @@ export default {
|
||||
item.statisticType = this.listQuery.statisticType;
|
||||
|
||||
// 匹配产线名称
|
||||
const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
|
||||
item.bindObjectName = targetLine ? targetLine.name : '';
|
||||
|
||||
// const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
|
||||
// item.bindObjectName = targetLine ? targetLine.name : ''
|
||||
return item;
|
||||
});
|
||||
})
|
||||
this.listQuery.total = response.data?.total || 0;
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
@@ -462,7 +462,7 @@ export default {
|
||||
this.originData = null;
|
||||
this.hasData = true;
|
||||
if (this.$refs.searchBarForm) {
|
||||
this.$refs.searchBarForm.form.timeVal = [];
|
||||
// this.$refs.searchBarForm.form.timeVal = [];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -216,6 +216,7 @@ import {
|
||||
import { getTree } from '@/api/base/equipment';
|
||||
import { getEquipmentTypePage } from '@/api/base/equipmentType';
|
||||
import { getEquipmentOverall } from '@/api/base/equipment';
|
||||
import { getTenantId } from '@/utils/auth'
|
||||
|
||||
// import * as XLSX from 'xlsx';
|
||||
// import FileSaver from 'file-saver';
|
||||
@@ -569,7 +570,7 @@ export default {
|
||||
const token = getAccessToken();
|
||||
const headers = new Headers({
|
||||
Authorization: `Bearer ${token}`,
|
||||
'tenant-id': store.getters.userId,
|
||||
'tenant-id': getTenantId(),
|
||||
'Content-Type': 'text/event-stream',
|
||||
});
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import JDatePickerScript from './JDatePicker.js'
|
||||
// import JDatePickerScript from './JDatePicker.js'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
||||
321
src/views/monitoring/eqParamAlarmLog/index.vue
Normal file
321
src/views/monitoring/eqParamAlarmLog/index.vue
Normal file
@@ -0,0 +1,321 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick"
|
||||
@select-changed="handleSearchBarItemChange" />
|
||||
|
||||
<!-- 列表 -->
|
||||
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list"
|
||||
@emitFun="handleEmitFun">
|
||||
<!-- <method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="120"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleTableBtnClick" /> -->
|
||||
</base-table>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<!-- <base-dialog
|
||||
:dialogTitle="title"
|
||||
:dialogVisible="open"
|
||||
width="500px"
|
||||
@close="cancel"
|
||||
@cancel="cancel"
|
||||
@confirm="submitForm">
|
||||
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
|
||||
</base-dialog> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getEquipmentAlarmLogPage,
|
||||
getEqList,
|
||||
getLineList
|
||||
} from '@/api/monitoring/eqParamAlarmLog';
|
||||
import Editor from '@/components/Editor';
|
||||
import moment from 'moment';
|
||||
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||
// import { getFactoryPage } from '@/api/core/base/factory';
|
||||
|
||||
export default {
|
||||
name: 'EquipmentAlarmLog',
|
||||
components: {
|
||||
Editor,
|
||||
},
|
||||
mixins: [basicPageMixin],
|
||||
data() {
|
||||
return {
|
||||
searchBarKeys: ['checkTime'],
|
||||
// optionArrUrl: [getFactoryPage,getEqList],
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi('base:equipment-alarm-log:update')
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '修改',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:equipment-alarm-log:delete')
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
tableProps: [
|
||||
{
|
||||
prop: 'factoryName',
|
||||
label: '工厂',
|
||||
},
|
||||
{ prop: 'lineName', label: '产线' },
|
||||
{ prop: 'equipmentName', label: '设备名称' },
|
||||
{ prop: 'paramName', label: '参数名称' },
|
||||
{ prop: 'paramLimit', label: '参数范围' },
|
||||
{
|
||||
prop: 'alarmType', label: '报警类型',
|
||||
filter: (val) => (val === 1 ? '高于上限' : val === 2 ?'低于下限' : '否'),
|
||||
},
|
||||
// {
|
||||
// // width: 90,
|
||||
// prop: 'alarmGrade',
|
||||
// label: '报警级别',
|
||||
// filter: publicFormatter(this.DICT_TYPE.EQU_ALARM_LEVEL),
|
||||
// },
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '报警时间',
|
||||
width: 180,
|
||||
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||
},
|
||||
{ prop: 'alarmContent', label: '报警内容' },
|
||||
// {
|
||||
// _action: 'equipment-group-show-alert',
|
||||
// label: '报警',
|
||||
// ,
|
||||
// subcomponent: {
|
||||
// props: ['injectData'],
|
||||
// render: function (h) {
|
||||
// const _this = this;
|
||||
// return h(
|
||||
// 'el-button',
|
||||
// {
|
||||
// props: { type: 'text', size: 'mini' },
|
||||
// on: {
|
||||
// click: function () {
|
||||
// console.log('inejctdata', _this.injectData);
|
||||
// _this.$emit('emitData', {
|
||||
// action: _this.injectData._action,
|
||||
// // value: _this.injectData.id,
|
||||
// value: _this.injectData,
|
||||
// });
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// '查看报警'
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
],
|
||||
searchBarFormConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '产线',
|
||||
selectOptions: [],
|
||||
param: 'lineId',
|
||||
onchange: true,
|
||||
filterable: true,
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '设备名称',
|
||||
selectOptions: [],
|
||||
param: 'equipmentId',
|
||||
filterable: true,
|
||||
// onchange: true,
|
||||
},
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间段',
|
||||
dateType: 'daterange', // datetimerange
|
||||
// format: 'yyyy-MM-dd HH:mm:ss',
|
||||
format: 'yyyy-MM-dd',
|
||||
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始日期',
|
||||
endPlaceholder: '结束日期',
|
||||
defaultTime: ['00:00:00', '23:59:59'],
|
||||
param: 'createTime',
|
||||
// width: 350,
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
factoryId: undefined,
|
||||
createTime: [],
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getArr();
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
async getArr() {
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 500,
|
||||
};
|
||||
getLineList().then((response) => {
|
||||
this.searchBarFormConfig[0].selectOptions = response.data
|
||||
});
|
||||
// const list = await getEqList();
|
||||
// this.searchBarFormConfig[1].selectOptions = list.data.map((eq) => ({
|
||||
// name: eq.name,
|
||||
// id: eq.id,
|
||||
// }))
|
||||
// this.optionArrUrl.forEach((item, index) => {
|
||||
// item(params).then((response) => {
|
||||
// this.searchBarFormConfig[index].selectOptions = response.data;
|
||||
// });
|
||||
// });
|
||||
},
|
||||
/** 重写 basicPageMixin 里的 handleSearchBarBtnClick */
|
||||
handleSearchBarBtnClick(btn) {
|
||||
// 仅查询一种情况
|
||||
this.queryParams.lineId = btn.lineId;
|
||||
this.queryParams.equipmentId = btn.equipmentId;
|
||||
|
||||
this.queryParams.createTime = btn.createTime;
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// 执行查询
|
||||
getEquipmentAlarmLogPage(this.queryParams).then((response) => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 取消按钮 */
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
alarmId: undefined,
|
||||
alarmContent: undefined,
|
||||
alarmValue: undefined,
|
||||
alarmEquipmentId: undefined,
|
||||
remark: undefined,
|
||||
};
|
||||
this.resetForm('form');
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
// /** 重置按钮操作 */
|
||||
// resetQuery() {
|
||||
// this.resetForm('queryForm');
|
||||
// this.handleQuery();
|
||||
// },
|
||||
// /** 新增按钮操作 */
|
||||
// handleAdd() {
|
||||
// this.reset();
|
||||
// this.open = true;
|
||||
// this.title = '添加设备报警日志';
|
||||
// },
|
||||
async handleSearchBarItemChange({ param, value: id }) {
|
||||
if (param == 'lineId') {
|
||||
if (id == '') {
|
||||
// 清除设备选框里的选项
|
||||
this.searchBarFormConfig[1].selectOptions = [];
|
||||
return;
|
||||
}
|
||||
const list = await getEqList({
|
||||
id
|
||||
});
|
||||
this.searchBarFormConfig[1].selectOptions = list.data.map((eq) => ({
|
||||
name: eq.name,
|
||||
id: eq.id,
|
||||
}));
|
||||
}
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
// handleUpdate(row) {
|
||||
// this.reset();
|
||||
// const id = row.id;
|
||||
// getEquipmentAlarmLog(id).then((response) => {
|
||||
// this.form = response.data;
|
||||
// this.open = true;
|
||||
// this.title = '修改设备报警日志';
|
||||
// });
|
||||
// },
|
||||
// /** 提交按钮 */
|
||||
// submitForm() {
|
||||
// this.$refs['form'].validate((valid) => {
|
||||
// if (!valid) {
|
||||
// return;
|
||||
// }
|
||||
// // 修改的提交
|
||||
// if (this.form.id != null) {
|
||||
// updateEquipmentAlarmLog(this.form).then((response) => {
|
||||
// this.$modal.msgSuccess('修改成功');
|
||||
// this.open = false;
|
||||
// this.getList();
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// // 添加的提交
|
||||
// createEquipmentAlarmLog(this.form).then((response) => {
|
||||
// this.$modal.msgSuccess('新增成功');
|
||||
// this.open = false;
|
||||
// this.getList();
|
||||
// });
|
||||
// });
|
||||
// },
|
||||
/** 删除按钮操作 */
|
||||
// handleDelete(row) {
|
||||
// const id = row.id;
|
||||
// this.$modal
|
||||
// .confirm('是否确认删除设备报警日志编号为"' + id + '"的数据项?')
|
||||
// .then(function () {
|
||||
// return deleteEquipmentAlarmLog(id);
|
||||
// })
|
||||
// .then(() => {
|
||||
// this.getList();
|
||||
// this.$modal.msgSuccess('删除成功');
|
||||
// })
|
||||
// .catch(() => {});
|
||||
// },
|
||||
/** 导出按钮操作 */
|
||||
},
|
||||
};
|
||||
</script>
|
||||
301
src/views/monitoring/equipmentStatusAndParams copy/index.vue
Normal file
301
src/views/monitoring/equipmentStatusAndParams copy/index.vue
Normal file
@@ -0,0 +1,301 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<SearchBar
|
||||
:formConfigs="searchBarFormConfig"
|
||||
ref="search-bar"
|
||||
@headBtnClick="handleSearchBarBtnClick"
|
||||
@select-changed="handleSearchBarItemChange" />
|
||||
|
||||
<!-- 列表 -->
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="queryParams.pageNo"
|
||||
:limit="queryParams.pageSize"
|
||||
:table-data="list"
|
||||
@emitFun="handleEmitFun">
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
label="操作"
|
||||
:width="120"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleTableBtnClick" />
|
||||
</base-table>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<!-- <base-dialog
|
||||
:dialogTitle="title"
|
||||
:dialogVisible="open"
|
||||
width="500px"
|
||||
@close="cancel"
|
||||
@cancel="cancel"
|
||||
@confirm="submitForm">
|
||||
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
|
||||
</base-dialog> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||
import { publicFormatter } from '@/utils/dict';
|
||||
import { getPdList } from '@/api/core/monitoring/auto';
|
||||
import { getProductionLinePage } from '@/api/core/base/productionLine';
|
||||
import { getFactoryPage } from '@/api/core/base/factory';
|
||||
|
||||
export default {
|
||||
name: 'EquipmentStatusAndParams',
|
||||
|
||||
mixins: [basicPageMixin],
|
||||
data() {
|
||||
return {
|
||||
searchBarKeys: ['equipmentId', 'productionLineId'],
|
||||
optionArrUrl: [getFactoryPage, getProductionLinePage],
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi('base:equipment-alarm-log:update')
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '修改',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:equipment-alarm-log:delete')
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
tableProps: [
|
||||
{
|
||||
prop: 'factoryName',
|
||||
label: '工厂',
|
||||
},
|
||||
{
|
||||
prop: 'lineName',
|
||||
label: '产线名',
|
||||
},
|
||||
{
|
||||
prop: 'workshopName',
|
||||
label: '工段名',
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
width: 200,
|
||||
prop: 'equipmentName',
|
||||
label: '设备名称',
|
||||
},
|
||||
{
|
||||
width: 150,
|
||||
showOverflowtooltip: true,
|
||||
prop: 'equipmentCode',
|
||||
label: '设备编码',
|
||||
},
|
||||
{ width: 128, prop: 'inQuantity', label: '投入数[片]' },
|
||||
{ width: 128, prop: 'outQuantity', label: '产出数[片]' },
|
||||
{
|
||||
width: 128,
|
||||
prop: 'run',
|
||||
label: '是否运行',
|
||||
filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
|
||||
},
|
||||
{
|
||||
width: 128,
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
filter: (val) =>
|
||||
val != null ? ['正常', '计划停机', '故障'][val] : '-',
|
||||
},
|
||||
// {
|
||||
// width: 128,
|
||||
// prop: 'error',
|
||||
// label: '是否故障',
|
||||
// filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
|
||||
// },
|
||||
// {
|
||||
// prop: 'quantityRecordTime',
|
||||
// label: '生产量记录时间',
|
||||
// width: 180,
|
||||
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||
// },
|
||||
// {
|
||||
// prop: 'statusRecordTime',
|
||||
// label: '状态记录时间',
|
||||
// width: 180,
|
||||
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||
// },
|
||||
{
|
||||
_action: 'params-monitor',
|
||||
label: '操作',
|
||||
width: 56,
|
||||
subcomponent: {
|
||||
props: ['injectData'],
|
||||
render: function (h) {
|
||||
const _this = this;
|
||||
return h(
|
||||
'el-button',
|
||||
{
|
||||
class: 'iconfont icon-detail',
|
||||
props: { type: 'text' },
|
||||
on: {
|
||||
click: function () {
|
||||
_this.$emit('emitData', {
|
||||
action: _this.injectData._action,
|
||||
// value: _this.injectData.id,
|
||||
value: _this.injectData,
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
// '查看详情'
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
searchBarFormConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '工厂',
|
||||
selectOptions: [],
|
||||
param: 'factoryId',
|
||||
onchange: true,
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '产线',
|
||||
onchange: true,
|
||||
placeholder: '请选择产线',
|
||||
selectOptions: [],
|
||||
param: 'productionLineId',
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '设备',
|
||||
placeholder: '请选择设备',
|
||||
param: 'equipmentId',
|
||||
selectOptions: [],
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
factoryId: null,
|
||||
productionLineId: [],
|
||||
equipmentId: null,
|
||||
},
|
||||
total: 0,
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getArr();
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
getArr() {
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 500,
|
||||
};
|
||||
this.optionArrUrl.forEach((item, index) => {
|
||||
item(params).then((response) => {
|
||||
this.searchBarFormConfig[index].selectOptions = response.data.list;
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 根据产线获取设备 */
|
||||
async getEquipmentList(id) {
|
||||
const { data } = await this.$axios({
|
||||
url: '/base/equipment/listByLine',
|
||||
method: 'get',
|
||||
params: { id },
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
/** 监听 search bar 的产线下拉框改变 */
|
||||
async handleSearchBarItemChange({ param, value: id }) {
|
||||
if (param == 'productionLineId') {
|
||||
if (id == '') {
|
||||
// 清除设备选框里的选项
|
||||
this.searchBarFormConfig[2].selectOptions = [];
|
||||
return;
|
||||
}
|
||||
const list = await this.getEquipmentList(id);
|
||||
this.searchBarFormConfig[2].selectOptions = list.map((eq) => ({
|
||||
name: eq.name,
|
||||
id: eq.id,
|
||||
}));
|
||||
} else if (param == 'factoryId') {
|
||||
// 清除设备选框里的选项
|
||||
this.searchBarFormConfig[2].selectOptions = [];
|
||||
this.queryParams.equipmentId = undefined;
|
||||
this.queryParams.productionLineId = [];
|
||||
this.$refs['search-bar'].formInline.equipmentId = undefined;
|
||||
this.$refs['search-bar'].formInline.productionLineId = undefined;
|
||||
getPdList(id).then((res) => {
|
||||
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handleSearchBarBtnClick(btn) {
|
||||
const { equipmentId, productionLineId,factoryId } = btn;
|
||||
if (equipmentId) this.queryParams.equipmentId = equipmentId;
|
||||
else this.queryParams.equipmentId = null;
|
||||
if (productionLineId)
|
||||
this.queryParams.productionLineId = [productionLineId];
|
||||
else this.queryParams.productionLineId = [];
|
||||
this.queryParams.factoryId = factoryId || null;
|
||||
this.getList();
|
||||
},
|
||||
|
||||
/** 查询列表 */
|
||||
async getList() {
|
||||
this.loading = true;
|
||||
const { data } = await this.$axios({
|
||||
url: '/monitoring/equipment-monitor/realtime-page',
|
||||
method: 'POST',
|
||||
data: this.queryParams,
|
||||
});
|
||||
this.list = data.list;
|
||||
this.total = data.total;
|
||||
},
|
||||
|
||||
handleEmitFun({ action, value }) {
|
||||
if (action == 'params-monitor') {
|
||||
const { equipmentId, equipmentName, equipmentCode } = value;
|
||||
this.$router.push({
|
||||
name: 'equipmentFullParams',
|
||||
params: {
|
||||
equipmentId,
|
||||
equipmentCode,
|
||||
equipmentName,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
400
src/views/monitoring/equipmentStatusAndParams/chart.vue
Normal file
400
src/views/monitoring/equipmentStatusAndParams/chart.vue
Normal file
@@ -0,0 +1,400 @@
|
||||
<!--
|
||||
filename: dialogForm.vue
|
||||
author: liubin
|
||||
date: 2023-09-11 15:55:13
|
||||
description: DialogForm for qualityInspectionRecord only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<el-dialog :title="title" :append-to-body="true" :visible.sync="dialogVisible" width="60%" :before-close="handleClose">
|
||||
<div>
|
||||
<!-- 保留ref="search-bar",用于获取组件实例 -->
|
||||
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
|
||||
<!-- 统一使用ref关联DOM,避免id选择器混乱 -->
|
||||
<div ref="coreLineChart" style="width: 95%; height: 400px;"></div>
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 引入echarts(确保项目已安装:npm install echarts --save)
|
||||
import * as echarts from 'echarts'; // 统一引入方式,兼容新版ECharts
|
||||
|
||||
export default {
|
||||
name: 'DialogForm',
|
||||
model: {
|
||||
prop: 'dataForm',
|
||||
event: 'update',
|
||||
},
|
||||
emits: ['update'],
|
||||
components: {},
|
||||
props: {
|
||||
dataForm: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
eqId: {
|
||||
type: [String, Number],
|
||||
default: () => '',
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchBarFormConfig: [
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间段',
|
||||
dateType: 'daterange',
|
||||
format: 'yyyy-MM-dd',
|
||||
valueFormat: 'timestamp', // 毫秒级时间戳格式
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始日期',
|
||||
endPlaceholder: '结束日期',
|
||||
defaultTime: ['00:00:00', '23:59:59'],
|
||||
defaultSelect: [],
|
||||
param: 'createTime', // 日期选择器的参数名,用于赋值
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
title:'趋势图',
|
||||
dialogVisible: false,
|
||||
listQuery: {
|
||||
equId: undefined,
|
||||
paramId: undefined,
|
||||
plcName: undefined,
|
||||
plcParamName: undefined,
|
||||
startTime: undefined,
|
||||
endTime: undefined
|
||||
},
|
||||
list: [],
|
||||
myChart: null, // ECharts实例
|
||||
resizeHandler: null // 缓存resize事件处理函数,方便销毁
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// 初始化图表(确保DOM渲染完成)
|
||||
this.$nextTick(() => {
|
||||
this.initChart(); // 调用正确的初始化方法
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 1. 移除resize事件监听,防止内存泄漏
|
||||
if (this.resizeHandler && window.removeEventListener) {
|
||||
window.removeEventListener('resize', this.resizeHandler);
|
||||
}
|
||||
// 2. 销毁ECharts实例
|
||||
if (this.myChart) {
|
||||
this.myChart.dispose();
|
||||
this.myChart = null;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 核心方法:获取最近30天时间段(毫秒级时间戳)
|
||||
getLast30DaysTimeRange() {
|
||||
const today = new Date();
|
||||
|
||||
// 起始时间:30天前 00:00:00.000
|
||||
const startDate = new Date(today);
|
||||
startDate.setDate(today.getDate() - 30);
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
const startTimeStamp = startDate.getTime();
|
||||
|
||||
// 结束时间:昨天 23:59:59.000
|
||||
const endDate = new Date(today);
|
||||
endDate.setDate(today.getDate() - 1);
|
||||
endDate.setHours(23, 59, 59, 0);
|
||||
const endTimeStamp = endDate.getTime();
|
||||
|
||||
return {
|
||||
startTime: startTimeStamp,
|
||||
endTime: endTimeStamp,
|
||||
timeRangeArr: [startTimeStamp, endTimeStamp] // 关键:数组格式,直接适配daterange
|
||||
};
|
||||
},
|
||||
|
||||
// 弹窗关闭回调
|
||||
handleClose(done) {
|
||||
this.dialogVisible = false;
|
||||
done();
|
||||
},
|
||||
|
||||
// 搜索栏按钮点击事件
|
||||
handleSearchBarBtnClick(btn) {
|
||||
const { createTime } = btn;
|
||||
|
||||
// 解析日期选择器的时间戳数组
|
||||
if (createTime && Array.isArray(createTime) && createTime.length === 2) {
|
||||
this.listQuery.startTime = createTime[0];
|
||||
this.listQuery.endTime = createTime[1];
|
||||
}
|
||||
|
||||
this.getList();
|
||||
},
|
||||
|
||||
// 初始化弹窗
|
||||
init(data) {
|
||||
this.dialogVisible = true;
|
||||
console.log('d', data);
|
||||
this.listQuery = {
|
||||
equId: data.equipmentId,
|
||||
paramId: data.paramId,
|
||||
plcName: data.plcName,
|
||||
plcParamNam: data.plcParamNam,
|
||||
startTime: undefined,
|
||||
endTime: undefined
|
||||
};
|
||||
this.title = (data.equipmentName ? data.equipmentName : '') + (data.paramName ? data.paramName : '') + '趋势图'
|
||||
// 1. 获取30天时间段的时间戳数组
|
||||
const { startTime, endTime, timeRangeArr } = this.getLast30DaysTimeRange();
|
||||
this.listQuery.startTime = startTime
|
||||
this.listQuery.endTime = endTime
|
||||
|
||||
// 2. 给日期选择器赋值
|
||||
this.$nextTick(() => {
|
||||
this.searchBarFormConfig[0].defaultSelect = timeRangeArr;
|
||||
});
|
||||
|
||||
// 若图表未初始化,重新初始化(弹窗打开后DOM可能重新渲染)
|
||||
if (!this.myChart) {
|
||||
this.initChart();
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
async getList() {
|
||||
try {
|
||||
const { data } = await this.$axios({
|
||||
url: '/monitoring/equipment-monitor/paramMonitorDet',
|
||||
method: 'post',
|
||||
data: {
|
||||
startTime: this.listQuery.startTime,
|
||||
endTime: this.listQuery.endTime,
|
||||
...this.listQuery
|
||||
},
|
||||
});
|
||||
let xData = []
|
||||
let maxData = []
|
||||
let minData = []
|
||||
let pData = []
|
||||
|
||||
data.paramValue.forEach(ele => {
|
||||
xData.push(ele.time)
|
||||
maxData.push(ele.paramMax)
|
||||
minData.push(ele.paramMin)
|
||||
pData.push(ele.paramMean)
|
||||
});
|
||||
this.updateChart(xData, maxData, minData, pData)
|
||||
} catch (error) {
|
||||
console.error('获取数据失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 统一初始化图表(修复核心:创建ECharts实例 + 绑定resize事件)
|
||||
initChart() {
|
||||
// 1. 通过ref获取DOM容器(避免id选择器冲突)
|
||||
const chartDom = this.$refs.coreLineChart;
|
||||
if (!chartDom) {
|
||||
console.error('图表容器未找到!');
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 销毁已有实例,避免重复创建
|
||||
if (this.myChart) {
|
||||
this.myChart.dispose();
|
||||
}
|
||||
|
||||
// 3. 创建ECharts实例
|
||||
this.myChart = echarts.init(chartDom);
|
||||
|
||||
// 4. 初始化空配置,防止图表报错
|
||||
this.myChart.setOption({
|
||||
xAxis: { type: 'category', data: [] },
|
||||
yAxis: { type: 'value' },
|
||||
series: []
|
||||
});
|
||||
|
||||
// 5. 绑定resize事件(仅绑定一次,缓存处理函数)
|
||||
this.resizeHandler = () => {
|
||||
if (this.myChart) {
|
||||
this.myChart.resize(); // 图表自适应窗口大小
|
||||
}
|
||||
};
|
||||
window.addEventListener('resize', this.resizeHandler);
|
||||
},
|
||||
|
||||
// 更新折线图(全部实现渐变样式)
|
||||
updateChart(xData, maxData, minData, pData) {
|
||||
// 容错:若实例未初始化,先初始化
|
||||
if (!this.myChart) {
|
||||
this.initChart();
|
||||
if (!this.myChart) return;
|
||||
}
|
||||
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
label: {
|
||||
backgroundColor: '#6a7985'
|
||||
}
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
top: 30,
|
||||
bottom: 120,
|
||||
right: 20,
|
||||
left: 40
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: true,
|
||||
axisTick: { show: false },
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: { color: 'rgba(0, 0, 0, 0.15)' }
|
||||
},
|
||||
axisLabel: {
|
||||
color: 'rgba(0, 0, 0, 0.45)',
|
||||
fontSize: 12,
|
||||
interval: 0,
|
||||
padding: [5, 0, 0, 0],
|
||||
rotate: 60, // 正确配置:文字旋转45度
|
||||
},
|
||||
data: xData
|
||||
}
|
||||
],
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
nameTextStyle: {
|
||||
color: 'rgba(0, 0, 0, 0.45)',
|
||||
fontSize: 12,
|
||||
align: 'right'
|
||||
},
|
||||
scale: true,
|
||||
splitNumber: 4,
|
||||
axisTick: { show: false },
|
||||
axisLabel: {
|
||||
color: 'rgba(0, 0, 0, 0.45)',
|
||||
fontSize: 12,
|
||||
formatter: '{value}'
|
||||
},
|
||||
splitLine: { lineStyle: { color: 'rgba(0, 0, 0, 0.15)' } },
|
||||
axisLine: { show: true, lineStyle: { color: 'rgba(0, 0, 0, 0.15)' } }
|
||||
},
|
||||
series: [
|
||||
// 1. 平均值折线图(渐变样式)
|
||||
// 2. 最大值折线图(渐变样式)
|
||||
{
|
||||
name: '最大值',
|
||||
type: 'line',
|
||||
lineStyle: {
|
||||
color: 'rgba(75, 157, 255, 1)',
|
||||
width: 2
|
||||
},
|
||||
itemStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'rgba(130, 204, 255, 1)' },
|
||||
{ offset: 1, color: 'rgba(75, 157, 255, 1)' }
|
||||
]),
|
||||
borderColor: 'rgba(75, 157, 255, 1)',
|
||||
borderWidth: 2,
|
||||
radius: 4
|
||||
},
|
||||
areaStyle: {
|
||||
opacity: 0.3,
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'rgba(130, 204, 255, 0.8)' },
|
||||
{ offset: 1, color: 'rgba(75, 157, 255, 0.1)' }
|
||||
])
|
||||
},
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
data: maxData || []
|
||||
},
|
||||
{
|
||||
name: '平均值',
|
||||
type: 'line',
|
||||
lineStyle: {
|
||||
color: 'rgba(118, 218, 190, 1)',
|
||||
width: 2
|
||||
},
|
||||
itemStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'rgba(174, 239, 224, 1)' },
|
||||
{ offset: 1, color: 'rgba(118, 218, 190, 1)' }
|
||||
]),
|
||||
borderColor: 'rgba(118, 218, 190, 1)',
|
||||
borderWidth: 2,
|
||||
radius: 4
|
||||
},
|
||||
// areaStyle: {
|
||||
// opacity: 0.3,
|
||||
// color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
// { offset: 0, color: 'rgba(174, 239, 224, 0.8)' },
|
||||
// { offset: 1, color: 'rgba(118, 218, 190, 0.1)' }
|
||||
// ])
|
||||
// },
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
data: pData || []
|
||||
},
|
||||
// 3. 最小值折线图(渐变样式)
|
||||
{
|
||||
name: '最小值',
|
||||
type: 'line',
|
||||
lineStyle: {
|
||||
color: 'rgba(249, 164, 74, 1)',
|
||||
width: 2
|
||||
},
|
||||
itemStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'rgba(253, 209, 129, 1)' },
|
||||
{ offset: 1, color: 'rgba(249, 164, 74, 1)' }
|
||||
]),
|
||||
borderColor: 'rgba(249, 164, 74, 1)',
|
||||
borderWidth: 2,
|
||||
radius: 4
|
||||
},
|
||||
areaStyle: {
|
||||
opacity: 0.3,
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'rgba(253, 209, 129, 0.8)' },
|
||||
{ offset: 1, color: 'rgba(249, 164, 74, 0.1)' }
|
||||
])
|
||||
},
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
data: minData || []
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// 更新图表配置,清空原有数据
|
||||
this.myChart.setOption(option, true);
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.el-date-editor,
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
215
src/views/monitoring/equipmentStatusAndParams/dialogForm.vue
Normal file
215
src/views/monitoring/equipmentStatusAndParams/dialogForm.vue
Normal file
@@ -0,0 +1,215 @@
|
||||
<!--
|
||||
filename: dialogForm.vue
|
||||
author: liubin
|
||||
date: 2023-09-11 15:55:13
|
||||
description: DialogForm for qualityInspectionRecord only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list">
|
||||
<method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn"
|
||||
@clickBtn="handleTableBtnClick" />
|
||||
</base-table>
|
||||
<chart v-if="open" ref="visRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import chart from './chart.vue';
|
||||
|
||||
export default {
|
||||
name: 'DialogForm',
|
||||
model: {
|
||||
prop: 'dataForm',
|
||||
event: 'update',
|
||||
},
|
||||
emits: ['update'],
|
||||
components: { chart },
|
||||
props: {
|
||||
dataForm: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
eqId: {
|
||||
type: [String, Number],
|
||||
default: () => '',
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
open: false,
|
||||
tableBtn: [{
|
||||
type: 'chart',
|
||||
btnName: '趋势图',
|
||||
}
|
||||
// this.$auth.hasPermi('base:equipment-alarm-log:delete')
|
||||
// ? {
|
||||
// type: 'delete',
|
||||
// btnName: '删除',
|
||||
// }
|
||||
// : undefined,
|
||||
].filter((v) => v),
|
||||
tableProps: [
|
||||
{
|
||||
prop: 'paramName',
|
||||
label: '参数名',
|
||||
},
|
||||
// {
|
||||
// prop: 'lineName',
|
||||
// label: '产线名',
|
||||
// },
|
||||
// {
|
||||
// prop: 'workshopName',
|
||||
// label: '工段名',
|
||||
// showOverflowtooltip: true,
|
||||
// },
|
||||
{
|
||||
// width: 200,
|
||||
prop: 'paramValue',
|
||||
label: '参数值',
|
||||
},
|
||||
{
|
||||
// width: 200,
|
||||
prop: 'paramLimit',
|
||||
label: '参数范围',
|
||||
},
|
||||
],
|
||||
list: [],
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// Promise.all([this.getProductLineList(), this.getInspectionDetList()]).then(
|
||||
// () => {
|
||||
// this.formLoading = false;
|
||||
// }
|
||||
// );
|
||||
},
|
||||
watch: {
|
||||
// 'innerDataForm.productionLineId': {
|
||||
// handler: async function (plId) {
|
||||
// if (plId) await this.getWorksectionList(plId);
|
||||
// },
|
||||
// immediate: true,
|
||||
// },
|
||||
eqId: {
|
||||
handler: function (value) {
|
||||
console.log(value, '11111');
|
||||
|
||||
// this.innerDataForm = Object.assign({}, dataForm);
|
||||
|
||||
// if (dataForm.productionLineId)
|
||||
this.getList();
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.open = false;
|
||||
},
|
||||
cancel() {
|
||||
this.open = false;
|
||||
// this.reset();
|
||||
},
|
||||
handleTableBtnClick({ data, type }) {
|
||||
if (type === 'chart') {
|
||||
console.log(data,);
|
||||
this.open = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.visRef.init(data)
|
||||
})
|
||||
}
|
||||
},
|
||||
/** 模拟透传 ref */
|
||||
// validate(cb) {
|
||||
// return this.$refs.form.validate(cb);
|
||||
// },
|
||||
// resetFields(args) {
|
||||
// return this.$refs.form.resetFields(args);
|
||||
// },
|
||||
async getList() {
|
||||
this.loading = true;
|
||||
const { data } = await this.$axios({
|
||||
url: '/monitoring/equipment-monitor/paramMonitor',
|
||||
method: 'get',
|
||||
params: {
|
||||
id: this.eqId
|
||||
},
|
||||
});
|
||||
console.log('data', data);
|
||||
|
||||
this.list = data
|
||||
// this.total = data.total;
|
||||
},
|
||||
// handleInspectionDetChange(value) {
|
||||
// const { id, content } = this.cacheInspectionDetList.find(
|
||||
// (item) => item.id == value
|
||||
// );
|
||||
// this.innerDataForm.inspectionDetId = id;
|
||||
// this.innerDataForm.inspectionDetContent = content;
|
||||
// this.$emit('update', this.innerDataForm);
|
||||
// },
|
||||
|
||||
// async handleProductlineChange(id) {
|
||||
// // await this.getWorksectionList(id);
|
||||
// this.innerDataForm.sectionId = null;
|
||||
// this.$emit('update', this.innerDataForm);
|
||||
// },
|
||||
|
||||
// // getCode
|
||||
// async getCode(url) {
|
||||
// const response = await this.$axios(url);
|
||||
// return response.data;
|
||||
// },
|
||||
|
||||
// // 获取产线列表
|
||||
// async getProductLineList() {
|
||||
// const response = await this.$axios('/base/production-line/listAll');
|
||||
// this.productionLineList = response.data.map((item) => ({
|
||||
// label: item.name,
|
||||
// value: item.id,
|
||||
// }));
|
||||
// },
|
||||
|
||||
// // 获取检测内容列表
|
||||
// async getInspectionDetList() {
|
||||
// const response = await this.$axios(
|
||||
// '/base/quality-inspection-det/listAll'
|
||||
// );
|
||||
// this.cacheInspectionDetList = response.data;
|
||||
// this.inspectionDetList = response.data.map((item) => ({
|
||||
// label: item.content,
|
||||
// value: item.id,
|
||||
// }));
|
||||
// },
|
||||
|
||||
// // 获取工段列表
|
||||
// async getWorksectionList(plId) {
|
||||
// const response = await this.$axios(
|
||||
// '/base/workshop-section/listByParentId',
|
||||
// {
|
||||
// params: {
|
||||
// id: plId,
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
// this.sectionList = response.data.map((item) => ({
|
||||
// label: item.name,
|
||||
// value: item.id,
|
||||
// }));
|
||||
// },
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.el-date-editor,
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -1,38 +1,25 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<SearchBar
|
||||
:formConfigs="searchBarFormConfig"
|
||||
ref="search-bar"
|
||||
@headBtnClick="handleSearchBarBtnClick"
|
||||
@select-changed="handleSearchBarItemChange" />
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick"
|
||||
@select-changed="handleSearchBarItemChange" />
|
||||
|
||||
<!-- 列表 -->
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="queryParams.pageNo"
|
||||
:limit="queryParams.pageSize"
|
||||
:table-data="list"
|
||||
@emitFun="handleEmitFun">
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
label="操作"
|
||||
:width="120"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleTableBtnClick" />
|
||||
</base-table>
|
||||
<!-- 列表 -->
|
||||
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list"
|
||||
@emitFun="handleEmitFun">
|
||||
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn"
|
||||
@clickBtn="handleTableBtnClick" /> -->
|
||||
</base-table>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<!-- <base-dialog
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
<base-dialog :dialogTitle="title" :dialogVisible="open" width="50%" @close="cancel" @cancel="cancel"
|
||||
@confirm="submitForm">
|
||||
<DialogForm v-if="open" ref="form" v-model="form" :eqId="eqId" />
|
||||
</base-dialog>
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<!-- <base-dialog
|
||||
:dialogTitle="title"
|
||||
:dialogVisible="open"
|
||||
width="500px"
|
||||
@@ -41,7 +28,7 @@
|
||||
@confirm="submitForm">
|
||||
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
|
||||
</base-dialog> -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -51,91 +38,87 @@ import { publicFormatter } from '@/utils/dict';
|
||||
import { getPdList } from '@/api/core/monitoring/auto';
|
||||
import { getProductionLinePage } from '@/api/core/base/productionLine';
|
||||
import { getFactoryPage } from '@/api/core/base/factory';
|
||||
|
||||
import DialogForm from './dialogForm.vue';
|
||||
export default {
|
||||
name: 'EquipmentStatusAndParams',
|
||||
|
||||
name: 'EquipmentStatusAndParams',
|
||||
components: {
|
||||
DialogForm
|
||||
},
|
||||
mixins: [basicPageMixin],
|
||||
data() {
|
||||
return {
|
||||
searchBarKeys: ['equipmentId', 'productionLineId'],
|
||||
optionArrUrl: [getFactoryPage, getProductionLinePage],
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi('base:equipment-alarm-log:update')
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '修改',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:equipment-alarm-log:delete')
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
return {
|
||||
eqId:undefined,
|
||||
// searchBarKeys: ['equipmentId', 'productionLineId'],
|
||||
optionArrUrl: [ getProductionLinePage],
|
||||
// tableBtn: [
|
||||
// this.$auth.hasPermi('base:equipment-alarm-log:update')
|
||||
// ? {
|
||||
// type: 'edit',
|
||||
// btnName: '修改',
|
||||
// }
|
||||
// : undefined,
|
||||
// this.$auth.hasPermi('base:equipment-alarm-log:delete')
|
||||
// ? {
|
||||
// type: 'delete',
|
||||
// btnName: '删除',
|
||||
// }
|
||||
// : undefined,
|
||||
// ].filter((v) => v),
|
||||
tableProps: [
|
||||
{
|
||||
prop: 'factoryName',
|
||||
label: '工厂',
|
||||
},
|
||||
{
|
||||
prop: 'lineName',
|
||||
label: '产线名',
|
||||
},
|
||||
{
|
||||
prop: 'workshopName',
|
||||
label: '工段名',
|
||||
showOverflowtooltip: true,
|
||||
},
|
||||
{
|
||||
width: 200,
|
||||
// width: 200,
|
||||
prop: 'equipmentName',
|
||||
label: '设备名称',
|
||||
},
|
||||
{
|
||||
width: 150,
|
||||
// width: 150,
|
||||
showOverflowtooltip: true,
|
||||
prop: 'equipmentCode',
|
||||
label: '设备编码',
|
||||
},
|
||||
{ width: 128, prop: 'inQuantity', label: '投入数[片]' },
|
||||
{ width: 128, prop: 'outQuantity', label: '产出数[片]' },
|
||||
{
|
||||
// width: 128,
|
||||
prop: 'inQuantity', label: '投入数(片)'
|
||||
},
|
||||
{
|
||||
// width: 128,
|
||||
prop: 'outQuantity', label: '产出数(片)'
|
||||
},
|
||||
{
|
||||
width: 128,
|
||||
// width: 128,
|
||||
prop: 'run',
|
||||
label: '是否运行',
|
||||
filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
|
||||
},
|
||||
{
|
||||
width: 128,
|
||||
// width: 128,
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
filter: (val) =>
|
||||
val != null ? ['正常', '计划停机', '故障'][val] : '-',
|
||||
},
|
||||
// {
|
||||
// width: 128,
|
||||
// prop: 'error',
|
||||
// label: '是否故障',
|
||||
// filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
|
||||
// },
|
||||
// {
|
||||
// prop: 'quantityRecordTime',
|
||||
// label: '生产量记录时间',
|
||||
// width: 180,
|
||||
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||
// },
|
||||
// {
|
||||
// prop: 'statusRecordTime',
|
||||
// label: '状态记录时间',
|
||||
// width: 180,
|
||||
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||
// },
|
||||
{
|
||||
width: 128,
|
||||
prop: 'error',
|
||||
label: '是否故障',
|
||||
filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
|
||||
},
|
||||
{
|
||||
prop: 'quantityRecordTime',
|
||||
label: '生产量记录时间',
|
||||
width: 180,
|
||||
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||
},
|
||||
{
|
||||
prop: 'statusRecordTime',
|
||||
label: '状态记录时间',
|
||||
width: 180,
|
||||
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||
},
|
||||
{
|
||||
_action: 'params-monitor',
|
||||
label: '操作',
|
||||
width: 56,
|
||||
label: '参数监控',
|
||||
width: 100,
|
||||
subcomponent: {
|
||||
props: ['injectData'],
|
||||
render: function (h) {
|
||||
@@ -162,13 +145,13 @@ export default {
|
||||
},
|
||||
],
|
||||
searchBarFormConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '工厂',
|
||||
selectOptions: [],
|
||||
param: 'factoryId',
|
||||
onchange: true,
|
||||
},
|
||||
// {
|
||||
// type: 'select',
|
||||
// label: '工厂',
|
||||
// selectOptions: [],
|
||||
// param: 'factoryId',
|
||||
// onchange: true,
|
||||
// },
|
||||
{
|
||||
type: 'select',
|
||||
label: '产线',
|
||||
@@ -192,7 +175,8 @@ export default {
|
||||
},
|
||||
],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
open: false,
|
||||
title:'',
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
@@ -239,25 +223,26 @@ export default {
|
||||
if (param == 'productionLineId') {
|
||||
if (id == '') {
|
||||
// 清除设备选框里的选项
|
||||
this.searchBarFormConfig[2].selectOptions = [];
|
||||
this.searchBarFormConfig[1].selectOptions = [];
|
||||
return;
|
||||
}
|
||||
const list = await this.getEquipmentList(id);
|
||||
this.searchBarFormConfig[2].selectOptions = list.map((eq) => ({
|
||||
this.searchBarFormConfig[1].selectOptions = list.map((eq) => ({
|
||||
name: eq.name,
|
||||
id: eq.id,
|
||||
}));
|
||||
} else if (param == 'factoryId') {
|
||||
// 清除设备选框里的选项
|
||||
this.searchBarFormConfig[2].selectOptions = [];
|
||||
this.queryParams.equipmentId = undefined;
|
||||
this.queryParams.productionLineId = [];
|
||||
this.$refs['search-bar'].formInline.equipmentId = undefined;
|
||||
this.$refs['search-bar'].formInline.productionLineId = undefined;
|
||||
getPdList(id).then((res) => {
|
||||
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||
});
|
||||
}
|
||||
}
|
||||
// else if (param == 'factoryId') {
|
||||
// // 清除设备选框里的选项
|
||||
// this.searchBarFormConfig[2].selectOptions = [];
|
||||
// this.queryParams.equipmentId = undefined;
|
||||
// this.queryParams.productionLineId = [];
|
||||
// this.$refs['search-bar'].formInline.equipmentId = undefined;
|
||||
// this.$refs['search-bar'].formInline.productionLineId = undefined;
|
||||
// getPdList(id).then((res) => {
|
||||
// this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||
// });
|
||||
// }
|
||||
},
|
||||
|
||||
handleSearchBarBtnClick(btn) {
|
||||
@@ -281,19 +266,35 @@ export default {
|
||||
});
|
||||
this.list = data.list;
|
||||
this.total = data.total;
|
||||
},
|
||||
|
||||
},
|
||||
handleShow(value) {
|
||||
// this.reset();
|
||||
this.open = true;
|
||||
this.eqId =value.equipmentId
|
||||
this.title = value.factoryName + '/' + value.lineName + '/' + value.equipmentName;
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.open = false;
|
||||
},
|
||||
cancel() {
|
||||
this.open = false;
|
||||
// this.reset();
|
||||
},
|
||||
handleEmitFun({ action, value }) {
|
||||
if (action == 'params-monitor') {
|
||||
const { equipmentId, equipmentName, equipmentCode } = value;
|
||||
this.$router.push({
|
||||
name: 'equipmentFullParams',
|
||||
params: {
|
||||
equipmentId,
|
||||
equipmentCode,
|
||||
equipmentName,
|
||||
},
|
||||
});
|
||||
if (action == 'params-monitor') {
|
||||
console.log('value', value);
|
||||
|
||||
const { equipmentId, equipmentName, factoryName, lineName } = value;
|
||||
this.handleShow(value)
|
||||
// this.$router.push({
|
||||
// name: 'equipmentFullParams',
|
||||
// params: {
|
||||
// equipmentId,
|
||||
// equipmentCode,
|
||||
// equipmentName,
|
||||
// },
|
||||
// });
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -121,6 +121,7 @@ export default {
|
||||
type: 'select',
|
||||
label: '产线',
|
||||
selectOptions: [],
|
||||
multiple: true,
|
||||
param: 'lineId',
|
||||
},
|
||||
{
|
||||
@@ -134,13 +135,14 @@ export default {
|
||||
label: '时间范围',
|
||||
dateType: 'datetimerange',
|
||||
format: 'yyyy-MM-dd HH:mm:ss',
|
||||
// valueFormat: 'timestamp',
|
||||
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||
valueFormat: 'timestamp',
|
||||
// valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'timeVal',
|
||||
width: 350
|
||||
width: 350,
|
||||
defaultSelect: [],
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
@@ -214,11 +216,55 @@ export default {
|
||||
// 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.getDict()
|
||||
},
|
||||
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() {
|
||||
getPdList().then(res => {
|
||||
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||
|
||||
@@ -150,7 +150,8 @@ export default {
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'timeVal',
|
||||
width: 350
|
||||
width: 350,
|
||||
defaultSelect: [],
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
@@ -226,11 +227,56 @@ export default {
|
||||
// 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.getDict()
|
||||
},
|
||||
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() {
|
||||
getPdList().then(res => {
|
||||
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||
|
||||
@@ -152,7 +152,8 @@ export default {
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'timeVal',
|
||||
width: 350
|
||||
width: 350,
|
||||
defaultSelect: [],
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
@@ -225,11 +226,56 @@ export default {
|
||||
// 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.getDict()
|
||||
},
|
||||
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() {
|
||||
getPdList().then(res => {
|
||||
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||
|
||||
Reference in New Issue
Block a user