Compare commits

...

17 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
1d698848c2 Merge pull request 'projects/line-new-zhp' (#461) from projects/line-new-zhp into projects/line-new
Reviewed-on: #461
2025-12-12 14:18:34 +08:00
‘937886381’
6d367b121c Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-12 14:17:56 +08:00
‘937886381’
e2385cf813 修改 2025-12-12 14:17:21 +08:00
25 changed files with 10960 additions and 9916 deletions

View File

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

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

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

View File

@@ -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

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

View File

@@ -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

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

View File

@@ -128,7 +128,7 @@ export default {
this.tableData = response.data; this.tableData = response.data;
this.dataListLoading = false; this.dataListLoading = false;
}); });
}, },
handleClick(val) { handleClick(val) {
const data = { const data = {
...this.time, ...this.time,

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

View File

@@ -80,6 +80,16 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<!-- <el-row :gutter="20">
<el-col :span="12">
<el-form-item label=" 基板类型" prop="typeDictValue">
<el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable
style="width: 100%" placeholder="请选择基板类型">
<el-option v-for="dict in typeList" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
</el-row> -->
</el-form> </el-form>
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true"> <small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
@@ -131,160 +141,184 @@
<script> <script>
import { import {
deleteProductAttr, deleteProductAttr,
getProductAttrPage, getProductAttrPage,
} from '@/api/core/base/productAttr'; } from '@/api/core/base/productAttr';
import { import {
createProduct, createProduct,
updateProduct, updateProduct,
getProduct, getProduct,
getCode, getCode,
} from '@/api/core/base/product'; } from '@/api/core/base/product';
import productAttrAdd from './attr-add'; import productAttrAdd from './attr-add';
import { parseTime } from '../../mixins/code-filter'; import { parseTime } from '../../mixins/code-filter';
import SmallTitle from './SmallTitle'; import SmallTitle from './SmallTitle';
import { listData } from "@/api/system/dict/data"; //数据字典接口
const tableBtn = [ const tableBtn = [
{ {
type: 'edit', type: 'edit',
btnName: '编辑', btnName: '编辑',
}, },
{ {
type: 'delete', type: 'delete',
btnName: '删除', btnName: '删除',
}, },
]; ];
const tableProps = [ const tableProps = [
{ {
prop: 'createTime', prop: 'createTime',
label: '添加时间', label: '添加时间',
filter: parseTime, filter: parseTime,
}, },
{ {
prop: 'name', prop: 'name',
label: '属性名', label: '属性名',
}, },
{ {
prop: 'value', prop: 'value',
label: '属性值', label: '属性值',
}, },
]; ];
export default { export default {
components: { productAttrAdd, SmallTitle }, components: { productAttrAdd, SmallTitle },
data() { data() {
return { return {
visible: false, visible: false,
addOrUpdateVisible: false, addOrUpdateVisible: false,
tableBtn, tableBtn,
tableProps, tableProps,
productAttributeList: [], productAttributeList: [],
dataForm: { dataForm: {
id: null, id: null,
name: '', // 产品名称 name: '', // 产品名称
code: '', // 产品编码 code: '', // 产品编码
area: 0, // 深加工单位平方数(float only) area: 0, // 深加工单位平方数(float only)
typeDictValue: null, // 产品类型id typeDictValue: null, // 产品类型id
processTime: null, // 单位产品用时 (s) processTime: null, // 单位产品用时 (s)
specifications: '', // 深加工规格 specifications: '', // 深加工规格
unitDictValue: '', // 单位id unitDictValue: '', // 单位id
originalSpecifications: '', // 原片规格 originalSpecifications: '', // 原片规格
originalArea: 0, // 原片单位平方数 originalArea: 0, // 原片单位平方数
processTypes: [], processTypes: [],
}, typeDictValue: null,
listQuery: { },
pageSize: 10, typeList:[],
pageNo: 1, listQuery: {
total: 0, pageSize: 10,
pageNo: 1,
total: 0,
}, },
processTypeList: [ processTypeList: [
{ // {
value: '1', // value: '1',
label:'压花丝印' // label: '压花丝印'
}, // },
{ // {
value: '2', // value: '2',
label: '无印打孔' // label: '无印打孔'
}, // },
{ // {
value: '3', // value: '3',
label: '单层镀膜' // label: '单层镀膜'
}, { // }, {
value: '4', // value: '4',
label: '双层镀膜' // label: '双层镀膜'
} // }
], ],
dataRule: { dataRule: {
code: [ code: [
{ {
required: true, required: true,
message: '产品编码不能为空', message: '产品编码不能为空',
trigger: 'blur', trigger: 'blur',
}, },
// { // {
// type: 'number', // type: 'number',
// message: '产品编码为数字类型', // message: '产品编码为数字类型',
// trigger: 'blur', // trigger: 'blur',
// transfom: 'val => Number(val)', // transfom: 'val => Number(val)',
// }, // },
], ],
name: [ name: [
{ {
required: true, required: true,
message: '产品名称不能为空', message: '产品名称不能为空',
trigger: 'blur', trigger: 'blur',
}, },
], ],
typeDictValue: [ typeDictValue: [
{ {
required: true, required: true,
message: '产品类型不能为空', message: '产品类型不能为空',
trigger: 'blur', trigger: 'blur',
}, },
], ],
area: [ area: [
{ {
type: 'number', type: 'number',
message: '请输入正确的数值', message: '请输入正确的数值',
trigger: 'change', trigger: 'change',
transform: (val) => Number(val), transform: (val) => Number(val),
}, },
], ],
processTime: [ processTime: [
{ {
required: true, required: true,
message: '完成单位产品用时不能为空', message: '完成单位产品用时不能为空',
trigger: 'blur', trigger: 'blur',
}, },
{ {
type: 'number', type: 'number',
message: '请输入正确的数值', message: '请输入正确的数值',
trigger: 'blur', trigger: 'blur',
transform: (val) => Number(val), transform: (val) => Number(val),
}, },
], ],
}, },
isdetail: false, isdetail: false,
}; };
}, },
methods: { methods: {
initData() { async initData() {
this.productAttributeList.splice(0); this.productAttributeList.splice(0);
this.listQuery.total = 0; this.listQuery.total = 0;
}, const typeRes = await listData({
init(id, isdetail) { pageNo:
this.initData(); 1,
this.isdetail = isdetail || false; pageSize
: 10,
dictType
: 'product_type'
})
this.typeList = typeRes.data.list
console.log('typeRes', this.typeList);
const processTypeRes = await listData({
pageNo:
1,
pageSize
: 10,
dictType
: 'process_type'
})
this.processTypeList = processTypeRes.data.list
console.log('typeRes', this.typeList);
},
init(id, isdetail) {
this.initData();
this.isdetail = isdetail || false;
this.dataForm.id = id || null; this.dataForm.id = id || null;
// this.dataForm.processTypes = [] // 清空工艺选择 // this.dataForm.processTypes = [] // 清空工艺选择
this.visible = true; this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['dataForm'].resetFields(); this.$refs['dataForm'].resetFields();
if (this.dataForm.id) { if (this.dataForm.id) {
// 获取产品详情 // 获取产品详情
getProduct(id).then((res) => { getProduct(id).then((res) => {
const resData = res.data || {}; const resData = res.data || {};
// 逐个字段赋值(保留响应式) // 逐个字段赋值(保留响应式)
@@ -305,161 +339,163 @@ export default {
console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式 console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式
}); });
// 获取产品的属性列表 // 获取产品的属性列表
this.getList(); this.getList();
} else { } else {
getCode().then((res) => { getCode().then((res) => {
this.dataForm.code = res.data; this.dataForm.code = res.data;
}); });
} }
}); });
}, },
getList() { getList() {
// 获取产品的属性列表 // 获取产品的属性列表
getProductAttrPage({ getProductAttrPage({
...this.listQuery, ...this.listQuery,
productId: this.dataForm.id, productId: this.dataForm.id,
}).then((response) => { }).then((response) => {
this.productAttributeList = response.data.list; this.productAttributeList = response.data.list;
this.listQuery.total = response.data.total; this.listQuery.total = response.data.total;
}); });
}, },
handleClick(raw) { handleClick(raw) {
if (raw.type === 'delete') { if (raw.type === 'delete') {
this.$confirm( this.$confirm(
`确定对${ `确定对${raw.data.name
raw.data.name ? '[名称=' + raw.data.name + ']'
? '[名称=' + raw.data.name + ']' : '[序号=' + raw.data._pageIndex + ']'
: '[序号=' + raw.data._pageIndex + ']' }进行删除操作?`,
}进行删除操作?`, '提示',
'提示', {
{ confirmButtonText: '确定',
confirmButtonText: '确定', cancelButtonText: '取消',
cancelButtonText: '取消', type: 'warning',
type: 'warning', }
} )
) .then(() => {
.then(() => { deleteProductAttr(raw.data.id).then(({ data }) => {
deleteProductAttr(raw.data.id).then(({ data }) => { this.$message({
this.$message({ message: '操作成功',
message: '操作成功', type: 'success',
type: 'success', duration: 1500,
duration: 1500, onClose: () => {
onClose: () => { this.getList();
this.getList(); },
}, });
}); });
}); })
}) .catch(() => { });
.catch(() => {}); } else {
} else { this.addNew(raw.data.id);
this.addNew(raw.data.id); }
} },
}, // 表单提交
// 表单提交 dataFormSubmit() {
dataFormSubmit() { this.$refs['dataForm'].validate((valid) => {
this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
// 修改的提交
if (this.dataForm.id) { // 修改的提交
updateProduct(this.dataForm).then((response) => { if (this.dataForm.id) {
this.$modal.msgSuccess('修改成功'); updateProduct(this.dataForm).then((response) => {
this.visible = false; this.$modal.msgSuccess('修改成功');
this.$emit('refreshDataList'); this.visible = false;
}); this.$emit('refreshDataList');
return; });
} return;
// 添加的提交 }
createProduct(this.dataForm).then((response) => { // 添加的提交
this.$modal.msgSuccess('新增成功'); createProduct(this.dataForm).then((response) => {
this.$confirm(`是否新增产品属性?`, '系统提示', { this.$modal.msgSuccess('新增成功');
confirmButtonText: '确定', this.$confirm(`是否新增产品属性?`, '系统提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning', cancelButtonText: '取消',
}) type: 'warning',
.then(() => { })
.then(() => {
this.dataForm.id = response.data this.dataForm.id = response.data
this.addNew(); this.addNew();
}) })
.catch(() => { .catch(() => {
this.visible = false; this.visible = false;
this.$emit('refreshDataList'); this.$emit('refreshDataList');
}); });
}); });
} }
}); });
}, },
goEdit() { goEdit() {
this.isdetail = false; this.isdetail = false;
}, },
// 新增 / 修改 // 新增 / 修改
addNew(id) { addNew(id) {
if (this.dataForm.id) { if (this.dataForm.id) {
this.addOrUpdateVisible = true; this.addOrUpdateVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.addOrUpdate.init(id); this.$refs.addOrUpdate.init(id);
}); });
} else { } else {
this.$message('请先创建产品!'); this.$message('请先创建产品!');
} }
}, },
goback() { goback() {
this.$emit('refreshDataList'); this.$emit('refreshDataList');
this.visible = false; this.visible = false;
this.initData(); this.initData();
}, },
}, },
}; };
</script> </script>
<style scoped> <style scoped>
.drawer >>> .el-drawer { .drawer>>>.el-drawer {
border-radius: 8px 0 0 8px; border-radius: 8px 0 0 8px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.drawer >>> .el-form-item__label { .drawer>>>.el-form-item__label {
padding: 0; padding: 0;
} }
.drawer >>> .el-drawer__header { .drawer>>>.el-drawer__header {
margin: 0; margin: 0;
padding: 32px 32px 24px; padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6; border-bottom: 1px solid #dcdfe6;
}
.drawer >>> .el-drawer__body {
flex: 1;
height: 1px;
display: flex;
flex-direction: column;
} }
.drawer >>> .content { .drawer>>>.el-drawer__body {
padding: 30px 24px; flex: 1;
flex: 1; height: 1px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* height: 100%; */
} }
.drawer >>> .visual-part { .drawer>>>.content {
flex: 1 auto; padding: 30px 24px;
max-height: 76vh; flex: 1;
overflow: hidden; display: flex;
overflow-y: scroll; flex-direction: column;
padding-right: 10px; /* 调整滚动条样式 */ /* height: 100%; */
} }
.drawer >>> .el-form, .drawer>>>.visual-part {
.drawer >>> .attr-list { flex: 1 auto;
padding: 0 16px; max-height: 76vh;
overflow: hidden;
overflow-y: scroll;
padding-right: 10px;
/* 调整滚动条样式 */
}
.drawer>>>.el-form,
.drawer>>>.attr-list {
padding: 0 16px;
} }
.drawer-body__footer { .drawer-body__footer {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
padding: 18px; padding: 18px;
} }
</style> </style>

View File

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

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

View File

@@ -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

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

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