diff --git a/src/views/paintLabManagement/dataBatch.vue b/src/views/paintLabManagement/dataBatch.vue index 6f37922..fceba5d 100644 --- a/src/views/paintLabManagement/dataBatch.vue +++ b/src/views/paintLabManagement/dataBatch.vue @@ -1,7 +1,18 @@ + --> + + + + + part.padStart(2, "0")); + const year = parseInt(parts[0], 10); + const month = parseInt(parts[1], 10); + const day = parseInt(parts[2], 10); + + // 创建日期对象(使用UTC避免时区问题) + const dateObj = new Date(Date.UTC(year, month - 1, day)); + const isValidDate = + dateObj.getUTCFullYear() === year && + dateObj.getUTCMonth() === month - 1 && + dateObj.getUTCDate() === day; + + // 验证时间范围(>=2024-01-01) + const minDate = new Date(Date.UTC(2024, 0, 1)); + return isValidDate && dateObj >= minDate; + }, + + // 修改formatDate方法 + formatDate(date) { + if (!date) return "-"; + return this.$dayjs(date).isValid() + ? this.$dayjs(date).format("YYYY-MM-DD HH:mm:ss") + : "-"; + }, + handleEditActived({ row }) { if (!this.modifiedRows[row.id]) { // 深拷贝原始数据 this.$set(this.modifiedRows, row.id, JSON.parse(JSON.stringify(row))); @@ -506,6 +574,9 @@ export default { // 生成6条更新记录(即使部分未修改) Array.from({ length: 6 }).forEach((_, i) => { const row = groupRows[i] || {}; + if (group.baseRow == undefined) { + throw new Error("需要保存的数据不在当前页"); + } updateList.push({ id: row.id, plIdGroup: row.idGroup, @@ -576,40 +647,47 @@ export default { // } // }, - async fetchData() { - try { - this.isLoading = true; - - // Properly format dates for the API - const query = { - starttime: this.$dayjs(this.search.starttime).format('YYYY-MM-DDTHH:mm:ss'), - endtime: this.$dayjs(this.search.endtime).format('YYYY-MM-DDTHH:mm:ss'), - workorderid: this.search.workorderid || undefined, // Send undefined instead of null - description: this.search.description || undefined, - pageNum: this.pagination.pageNum, - pageSize: this.pagination.pageSize - }; + async fetchData() { + try { + this.isLoading = true; - const { code, data } = await GetTestlist(query); - if (code === 200) { - this.qualityStatisticsTable = data.item1.map(item => ({ - ...item, - dt: this.$dayjs(item.dt).isValid() - ? this.$dayjs(item.dt).format('YYYY-MM-DD HH:mm:ss') - : null - })); - - this.pagination.total = data.item2; - this.realTotal = Math.ceil(data.item2 / 6); - this.$nextTick(() => this.mergeTableRows(6)); - } - } catch (error) { - console.error('数据加载失败:', error); - this.$message.error('数据加载失败: ' + (error.response?.data?.message || error.message)); - } finally { - this.isLoading = false; - } -}, + // Properly format dates for the API + const query = { + starttime: this.$dayjs(this.search.starttime).format( + "YYYY-MM-DDTHH:mm:ss" + ), + endtime: this.$dayjs(this.search.endtime).format( + "YYYY-MM-DDTHH:mm:ss" + ), + workorderid: this.search.workorderid || undefined, // Send undefined instead of null + description: this.search.description || undefined, + pageNum: this.pagination.pageNum, + pageSize: this.pagination.pageSize, + dateType:this.search.dateType + }; + + const { code, data } = await GetTestlist(query); + if (code === 200) { + this.qualityStatisticsTable = data.item1.map((item) => ({ + ...item, + dt: this.$dayjs(item.dt).isValid() + ? this.$dayjs(item.dt).format("YYYY-MM-DD HH:mm:ss") + : null, + })); + + this.pagination.total = data.item2; + this.realTotal = Math.ceil(data.item2 / 6); + this.$nextTick(() => this.mergeTableRows(6)); + } + } catch (error) { + console.error("数据加载失败:", error); + this.$message.error( + "数据加载失败: " + (error.response?.data?.message || error.message) + ); + } finally { + this.isLoading = false; + } + }, // fetchData() { // this.isLoading = true; // setTimeout(() => { @@ -631,32 +709,44 @@ export default { // } // }); // }, - // 优化后的合并单元格方法 - mergeTableRows(rowsPerGroup) { - this.mergeCells = []; - const table = this.$refs.xTable; - if (!table) { - console.warn('表格引用未找到'); - return; - } + // 优化后的合并单元格方法 + mergeTableRows(rowsPerGroup) { + this.mergeCells = []; + const table = this.$refs.xTable; + if (!table) { + console.warn("表格引用未找到"); + return; + } - const columns = table.getColumns().filter(col => col.visible); - // 定义需要合并的列字段 - const mergeFields = ['dt', 'code', 'description', 'value06', 'value07', 'value08', 'value16']; - - for (let i = 0; i < this.qualityStatisticsTable.length; i += rowsPerGroup) { - columns.forEach((col, colIndex) => { - if (mergeFields.includes(col.property)) { - this.mergeCells.push({ - row: i, - col: colIndex, - rowspan: rowsPerGroup, - colspan: 1 + const columns = table.getColumns().filter((col) => col.visible); + // 定义需要合并的列字段 + const mergeFields = [ + "dt", + "code", + "description", + "value06", + "value07", + "value08", + "value16", + ]; + + for ( + let i = 0; + i < this.qualityStatisticsTable.length; + i += rowsPerGroup + ) { + columns.forEach((col, colIndex) => { + if (mergeFields.includes(col.property)) { + this.mergeCells.push({ + row: i, + col: colIndex, + rowspan: rowsPerGroup, + colspan: 1, + }); + } }); } - }); - } -}, + }, showAddDialog() { this.isAddDialogVisible = true; }, diff --git a/src/views/wmsManagement/WmBlankInventory.vue b/src/views/wmsManagement/WmBlankInventory.vue index 720ed67..d278944 100644 --- a/src/views/wmsManagement/WmBlankInventory.vue +++ b/src/views/wmsManagement/WmBlankInventory.vue @@ -21,6 +21,9 @@ > + + + @@ -279,6 +282,7 @@ export default { status: 1, sort: undefined, sortType: undefined, + description:null }, // 弹出层标题 title: '',