| | |
| | | <script setup> |
| | | |
| | | import {reactive, ref} from "vue"; |
| | | import {onMounted, reactive, ref} from "vue"; |
| | | import {useRouter} from 'vue-router' |
| | | import request from "@/utils/request"; |
| | | import deepClone from "@/utils/deepClone"; |
| | | import {ElDatePicker, ElMessage} from "element-plus"; |
| | | import {useI18n} from 'vue-i18n' |
| | | import footSum from "@/hook/footSum" |
| | | import {addListener, toolbarButtonClickEvent} from "@/hook/mouseMove" |
| | | import {VxeUI} from "vxe-pc-ui"; |
| | | import companyInfo from "@/stores/sd/companyInfo"; |
| | | //语言获取 |
| | | const {t} = useI18n() |
| | | let router = useRouter() |
| | | let filterData = ref({}) |
| | | const company = companyInfo() |
| | | //提交的表单 |
| | | const form = reactive({ |
| | | date1: '', |
| | |
| | | let pageNum = ref(1) |
| | | let pageState = null |
| | | |
| | | let newItem= ref({ |
| | | basic_name: '全部', |
| | | basic_type: 'product', |
| | | basic_category: 'process', |
| | | id: "001" |
| | | }) |
| | | //计算时间差 |
| | | function getDaysBetween(startTime, endTime, includeEnd = false) { |
| | | const start = new Date(startTime) |
| | | const end = new Date(endTime) |
| | | |
| | | //获取七天前到当前时间 |
| | | function getNowTime() { |
| | | const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3) |
| | | .toISOString() |
| | | .replace('T', ' ') |
| | | .slice(0, 10) //默认开始时间7天前 |
| | | const end = new Date(new Date().getTime()) |
| | | .toISOString() |
| | | .replace('T', ' ') |
| | | .slice(0, 10)//默认结束时间当前时间 |
| | | return [start, end] |
| | | // 转为时间戳计算差值 |
| | | const diffMs = end.setHours(0, 0, 0, 0) - start.setHours(0, 0, 0, 0) |
| | | const diffDays = diffMs / (1000 * 60 * 60 * 24) |
| | | |
| | | // 返回整数天数 |
| | | return includeEnd ? diffDays + 1 : diffDays |
| | | } |
| | | |
| | | const times=company.reportTime |
| | | //获取七天前到当前时间 |
| | | function getNowTime() { |
| | | const pad = (n) => n.toString().padStart(2, '0'); |
| | | |
| | | const formatDate = (date) => { |
| | | const year = date.getFullYear(); |
| | | const month = pad(date.getMonth() + 1); |
| | | const day = pad(date.getDate()); |
| | | return `${year}-${month}-${day} ${times}`; |
| | | }; |
| | | |
| | | const now = new Date(); |
| | | const startDate = new Date(now.getTime() - 3600 * 1000 * 24 * 3); // 三天前 |
| | | const start = formatDate(startDate); |
| | | const end = formatDate(now); |
| | | |
| | | return [start, end]; |
| | | } |
| | | |
| | | onMounted(() => { |
| | | //启用表格拖动选中 |
| | | addListener(xGrid.value, gridOptions) |
| | | |
| | | }) |
| | | |
| | | //第一次加载获取近七天时间和默认状态 |
| | | form.date1 = getNowTime() |
| | |
| | | let date = new Date(endTime); // 将日期字符串转为 Date 对象 |
| | | // 使用 setDate 方法加一天 |
| | | date.setDate(date.getDate() + 1); |
| | | let newEndTime = date.toISOString().split('T')[0]; // 获取 YYYY-MM-DD 格式的字符串 |
| | | const pad = (n) => n.toString().padStart(2, '0'); |
| | | let year = date.getFullYear(); |
| | | let month = pad(date.getMonth() + 1); |
| | | let day = pad(date.getDate()); |
| | | let newEndTime = `${year}-${month}-${day} ${times}`; |
| | | //第一次加载数据 |
| | | request.post(`/report/teamOutput/1/${total.pageSize}/${startTime}/${newEndTime}/${selectProcesses}`, filterData.value).then((res) => { |
| | | |
| | | if (res.code == 200) { |
| | | total.value = res.data.footSum |
| | | total.dataTotal = res.data.total.total*1 |
| | | total.pageTotal= res.data.total.pageTotal |
| | | pageTotal.value = res.data.total |
| | | produceList = produceList.value.concat(deepClone(res.data.data)) |
| | | titleSelectJson.value.processType = res.data.process |
| | | titleSelectJson.value.processType.unshift(newItem.value) |
| | | produceList.forEach(item => { |
| | | item.mmTotal = sumMmValues(item.workProcessName); |
| | | }); |
| | | xGrid.value.reloadData(produceList) |
| | | gridOptions.loading = false |
| | | } else { |
| | |
| | | |
| | | //页脚翻页查询 |
| | | const selectPageList = () => { |
| | | let startTime = form.date1[0] |
| | | let endTime = form.date1[1] |
| | | let selectProcesses = procseeValue.value |
| | | let date = new Date(endTime); // 将日期字符串转为 Date 对象 |
| | | // 使用 setDate 方法加一天 |
| | | date.setDate(date.getDate() + 1); |
| | | let newEndTime = date.toISOString().split('T')[0]; // 获取 YYYY-MM-DD 格式的字符串 |
| | | gridOptions.loading = true |
| | | // 解析 company.reportTime |
| | | const [reportHourStr, reportMinuteStr] = company.reportTime.split(":"); |
| | | const reportHour = parseInt(reportHourStr); |
| | | const reportMinute = parseInt(reportMinuteStr); |
| | | |
| | | // 原始 form.date1 是日期对象数组 |
| | | const rawStart = new Date(form.date1[0]); |
| | | const rawEnd = new Date(form.date1[1]); |
| | | |
| | | // 判断时间部分是否需要修正为 company.reportTime |
| | | const isZeroOrReport = (dateObj) => { |
| | | const h = dateObj.getHours(); |
| | | const m = dateObj.getMinutes(); |
| | | // 判断条件:是 00:00 或者是 reportTime 对应的时间 |
| | | return (h === 0 && m === 0) || (h === reportHour && m === reportMinute); |
| | | }; |
| | | |
| | | if (isZeroOrReport(rawStart)) { |
| | | rawStart.setHours(reportHour, reportMinute, 0, 0); |
| | | } |
| | | if (isZeroOrReport(rawEnd)) { |
| | | rawEnd.setHours(reportHour, reportMinute, 0, 0); |
| | | } |
| | | const startTime = formatDateTime(rawStart); |
| | | const endPlusOne = new Date(rawEnd); |
| | | endPlusOne.setDate(endPlusOne.getDate()); |
| | | const newEndTime = formatDateTime(endPlusOne); |
| | | const selectProcesses = procseeValue.value; |
| | | form.date1 = [startTime, newEndTime]; |
| | | request.post(`/report/teamOutput/${pageNum.value}/${total.pageSize}/${startTime}/${newEndTime}/${selectProcesses}`, filterData.value).then((res) => { |
| | | if (res.code == 200) { |
| | | |
| | | |
| | | total.value = res.data.footSum |
| | | produceList = deepClone(res.data.data) |
| | | produceList.forEach(item => { |
| | | item.mmTotal = sumMmValues(item.workProcessName); |
| | | }); |
| | | xGrid.value.reloadData(produceList) |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | //点击查询 |
| | | const getWorkOrder = () => { |
| | | |
| | | let startTime = form.date1[0] |
| | | let endTime = form.date1[1] |
| | | let selectProcesses = procseeValue.value |
| | | let date = new Date(endTime); // 将日期字符串转为 Date 对象 |
| | | // 使用 setDate 方法加一天 |
| | | date.setDate(date.getDate() + 1); |
| | | let newEndTime = date.toISOString().split('T')[0]; // 获取 YYYY-MM-DD 格式的字符串 |
| | | request.post(`/report/teamOutput/${pageNum.value}/${total.pageSize}/${startTime}/${newEndTime}/${selectProcesses}`, filterData.value).then((res) => { |
| | | |
| | | if (res.code == 200) { |
| | | total.dataTotal = res.data.total.total * 1 |
| | | total.pageTotal = res.data.total.pageTotal |
| | | pageTotal.value = res.data.total |
| | | xGrid.value.loadData(res.data.data) |
| | | gridOptions.loading = false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | } |
| | | }) |
| | | } |
| | | const formatDateTime = (date) => { |
| | | const year = date.getFullYear(); |
| | | const month = pad(date.getMonth() + 1); |
| | | const day = pad(date.getDate()); |
| | | const hour = pad(date.getHours()); |
| | | const minute = pad(date.getMinutes()); |
| | | return `${year}-${month}-${day} ${hour}:${minute}:00`; |
| | | }; |
| | | |
| | | |
| | | //点击查询 |
| | | const getWorkOrder = () => { |
| | | gridOptions.loading = true; |
| | | |
| | | // 解析 company.reportTime |
| | | const [reportHourStr, reportMinuteStr] = company.reportTime.split(":"); |
| | | const reportHour = parseInt(reportHourStr); |
| | | const reportMinute = parseInt(reportMinuteStr); |
| | | |
| | | // 原始 form.date1 是日期对象数组 |
| | | const rawStart = new Date(form.date1[0]); |
| | | const rawEnd = new Date(form.date1[1]); |
| | | |
| | | // 判断时间部分是否需要修正为 company.reportTime |
| | | const isZeroOrReport = (dateObj) => { |
| | | const h = dateObj.getHours(); |
| | | const m = dateObj.getMinutes(); |
| | | // 判断条件:是 00:00 或者是 reportTime 对应的时间 |
| | | return (h === 0 && m === 0) || (h === reportHour && m === reportMinute); |
| | | }; |
| | | |
| | | if (isZeroOrReport(rawStart)) { |
| | | rawStart.setHours(reportHour, reportMinute, 0, 0); |
| | | } |
| | | if (isZeroOrReport(rawEnd)) { |
| | | rawEnd.setHours(reportHour, reportMinute, 0, 0); |
| | | } |
| | | |
| | | // 格式化 |
| | | const startTime = formatDateTime(rawStart); |
| | | |
| | | const endPlusOne = new Date(rawEnd); |
| | | endPlusOne.setDate(endPlusOne.getDate()); |
| | | const newEndTime = formatDateTime(endPlusOne); |
| | | |
| | | const selectProcesses = procseeValue.value; |
| | | |
| | | const timeDifference = getDaysBetween(startTime, newEndTime); |
| | | if (timeDifference > 180) { |
| | | ElMessage.warning(t('report.theTimeLimitCannotExceed180Days')); |
| | | gridOptions.loading = false; |
| | | return; |
| | | } |
| | | |
| | | form.date1 = [startTime, newEndTime]; |
| | | |
| | | request.post(`/report/teamOutput/${pageNum.value}/${total.pageSize}/${startTime}/${newEndTime}/${selectProcesses}`, filterData.value) |
| | | .then((res) => { |
| | | if (res.code == 200) { |
| | | total.value = res.data.footSum; |
| | | total.dataTotal = res.data.total.total * 1; |
| | | total.pageTotal = res.data.total.pageTotal; |
| | | pageTotal.value = res.data.total; |
| | | |
| | | produceList = res.data.data; |
| | | produceList.forEach(item => { |
| | | item.mmTotal = sumMmValues(item.workProcessName); |
| | | }); |
| | | |
| | | xGrid.value.loadData(produceList); |
| | | gridOptions.loading = false; |
| | | } else { |
| | | ElMessage.warning(res.msg); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | const sumMmValues = (workProcessName) => { |
| | | if (!workProcessName) return 0; |
| | | |
| | | return workProcessName |
| | | .split('+') // 拆分每个部分 |
| | | .map(part => { |
| | | const match = part.match(/^(\d+)(?=mm)/); // 提取 mm 前面的数字 |
| | | return match ? parseInt(match[1], 10) : 0; |
| | | }) |
| | | .reduce((sum, num) => sum + num, 0); // 求和 |
| | | } |
| | | //页脚跳转 |
| | | const handlePageChange = ({currentPage, pageSize}) => { |
| | | pageNum.value = currentPage |
| | |
| | | } |
| | | |
| | | function filterChanged(column){ |
| | | gridOptions.loading = true |
| | | let selectProcesses = procseeValue.value |
| | | //gridOptions.loading=true |
| | | //筛选条件发生变化条件发生变化 |
| | |
| | | }else{ |
| | | filterData.value[column.property] = value |
| | | } |
| | | gridOptions.loading = true |
| | | |
| | | let startTime = form.date1[0] |
| | | let endTime = form.date1[1] |
| | | let date = new Date(endTime); // 将日期字符串转为 Date 对象 |
| | | // 使用 setDate 方法加一天 |
| | | date.setDate(date.getDate() + 1); |
| | | let newEndTime = date.toISOString().split('T')[0]; // 获取 YYYY-MM-DD 格式的字符串 |
| | | // 解析 company.reportTime |
| | | const [reportHourStr, reportMinuteStr] = company.reportTime.split(":"); |
| | | const reportHour = parseInt(reportHourStr); |
| | | const reportMinute = parseInt(reportMinuteStr); |
| | | |
| | | // 原始 form.date1 是日期对象数组 |
| | | const rawStart = new Date(form.date1[0]); |
| | | const rawEnd = new Date(form.date1[1]); |
| | | |
| | | // 判断时间部分是否需要修正为 company.reportTime |
| | | const isZeroOrReport = (dateObj) => { |
| | | const h = dateObj.getHours(); |
| | | const m = dateObj.getMinutes(); |
| | | // 判断条件:是 00:00 或者是 reportTime 对应的时间 |
| | | return (h === 0 && m === 0) || (h === reportHour && m === reportMinute); |
| | | }; |
| | | |
| | | if (isZeroOrReport(rawStart)) { |
| | | rawStart.setHours(reportHour, reportMinute, 0, 0); |
| | | } |
| | | if (isZeroOrReport(rawEnd)) { |
| | | rawEnd.setHours(reportHour, reportMinute, 0, 0); |
| | | } |
| | | const startTime = formatDateTime(rawStart); |
| | | const endPlusOne = new Date(rawEnd); |
| | | endPlusOne.setDate(endPlusOne.getDate()); |
| | | const newEndTime = formatDateTime(endPlusOne); |
| | | form.date1 = [startTime, newEndTime]; |
| | | request.post(`/report/teamOutput/1/${total.pageSize}/${startTime}/${newEndTime}/${selectProcesses}`, filterData.value).then((res) => { |
| | | |
| | | if (res.code == 200) { |
| | | total.dataTotal = res.data.total.total*1 |
| | | total.pageTotal=parseInt(res.data.total) |
| | | pageNum.value=1 |
| | | total.value = res.data.footSum |
| | | produceList = deepClone(res.data.data) |
| | | xGrid.value.reloadData(produceList) |
| | | produceList.forEach(item => { |
| | | item.mmTotal = sumMmValues(item.workProcessName); |
| | | }); |
| | | xGrid.value.loadData(produceList) |
| | | |
| | | gridOptions.loading=false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | |
| | | //子组件接收参数 |
| | | const xGrid = ref() |
| | | const gridOptions = reactive({ |
| | | loading: true, |
| | | border: "full",//表格加边框 |
| | | keepSource: true,//保持源数据 |
| | | align: 'center',//文字居中 |
| | |
| | | { |
| | | field: 'project', width: 120, title: t('order.project'),filters:[{ data: '' }],slots: { filter: 'num1_filter' } |
| | | }, |
| | | {field: 'batch', width: 90, title: t('order.batch'), |
| | | filters:[{ data: '' }],slots: { filter: 'num1_filter' }}, |
| | | {field: 'orderType', width: 90, title: t('order.orderType')}, |
| | | { |
| | | field: 'processId', width: 140, title: t('processCard.processId'),filters:[{ data: '' }],slots: { filter: 'num1_filter' } |
| | | }, |
| | | {field: 'orderNumber', width: 90, title: t('order.OrderNum')}, |
| | | {field: 'code', width: 60, title: t('reportingWorks.glassNumber')}, |
| | | {field: 'width', width: 100, title: t('order.width')}, |
| | | {field: 'height', width: 100, title: t('order.height')}, |
| | | {field: 'code', width: 100, title: t('reportingWorks.glassNumber')}, |
| | | {field: 'width', width: 90, title: t('order.width')}, |
| | | {field: 'height', width: 90, title: t('order.height')}, |
| | | {field: 'thicknessSum',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, width: 90, title: t('order.totalThickness')}, |
| | | {field: 'thicknessArea', width: 90, title: t('report.thicknessArea')}, |
| | | { |
| | | field: 'deviceName', width: 140, title: t('machine.basicName'),filters:[{ data: '' }],slots: { filter: 'num1_filter' } |
| | | }, |
| | | {field: 'workProcessName', width: 120, title: t('report.workProcessName'), |
| | | filters:[{ data: '' }],slots: { filter: 'num1_filter' }}, |
| | | {field: 'edgingType', width: 110, title: t('order.edgingType'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }}, |
| | | {field: 'completedQuantity', width: 90, title: t('reportingWorks.completedQuantity')}, |
| | | {field: 'area', width: 100, title: t('reportingWorks.completedArea')}, |
| | | {field: 'productName', title: t('order.product')}, |
| | | {field: 'reviewed',width: 80, title: t('processCard.reviewed')}, |
| | | {field: 'examineTime',width: 80, title: t('ingredientsStock.reviewedTime')}, |
| | | {field: 'productName',width: 150, title: t('order.product')}, |
| | | ],//表头按钮 |
| | | |
| | | toolbarConfig: { |
| | |
| | | if (columnIndex === 0) { |
| | | return t('basicData.total') |
| | | } |
| | | const List = ["completedQuantity",'area',] |
| | | const List = ["completedQuantity",'area','thicknessArea'] |
| | | if (List.includes(column.field)) { |
| | | return footSum(data, column.field) |
| | | //return footSum(data, column.field) |
| | | return total.value?.[column.field] ?? 0 |
| | | } |
| | | return '' |
| | | }) |
| | |
| | | }) |
| | | |
| | | function exportExcel(url, fileName,date) { |
| | | gridOptions.loading = true |
| | | let processes = procseeValue.value |
| | | if(date===null){ |
| | | ElMessage.warning(t('report.pleaseSelectADateFirst')) |
| | |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | document.body.removeChild(elink) |
| | | gridOptions.loading = false |
| | | } else { // IE10+下载 |
| | | navigator.msSaveBlob(blob, fileName) |
| | | } |
| | | |
| | | }) |
| | | } |
| | | |
| | | const handleCellDblClick = ({ row, column, cell, $event }) => { |
| | | VxeUI.clipboard.copy(row[column.property]) |
| | | } |
| | | </script> |
| | | |
| | |
| | | v-model="form.date1" |
| | | :start-placeholder="$t('basicData.startDate')" |
| | | :end-placeholder="$t('basicData.endDate')" |
| | | format="YYYY/MM/DD" |
| | | style="width: 250px" |
| | | format="YYYY/MM/DD HH:mm" |
| | | style="width: 350px" |
| | | type="daterange" |
| | | value-format="YYYY-MM-DD" |
| | | value-format="YYYY/MM/DD HH:mm" |
| | | /> |
| | | |
| | | <el-select v-model="procseeValue" clearable default-value="default_city" style="width: 120px"> |
| | | <el-option |
| | | :label="t('report.allProcess')" |
| | | :value="'all'" |
| | | /> |
| | | <el-option |
| | | v-for="item in titleSelectJson['processType']" |
| | | :key="item.id" |
| | |
| | | height="100%" |
| | | v-bind="gridOptions" |
| | | @filter-change="filterChanged" |
| | | @cell-dblclick="handleCellDblClick" |
| | | |
| | | > |
| | | <!-- @toolbar-button-click="toolbarButtonClickEvent"--> |
| | |
| | | width: 100%; |
| | | height: calc(100% - 35px); |
| | | } |
| | | .vxe-grid { |
| | | /* 禁用浏览器默认选中 */ |
| | | -webkit-user-select: none; |
| | | -moz-user-select: none; |
| | | -ms-user-select: none; |
| | | user-select: none; |
| | | } |
| | | </style> |