Compare commits

...

14 Commits

Author SHA1 Message Date
00393f76c7 Merge pull request 'projects/line-new-zhp' (#469) from projects/line-new-zhp into projects/line-new
Reviewed-on: #469
2025-12-24 16:36:24 +08:00
‘937886381’
35fb0d8bfb Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-24 16:35:44 +08:00
‘937886381’
0c52306cc6 修改 2025-12-24 16:34:37 +08:00
a5fba28ff7 Merge pull request 'projects/line-new-zhp' (#468) from projects/line-new-zhp into projects/line-new
Reviewed-on: #468
2025-12-23 08:53:19 +08:00
‘937886381’
1f8b994218 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-23 08:49:07 +08:00
‘937886381’
ccfa73f3bc xiugai 2025-12-23 08:46:44 +08:00
‘937886381’
89ff79bfd7 修改 2025-12-23 08:35:46 +08:00
70a0fbb170 Merge pull request 'projects/line-new-zhp' (#466) from projects/line-new-zhp into projects/line-new
Reviewed-on: #466
2025-12-17 16:30:30 +08:00
‘937886381’
c86d94ac92 修改 2025-12-17 16:26:21 +08:00
‘937886381’
484ba6ca53 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-15 10:45:49 +08:00
‘937886381’
f403375594 修改bug 2025-12-15 10:45:06 +08:00
1cd0b13aae Merge pull request 'projects/line-new-zhp' (#463) from projects/line-new-zhp into projects/line-new
Reviewed-on: #463
2025-12-12 16:54:55 +08:00
‘937886381’
d2b0565cd1 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-12 16:53:32 +08:00
‘937886381’
7661dc5691 修改 2025-12-12 16:52:45 +08:00
19 changed files with 10310 additions and 9498 deletions

BIN
dist.zip

Binary file not shown.

View File

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

View File

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

View File

@@ -89,6 +89,31 @@ export default {
}, },
created() {}, created() {},
methods: { methods: {
dataFormSubmit() {
this.$refs["dataForm"].validate((valid) => {
if (!valid) {
return false;
}
// 修改的提交
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.visible = false;
this.$emit("refreshDataList");
});
return;
}
// 添加的提交
this.urlOptions.createURL(this.dataForm).then(response => {
if (response.code === 1001033 || response.code === 1001034) {
return this.$modal.msgError(response.msg);
}
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
}, },
}; };
</script> </script>

View File

@@ -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");
});
});
}, },
}, },
}; };

View File

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

View File

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

View File

@@ -80,7 +80,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <!-- <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label=" 基板类型" prop="typeDictValue"> <el-form-item label=" 基板类型" prop="typeDictValue">
<el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable <el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable
@@ -89,7 +89,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </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">

File diff suppressed because it is too large Load Diff

View File

@@ -101,7 +101,7 @@ const tableProps = [
}, },
{ {
prop: 'thick', prop: 'thick',
label: '玻璃度/mm' label: '玻璃度/mm'
}, },
]; ];
@@ -275,7 +275,7 @@ export default {
fileName += this.listQuery.thick + '_'; fileName += this.listQuery.thick + '_';
} }
// 添加时间戳避免文件名重复 // 添加时间戳避免文件名重复
fileName += + '.xlsx'; fileName + '.xlsx';
FileSaver.saveAs(blob, fileName); FileSaver.saveAs(blob, fileName);
this.$message.success('导出成功'); this.$message.success('导出成功');

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -462,7 +462,7 @@ export default {
this.originData = null; this.originData = null;
this.hasData = true; this.hasData = true;
if (this.$refs.searchBarForm) { if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.form.timeVal = []; // this.$refs.searchBarForm.form.timeVal = [];
} }
}, },

View File

@@ -216,6 +216,7 @@ import {
import { getTree } from '@/api/base/equipment'; import { getTree } from '@/api/base/equipment';
import { getEquipmentTypePage } from '@/api/base/equipmentType'; import { getEquipmentTypePage } from '@/api/base/equipmentType';
import { getEquipmentOverall } from '@/api/base/equipment'; import { getEquipmentOverall } from '@/api/base/equipment';
import { getTenantId } from '@/utils/auth'
// import * as XLSX from 'xlsx'; // import * as XLSX from 'xlsx';
// import FileSaver from 'file-saver'; // import FileSaver from 'file-saver';
@@ -569,7 +570,7 @@ export default {
const token = getAccessToken(); const token = getAccessToken();
const headers = new Headers({ const headers = new Headers({
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
'tenant-id': store.getters.userId, 'tenant-id': getTenantId(),
'Content-Type': 'text/event-stream', 'Content-Type': 'text/event-stream',
}); });

View File

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

View File

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

View File

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

View File

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

17160
yarn.lock

File diff suppressed because it is too large Load Diff