Compare commits

...

11 Commits

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

@@ -88,7 +88,32 @@ 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,7 +120,30 @@ 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");
});
});
},
}, },
}; };
</script> </script>

View File

@@ -6,65 +6,39 @@
* @Description: * @Description:
--> -->
<template> <template>
<div class="app-container"> <div class="app-container">
<search-bar <search-bar :formConfigs="formConfig" ref="searchBarForm" @select-changed="handleSearchBarChanged"
:formConfigs="formConfig" @headBtnClick="buttonClick" />
ref="searchBarForm" <div v-if="showData.length">
@select-changed="handleSearchBarChanged" <base-table class="right-aside" v-loading="dataListLoading" :table-props="tableProps" :page="1" :limit="999"
@headBtnClick="buttonClick" /> :table-data="showData">
<div v-if="showData.length"> <method-btn v-if="showData.length" slot="handleBtn" :width="80" label="操作" :method-list="tableBtn"
<base-table @clickBtn="handleClick" />
class="right-aside" </base-table>
v-loading="dataListLoading" <barChart v-for="item in chartData" :key="item.name + 'echart'" style="margin-top: 50px" height="600px"
:table-props="tableProps" :id="item.name + 'echart'" :title="item.name + ' 节拍趋势图'" :bar-data="item" />
:page="1" </div>
:limit="999" <div v-else class="no-data-bg"></div>
:table-data="showData"> <base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="addOrUpdateVisible" @cancel="handleCancel"
<method-btn @confirm="handleConfirm" :before-close="handleCancel" close-on-click-modal top="0" width="50%">
v-if="showData.length" <eq-detail ref="eqDetail" />
slot="handleBtn" <slot name="footer">
:width="80" <el-row slot="footer" type="flex" justify="end">
label="操作" <el-col :span="24">
:method-list="tableBtn" <el-button size="small" class="btnTextStyle" @click="handleCancel">
@clickBtn="handleClick" /> 取消
</base-table> </el-button>
<barChart </el-col>
v-for="item in chartData" </el-row>
:key="item.name + 'echart'" </slot>
style="margin-top: 50px" </base-dialog>
height="600px" </div>
:id="item.name + 'echart'"
:title="item.name + ' 节拍趋势图'"
:bar-data="item" />
</div>
<div v-else class="no-data-bg"></div>
<base-dialog
:dialogTitle="addOrEditTitle"
:dialogVisible="addOrUpdateVisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
close-on-click-modal
top="0"
width="50%">
<eq-detail ref="eqDetail" />
<slot name="footer">
<el-row slot="footer" type="flex" justify="end">
<el-col :span="24">
<el-button size="small" class="btnTextStyle" @click="handleCancel">
取消
</el-button>
</el-col>
</el-row>
</slot>
</base-dialog>
</div>
</template> </template>
<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'
@@ -73,230 +47,233 @@ import FileSaver from 'file-saver';
import barChart from './BarChart.vue'; import barChart from './BarChart.vue';
const tableProps = [ const tableProps = [
{ {
prop: 'factoryName', prop: 'factoryName',
label: '工厂', label: '工厂',
}, },
{ {
prop: 'lineName', prop: 'lineName',
label: '产线', label: '产线',
}, },
{ {
prop: 'size', prop: 'size',
label: '规格', label: '规格',
showOverflowtooltip: true, showOverflowtooltip: true,
}, },
{ {
prop: 'process', prop: 'process',
label: '产品工艺', label: '产品工艺',
}, },
{ {
prop: 'edgeCt', prop: 'edgeCt',
label: '磨边当前节拍pcs/min', label: '磨边当前节拍pcs/min',
}, },
{ {
prop: 'temperCt', prop: 'temperCt',
label: '钢化当前节拍pcs/min', label: '钢化当前节拍pcs/min',
}, },
{ {
prop: 'downCt', prop: 'downCt',
label: '下片当前节拍pcs/min', label: '下片当前节拍pcs/min',
}, },
]; ];
export default { export default {
components: { components: {
barChart, barChart,
eqDetail, eqDetail,
}, },
data() { data() {
return { return {
urlOptions: { urlOptions: {
getDataListURL: getNewCTNow, getDataListURL: getNewCTNow,
}, },
listQuery: { listQuery: {
lineId: [], lineId: [],
}, },
fileName: '', fileName: '',
dataListLoading: false, dataListLoading: false,
tableProps, tableProps,
tableBtn: [ tableBtn: [
{ {
type: 'eq', type: 'eq',
btnName: '详情', btnName: '详情',
}, },
].filter((v) => v), ].filter((v) => v),
showData: [], showData: [],
tableData: [], tableData: [],
chartData: [], chartData: [],
formConfig: [ formConfig: [
{ {
type: 'select', type: 'select',
label: '工厂', label: '工厂',
selectOptions: [], selectOptions: [],
param: 'factoryId', param: 'factoryId',
onchange: true, collapseTags: true,
}, multiple: true,
{ onchange: true,
type: 'select', },
label: '产线', {
selectOptions: [], type: 'select',
param: 'lineId', label: '产线',
multiple: true, selectOptions: [],
}, param: 'lineId',
{ collapseTags: true,
type: 'datePicker', multiple: true,
label: '时间范围', },
dateType: 'datetimerange', {
format: 'yyyy-MM-dd HH:mm:ss', type: 'datePicker',
valueFormat: 'timestamp', label: '时间范围',
rangeSeparator: '-', dateType: 'datetimerange',
startPlaceholder: '开始时间', format: 'yyyy-MM-dd HH:mm:ss',
endPlaceholder: '结束时间', valueFormat: 'timestamp',
defaultTime: ['00:00:00', '23:59:59'], rangeSeparator: '-',
param: 'timeVal', startPlaceholder: '开始时间',
width: 350, endPlaceholder: '结束时间',
clearable: false, defaultTime: ['00:00:00', '23:59:59'],
}, param: 'timeVal',
{ width: 350,
type: 'button', clearable: false,
btnName: '查询', },
name: 'search', {
color: 'primary', type: 'button',
}, btnName: '查询',
// { name: 'search',
// type: 'separate', color: 'primary',
// }, },
// { // {
// // type: this.$auth.hasPermi('base:factory:export') ? 'button' : '', // type: 'separate',
// type: 'button', // },
// btnName: '导出', // {
// name: 'export', // // type: this.$auth.hasPermi('base:factory:export') ? 'button' : '',
// color: 'warning', // type: 'button',
// }, // btnName: '导出',
], // name: 'export',
addOrEditTitle: '', // color: 'warning',
addOrUpdateVisible: false, // },
}; ],
}, addOrEditTitle: '',
created() { addOrUpdateVisible: false,
// 获取当前时间 };
const now = new Date(); },
// 获取前一天的同一时间 created() {
const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000); // 获取当前时间
// 设置为00:00:00 const now = new Date();
yesterday.setHours(0, 0, 0, 0); // 获取前一天的同一时间
// 设置为23:59:59 const yesterday = new Date(now.getTime());
const end = new Date(yesterday.getTime()); // 设置为00:00:00
end.setHours(23, 59, 59, 59); yesterday.setHours(0, 0, 0, 0);
this.listQuery.startTime = yesterday.getTime(); // 设置为23:59:59
this.listQuery.endTime = end.getTime(); const end = new Date(yesterday.getTime());
this.$nextTick(() => { end.setHours(23, 59, 59, 59);
this.$refs.searchBarForm.formInline.timeVal = [ this.listQuery.startTime = yesterday.getTime();
yesterday.getTime(), this.listQuery.endTime = end.getTime();
end.getTime(), this.$nextTick(() => {
]; this.$refs.searchBarForm.formInline.timeVal = [
}); yesterday.getTime(),
this.getDataList(); end.getTime(),
this.getPdLineList(); ];
}, });
methods: { this.getDataList();
handleExport() { this.getPdLineList();
let tables = document.querySelector('.el-table').cloneNode(true); },
const fix = tables.querySelector('.el-table__fixed'); methods: {
const fixRight = tables.querySelector('.el-table__fixed-right'); handleExport() {
if (fix) { let tables = document.querySelector('.el-table').cloneNode(true);
tables.removeChild(tables.querySelector('.el-table__fixed')); const fix = tables.querySelector('.el-table__fixed');
} const fixRight = tables.querySelector('.el-table__fixed-right');
if (fixRight) { if (fix) {
tables.removeChild(tables.querySelector('.el-table__fixed-right')); tables.removeChild(tables.querySelector('.el-table__fixed'));
} }
let exportTable = XLSX.utils.table_to_book(tables); if (fixRight) {
tables.removeChild(tables.querySelector('.el-table__fixed-right'));
}
let exportTable = XLSX.utils.table_to_book(tables);
var exportTableOut = XLSX.write(exportTable, { var exportTableOut = XLSX.write(exportTable, {
bookType: 'xlsx', bookType: 'xlsx',
bookSST: true, bookSST: true,
type: 'array', type: 'array',
}); });
// sheetjs.xlsx为导出表格的标题名称 // sheetjs.xlsx为导出表格的标题名称
try { try {
FileSaver.saveAs( FileSaver.saveAs(
new Blob([exportTableOut], { new Blob([exportTableOut], {
type: 'application/octet-stream', type: 'application/octet-stream',
}), }),
this.fileName + '产线自动报表.xlsx' this.fileName + '产线自动报表.xlsx'
); );
} catch (e) { } catch (e) {
if (typeof console !== 'undefined') console.log(e, exportTableOut); if (typeof console !== 'undefined') console.log(e, exportTableOut);
} }
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,
}; };
getFactoryPage(params).then((res) => { getFactoryPage(params).then((res) => {
this.formConfig[0].selectOptions = res.data.list || []; this.formConfig[0].selectOptions = res.data.list || [];
}); });
}, },
buttonClick(val) { buttonClick(val) {
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
this.listQuery.factoryId = val.factoryId || undefined; this.listQuery.factoryId = val.factoryId || undefined;
this.listQuery.lineId = val.lineId ? val.lineId : []; this.listQuery.lineId = val.lineId ? val.lineId : [];
this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined; this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined;
this.listQuery.endTime = val.timeVal ? val.timeVal[1] : undefined; this.listQuery.endTime = val.timeVal ? val.timeVal[1] : undefined;
this.getDataList(); this.getDataList();
break; break;
case 'export': case 'export':
this.handleExport(); this.handleExport();
break; break;
default: default:
console.log(val); console.log(val);
} }
}, },
// 获取数据列表 // 获取数据列表
getDataList() { getDataList() {
this.dataListLoading = true; this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then((response) => { this.urlOptions.getDataListURL(this.listQuery).then((response) => {
this.tableData = response.data; this.tableData = response.data;
this.dataListLoading = false; this.dataListLoading = false;
this.showData = this.tableData; this.showData = this.tableData;
}); });
getNewCTCharts(this.listQuery).then((response) => { getNewCTCharts(this.listQuery).then((response) => {
this.chartData = response.data; this.chartData = response.data;
}); });
}, },
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 || [];
}); });
}, },
handleClick(val) { handleClick(val) {
this.addOrUpdateVisible = true; this.addOrUpdateVisible = true;
this.addOrEditTitle = this.addOrEditTitle =
val.data?.factoryName + '-' + val.data?.lineName + ' 详情'; val.data?.factoryName + '-' + val.data?.lineName + ' 详情';
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.eqDetail.init( this.$refs.eqDetail.init(
val.data.lineId, val.data.lineId,
this.listQuery.startTime, this.listQuery.startTime,
this.listQuery.endTime this.listQuery.endTime
); );
}); });
}, },
handleCancel() { handleCancel() {
this.addOrUpdateVisible = false; this.addOrUpdateVisible = false;
this.addOrEditTitle = ''; this.addOrEditTitle = '';
}, },
handleConfirm() { handleConfirm() {
this.handleCancel(); this.handleCancel();
}, },
}, },
}; };
</script> </script>

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