Compare commits

...

10 Commits

Author SHA1 Message Date
a2375325a0 Merge pull request 'projects/qhd-line-zhp' (#467) from projects/qhd-line-zhp into projects/qhd-line-test
Reviewed-on: #467
2025-12-23 08:52:44 +08:00
‘937886381’
04d5896f6e Merge branch 'projects/qhd-line-test' into projects/qhd-line-zhp 2025-12-23 08:51:19 +08:00
‘937886381’
46a23c249c 修改 2025-12-23 08:49:37 +08:00
242a52b98e Merge pull request 'projects/qhd-line-zhp' (#465) from projects/qhd-line-zhp into projects/qhd-line-test
Reviewed-on: #465
2025-12-17 16:30:08 +08:00
‘937886381’
945237557f 修改 2025-12-17 16:27:13 +08:00
‘937886381’
8eb0a9fee1 Merge branch 'projects/qhd-line-test' into projects/qhd-line-zhp 2025-12-15 10:48:29 +08:00
‘937886381’
a9645d03a9 修改bug 2025-12-15 10:46:44 +08:00
2b5e476fdd Merge pull request 'projects/qhd-line-zhp' (#464) from projects/qhd-line-zhp into projects/qhd-line-test
Reviewed-on: #464
2025-12-12 16:57:01 +08:00
‘937886381’
f95d0473bf Merge branch 'projects/qhd-line-test' into projects/qhd-line-zhp 2025-12-12 16:51:39 +08:00
‘937886381’
25dc76dfbe 修改bug 2025-12-12 16:50:46 +08:00
17 changed files with 1725 additions and 1018 deletions

View File

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

Binary file not shown.

View File

@@ -111,3 +111,17 @@ export function getProcessAutoReportNew(data) {
data: data, data: data,
}); });
} }
export function getProcessAutoReportLastGroup(data) {
return request({
url: '/monitoring/production-monitor/getProcessAutoReportLastGroup',
method: 'post',
data: data,
});
}
export function getPLlistByFactory(data) {
return request({
url: 'base/production-line/listByFactory',
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

@@ -120,6 +120,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', response);
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
}, },
}, },
}; };

View File

@@ -7,46 +7,20 @@
--> -->
<template> <template>
<div class="app-container"> <div class="app-container">
<search-bar <search-bar :formConfigs="formConfig" ref="searchBarForm" @select-changed="handleSearchBarChanged"
:formConfigs="formConfig"
ref="searchBarForm"
@select-changed="handleSearchBarChanged"
@headBtnClick="buttonClick" /> @headBtnClick="buttonClick" />
<div v-if="showData.length"> <div v-if="showData.length">
<base-table <base-table class="right-aside" v-loading="dataListLoading" :table-props="tableProps" :page="1" :limit="999"
class="right-aside"
v-loading="dataListLoading"
:table-props="tableProps"
:page="1"
:limit="999"
:table-data="showData"> :table-data="showData">
<method-btn <method-btn v-if="showData.length" slot="handleBtn" :width="80" label="操作" :method-list="tableBtn"
v-if="showData.length"
slot="handleBtn"
:width="80"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" /> @clickBtn="handleClick" />
</base-table> </base-table>
<barChart <barChart v-for="item in chartData" :key="item.name + 'echart'" style="margin-top: 50px" height="600px"
v-for="item in chartData" :id="item.name + 'echart'" :title="item.name + ' 节拍趋势图'" :bar-data="item" />
:key="item.name + 'echart'"
style="margin-top: 50px"
height="600px"
:id="item.name + 'echart'"
:title="item.name + ' 节拍趋势图'"
:bar-data="item" />
</div> </div>
<div v-else class="no-data-bg"></div> <div v-else class="no-data-bg"></div>
<base-dialog <base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="addOrUpdateVisible" @cancel="handleCancel"
:dialogTitle="addOrEditTitle" @confirm="handleConfirm" :before-close="handleCancel" close-on-click-modal top="0" width="50%">
:dialogVisible="addOrUpdateVisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
close-on-click-modal
top="0"
width="50%">
<eq-detail ref="eqDetail" /> <eq-detail ref="eqDetail" />
<slot name="footer"> <slot name="footer">
<el-row slot="footer" type="flex" justify="end"> <el-row slot="footer" type="flex" justify="end">
@@ -64,7 +38,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 +109,8 @@ export default {
label: '工厂', label: '工厂',
selectOptions: [], selectOptions: [],
param: 'factoryId', param: 'factoryId',
collapseTags: true,
multiple: true,
onchange: true, onchange: true,
}, },
{ {
@@ -142,6 +118,7 @@ export default {
label: '产线', label: '产线',
selectOptions: [], selectOptions: [],
param: 'lineId', param: 'lineId',
collapseTags: true,
multiple: true, multiple: true,
}, },
{ {
@@ -183,7 +160,7 @@ export default {
// 获取当前时间 // 获取当前时间
const now = new Date(); const now = new Date();
// 获取前一天的同一时间 // 获取前一天的同一时间
const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000); const yesterday = new Date(now.getTime());
// 设置为00:00:00 // 设置为00:00:00
yesterday.setHours(0, 0, 0, 0); yesterday.setHours(0, 0, 0, 0);
// 设置为23:59:59 // 设置为23:59:59
@@ -232,9 +209,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 +251,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

@@ -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 style="width: 100%" <el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable style="width: 100%"
@@ -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">

View File

@@ -348,7 +348,7 @@ export default {
dataListLoading: false, dataListLoading: false,
tableProps, tableProps,
tableBtn: [ tableBtn: [
this.$auth.hasPermi(`monitoring:group-off:update`) this.$auth.hasPermi(`monitoring:group-off:detail`)
? { ? {
type: 'eq', type: 'eq',
btnName: '详情', btnName: '详情',

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,8 @@ export default {
handleExport() { handleExport() {
// 处理查询参数 // 处理查询参数
let params = { ...this.listQuery }; let params = { ...this.listQuery };
params.pageNo = undefined; // params.pageNo = undefined;
params.pageSize = 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

@@ -216,7 +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';
import ButtonNav from '@/components/ButtonNav'; import ButtonNav from '@/components/ButtonNav';
@@ -569,7 +569,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

@@ -278,8 +278,8 @@ export default {
mobileCodeTimer: 0, mobileCodeTimer: 0,
loginForm: { loginForm: {
loginType: 'uname', loginType: 'uname',
username: 'admin', username: '',
password: 'admin123', password: '',
captchaVerification: '', captchaVerification: '',
mobile: '', mobile: '',
mobileCode: '', mobileCode: '',

View File

@@ -34,28 +34,7 @@ export default {
mixins: [basicPageMixin], mixins: [basicPageMixin],
data() { data() {
return { return {
// tableBtn: [
// this.$auth.hasPermi('base:quality-inspection-type:update')
// ? {
// type: 'edit',
// btnName: '修改',
// }
// : undefined,
// this.$auth.hasPermi('base:quality-inspection-type:delete')
// ? {
// type: 'delete',
// btnName: '删除',
// }
// : undefined,
// ].filter((v) => v),
tableProps: [ tableProps: [
// {
// prop: 'createTime',
// label: '添加时间',
// fixed: true,
// width: 180,
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
// },
{ prop: 'factoryName', label: '工厂' }, { prop: 'factoryName', label: '工厂' },
{ prop: 'lineName', label: '产线' }, { prop: 'lineName', label: '产线' },
{ prop: 'remark', label: '玻璃编号' }, { prop: 'remark', label: '玻璃编号' },
@@ -74,42 +53,7 @@ export default {
}, },
{ prop: 'reason', label: '判等原因' }, { prop: 'reason', label: '判等原因' },
{ prop: 'specifications', label: '规格' }, { prop: 'specifications', label: '规格' },
// {
// label: '操作',
// alignt: 'center',
// subcomponent: {
// render: function (h) {
// return h('div', null, [
// h(
// 'el-button',
// {
// props: {
// icon: 'el-icon-edit',
// size: 'mini',
// type: 'text',
// },
// },
// ' 修改'
// ),
// h(
// 'el-button',
// {
// props: {
// icon: 'el-icon-edit',
// size: 'mini',
// type: 'text',
// },
// },
// ' 修改'
// ),
// ]);
// },
// },
// },
], ],
//
searchBarFormConfig: [ searchBarFormConfig: [
{ {
type: 'select', type: 'select',
@@ -121,6 +65,7 @@ export default {
type: 'select', type: 'select',
label: '产线', label: '产线',
selectOptions: [], selectOptions: [],
multiple: true,
param: 'lineId', param: 'lineId',
}, },
{ {
@@ -134,13 +79,13 @@ 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',
rangeSeparator: '-', rangeSeparator: '-',
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
width: 350 width: 350,
defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
@@ -148,23 +93,9 @@ export default {
name: 'search', name: 'search',
color: 'primary', color: 'primary',
}, },
// {
// type: 'button',
// btnName: '重置',
// name: 'reset',
// },
{ {
type: 'separate', type: 'separate',
}, },
// {
// type: this.$auth.hasPermi('base:quality-inspection-type:create')
// ? 'button'
// : '',
// btnName: '新增',
// name: 'add',
// plain: true,
// color: 'success',
// },
{ {
type: this.$auth.hasPermi('base:quality-inspection-type:export') type: this.$auth.hasPermi('base:quality-inspection-type:export')
? 'button' ? 'button'
@@ -214,11 +145,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 || [];
@@ -249,11 +224,6 @@ export default {
this.queryParams.startTime = btn.timeVal ? btn.timeVal[0] : undefined this.queryParams.startTime = btn.timeVal ? btn.timeVal[0] : undefined
this.queryParams.endTime = btn.timeVal ? btn.timeVal[1] : undefined this.queryParams.endTime = btn.timeVal ? btn.timeVal[1] : undefined
this.queryParams.checkNum = btn.checkNum ? btn.checkNum : undefined this.queryParams.checkNum = btn.checkNum ? btn.checkNum : undefined
// keys.forEach((key) => {
// this.queryParams[key] = btn[key] || null;
// });
this.getList(); this.getList();
break; break;
case 'add': case 'add':
@@ -262,10 +232,6 @@ export default {
case 'export': case 'export':
this.handleExport(); this.handleExport();
break; break;
// case 'reset':
// this.$refs['search-bar'].resetForm();
// this.resetQuery();
// break;
} }
}, },
/** 查询列表 */ /** 查询列表 */

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 || [];