修改
This commit is contained in:
@@ -89,6 +89,31 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
|
dataFormSubmit() {
|
||||||
|
this.$refs["dataForm"].validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
if (this.dataForm.id) {
|
||||||
|
this.urlOptions.updateURL(this.dataForm).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
this.urlOptions.createURL(this.dataForm).then(response => {
|
||||||
|
if (response.code === 1001033 || response.code === 1001034) {
|
||||||
|
return this.$modal.msgError(response.msg);
|
||||||
|
}
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -152,6 +152,29 @@ export default {
|
|||||||
.label;
|
.label;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
dataFormSubmit() {
|
||||||
|
this.$refs["dataForm"].validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
if (this.dataForm.id) {
|
||||||
|
this.urlOptions.updateURL(this.dataForm).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
this.urlOptions.createURL(this.dataForm).then(response => {
|
||||||
|
// console.log('response',);
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ export default {
|
|||||||
label: '工厂',
|
label: '工厂',
|
||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'factoryId',
|
param: 'factoryId',
|
||||||
|
collapseTags: true,
|
||||||
|
multiple: true,
|
||||||
onchange: true,
|
onchange: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -190,7 +190,160 @@ import barChart from './BarChart.vue';
|
|||||||
import ButtonNav from '@/components/ButtonNav';
|
import ButtonNav from '@/components/ButtonNav';
|
||||||
import { listData } from '@/api/system/dict/data';
|
import { listData } from '@/api/system/dict/data';
|
||||||
// 表格列配置
|
// 表格列配置
|
||||||
const tableProps = [
|
|
||||||
|
export default {
|
||||||
|
components: { barChart, ButtonNav, baseTableS },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
urlOptions: { getDataListURL: getLineAuto },
|
||||||
|
listQuery: {
|
||||||
|
lineId: [],
|
||||||
|
pageSize: 10,
|
||||||
|
pageNo: 1,
|
||||||
|
total: 1,
|
||||||
|
timeType: 1 // 1-当天,2-自定义
|
||||||
|
},
|
||||||
|
isPeriodicReport:false,
|
||||||
|
reportTypeMap: {
|
||||||
|
1: '日报',
|
||||||
|
2: '周报',
|
||||||
|
3: '月报',
|
||||||
|
4: '年报'
|
||||||
|
},
|
||||||
|
activeLabel: 'table', // 当班数据tab
|
||||||
|
activeLabelDay: 'table', // 当天数据tab
|
||||||
|
fileName: '',
|
||||||
|
headFormValue:{},
|
||||||
|
dataListLoading: false,
|
||||||
|
factoryColumns: [],
|
||||||
|
factoryColumnsDay: [],
|
||||||
|
activeName: 'product',
|
||||||
|
tableBtn: [],
|
||||||
|
showData: [],
|
||||||
|
tableData: [],
|
||||||
|
tableData2: [], // 示例数据,实际从接口获取
|
||||||
|
productTableData: [],
|
||||||
|
productTableDataDay: [],
|
||||||
|
tableDataCustom: [],
|
||||||
|
list: [], // 折线图数据
|
||||||
|
timeTypeOptions: {
|
||||||
|
productLine: [ // 按产线监控(包含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
],
|
||||||
|
product: [ // 按产品监控(不含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
formConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '时间维度',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
],
|
||||||
|
width: 100,
|
||||||
|
onchange: true,
|
||||||
|
// defaultSelect: 1,
|
||||||
|
clearable: false,
|
||||||
|
param: 'timeType'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '查询类型',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '统计数据' },
|
||||||
|
{ id: 2, name: '周期性汇总报表' }
|
||||||
|
],
|
||||||
|
width: 120,
|
||||||
|
onchange: true,
|
||||||
|
param: 'searchType'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '工厂',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'factoryId',
|
||||||
|
multiple: true,
|
||||||
|
onchange: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'lineId',
|
||||||
|
multiple: true,
|
||||||
|
onchange: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产品工艺',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'process',
|
||||||
|
multiple: true,
|
||||||
|
labelField: 'label',
|
||||||
|
valueField: 'label',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '产品类型',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '面板' },
|
||||||
|
{ id: 2, name: '背板' },
|
||||||
|
],
|
||||||
|
multiple: true,
|
||||||
|
param: 'processType',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '报表类型',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '日' },
|
||||||
|
{ id: 2, name: '周' },
|
||||||
|
{ id: 3, name: '月' },
|
||||||
|
{ id: 4, name: '年' }
|
||||||
|
],
|
||||||
|
onchange: true,
|
||||||
|
width: 80,
|
||||||
|
param: 'reportType'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350
|
||||||
|
},
|
||||||
|
{ type: 'button', btnName: '查询', name: 'search', color: 'primary' },
|
||||||
|
{ type: 'separate' },
|
||||||
|
{ type: 'button', btnName: '导出', name: 'export', color: 'warning' },
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '重置',
|
||||||
|
name: 'reset',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: 'label', // 初始隐藏
|
||||||
|
// label: '刷新时间', // 自定义标识
|
||||||
|
// // slot: 'currentTimeSlot', // 自定义插槽名
|
||||||
|
// // width: 200, // 宽度适配
|
||||||
|
// },
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
tableProps() {
|
||||||
|
const props = [
|
||||||
{
|
{
|
||||||
prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
label: '工厂',
|
label: '工厂',
|
||||||
@@ -213,6 +366,12 @@ const tableProps = [
|
|||||||
label: '产品工艺',
|
label: '产品工艺',
|
||||||
fixed: true
|
fixed: true
|
||||||
},
|
},
|
||||||
|
(this.isPeriodicReport ? {
|
||||||
|
prop: 'reportDate',
|
||||||
|
label: '日期',
|
||||||
|
fixed: true,
|
||||||
|
width: 120
|
||||||
|
} : ''),
|
||||||
{
|
{
|
||||||
prop: 'inputN',
|
prop: 'inputN',
|
||||||
label: '投入',
|
label: '投入',
|
||||||
@@ -359,158 +518,8 @@ const tableProps = [
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
return props
|
||||||
export default {
|
|
||||||
components: { barChart, ButtonNav, baseTableS },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
urlOptions: { getDataListURL: getLineAuto },
|
|
||||||
listQuery: {
|
|
||||||
lineId: [],
|
|
||||||
pageSize: 10,
|
|
||||||
pageNo: 1,
|
|
||||||
total: 1,
|
|
||||||
timeType: 1 // 1-当天,2-自定义
|
|
||||||
},
|
},
|
||||||
reportTypeMap: {
|
|
||||||
1: '日报',
|
|
||||||
2: '周报',
|
|
||||||
3: '月报',
|
|
||||||
4: '年报'
|
|
||||||
},
|
|
||||||
activeLabel: 'table', // 当班数据tab
|
|
||||||
activeLabelDay: 'table', // 当天数据tab
|
|
||||||
fileName: '',
|
|
||||||
headFormValue:{},
|
|
||||||
dataListLoading: false,
|
|
||||||
tableProps,
|
|
||||||
factoryColumns: [],
|
|
||||||
factoryColumnsDay: [],
|
|
||||||
activeName: 'product',
|
|
||||||
tableBtn: [],
|
|
||||||
showData: [],
|
|
||||||
tableData: [],
|
|
||||||
tableData2: [], // 示例数据,实际从接口获取
|
|
||||||
productTableData: [],
|
|
||||||
productTableDataDay: [],
|
|
||||||
tableDataCustom: [],
|
|
||||||
list: [], // 折线图数据
|
|
||||||
timeTypeOptions: {
|
|
||||||
productLine: [ // 按产线监控(包含上一班)
|
|
||||||
{ id: 1, name: '当天' },
|
|
||||||
{ id: 2, name: '自定义' },
|
|
||||||
{ id: 3, name: '上一班' }
|
|
||||||
],
|
|
||||||
product: [ // 按产品监控(不含上一班)
|
|
||||||
{ id: 1, name: '当天' },
|
|
||||||
{ id: 2, name: '自定义' },
|
|
||||||
{ id: 3, name: '上一班' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
formConfig: [
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '时间维度',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '当天' },
|
|
||||||
{ id: 2, name: '自定义' },
|
|
||||||
{ id: 3, name: '上一班' }
|
|
||||||
],
|
|
||||||
width: 100,
|
|
||||||
onchange: true,
|
|
||||||
// defaultSelect: 1,
|
|
||||||
clearable: false,
|
|
||||||
param: 'timeType'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '查询类型',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '统计数据' },
|
|
||||||
{ id: 2, name: '周期性汇总报表' }
|
|
||||||
],
|
|
||||||
width: 120,
|
|
||||||
onchange: true,
|
|
||||||
param: 'searchType'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '工厂',
|
|
||||||
selectOptions: [],
|
|
||||||
param: 'factoryId',
|
|
||||||
multiple: true,
|
|
||||||
onchange: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '产线',
|
|
||||||
selectOptions: [],
|
|
||||||
param: 'lineId',
|
|
||||||
multiple: true,
|
|
||||||
onchange: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '产品工艺',
|
|
||||||
selectOptions: [],
|
|
||||||
param: 'process',
|
|
||||||
multiple: true,
|
|
||||||
labelField: 'label',
|
|
||||||
valueField: 'label',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '产品类型',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '面板' },
|
|
||||||
{ id: 2, name: '背板' },
|
|
||||||
],
|
|
||||||
multiple: true,
|
|
||||||
param: 'processType',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '报表类型',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '日' },
|
|
||||||
{ id: 2, name: '周' },
|
|
||||||
{ id: 3, name: '月' },
|
|
||||||
{ id: 4, name: '年' }
|
|
||||||
],
|
|
||||||
onchange: true,
|
|
||||||
width: 80,
|
|
||||||
param: 'reportType'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '时间范围',
|
|
||||||
dateType: 'datetimerange',
|
|
||||||
format: 'yyyy-MM-dd HH:mm:ss',
|
|
||||||
valueFormat: 'timestamp',
|
|
||||||
rangeSeparator: '-',
|
|
||||||
startPlaceholder: '开始时间',
|
|
||||||
endPlaceholder: '结束时间',
|
|
||||||
param: 'timeVal',
|
|
||||||
width: 350
|
|
||||||
},
|
|
||||||
{ type: 'button', btnName: '查询', name: 'search', color: 'primary' },
|
|
||||||
{ type: 'separate' },
|
|
||||||
{ type: 'button', btnName: '导出', name: 'export', color: 'warning' },
|
|
||||||
{
|
|
||||||
type: 'button',
|
|
||||||
btnName: '重置',
|
|
||||||
name: 'reset',
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// type: 'label', // 初始隐藏
|
|
||||||
// label: '刷新时间', // 自定义标识
|
|
||||||
// // slot: 'currentTimeSlot', // 自定义插槽名
|
|
||||||
// // width: 200, // 宽度适配
|
|
||||||
// },
|
|
||||||
]
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
productTableProps() {
|
productTableProps() {
|
||||||
// 当班数据的完整表头(基础列 + 当班动态表头)
|
// 当班数据的完整表头(基础列 + 当班动态表头)
|
||||||
const baseColumns = [
|
const baseColumns = [
|
||||||
@@ -530,14 +539,20 @@ export default {
|
|||||||
prop: 'processType',
|
prop: 'processType',
|
||||||
label: '产品类型',
|
label: '产品类型',
|
||||||
filter: (val) => (val === 1 ? '面板' : '背板'),
|
filter: (val) => (val === 1 ? '面板' : '背板'),
|
||||||
fixed: true,
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
fixed: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
label: '工厂',
|
label: '工厂',
|
||||||
fixed: true
|
fixed: true
|
||||||
}
|
},
|
||||||
|
(this.isPeriodicReport ? {
|
||||||
|
prop: 'reportDate',
|
||||||
|
label: '日期',
|
||||||
|
fixed: true,
|
||||||
|
width: 120
|
||||||
|
} : ''),
|
||||||
];
|
];
|
||||||
return [...baseColumns, ...this.factoryColumns];
|
return [...baseColumns, ...this.factoryColumns];
|
||||||
},
|
},
|
||||||
@@ -559,7 +574,7 @@ export default {
|
|||||||
{
|
{
|
||||||
prop: 'processType',
|
prop: 'processType',
|
||||||
label: '产品类型',
|
label: '产品类型',
|
||||||
filter: (val) => (val === 1 ? '面板' : '背板'),
|
filter: (val) => (val != 1 ? '面板' : '背板'),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
fixed: true
|
fixed: true
|
||||||
},
|
},
|
||||||
@@ -567,7 +582,13 @@ export default {
|
|||||||
prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
label: '工厂',
|
label: '工厂',
|
||||||
fixed: true
|
fixed: true
|
||||||
}
|
},
|
||||||
|
(this.isPeriodicReport ? {
|
||||||
|
prop: 'reportDate',
|
||||||
|
label: '日期',
|
||||||
|
fixed: true,
|
||||||
|
width: 120
|
||||||
|
} : ''),
|
||||||
];
|
];
|
||||||
return [...baseColumns, ...this.factoryColumnsDay];
|
return [...baseColumns, ...this.factoryColumnsDay];
|
||||||
}
|
}
|
||||||
@@ -704,46 +725,59 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出表格
|
// 导出表格(改为async方法,支持await调用)
|
||||||
handleExport() {
|
async handleExport() {
|
||||||
// 按产线监控
|
// 按产线监控
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
this.exportMultipleTables([
|
await this.exportMultipleTables([
|
||||||
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
||||||
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
||||||
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
} else if (this.listQuery.timeType === 1) {
|
} else if (this.listQuery.timeType === 3) {
|
||||||
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
// 修复:注释错误,原为“产线-当天”,实际是“产线-上一班”
|
||||||
this.exportMultipleTables([
|
// 产线-上一班:导出单个表格
|
||||||
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
|
await this.exportSingleTable('lineCustomTable', '产线监控_上一班时间数据');
|
||||||
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
|
||||||
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
|
||||||
} else {
|
} else {
|
||||||
// 产线-自定义:导出一个表格(自定义文件名)
|
// 产线-自定义:导出一个表格(自定义文件名)
|
||||||
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
await this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 按产品监控
|
// 按产品监控
|
||||||
else {
|
else {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
this.exportMultipleTables([
|
await this.exportMultipleTables([
|
||||||
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
|
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
|
||||||
{ ref: 'productTodayTable', name: '产品监控_当天数据' }
|
{ ref: 'productCurrentShiftTable', name: '产品监控_当天数据' }
|
||||||
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
|
} else if (this.listQuery.timeType === 3) {
|
||||||
|
// 修复:注释错误,原为“产线-当天”,实际是“产品-上一班”
|
||||||
|
// 产品-上一班:导出单个表格
|
||||||
|
await this.exportSingleTable('productCustomTable', '产品监控_上一班时间数据');
|
||||||
} else {
|
} else {
|
||||||
// 产品-自定义:导出一个表格(自定义文件名)
|
// 产品-自定义:导出一个表格(自定义文件名)
|
||||||
this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
|
await this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出单个表格(保持原有逻辑,文件名由调用方传入,已区分不同场景)
|
// 导出单个表格(改为async方法,使用await获取DOM)
|
||||||
exportSingleTable(refName, fileName) {
|
async exportSingleTable(refName, fileName) {
|
||||||
const table = this.getTableDom(refName);
|
try {
|
||||||
if (!table) return;
|
// 关键修复:使用await等待getTableDom返回DOM元素(而非Promise)
|
||||||
|
const table = await this.getTableDom(refName);
|
||||||
|
if (!table) {
|
||||||
|
this.$message.warning(`无法导出:${refName}表格DOM获取失败`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认table是原生DOM元素后再调用cloneNode
|
||||||
|
if (!(table instanceof HTMLElement)) {
|
||||||
|
this.$message.error(`无法导出:${refName}表格不是合法的DOM元素`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const clonedTable = table.cloneNode(true);
|
const clonedTable = table.cloneNode(true);
|
||||||
this.adjustTableForExport(clonedTable);
|
this.adjustTableForExport(clonedTable);
|
||||||
@@ -751,16 +785,31 @@ export default {
|
|||||||
const workbook = XLSX.utils.table_to_book(clonedTable);
|
const workbook = XLSX.utils.table_to_book(clonedTable);
|
||||||
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
|
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
|
||||||
XLSX.writeFile(workbook, fullName);
|
XLSX.writeFile(workbook, fullName);
|
||||||
|
} catch (error) {
|
||||||
|
this.$message.error(`导出表格失败:${error.message}`);
|
||||||
|
console.error('单个表格导出错误:', error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出多个表格(新增自定义汇总文件名参数,适配不同选项卡)
|
// 导出多个表格(改为async方法,使用await获取DOM)
|
||||||
exportMultipleTables(tables, customSummaryName) {
|
async exportMultipleTables(tables, customSummaryName) {
|
||||||
|
try {
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
let hasValidTable = false;
|
let hasValidTable = false;
|
||||||
|
|
||||||
tables.forEach(({ ref, name }) => {
|
// 遍历表格配置,使用await获取每个表格的DOM
|
||||||
const table = this.getTableDom(ref);
|
for (const { ref, name } of tables) { // 改用for...of循环,支持await
|
||||||
if (!table) return;
|
const table = await this.getTableDom(ref);
|
||||||
|
if (!table) {
|
||||||
|
this.$message.warning(`${ref}表格DOM获取失败,跳过该表格`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认table是原生DOM元素
|
||||||
|
if (!(table instanceof HTMLElement)) {
|
||||||
|
this.$message.warning(`${ref}表格不是合法的DOM元素,跳过该表格`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
hasValidTable = true;
|
hasValidTable = true;
|
||||||
const clonedTable = table.cloneNode(true);
|
const clonedTable = table.cloneNode(true);
|
||||||
@@ -768,30 +817,65 @@ export default {
|
|||||||
|
|
||||||
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
|
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, name);
|
XLSX.utils.book_append_sheet(workbook, worksheet, name);
|
||||||
});
|
}
|
||||||
|
|
||||||
if (!hasValidTable) {
|
if (!hasValidTable) {
|
||||||
this.$message.warning('未找到有效表格数据');
|
this.$message.warning('未找到有效表格数据,导出失败');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动态生成汇总文件名:自定义名称 + 日期
|
// 动态生成汇总文件名:自定义名称 + 日期
|
||||||
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
|
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
|
||||||
XLSX.writeFile(workbook, fullName);
|
XLSX.writeFile(workbook, fullName);
|
||||||
|
} catch (error) {
|
||||||
|
this.$message.error(`导出多个表格失败:${error.message}`);
|
||||||
|
console.error('多个表格导出错误:', error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 辅助方法:获取表格DOM元素(包含表头)
|
|
||||||
getTableDom(refName) {
|
/**
|
||||||
|
* 获取表格DOM元素(支持异步重试)
|
||||||
|
* @param {string} refName - 表格的ref名称
|
||||||
|
* @param {number} retryCount - 当前重试次数(内部使用,外部调用无需传参)
|
||||||
|
* @returns {Promise<HTMLElement|null>} 表格DOM元素Promise
|
||||||
|
*/
|
||||||
|
async getTableDom(refName, retryCount = 0) {
|
||||||
|
// 1. 配置常量,便于维护
|
||||||
|
const maxRetry = 5; // 最大重试次数
|
||||||
|
const retryDelay = 300; // 每次重试延迟时间(ms)
|
||||||
|
|
||||||
|
// 2. 设置激活标签,确保重试时也能执行该逻辑
|
||||||
|
this.activeLabel = 'table';
|
||||||
|
this.activeLabelDay = 'table';
|
||||||
|
// 若需调试,可保留日志
|
||||||
|
// console.log(`[getTableDom-${refName}] activeLabel:`, this.activeLabel, 'activeLabelDay:', this.activeLabelDay);
|
||||||
|
|
||||||
|
// 3. 获取表格组件
|
||||||
const tableComponent = this.$refs[refName];
|
const tableComponent = this.$refs[refName];
|
||||||
|
|
||||||
|
// 4. 表格组件不存在时,处理重试逻辑
|
||||||
if (!tableComponent) {
|
if (!tableComponent) {
|
||||||
this.$message.warning(`未找到${refName}表格`);
|
// 达到最大重试次数,返回失败
|
||||||
|
if (retryCount >= maxRetry) {
|
||||||
|
this.$message.warning(`未找到${refName}表格,已达到最大重试次数(${maxRetry}次)`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 获取完整表格容器(包含表头和表体)
|
|
||||||
|
// 未达到最大重试次数,延迟后重试
|
||||||
|
this.$message.warning(`未找到${refName}表格,将进行第${retryCount + 1}次重试...`);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
||||||
|
// 递归调用并返回结果
|
||||||
|
return this.getTableDom(refName, retryCount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 获取完整表格容器(包含表头和表体)
|
||||||
const tableContainer = tableComponent.$el.querySelector('.el-table');
|
const tableContainer = tableComponent.$el.querySelector('.el-table');
|
||||||
if (!tableContainer) {
|
if (!tableContainer) {
|
||||||
this.$message.warning(`${refName}表格数据为空`);
|
this.$message.warning(`${refName}表格容器不存在(可能表格数据为空)`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 6. 成功获取表格DOM,返回结果
|
||||||
return tableContainer;
|
return tableContainer;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -856,7 +940,7 @@ export default {
|
|||||||
if (mainTable && allHeaderRows.length > 0) {
|
if (mainTable && allHeaderRows.length > 0) {
|
||||||
const newThead = document.createElement('thead');
|
const newThead = document.createElement('thead');
|
||||||
// 按层级添加表头行
|
// 按层级添加表头行
|
||||||
allHeaderRows.forEach(cells => {
|
allHeaderRows.forEach((cells, rowIndex) => {
|
||||||
const newTr = document.createElement('tr');
|
const newTr = document.createElement('tr');
|
||||||
cells.forEach(cell => {
|
cells.forEach(cell => {
|
||||||
// 复制单元格(避免DOM残留引用问题)
|
// 复制单元格(避免DOM残留引用问题)
|
||||||
@@ -867,6 +951,18 @@ export default {
|
|||||||
});
|
});
|
||||||
// 将新表头插入主表体最前面
|
// 将新表头插入主表体最前面
|
||||||
mainTable.insertBefore(newThead, mainTable.firstChild);
|
mainTable.insertBefore(newThead, mainTable.firstChild);
|
||||||
|
|
||||||
|
// ================ 新增:修改第一列表头为“序号” ================
|
||||||
|
// 找到第一层级的第一个表头单元格(<th>)
|
||||||
|
const firstHeaderCell = newThead.querySelector('tr:first-child th:first-child');
|
||||||
|
if (firstHeaderCell) {
|
||||||
|
// 清空原有内容,设置为“序号”
|
||||||
|
firstHeaderCell.innerHTML = ''; // 清空原有内容(包括子元素)
|
||||||
|
firstHeaderCell.textContent = '序号'; // 设置纯文本“序号”(更稳定)
|
||||||
|
// 可选:添加样式(如居中,根据需求调整)
|
||||||
|
// firstHeaderCell.style.textAlign = 'center';
|
||||||
|
}
|
||||||
|
// =============================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 合并固定列数据到主表体(仅处理tbody数据)
|
// 7. 合并固定列数据到主表体(仅处理tbody数据)
|
||||||
@@ -897,6 +993,23 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================ 可选优化:为tbody第一列添加序号数字 ================
|
||||||
|
// 如果表格体的第一列原本无数据,可补充1、2、3...的序号
|
||||||
|
if (mainTable) {
|
||||||
|
const tbodyRows = mainTable.querySelectorAll('tbody tr');
|
||||||
|
tbodyRows.forEach((row, index) => {
|
||||||
|
const firstTd = row.querySelector('td:first-child');
|
||||||
|
if (firstTd) {
|
||||||
|
// 清空原有内容,设置为序号(index+1,因为索引从0开始)
|
||||||
|
firstTd.innerHTML = '';
|
||||||
|
firstTd.textContent = index + 1;
|
||||||
|
// 可选:居中显示
|
||||||
|
// firstTd.style.textAlign = 'center';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// =============================================================
|
||||||
},
|
},
|
||||||
|
|
||||||
// 辅助方法:格式化日期(用于文件名)
|
// 辅助方法:格式化日期(用于文件名)
|
||||||
@@ -1517,6 +1630,7 @@ export default {
|
|||||||
// 搜索栏下拉选择变化
|
// 搜索栏下拉选择变化
|
||||||
handleSearchBarChanged({ param, value }) {
|
handleSearchBarChanged({ param, value }) {
|
||||||
if (param === 'timeType') {
|
if (param === 'timeType') {
|
||||||
|
this.isPeriodicReport = false
|
||||||
this.tableData2 = []
|
this.tableData2 = []
|
||||||
this.tableDataCustom = []
|
this.tableDataCustom = []
|
||||||
this.tableData = []
|
this.tableData = []
|
||||||
@@ -1584,15 +1698,59 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (param === 'searchType') {
|
} else if (param === 'searchType') {
|
||||||
|
this.isPeriodicReport = value === 2;
|
||||||
|
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
|
||||||
|
const formInline = this.$refs.searchBarForm.formInline;
|
||||||
|
formInline.reportType = ''
|
||||||
|
// 精准判断:只有字段存在时,才置为undefined(不存在则不处理)
|
||||||
|
if ('timeVal' in formInline) {
|
||||||
|
formInline.timeVal = undefined;
|
||||||
|
}
|
||||||
|
if ('timeValWeek' in formInline) {
|
||||||
|
formInline.timeValWeek = undefined;
|
||||||
|
}
|
||||||
|
if ('timeValMonth' in formInline) {
|
||||||
|
formInline.timeValMonth = undefined;
|
||||||
|
}
|
||||||
|
if ('timeValYear' in formInline) {
|
||||||
|
formInline.timeValYear = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// const formInline = this.$refs.searchBarForm.formInline;
|
||||||
|
this.listQuery.startTime = undefined
|
||||||
|
this.listQuery.endTime = undefined
|
||||||
|
console.log(this.listQuery,'list');
|
||||||
if (value === 1) {
|
if (value === 1) {
|
||||||
// 统计数据:显示时间范围,隐藏报表类型
|
// 统计数据:显示时间范围,隐藏报表类型
|
||||||
this.formConfig[7].type = 'datePicker';
|
this.formConfig[7] = {
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350
|
||||||
|
};
|
||||||
this.formConfig[6].type = '';
|
this.formConfig[6].type = '';
|
||||||
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
|
||||||
} else {
|
} else {
|
||||||
// 周期性报表:显示报表类型,隐藏时间范围
|
// 周期性报表:显示报表类型,隐藏时间范围
|
||||||
this.formConfig[6].type = 'select';
|
this.formConfig[6].type = 'select';
|
||||||
this.formConfig[7].type = 'datePicker';
|
this.formConfig[7] = {
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350
|
||||||
|
};
|
||||||
}
|
}
|
||||||
} else if (param === 'reportType') {
|
} else if (param === 'reportType') {
|
||||||
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
|
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
|
||||||
|
|||||||
@@ -190,7 +190,154 @@ import barChart from './BarChart.vue';
|
|||||||
import ButtonNav from '@/components/ButtonNav';
|
import ButtonNav from '@/components/ButtonNav';
|
||||||
import { listData } from '@/api/system/dict/data';
|
import { listData } from '@/api/system/dict/data';
|
||||||
// 表格列配置
|
// 表格列配置
|
||||||
const tableProps = [
|
export default {
|
||||||
|
components: { barChart, ButtonNav, baseTableS },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
urlOptions: { getDataListURL: getLineAuto },
|
||||||
|
listQuery: {
|
||||||
|
lineId: [],
|
||||||
|
pageSize: 10,
|
||||||
|
pageNo: 1,
|
||||||
|
total: 1,
|
||||||
|
timeType: 1 // 1-当天,2-自定义
|
||||||
|
},
|
||||||
|
reportTypeMap: {
|
||||||
|
1: '日报',
|
||||||
|
2: '周报',
|
||||||
|
3: '月报',
|
||||||
|
4: '年报'
|
||||||
|
},
|
||||||
|
activeLabel: 'table', // 当班数据tab
|
||||||
|
activeLabelDay: 'table', // 当天数据tab
|
||||||
|
fileName: '',
|
||||||
|
dataListLoading: false,
|
||||||
|
factoryColumns: [],
|
||||||
|
factoryColumnsDay: [],
|
||||||
|
activeName: 'product',
|
||||||
|
headFormValue:{},
|
||||||
|
tableBtn: [],
|
||||||
|
showData: [],
|
||||||
|
isPeriodicReport:false,
|
||||||
|
tableData: [],
|
||||||
|
tableData2: [], // 示例数据,实际从接口获取
|
||||||
|
productTableData: [],
|
||||||
|
productTableDataDay: [],
|
||||||
|
tableDataCustom: [],
|
||||||
|
list: [], // 折线图数据
|
||||||
|
timeTypeOptions: {
|
||||||
|
productLine: [ // 按产线监控(包含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
],
|
||||||
|
product: [ // 按产品监控(不含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
formConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '时间维度',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
],
|
||||||
|
width: 100,
|
||||||
|
onchange: true,
|
||||||
|
// defaultSelect: 1,
|
||||||
|
clearable: false,
|
||||||
|
param: 'timeType'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '查询类型',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '统计数据' },
|
||||||
|
{ id: 2, name: '周期性汇总报表' }
|
||||||
|
],
|
||||||
|
width: 120,
|
||||||
|
onchange: true,
|
||||||
|
param: 'searchType'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '工厂',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'factoryId',
|
||||||
|
multiple: true,
|
||||||
|
onchange: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'lineId',
|
||||||
|
multiple: true,
|
||||||
|
onchange: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产品工艺',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'process',
|
||||||
|
multiple: true,
|
||||||
|
labelField: 'label',
|
||||||
|
valueField: 'label',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '产品类型',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '面板' },
|
||||||
|
{ id: 2, name: '背板' },
|
||||||
|
],
|
||||||
|
multiple: true,
|
||||||
|
param: 'processType',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '报表类型',
|
||||||
|
selectOptions: [
|
||||||
|
{ id: 1, name: '日' },
|
||||||
|
{ id: 2, name: '周' },
|
||||||
|
{ id: 3, name: '月' },
|
||||||
|
{ id: 4, name: '年' }
|
||||||
|
],
|
||||||
|
width: 80,
|
||||||
|
onchange: true,
|
||||||
|
param: 'reportType'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350
|
||||||
|
},
|
||||||
|
{ type: 'button', btnName: '查询', name: 'search', color: 'primary' },
|
||||||
|
{ type: 'separate' },
|
||||||
|
{ type: 'button', btnName: '导出', name: 'export', color: 'warning' },
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '重置',
|
||||||
|
name: 'reset',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
tableProps() {
|
||||||
|
const props = [
|
||||||
{
|
{
|
||||||
prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
label: '工厂',
|
label: '工厂',
|
||||||
@@ -213,6 +360,12 @@ const tableProps = [
|
|||||||
label: '产品工艺',
|
label: '产品工艺',
|
||||||
fixed: true
|
fixed: true
|
||||||
},
|
},
|
||||||
|
(this.isPeriodicReport ? {
|
||||||
|
prop: 'reportDate',
|
||||||
|
label: '日期',
|
||||||
|
fixed: true,
|
||||||
|
width: 120
|
||||||
|
} : ''),
|
||||||
{
|
{
|
||||||
prop: 'inputN',
|
prop: 'inputN',
|
||||||
label: '投入',
|
label: '投入',
|
||||||
@@ -359,153 +512,8 @@ const tableProps = [
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
return props
|
||||||
export default {
|
|
||||||
components: { barChart, ButtonNav, baseTableS },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
urlOptions: { getDataListURL: getLineAuto },
|
|
||||||
listQuery: {
|
|
||||||
lineId: [],
|
|
||||||
pageSize: 10,
|
|
||||||
pageNo: 1,
|
|
||||||
total: 1,
|
|
||||||
timeType: 1 // 1-当天,2-自定义
|
|
||||||
},
|
},
|
||||||
reportTypeMap: {
|
|
||||||
1: '日报',
|
|
||||||
2: '周报',
|
|
||||||
3: '月报',
|
|
||||||
4: '年报'
|
|
||||||
},
|
|
||||||
activeLabel: 'table', // 当班数据tab
|
|
||||||
activeLabelDay: 'table', // 当天数据tab
|
|
||||||
fileName: '',
|
|
||||||
dataListLoading: false,
|
|
||||||
tableProps,
|
|
||||||
factoryColumns: [],
|
|
||||||
factoryColumnsDay: [],
|
|
||||||
activeName: 'product',
|
|
||||||
headFormValue:{},
|
|
||||||
tableBtn: [],
|
|
||||||
showData: [],
|
|
||||||
tableData: [],
|
|
||||||
tableData2: [], // 示例数据,实际从接口获取
|
|
||||||
productTableData: [],
|
|
||||||
productTableDataDay: [],
|
|
||||||
tableDataCustom: [],
|
|
||||||
list: [], // 折线图数据
|
|
||||||
timeTypeOptions: {
|
|
||||||
productLine: [ // 按产线监控(包含上一班)
|
|
||||||
{ id: 1, name: '当天' },
|
|
||||||
{ id: 2, name: '自定义' },
|
|
||||||
{ id: 3, name: '上一班' }
|
|
||||||
],
|
|
||||||
product: [ // 按产品监控(不含上一班)
|
|
||||||
{ id: 1, name: '当天' },
|
|
||||||
{ id: 2, name: '自定义' },
|
|
||||||
{ id: 3, name: '上一班' }
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
formConfig: [
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '时间维度',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '当天' },
|
|
||||||
{ id: 2, name: '自定义' },
|
|
||||||
{ id: 3, name: '上一班' }
|
|
||||||
],
|
|
||||||
width: 100,
|
|
||||||
onchange: true,
|
|
||||||
// defaultSelect: 1,
|
|
||||||
clearable: false,
|
|
||||||
param: 'timeType'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '查询类型',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '统计数据' },
|
|
||||||
{ id: 2, name: '周期性汇总报表' }
|
|
||||||
],
|
|
||||||
width: 120,
|
|
||||||
onchange: true,
|
|
||||||
param: 'searchType'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '工厂',
|
|
||||||
selectOptions: [],
|
|
||||||
param: 'factoryId',
|
|
||||||
multiple: true,
|
|
||||||
onchange: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '产线',
|
|
||||||
selectOptions: [],
|
|
||||||
param: 'lineId',
|
|
||||||
multiple: true,
|
|
||||||
onchange: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '产品工艺',
|
|
||||||
selectOptions: [],
|
|
||||||
param: 'process',
|
|
||||||
multiple: true,
|
|
||||||
labelField: 'label',
|
|
||||||
valueField: 'label',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '产品类型',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '面板' },
|
|
||||||
{ id: 2, name: '背板' },
|
|
||||||
],
|
|
||||||
multiple: true,
|
|
||||||
param: 'processType',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '报表类型',
|
|
||||||
selectOptions: [
|
|
||||||
{ id: 1, name: '日' },
|
|
||||||
{ id: 2, name: '周' },
|
|
||||||
{ id: 3, name: '月' },
|
|
||||||
{ id: 4, name: '年' }
|
|
||||||
],
|
|
||||||
width: 80,
|
|
||||||
onchange: true,
|
|
||||||
param: 'reportType'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: '',
|
|
||||||
label: '时间范围',
|
|
||||||
dateType: 'datetimerange',
|
|
||||||
format: 'yyyy-MM-dd HH:mm:ss',
|
|
||||||
valueFormat: 'timestamp',
|
|
||||||
rangeSeparator: '-',
|
|
||||||
startPlaceholder: '开始时间',
|
|
||||||
endPlaceholder: '结束时间',
|
|
||||||
param: 'timeVal',
|
|
||||||
width: 350
|
|
||||||
},
|
|
||||||
{ type: 'button', btnName: '查询', name: 'search', color: 'primary' },
|
|
||||||
{ type: 'separate' },
|
|
||||||
{ type: 'button', btnName: '导出', name: 'export', color: 'warning' },
|
|
||||||
{
|
|
||||||
type: 'button',
|
|
||||||
btnName: '重置',
|
|
||||||
name: 'reset',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
productTableProps() {
|
productTableProps() {
|
||||||
// 当班数据的完整表头(基础列 + 当班动态表头)
|
// 当班数据的完整表头(基础列 + 当班动态表头)
|
||||||
const baseColumns = [
|
const baseColumns = [
|
||||||
@@ -532,7 +540,13 @@ export default {
|
|||||||
prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
label: '工厂',
|
label: '工厂',
|
||||||
fixed: true
|
fixed: true
|
||||||
}
|
},
|
||||||
|
(this.isPeriodicReport ? {
|
||||||
|
prop: 'reportDate',
|
||||||
|
label: '日期',
|
||||||
|
fixed: true,
|
||||||
|
width: 120
|
||||||
|
} : ''),
|
||||||
];
|
];
|
||||||
return [...baseColumns, ...this.factoryColumns];
|
return [...baseColumns, ...this.factoryColumns];
|
||||||
},
|
},
|
||||||
@@ -562,7 +576,13 @@ export default {
|
|||||||
prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
label: '工厂',
|
label: '工厂',
|
||||||
fixed: true
|
fixed: true
|
||||||
}
|
},
|
||||||
|
(this.isPeriodicReport ? {
|
||||||
|
prop: 'reportDate',
|
||||||
|
label: '日期',
|
||||||
|
fixed: true,
|
||||||
|
width: 120
|
||||||
|
} : ''),
|
||||||
];
|
];
|
||||||
return [...baseColumns, ...this.factoryColumnsDay];
|
return [...baseColumns, ...this.factoryColumnsDay];
|
||||||
}
|
}
|
||||||
@@ -787,46 +807,59 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
// 导出表格
|
// 导出表格(改为async方法,支持await调用)
|
||||||
handleExport() {
|
async handleExport() {
|
||||||
// 按产线监控
|
// 按产线监控
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
this.exportMultipleTables([
|
await this.exportMultipleTables([
|
||||||
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
||||||
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
||||||
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
} else if (this.listQuery.timeType === 1) {
|
} else if (this.listQuery.timeType === 3) {
|
||||||
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
// 修复:注释错误,原为“产线-当天”,实际是“产线-上一班”
|
||||||
this.exportMultipleTables([
|
// 产线-上一班:导出单个表格
|
||||||
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
|
await this.exportSingleTable('lineCustomTable', '产线监控_上一班时间数据');
|
||||||
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
|
||||||
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
|
||||||
} else {
|
} else {
|
||||||
// 产线-自定义:导出一个表格(自定义文件名)
|
// 产线-自定义:导出一个表格(自定义文件名)
|
||||||
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
await this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 按产品监控
|
// 按产品监控
|
||||||
else {
|
else {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
this.exportMultipleTables([
|
await this.exportMultipleTables([
|
||||||
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
|
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
|
||||||
{ ref: 'productTodayTable', name: '产品监控_当天数据' }
|
{ ref: 'productCurrentShiftTable', name: '产品监控_当天数据' }
|
||||||
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
|
} else if (this.listQuery.timeType === 3) {
|
||||||
|
// 修复:注释错误,原为“产线-当天”,实际是“产品-上一班”
|
||||||
|
// 产品-上一班:导出单个表格
|
||||||
|
await this.exportSingleTable('productCustomTable', '产品监控_上一班时间数据');
|
||||||
} else {
|
} else {
|
||||||
// 产品-自定义:导出一个表格(自定义文件名)
|
// 产品-自定义:导出一个表格(自定义文件名)
|
||||||
this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
|
await this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出单个表格(保持原有逻辑,文件名由调用方传入,已区分不同场景)
|
// 导出单个表格(改为async方法,使用await获取DOM)
|
||||||
exportSingleTable(refName, fileName) {
|
async exportSingleTable(refName, fileName) {
|
||||||
const table = this.getTableDom(refName);
|
try {
|
||||||
if (!table) return;
|
// 关键修复:使用await等待getTableDom返回DOM元素(而非Promise)
|
||||||
|
const table = await this.getTableDom(refName);
|
||||||
|
if (!table) {
|
||||||
|
this.$message.warning(`无法导出:${refName}表格DOM获取失败`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认table是原生DOM元素后再调用cloneNode
|
||||||
|
if (!(table instanceof HTMLElement)) {
|
||||||
|
this.$message.error(`无法导出:${refName}表格不是合法的DOM元素`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const clonedTable = table.cloneNode(true);
|
const clonedTable = table.cloneNode(true);
|
||||||
this.adjustTableForExport(clonedTable);
|
this.adjustTableForExport(clonedTable);
|
||||||
@@ -834,16 +867,31 @@ export default {
|
|||||||
const workbook = XLSX.utils.table_to_book(clonedTable);
|
const workbook = XLSX.utils.table_to_book(clonedTable);
|
||||||
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
|
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
|
||||||
XLSX.writeFile(workbook, fullName);
|
XLSX.writeFile(workbook, fullName);
|
||||||
|
} catch (error) {
|
||||||
|
this.$message.error(`导出表格失败:${error.message}`);
|
||||||
|
console.error('单个表格导出错误:', error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出多个表格(新增自定义汇总文件名参数,适配不同选项卡)
|
// 导出多个表格(改为async方法,使用await获取DOM)
|
||||||
exportMultipleTables(tables, customSummaryName) {
|
async exportMultipleTables(tables, customSummaryName) {
|
||||||
|
try {
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
let hasValidTable = false;
|
let hasValidTable = false;
|
||||||
|
|
||||||
tables.forEach(({ ref, name }) => {
|
// 遍历表格配置,使用await获取每个表格的DOM
|
||||||
const table = this.getTableDom(ref);
|
for (const { ref, name } of tables) { // 改用for...of循环,支持await
|
||||||
if (!table) return;
|
const table = await this.getTableDom(ref);
|
||||||
|
if (!table) {
|
||||||
|
this.$message.warning(`${ref}表格DOM获取失败,跳过该表格`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认table是原生DOM元素
|
||||||
|
if (!(table instanceof HTMLElement)) {
|
||||||
|
this.$message.warning(`${ref}表格不是合法的DOM元素,跳过该表格`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
hasValidTable = true;
|
hasValidTable = true;
|
||||||
const clonedTable = table.cloneNode(true);
|
const clonedTable = table.cloneNode(true);
|
||||||
@@ -851,33 +899,67 @@ export default {
|
|||||||
|
|
||||||
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
|
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, name);
|
XLSX.utils.book_append_sheet(workbook, worksheet, name);
|
||||||
});
|
}
|
||||||
|
|
||||||
if (!hasValidTable) {
|
if (!hasValidTable) {
|
||||||
this.$message.warning('未找到有效表格数据');
|
this.$message.warning('未找到有效表格数据,导出失败');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动态生成汇总文件名:自定义名称 + 日期
|
// 动态生成汇总文件名:自定义名称 + 日期
|
||||||
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
|
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
|
||||||
XLSX.writeFile(workbook, fullName);
|
XLSX.writeFile(workbook, fullName);
|
||||||
},
|
} catch (error) {
|
||||||
// 辅助方法:获取表格DOM元素(包含表头)
|
this.$message.error(`导出多个表格失败:${error.message}`);
|
||||||
getTableDom(refName) {
|
console.error('多个表格导出错误:', error);
|
||||||
const tableComponent = this.$refs[refName];
|
|
||||||
if (!tableComponent) {
|
|
||||||
this.$message.warning(`未找到${refName}表格`);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
// 获取完整表格容器(包含表头和表体)
|
|
||||||
const tableContainer = tableComponent.$el.querySelector('.el-table');
|
|
||||||
if (!tableContainer) {
|
|
||||||
this.$message.warning(`${refName}表格数据为空`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return tableContainer;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取表格DOM元素(支持异步重试)
|
||||||
|
* @param {string} refName - 表格的ref名称
|
||||||
|
* @param {number} retryCount - 当前重试次数(内部使用,外部调用无需传参)
|
||||||
|
* @returns {Promise<HTMLElement|null>} 表格DOM元素Promise
|
||||||
|
*/
|
||||||
|
async getTableDom(refName, retryCount = 0) {
|
||||||
|
// 1. 配置常量,便于维护
|
||||||
|
const maxRetry = 5; // 最大重试次数
|
||||||
|
const retryDelay = 300; // 每次重试延迟时间(ms)
|
||||||
|
|
||||||
|
// 2. 设置激活标签,确保重试时也能执行该逻辑
|
||||||
|
this.activeLabel = 'table';
|
||||||
|
this.activeLabelDay = 'table';
|
||||||
|
// 若需调试,可保留日志
|
||||||
|
// console.log(`[getTableDom-${refName}] activeLabel:`, this.activeLabel, 'activeLabelDay:', this.activeLabelDay);
|
||||||
|
|
||||||
|
// 3. 获取表格组件
|
||||||
|
const tableComponent = this.$refs[refName];
|
||||||
|
|
||||||
|
// 4. 表格组件不存在时,处理重试逻辑
|
||||||
|
if (!tableComponent) {
|
||||||
|
// 达到最大重试次数,返回失败
|
||||||
|
if (retryCount >= maxRetry) {
|
||||||
|
this.$message.warning(`未找到${refName}表格,已达到最大重试次数(${maxRetry}次)`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未达到最大重试次数,延迟后重试
|
||||||
|
this.$message.warning(`未找到${refName}表格,将进行第${retryCount + 1}次重试...`);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
||||||
|
// 递归调用并返回结果
|
||||||
|
return this.getTableDom(refName, retryCount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 获取完整表格容器(包含表头和表体)
|
||||||
|
const tableContainer = tableComponent.$el.querySelector('.el-table');
|
||||||
|
if (!tableContainer) {
|
||||||
|
this.$message.warning(`${refName}表格容器不存在(可能表格数据为空)`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 成功获取表格DOM,返回结果
|
||||||
|
return tableContainer;
|
||||||
|
},
|
||||||
// 重点修复:调整表格结构(解决表头重复问题)
|
// 重点修复:调整表格结构(解决表头重复问题)
|
||||||
adjustTableForExport(tableContainer) {
|
adjustTableForExport(tableContainer) {
|
||||||
// 1. 移除空表格提示和分页等无关元素
|
// 1. 移除空表格提示和分页等无关元素
|
||||||
@@ -939,7 +1021,7 @@ export default {
|
|||||||
if (mainTable && allHeaderRows.length > 0) {
|
if (mainTable && allHeaderRows.length > 0) {
|
||||||
const newThead = document.createElement('thead');
|
const newThead = document.createElement('thead');
|
||||||
// 按层级添加表头行
|
// 按层级添加表头行
|
||||||
allHeaderRows.forEach(cells => {
|
allHeaderRows.forEach((cells, rowIndex) => {
|
||||||
const newTr = document.createElement('tr');
|
const newTr = document.createElement('tr');
|
||||||
cells.forEach(cell => {
|
cells.forEach(cell => {
|
||||||
// 复制单元格(避免DOM残留引用问题)
|
// 复制单元格(避免DOM残留引用问题)
|
||||||
@@ -950,6 +1032,18 @@ export default {
|
|||||||
});
|
});
|
||||||
// 将新表头插入主表体最前面
|
// 将新表头插入主表体最前面
|
||||||
mainTable.insertBefore(newThead, mainTable.firstChild);
|
mainTable.insertBefore(newThead, mainTable.firstChild);
|
||||||
|
|
||||||
|
// ================ 新增:修改第一列表头为“序号” ================
|
||||||
|
// 找到第一层级的第一个表头单元格(<th>)
|
||||||
|
const firstHeaderCell = newThead.querySelector('tr:first-child th:first-child');
|
||||||
|
if (firstHeaderCell) {
|
||||||
|
// 清空原有内容,设置为“序号”
|
||||||
|
firstHeaderCell.innerHTML = ''; // 清空原有内容(包括子元素)
|
||||||
|
firstHeaderCell.textContent = '序号'; // 设置纯文本“序号”(更稳定)
|
||||||
|
// 可选:添加样式(如居中,根据需求调整)
|
||||||
|
// firstHeaderCell.style.textAlign = 'center';
|
||||||
|
}
|
||||||
|
// =============================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 合并固定列数据到主表体(仅处理tbody数据)
|
// 7. 合并固定列数据到主表体(仅处理tbody数据)
|
||||||
@@ -980,6 +1074,23 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================ 可选优化:为tbody第一列添加序号数字 ================
|
||||||
|
// 如果表格体的第一列原本无数据,可补充1、2、3...的序号
|
||||||
|
if (mainTable) {
|
||||||
|
const tbodyRows = mainTable.querySelectorAll('tbody tr');
|
||||||
|
tbodyRows.forEach((row, index) => {
|
||||||
|
const firstTd = row.querySelector('td:first-child');
|
||||||
|
if (firstTd) {
|
||||||
|
// 清空原有内容,设置为序号(index+1,因为索引从0开始)
|
||||||
|
firstTd.innerHTML = '';
|
||||||
|
firstTd.textContent = index + 1;
|
||||||
|
// 可选:居中显示
|
||||||
|
// firstTd.style.textAlign = 'center';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// =============================================================
|
||||||
},
|
},
|
||||||
|
|
||||||
// 辅助方法:格式化日期(用于文件名)
|
// 辅助方法:格式化日期(用于文件名)
|
||||||
@@ -1003,7 +1114,45 @@ export default {
|
|||||||
this.formConfig[2].selectOptions = res.data.list || [];
|
this.formConfig[2].selectOptions = res.data.list || [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getWeekTimeRange(date) {
|
||||||
|
const targetDate = new Date(date);
|
||||||
|
const day = targetDate.getDay() || 7; // 周日转为7
|
||||||
|
const year = targetDate.getFullYear();
|
||||||
|
const month = targetDate.getMonth();
|
||||||
|
const dateNum = targetDate.getDate();
|
||||||
|
|
||||||
|
// 本周一 00:00:00
|
||||||
|
const startDate = new Date(year, month, dateNum - day + 1);
|
||||||
|
startDate.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
// 本周日 23:59:59
|
||||||
|
const endDate = new Date(year, month, dateNum - day + 7);
|
||||||
|
endDate.setHours(23, 59, 59, 999);
|
||||||
|
|
||||||
|
return {
|
||||||
|
startTime: startDate.getTime(),
|
||||||
|
endTime: endDate.getTime()
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
// 辅助函数:获取本年的开始和结束时间戳(1月1日00:00:00 到 12月31日23:59:59)
|
||||||
|
getYearTimeRange(date) {
|
||||||
|
const targetDate = new Date(date);
|
||||||
|
const year = targetDate.getFullYear();
|
||||||
|
|
||||||
|
// 本年1月1日 00:00:00
|
||||||
|
const startDate = new Date(year, 0, 1);
|
||||||
|
startDate.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
// 本年12月31日 23:59:59
|
||||||
|
const endDate = new Date(year, 11, 31);
|
||||||
|
endDate.setHours(23, 59, 59, 999);
|
||||||
|
|
||||||
|
return {
|
||||||
|
startTime: startDate.getTime(),
|
||||||
|
endTime: endDate.getTime()
|
||||||
|
};
|
||||||
|
},
|
||||||
// 搜索/导出按钮点击
|
// 搜索/导出按钮点击
|
||||||
buttonClick(val) {
|
buttonClick(val) {
|
||||||
this.headFormValue = val
|
this.headFormValue = val
|
||||||
@@ -1498,6 +1647,7 @@ export default {
|
|||||||
handleSearchBarChanged({ param, value }) {
|
handleSearchBarChanged({ param, value }) {
|
||||||
console.log(value, param);
|
console.log(value, param);
|
||||||
if (param === 'timeType') {
|
if (param === 'timeType') {
|
||||||
|
this.isPeriodicReport = false
|
||||||
this.tableData = []
|
this.tableData = []
|
||||||
this.tableDataCustom = []
|
this.tableDataCustom = []
|
||||||
this.tableData2 = []
|
this.tableData2 = []
|
||||||
@@ -1566,15 +1716,60 @@ export default {
|
|||||||
this.formConfig[7].type = '';
|
this.formConfig[7].type = '';
|
||||||
}
|
}
|
||||||
} else if (param === 'searchType') {
|
} else if (param === 'searchType') {
|
||||||
|
this.isPeriodicReport = value === 2;
|
||||||
|
console.log('this.isPeriodicReport ', this.isPeriodicReport);
|
||||||
|
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
|
||||||
|
const formInline = this.$refs.searchBarForm.formInline;
|
||||||
|
formInline.reportType = ''
|
||||||
|
// 精准判断:只有字段存在时,才置为undefined(不存在则不处理)
|
||||||
|
if ('timeVal' in formInline) {
|
||||||
|
formInline.timeVal = undefined;
|
||||||
|
}
|
||||||
|
if ('timeValWeek' in formInline) {
|
||||||
|
formInline.timeValWeek = undefined;
|
||||||
|
}
|
||||||
|
if ('timeValMonth' in formInline) {
|
||||||
|
formInline.timeValMonth = undefined;
|
||||||
|
}
|
||||||
|
if ('timeValYear' in formInline) {
|
||||||
|
formInline.timeValYear = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// const formInline = this.$refs.searchBarForm.formInline;
|
||||||
|
this.listQuery.startTime = undefined
|
||||||
|
this.listQuery.endTime = undefined
|
||||||
|
console.log(this.listQuery, 'list');
|
||||||
if (value === 1) {
|
if (value === 1) {
|
||||||
// 统计数据:显示时间范围,隐藏报表类型
|
// 统计数据:显示时间范围,隐藏报表类型
|
||||||
this.formConfig[7].type = 'datePicker';
|
this.formConfig[7] = {
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350
|
||||||
|
};
|
||||||
this.formConfig[6].type = '';
|
this.formConfig[6].type = '';
|
||||||
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
|
||||||
} else {
|
} else {
|
||||||
// 周期性报表:显示报表类型,隐藏时间范围
|
// 周期性报表:显示报表类型,隐藏时间范围
|
||||||
this.formConfig[6].type = 'select';
|
this.formConfig[6].type = 'select';
|
||||||
this.formConfig[7].type = 'datePicker';
|
this.formConfig[7] = {
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350
|
||||||
|
};
|
||||||
}
|
}
|
||||||
} else if (param === 'reportType') {
|
} else if (param === 'reportType') {
|
||||||
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
|
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
|
||||||
|
|||||||
Reference in New Issue
Block a user