列表时间统一只展示年月日,库存最近更新时间用创建时间兜底
- 新增 toDateOnly 工具,el-table 原生列通过全局 formatter 兜底
- parseTime/formatDate 默认改为年月日,PIMTable 显式转换
- 库存管理各列表:update_time 为空时显示 create_time
Co-Authored-By: Claude Code <noreply@anthropic.com>
| | |
| | | class="cell link" |
| | | style="width: 100%" |
| | | @click="goLink(scope.row, item.linkMethod)"> |
| | | <span v-if="!item.formatData">{{ scope.row[item.prop] }}</span> |
| | | <span v-if="!item.formatData">{{ |
| | | toDateOnly(scope.row[item.prop]) |
| | | }}</span> |
| | | </div> |
| | | <!-- é»è®¤çº¯å±ç¤ºæ°æ® --> |
| | | <div v-else |
| | | class="cell" |
| | | style="width: 100%"> |
| | | <span v-if="!item.formatData">{{ scope.row[item.prop] }}</span> |
| | | <span v-if="!item.formatData">{{ |
| | | toDateOnly(scope.row[item.prop]) |
| | | }}</span> |
| | | <span v-else>{{ |
| | | formatters(scope.row[item.prop], item.formatData) |
| | | toDateOnly(formatters(scope.row[item.prop], item.formatData)) |
| | | }}</span> |
| | | </div> |
| | | </template> |
| | |
| | | import pagination from "./Pagination.vue"; |
| | | import { computed, ref, inject, getCurrentInstance } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { toDateOnly } from "@/utils/dateDisplay"; |
| | | |
| | | // è·åå
¨å±ç uploadHeader |
| | | const { proxy } = getCurrentInstance(); |
| | |
| | | import PageHeader from "@/components/PageHeader/index.vue"; |
| | | |
| | | import { getToken } from "@/utils/auth"; |
| | | import { toDateOnly } from "@/utils/dateDisplay"; |
| | | import { |
| | | calculateTaxExclusiveTotalPrice, |
| | | summarizeTable, |
| | |
| | | app.config.globalProperties.addDateRange = addDateRange; |
| | | app.config.globalProperties.selectDictLabel = selectDictLabel; |
| | | app.config.globalProperties.selectDictLabels = selectDictLabels; |
| | | app.config.globalProperties.formatDateOnly = toDateOnly; |
| | | app.config.globalProperties.javaApi = __BASE_API__; |
| | | app.config.globalProperties.HaveJson = (val) => { |
| | | return JSON.parse(JSON.stringify(val)); |
| | |
| | | }); |
| | | app._context.components.ElDialog.props.closeOnClickModal.default = false; |
| | | |
| | | // å表æ¶é´ç»ä¸åªå±ç¤ºå¹´ææ¥ï¼æªåç¬é
ç½® formatter çè¡¨æ ¼åèµ°è¿é |
| | | const tableColumnFormatter = |
| | | app._context.components.ElTableColumn?.props?.formatter; |
| | | if (tableColumnFormatter) { |
| | | const formatCell = (row, column, cellValue) => toDateOnly(cellValue); |
| | | if (typeof tableColumnFormatter === "function") { |
| | | app._context.components.ElTableColumn.props.formatter = { |
| | | type: Function, |
| | | default: formatCell, |
| | | }; |
| | | } else { |
| | | tableColumnFormatter.default = formatCell; |
| | | } |
| | | } |
| | | |
| | | app.mount("#app"); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | /** |
| | | * å表å±ç¤ºç¨çæ¥æå¤çï¼å¸¦æ¶åç§çæ¥ææ¶é´åªä¿çå¹´ææ¥ï¼ |
| | | * æ¬æ¥å°±æ¯æ¥æãæ¶é´æå
¶å®å
容çå¼åæ ·è¿åã |
| | | */ |
| | | const DATE_TIME_PATTERN = |
| | | /^(\d{4})[-/å¹´](\d{1,2})[-/æ](\d{1,2})æ¥?[ T]\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/; |
| | | |
| | | function pad2(value) { |
| | | return String(value).padStart(2, "0"); |
| | | } |
| | | |
| | | export function toDateOnly(value) { |
| | | if (value == null || value === "") return value; |
| | | |
| | | if (value instanceof Date) { |
| | | if (Number.isNaN(value.getTime())) return value; |
| | | return `${value.getFullYear()}-${pad2(value.getMonth() + 1)}-${pad2( |
| | | value.getDate() |
| | | )}`; |
| | | } |
| | | |
| | | if (typeof value !== "string") { |
| | | // 对象/æ°ç»æè¡¨æ ¼åææ¹å¼è½¬æææ¬ï¼é¿å
æéåç¬¦ä¸²ç´æ¥äº¤ç»æ¸²æå± |
| | | return typeof value === "object" ? String(value) : value; |
| | | } |
| | | |
| | | const text = value.trim(); |
| | | const matched = text.match(DATE_TIME_PATTERN); |
| | | if (!matched) return value; |
| | | |
| | | return `${matched[1]}-${pad2(matched[2])}-${pad2(matched[3])}`; |
| | | } |
| | |
| | | ? "0" + (date.getMonth() + 1)
|
| | | : date.getMonth() + 1;
|
| | | var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
| | | var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
| | | var minutes =
|
| | | date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
| | | var seconds =
|
| | | date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
| | | return (
|
| | | year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds
|
| | | );
|
| | | return year + "-" + month + "-" + day;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | if (arguments.length === 0 || !time) {
|
| | | return null
|
| | | }
|
| | | const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
|
| | | const format = pattern || '{y}-{m}-{d}'
|
| | | let date
|
| | | if (typeof time === 'object') {
|
| | | date = time
|
| | |
| | | // æ ¼å¼åæ¥ææ¶é´ |
| | | const formatDateTime = (dateTime) => { |
| | | if (!dateTime) return '' |
| | | return dateTime.replace(' ', '\n') |
| | | const matched = String(dateTime).match( |
| | | /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/ |
| | | ) |
| | | if (!matched) return dateTime |
| | | return `${matched[1]}-${matched[2].padStart(2, '0')}-${matched[3].padStart(2, '0')}` |
| | | } |
| | | |
| | | // 页é¢å è½½æ¶è·åæ°æ® |
| | |
| | | // æ ¼å¼åæ¥ææ¶é´ |
| | | const formatDateTime = (dateTime) => { |
| | | if (!dateTime) return '' |
| | | return dateTime.replace(' ', '\n') |
| | | const matched = String(dateTime).match( |
| | | /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/ |
| | | ) |
| | | if (!matched) return dateTime |
| | | return `${matched[1]}-${matched[2].padStart(2, '0')}-${matched[3].padStart(2, '0')}` |
| | | } |
| | | |
| | | // æäº¤å®¡æ¹ |
| | |
| | | // æ ¼å¼åæ¥ææ¶é´ |
| | | const formatDateTime = (dateTime) => { |
| | | if (!dateTime) return '' |
| | | return dateTime.replace(' ', '\n') |
| | | const matched = String(dateTime).match( |
| | | /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/ |
| | | ) |
| | | if (!matched) return dateTime |
| | | return `${matched[1]}-${matched[2].padStart(2, '0')}-${matched[3].padStart(2, '0')}` |
| | | } |
| | | |
| | | // æäº¤åå¸ |
| | |
| | | // æ ¼å¼åæ¥ææ¶é´ |
| | | const formatDateTime = (dateTime) => { |
| | | if (!dateTime) return '' |
| | | return dateTime.replace(' ', '\n') |
| | | const matched = String(dateTime).match( |
| | | /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/ |
| | | ) |
| | | if (!matched) return dateTime |
| | | return `${matched[1]}-${matched[2].padStart(2, '0')}-${matched[3].padStart(2, '0')}` |
| | | } |
| | | |
| | | // 页é¢å è½½æ¶è·åæ°æ® |
| | |
| | | formatData: cell => { |
| | | if (!cell) return "-"; |
| | | try { |
| | | return dayjs(cell).format("YYYY-MM-DD HH:mm:ss"); |
| | | return dayjs(cell).format("YYYY-MM-DD"); |
| | | } catch { |
| | | return cell; |
| | | } |
| | |
| | | prop: "registrationDate", |
| | | label: "ç»è®°æ¥æ", |
| | | minWidth: 100, |
| | | formatData: cell => |
| | | cell ? dayjs(cell).format("YYYY-MM-DD HH:mm:ss") : "-", |
| | | formatData: cell => (cell ? dayjs(cell).format("YYYY-MM-DD") : "-"), |
| | | }, |
| | | { |
| | | fixed: "right", |
| | |
| | | label: "å®é
ä¿å
»æ¥æ", |
| | | align: "center", |
| | | prop: "maintenanceActuallyTime", |
| | | formatData: cell => |
| | | cell ? dayjs(cell).format("YYYY-MM-DD HH:mm:ss") : "-", |
| | | formatData: cell => (cell ? dayjs(cell).format("YYYY-MM-DD") : "-"), |
| | | }, |
| | | { |
| | | label: "ä¿å
ȍȾ", |
| | |
| | | }" |
| | | @pagination="changePage"> |
| | | <template #inboundDate="{ row }"> |
| | | {{ row.inboundDate ?? row.InboundDate ?? "" }} |
| | | {{ formatDateOnly(row.inboundDate ?? row.InboundDate ?? "") }} |
| | | </template> |
| | | </PIMTable> |
| | | </div> |
| | |
| | | <li v-for="item in todoList" :key="item.id" class="todo-item"> |
| | | <div class="todo-head"> |
| | | <span class="todo-no">å¾
åç¼å·ï¼{{ item.approveId }}</span> |
| | | <span class="todo-time">{{ item.approveTime }}</span> |
| | | <span class="todo-time">{{ formatDateOnly(item.approveTime) }}</span> |
| | | </div> |
| | | <div class="todo-desc">é¨é¨ï¼{{ item.approveDeptName }}</div> |
| | | <div class="todo-desc">äºç±ï¼{{ item.approveReason }}</div> |
| | |
| | | </div> |
| | | <div class="plan-meta"> |
| | | <span>计å {{ item.planQty }}</span> |
| | | <span>交æ {{ item.deliveryDate }}</span> |
| | | <span>交æ {{ formatDateOnly(item.deliveryDate) }}</span> |
| | | </div> |
| | | </li> |
| | | </ul> |
| | |
| | | label="æè¿æ´æ°æ¶é´" |
| | | prop="updateTime" |
| | | show-overflow-tooltip |
| | | /> |
| | | > |
| | | <template #default="scope"> |
| | | {{ formatDateOnly(scope.row.updateTime || scope.row.createTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" label="æä½" min-width="180" align="center"> |
| | | <template #default="scope"> |
| | | <el-button |
| | |
| | | <el-table-column label="å»ç»æ°é" prop="lockedQuantity" show-overflow-tooltip /> |
| | | <el-table-column label="åºåé¢è¦æ°é" prop="warnNum" show-overflow-tooltip /> |
| | | <el-table-column label="夿³¨" prop="remark" show-overflow-tooltip /> |
| | | <el-table-column label="æè¿æ´æ°æ¶é´" prop="updateTime" show-overflow-tooltip /> |
| | | <el-table-column label="æè¿æ´æ°æ¶é´" prop="updateTime" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | {{ formatDateOnly(scope.row.updateTime || scope.row.createTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" label="æä½" min-width="90" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="showSubtractModal(scope.row)" :disabled="scope.row.unLockedQuantity === 0">é¢ç¨</el-button> |
| | |
| | | show-overflow-tooltip /> |
| | | <el-table-column label="æè¿æ´æ°æ¶é´" |
| | | prop="updateTime" |
| | | show-overflow-tooltip /> |
| | | show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | {{ formatDateOnly(scope.row.updateTime || scope.row.createTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" |
| | | label="æä½" |
| | | min-width="80" |
| | |
| | | <el-table-column label="åºåæ°é" prop="qualitity" show-overflow-tooltip /> |
| | | <el-table-column label="å»ç»æ°é" prop="lockedQuantity" show-overflow-tooltip /> |
| | | <el-table-column label="夿³¨" prop="remark" show-overflow-tooltip /> |
| | | <el-table-column label="æè¿æ´æ°æ¶é´" prop="updateTime" show-overflow-tooltip /> |
| | | <el-table-column label="æè¿æ´æ°æ¶é´" prop="updateTime" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | {{ formatDateOnly(scope.row.updateTime || scope.row.createTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" label="æä½" min-width="90" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="showSubtractModal(scope.row)" :disabled="scope.row.unLockedQuantity === 0">é¢ç¨</el-button> |
| | |
| | | if (val == null || val === "") return ""; |
| | | if (Array.isArray(val) && val.length >= 3) { |
| | | const [y, m, d, h = 0, min = 0, s = 0] = val; |
| | | return dayjs(new Date(y, m - 1, d, h, min, s)).format("YYYY-MM-DD HH:mm:ss"); |
| | | return dayjs(new Date(y, m - 1, d, h, min, s)).format("YYYY-MM-DD"); |
| | | } |
| | | if (typeof val === "number") { |
| | | const d = val > 1e12 ? dayjs(val) : dayjs.unix(val); |
| | | return d.isValid() ? d.format("YYYY-MM-DD HH:mm:ss") : ""; |
| | | return d.isValid() ? d.format("YYYY-MM-DD") : ""; |
| | | } |
| | | const s = String(val).trim(); |
| | | if (!s) return ""; |
| | | const parsed = dayjs(s.includes("T") ? s : s.replace(/-/g, "/")); |
| | | return parsed.isValid() ? parsed.format("YYYY-MM-DD HH:mm:ss") : s; |
| | | return parsed.isValid() ? parsed.format("YYYY-MM-DD") : s; |
| | | } |
| | | |
| | | export function formatDisplayTime(val) { |
| | |
| | | { |
| | | label: "ç»è®°æ¥æ", |
| | | prop: "registrationtDate", |
| | | formatData: cell => |
| | | cell ? dayjs(cell).format("YYYY-MM-DD HH:mm:ss") : "-", |
| | | formatData: cell => (cell ? dayjs(cell).format("YYYY-MM-DD") : "-"), |
| | | }, |
| | | ]); |
| | | const tableData = ref([]); |
| | |
| | | class="cell link" |
| | | style="width: 100%" |
| | | @click="goLink(scope.row, item.linkMethod)"> |
| | | <span v-if="!item.formatData">{{ scope.row[item.prop] }}</span> |
| | | <span v-if="!item.formatData">{{ |
| | | toDateOnly(scope.row[item.prop]) |
| | | }}</span> |
| | | </div> |
| | | <!-- é»è®¤çº¯å±ç¤ºæ°æ® --> |
| | | <div v-else |
| | | class="cell" |
| | | :class="item.className || ''" |
| | | style="width: 100%"> |
| | | <span v-if="!item.formatData">{{ scope.row[item.prop] }}</span> |
| | | <span v-if="!item.formatData">{{ |
| | | toDateOnly(scope.row[item.prop]) |
| | | }}</span> |
| | | <span v-else>{{ |
| | | formatters(scope.row[item.prop], item.formatData) |
| | | toDateOnly(formatters(scope.row[item.prop], item.formatData)) |
| | | }}</span> |
| | | </div> |
| | | </template> |
| | |
| | | import pagination from "../../../../components/PIMTable/Pagination.vue"; |
| | | import { ref, inject, getCurrentInstance } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { toDateOnly } from "@/utils/dateDisplay"; |
| | | |
| | | // è·åå
¨å±ç uploadHeader |
| | | const { proxy } = getCurrentInstance(); |
| | |
| | | <el-table-column label="èç³»æ¹å¼" prop="contact" width="140" /> |
| | | <el-table-column label="å馿¶é´" prop="feedbackTime" width="160"> |
| | | <template #default="scope"> |
| | | <span>{{ scope.row.feedbackTime }}</span> |
| | | <span>{{ formatDateOnly(scope.row.feedbackTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="é®é¢æè¿°" prop="problemDesc" show-overflow-tooltip /> |
| | |
| | | > |
| | | <div class="todo-title">ç³è¯·ç±»åï¼{{ item.approveTypeName }}</div> |
| | | <div class="todo-division">ç³è¯·é¨é¨ï¼{{ item.approveDeptName }}</div> |
| | | <div class="todo-time">{{ item.approveTime }}</div> |
| | | <div class="todo-time">{{ formatDateOnly(item.approveTime) }}</div> |
| | | </div> |
| | | |
| | | </div> |
| | |
| | | <template #default="scope"> |
| | | <div> |
| | | <div v-if="scope.row.shippingDate"> |
| | | {{ scope.row.shippingDate }} |
| | | {{ formatDateOnly(scope.row.shippingDate) }} |
| | | </div> |
| | | <el-tag v-else type="info">- </el-tag> |
| | | </div> |
| | |
| | | </el-table-column> |
| | | <el-table-column prop="validPeriod" label="æææ" width="200"> |
| | | <template #default="scope"> |
| | | {{ scope.row.startDate }} è³ {{ scope.row.endDate }} |
| | | {{ formatDateOnly(scope.row.startDate) }} è³ {{ formatDateOnly(scope.row.endDate) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="status" label="ç¶æ" width="80"> |
| | |
| | | <el-table-column label="çæ¬å·" prop="version" align="center" width="120"/> |
| | | <el-table-column label="å建æ¶é´" prop="createTime" align="center" width="170"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="æ´æ°æ¶é´" prop="updateTime" align="center" width="170"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.updateTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span> |
| | | <span>{{ parseTime(scope.row.updateTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="å建人" prop="createUser" align="center" width="100"/> |