This commit is contained in:
‘937886381’
2025-12-12 14:17:21 +08:00
parent 1e12b653d6
commit e2385cf813
12 changed files with 660 additions and 428 deletions

View File

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

View File

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

View File

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

View File

@@ -63,7 +63,7 @@
style="width: 75%" style="width: 75%"
v-model="dataForm.price" v-model="dataForm.price"
clearable clearable
placeholder="请输入允许留存时间" /> placeholder="请输入单价" />
{{ unit }} {{ unit }}
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -141,12 +141,14 @@ export default {
} }
}, },
setCode() { setCode() {
console.log('this.MaterialList', this.urlOptions.dictArr.dict0);
this.MaterialList.forEach((item) => { this.MaterialList.forEach((item) => {
if (item.id === this.dataForm.materialId) { if (item.id === this.dataForm.materialId) {
this.dataForm.code = item.code; this.dataForm.code = item.code;
this.unit = this.unit =
'元/' + '元/' +
this.urlOptions.dictArr.dict0.find((d) => d.value === item.unit) this.urlOptions.dictArr.dict0.find((d) => d.value == item.unit)
.label; .label;
} }
}); });

View File

@@ -90,6 +90,7 @@ export default {
param: 'lineIds', param: 'lineIds',
defaultSelect: [], defaultSelect: [],
multiple: true, multiple: true,
collapseTags: true,
filterable: true, filterable: true,
width: 300, width: 300,
}, },

View File

@@ -80,6 +80,16 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label=" 基板类型" prop="typeDictValue">
<el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable
style="width: 100%" placeholder="请选择基板类型">
<el-option v-for="dict in typeList" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true"> <small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
@@ -144,7 +154,7 @@ import {
import productAttrAdd from './attr-add'; import productAttrAdd from './attr-add';
import { parseTime } from '../../mixins/code-filter'; import { parseTime } from '../../mixins/code-filter';
import SmallTitle from './SmallTitle'; import SmallTitle from './SmallTitle';
import { listData } from "@/api/system/dict/data"; //数据字典接口
const tableBtn = [ const tableBtn = [
{ {
type: 'edit', type: 'edit',
@@ -192,28 +202,30 @@ export default {
originalSpecifications: '', // 原片规格 originalSpecifications: '', // 原片规格
originalArea: 0, // 原片单位平方数 originalArea: 0, // 原片单位平方数
processTypes: [], processTypes: [],
typeDictValue: null,
}, },
typeList:[],
listQuery: { listQuery: {
pageSize: 10, pageSize: 10,
pageNo: 1, pageNo: 1,
total: 0, total: 0,
}, },
processTypeList: [ processTypeList: [
{ // {
value: '1', // value: '1',
label:'压花丝印' // label: '压花丝印'
}, // },
{ // {
value: '2', // value: '2',
label: '无印打孔' // label: '无印打孔'
}, // },
{ // {
value: '3', // value: '3',
label: '单层镀膜' // label: '单层镀膜'
}, { // }, {
value: '4', // value: '4',
label: '双层镀膜' // label: '双层镀膜'
} // }
], ],
dataRule: { dataRule: {
code: [ code: [
@@ -269,9 +281,31 @@ export default {
}; };
}, },
methods: { methods: {
initData() { async initData() {
this.productAttributeList.splice(0); this.productAttributeList.splice(0);
this.listQuery.total = 0; this.listQuery.total = 0;
const typeRes = await listData({
pageNo:
1,
pageSize
: 10,
dictType
: 'product_type'
})
this.typeList = typeRes.data.list
console.log('typeRes', this.typeList);
const processTypeRes = await listData({
pageNo:
1,
pageSize
: 10,
dictType
: 'process_type'
})
this.processTypeList = processTypeRes.data.list
console.log('typeRes', this.typeList);
}, },
init(id, isdetail) { init(id, isdetail) {
this.initData(); this.initData();
@@ -328,8 +362,7 @@ export default {
handleClick(raw) { handleClick(raw) {
if (raw.type === 'delete') { if (raw.type === 'delete') {
this.$confirm( this.$confirm(
`确定对${ `确定对${raw.data.name
raw.data.name
? '[名称=' + raw.data.name + ']' ? '[名称=' + raw.data.name + ']'
: '[序号=' + raw.data._pageIndex + ']' : '[序号=' + raw.data._pageIndex + ']'
}进行删除操作?`, }进行删除操作?`,
@@ -361,6 +394,7 @@ export default {
dataFormSubmit() { dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
// 修改的提交 // 修改的提交
if (this.dataForm.id) { if (this.dataForm.id) {
updateProduct(this.dataForm).then((response) => { updateProduct(this.dataForm).then((response) => {
@@ -429,6 +463,7 @@ export default {
padding: 32px 32px 24px; padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6; border-bottom: 1px solid #dcdfe6;
} }
.drawer>>>.el-drawer__body { .drawer>>>.el-drawer__body {
flex: 1; flex: 1;
height: 1px; height: 1px;
@@ -449,7 +484,8 @@ export default {
max-height: 76vh; max-height: 76vh;
overflow: hidden; overflow: hidden;
overflow-y: scroll; overflow-y: scroll;
padding-right: 10px; /* 调整滚动条样式 */ padding-right: 10px;
/* 调整滚动条样式 */
} }
.drawer>>>.el-form, .drawer>>>.el-form,

View File

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

View File

@@ -519,6 +519,12 @@ export default {
btnName: '重置', btnName: '重置',
name: 'reset', name: 'reset',
}, },
// {
// type: 'label', // 初始隐藏
// label: '刷新时间', // 自定义标识
// // slot: 'currentTimeSlot', // 自定义插槽名
// // width: 200, // 宽度适配
// },
] ]
}; };
}, },
@@ -541,7 +547,7 @@ export default {
{ {
prop: 'processType', prop: 'processType',
label: '产品类型', label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'), filter: (val) => (val === 1 ? '面板' : '背板'),
fixed: true, fixed: true,
sortable: true, sortable: true,
}, },
@@ -588,12 +594,12 @@ export default {
// end.getTime() // end.getTime()
// ]; // ];
this.$refs.searchBarForm.formInline.timeType = 1 this.$refs.searchBarForm.formInline.timeType = 3
} }
}); });
this.getDayDataList(); // this.getLastDayDataList();
this.getPdLineList(); this.getPdLineList();
const queryParams = { const queryParams = {
pageNo: 1, pageNo: 1,
@@ -642,6 +648,12 @@ export default {
this.formConfig[1].type = ''; // 隐藏查询类型 this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型 this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围 this.formConfig[7].type = ''; // 隐藏时间范围
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
}; };
// 3. 执行公共重置 // 3. 执行公共重置
@@ -656,14 +668,43 @@ export default {
this.formConfig[3].type = 'select'; // 显示产线 this.formConfig[3].type = 'select'; // 显示产线
this.formConfig[4].type = ''; // 隐藏产品工艺 this.formConfig[4].type = ''; // 隐藏产品工艺
this.formConfig[5].type = ''; // 隐藏产品类型 this.formConfig[5].type = ''; // 隐藏产品类型
this.getDayDataList(); this.listQuery.timeType = 3;
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.formInline.timeType = 3;
}
// 主动调用上一班数据接口
this.getLastDayDataList();
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else { } else {
this.formConfig.push(timeLabel);
}
} else {
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班 // 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班 this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
this.formConfig[3].type = ''; // 隐藏产线 this.formConfig[3].type = ''; // 隐藏产线
this.formConfig[4].type = 'select'; // 显示产品工艺 this.formConfig[4].type = 'select'; // 显示产品工艺
this.formConfig[5].type = 'select'; // 显示产品类型 this.formConfig[5].type = 'select'; // 显示产品类型
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
this.getProductList(); this.getProductList();
} }
@@ -995,6 +1036,26 @@ export default {
} }
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
// 仅当时间维度为【当天】时,添加/更新刷新时间
if (this.listQuery.timeType === 1 || this.listQuery.timeType === 3) {
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
} else if (timeItemIndex > -1) {
// 非当天时,移除刷新时间
this.formConfig.splice(timeItemIndex, 1);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
if (this.listQuery.timeType === 1) { if (this.listQuery.timeType === 1) {
this.getDayDataList(); this.getDayDataList();
@@ -1012,7 +1073,7 @@ export default {
break; break;
case 'reset': case 'reset':
this.$refs.searchBarForm.resetForm(); this.$refs.searchBarForm.resetForm();
this.$refs.searchBarForm.formInline.timeType = 1; this.$refs.searchBarForm.formInline.timeType = 3;
this.formConfig[0].selectOptions = this.activeName === 'productLine' this.formConfig[0].selectOptions = this.activeName === 'productLine'
? this.timeTypeOptions.productLine ? this.timeTypeOptions.productLine
: this.timeTypeOptions.product; : this.timeTypeOptions.product;
@@ -1020,10 +1081,23 @@ export default {
pageSize: 100, pageSize: 100,
pageNo: 1, pageNo: 1,
total: 0, total: 0,
timeType: 1, timeType: this.activeName === 'productLine' ? 3 : 1,
}; };
// 重置后默认是当天,添加刷新时间
const resetTimeIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const resetTimeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (resetTimeIndex > -1) {
this.formConfig.splice(resetTimeIndex, 1, resetTimeLabel);
} else {
this.formConfig.push(resetTimeLabel);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
this.getDayDataList(); this.getLastDayDataList();
} else { } else {
this.getProductList(); this.getProductList();
} }
@@ -1350,29 +1424,48 @@ export default {
this.listQuery.pageNo = val; this.listQuery.pageNo = val;
this.getDataList(); this.getDataList();
}, },
formatCurrentTime() {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${hours}:${minutes}:${seconds} ${year}.${month}.${day}`;
},
// 搜索栏下拉选择变化 // 搜索栏下拉选择变化
handleSearchBarChanged({ param, value }) { handleSearchBarChanged({ param, value }) {
if (param === 'timeType') { if (param === 'timeType') {
console.log(value); this.listQuery.timeType = value;
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
// 仅移除,不添加(查询时才添加)
if (value !== 1 && value !== 3 && timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
this.listQuery.timeType = value;
if (value === 2) {
// 切换为“自定义”:显示查询类型和时间范围
this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.timeType = value; this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value; this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
if (value === 1) {
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
} else if (value === 2) {
this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.searchType = 1;
this.formConfig[7].type = 'datePicker'; this.formConfig[7].type = 'datePicker';
} else { } else {
this.formConfig[1].type = ''; this.formConfig[1].type = '';
this.formConfig[6].type = ''; this.formConfig[6].type = '';
this.formConfig[7].type = ''; this.formConfig[7].type = '';
this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value;
this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
} }
} else if (param === 'searchType') { } else if (param === 'searchType') {
if (value === 1) { if (value === 1) {
// 统计数据:显示时间范围,隐藏报表类型 // 统计数据:显示时间范围,隐藏报表类型
@@ -1422,7 +1515,10 @@ export default {
label: '时间范围', label: '时间范围',
dateType: 'week', dateType: 'week',
placeholder: '选择日期', placeholder: '选择日期',
format: 'yyyy-MM-dd', format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek', param: 'timeValWeek',
width: 250, width: 250,

View File

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

View File

@@ -570,22 +570,35 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
// 1. 强制设置当前激活标签为 按产品监控
this.activeName = 'product';
if (this.$refs.buttonNav) { if (this.$refs.buttonNav) {
this.$refs.buttonNav.currentMenu = '按产品监控'; this.$refs.buttonNav.currentMenu = '按产品监控';
// 时间维度选项只显示 当天/自定义(无 上一班)
this.formConfig[0].selectOptions = this.timeTypeOptions.product; this.formConfig[0].selectOptions = this.timeTypeOptions.product;
} }
if (this.$refs.searchBarForm) { if (this.$refs.searchBarForm) {
// this.$refs.searchBarForm.formInline.timeVal = [ // 2. 强制设置搜索表单的 timeType 为 1当天
// yesterday.getTime(), this.$refs.searchBarForm.formInline.timeType = 1;
// end.getTime() // 同步查询参数的 timeType
// ]; this.listQuery.timeType = 1;
}
this.$refs.searchBarForm.formInline.timeType = 1 const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
} }
}); });
this.getDayDataList(); // 3. 初始化直接调用 按产品监控 的接口
this.getProductList();
this.getPdLineList(); this.getPdLineList();
const queryParams = { const queryParams = {
pageNo: 1, pageNo: 1,
@@ -597,11 +610,22 @@ export default {
}); });
}, },
methods: { methods: {
formatCurrentTime() {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${hours}:${minutes}:${seconds} ${year}.${month}.${day}`;
},
// 切换按产线/按产品监控 // 切换按产线/按产品监控
currentMenu(val) { currentMenu(val) {
// 1. 确定当前激活的类型(产线/产品) // 1. 确定当前激活的类型(产线/产品)
const isProductLine = val === '按产线监控'; const isProductLine = val === '按产线监控';
this.activeName = isProductLine ? 'productLine' : 'product'; this.activeName = isProductLine ? 'productLine' : 'product';
console.log('isProductLine', isProductLine);
// 2. 提取公共重置逻辑(无论切换到哪个标签,都需要执行的操作) // 2. 提取公共重置逻辑(无论切换到哪个标签,都需要执行的操作)
const resetCommon = () => { const resetCommon = () => {
@@ -634,11 +658,19 @@ export default {
this.formConfig[1].type = ''; // 隐藏查询类型 this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型 this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围 this.formConfig[7].type = ''; // 隐藏时间范围
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
}; };
// 3. 执行公共重置 // 3. 执行公共重置
resetCommon(); resetCommon();
// if (this.activeName === 'productLine') {
// } else {
// }
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分) // 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
if (isProductLine) { if (isProductLine) {
// 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班 // 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班
@@ -646,16 +678,44 @@ export default {
this.formConfig[3].type = 'select'; // 显示产线 this.formConfig[3].type = 'select'; // 显示产线
this.formConfig[4].type = ''; // 隐藏产品工艺 this.formConfig[4].type = ''; // 隐藏产品工艺
this.formConfig[5].type = ''; // 隐藏产品类型 this.formConfig[5].type = ''; // 隐藏产品类型
this.getDayDataList(); this.listQuery.timeType = 3;
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.formInline.timeType = 3;
}
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
// 主动调用上一班数据接口
this.getLastDayDataList();
} else { } else {
this.getProductList();
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班 // 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班 this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
this.formConfig[3].type = ''; // 隐藏产线 this.formConfig[3].type = ''; // 隐藏产线
this.formConfig[4].type = 'select'; // 显示产品工艺 this.formConfig[4].type = 'select'; // 显示产品工艺
this.formConfig[5].type = 'select'; // 显示产品类型 this.formConfig[5].type = 'select'; // 显示产品类型
this.getProductList();
} }
}, },
@@ -947,6 +1007,25 @@ export default {
} }
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
// 仅当时间维度为【当天】时,添加/更新刷新时间
if (this.listQuery.timeType === 1 || this.listQuery.timeType === 3) {
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
} else if (timeItemIndex > -1) {
// 非当天时,移除刷新时间
this.formConfig.splice(timeItemIndex, 1);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
if (this.listQuery.timeType === 1) { if (this.listQuery.timeType === 1) {
this.getDayDataList(); this.getDayDataList();
@@ -965,15 +1044,27 @@ export default {
case 'reset': case 'reset':
this.$refs.searchBarForm.resetForm(); this.$refs.searchBarForm.resetForm();
this.$refs.searchBarForm.formInline.timeType = 1; this.$refs.searchBarForm.formInline.timeType = 1;
this.formConfig[0].selectOptions = this.activeName === 'productLine' this.formConfig[0].selectOptions = this.activeName === 'product'
? this.timeTypeOptions.productLine ? this.timeTypeOptions.productLine
: this.timeTypeOptions.product; : this.timeTypeOptions.product;
this.listQuery = { this.listQuery = {
pageSize: 100, pageSize: 100,
pageNo: 1, pageNo: 1,
total: 0, total: 0,
timeType: 1, timeType: this.activeName === 'productLine' ? 3 : 1,
}; };
const resetTimeIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const resetTimeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (resetTimeIndex > -1) {
this.formConfig.splice(resetTimeIndex, 1, resetTimeLabel);
} else {
this.formConfig.push(resetTimeLabel);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
this.getDayDataList(); this.getDayDataList();
} else { } else {
@@ -1307,24 +1398,33 @@ export default {
handleSearchBarChanged({ param, value }) { handleSearchBarChanged({ param, value }) {
console.log(value, param); console.log(value, param);
if (param === 'timeType') { if (param === 'timeType') {
console.log(value); this.listQuery.timeType = value;
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
// 仅移除,不添加(查询时才添加)
if (value !== 1 && value !== 3 && timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
this.listQuery.timeType = value;
if (value === 2) {
// 切换为“自定义”:显示查询类型和时间范围
this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.timeType = value; this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value; this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
if (value === 1) {
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
} else if (value === 2) {
this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.searchType = 1;
this.formConfig[7].type = 'datePicker'; this.formConfig[7].type = 'datePicker';
} else { } else {
this.formConfig[1].type = ''; this.formConfig[1].type = '';
this.formConfig[6].type = ''; this.formConfig[6].type = '';
this.formConfig[7].type = ''; this.formConfig[7].type = '';
this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value;
this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
} }
} else if (param === 'searchType') { } else if (param === 'searchType') {
if (value === 1) { if (value === 1) {
@@ -1375,7 +1475,10 @@ export default {
label: '时间范围', label: '时间范围',
dateType: 'week', dateType: 'week',
placeholder: '选择日期', placeholder: '选择日期',
format: 'yyyy-MM-dd', format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek', param: 'timeValWeek',
width: 250, width: 250,

View File

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