fix(易损件维护):

1.胶辊类型导入时,开始使用时间设置为yyyy-MM-dd格式;
This commit is contained in:
leiqiaozhen 2025-05-12 14:19:19 +08:00
parent 37d5ecb979
commit 51ea5095cf

View File

@ -444,6 +444,7 @@
</template>
<script>
import moment from 'moment'
import {fetchList, getZWearPartNoList,getDictItemValueList, addObj, putObj, delObj, doJGImport, doGLQImport} from '@/api/mes/prd/wear-part'
import { tableOption } from '@/views/mes/prd/wear-part/init'
import { mapGetters } from 'vuex'
@ -1004,7 +1005,6 @@ export default {
// 如果是胶辊类型
if ((rows[0][0] == 'JG')) {
for (let i = 1; i < rows.length; i++) {
debugger
let row = {
type: rows[i][0],
status: rows[i][1],
@ -1012,7 +1012,7 @@ export default {
description: rows[i][3],
productLine: rows[i][4],
useTimes: rows[i][5],
startTime: rows[i][6],
startTime: this.formatDate(rows[i][6]), // 处理日期字段
storageLocation: rows[i][7],
supplier: rows[i][8],
remark: rows[i][9]
@ -1079,6 +1079,31 @@ export default {
this.downBlobFile(iep('/z-wear-part-detail/export'), this.searchForm, this.site + '_易损件维护.xlsx')
},
// 工具方法:将 Excel 的日期序列号转换为 JS Date 对象
excelDateToJSDate(serial) {
if (typeof serial !== 'number') return null;
const utc_days = Math.floor(serial - 25569);
const utc_value = utc_days * 86400;
const date_info = new Date(utc_value * 1000);
const fractional_day = serial - Math.floor(serial) + 0.0000001;
let hour = Math.floor(24 * fractional_day);
const minute = Math.floor(60 * (24 * fractional_day - hour));
const second = Math.floor(60 * (60 * (24 * fractional_day - hour) - minute));
date_info.setHours(hour, minute, second);
return date_info;
},
// 开始使用日期设置为YYYY-MM-DD格式
formatDate(cell) {
if (!cell) return '';
const date = typeof cell === 'number' ? this.excelDateToJSDate(cell) : new Date(cell);
return moment(date).isValid() ? moment(date).format('YYYY-MM-DD') : '';
},
// 查看(開窗)
async handleView(row, index) {
let me = this