From 4c54ad5d917083f7a2024f12b9f96f80337e5a95 Mon Sep 17 00:00:00 2001 From: liugongyu <290219706@qq.com> Date: Wed, 24 Dec 2025 16:25:18 +0800 Subject: [PATCH] 转工单 选择是 传紧急程度和希望完成时间 --- api/regional-order-manage/regional-order-manage.js | 0 common/utils/common.js | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- common/utils/useUploadImgs.js | 2 ++ pages-sub/daily/patrol-manage/add-patrol-record.vue | 250 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------- pages-sub/daily/quick-order/add-order.vue | 4 ++++ pages-sub/daily/quick-order/order-detail.vue | 15 ++++++++------- pages-sub/problem/regional-order-manage/add-order.vue | 15 +++++++++++++++ pages-sub/problem/regional-order-manage/index.vue | 15 +++++++++++++++ pages-sub/problem/regional-order-manage/order-detail.vue | 15 +++++++++++++++ pages-sub/problem/work-order-manage/add-order.vue | 18 ++++++++++-------- pages-sub/problem/work-order-manage/order-detail.vue | 15 +++++++++++---- pages.json | 19 +++++++++++++++---- 12 files changed, 382 insertions(+), 95 deletions(-) create mode 100644 api/regional-order-manage/regional-order-manage.js create mode 100644 pages-sub/problem/regional-order-manage/add-order.vue create mode 100644 pages-sub/problem/regional-order-manage/index.vue create mode 100644 pages-sub/problem/regional-order-manage/order-detail.vue diff --git a/api/regional-order-manage/regional-order-manage.js b/api/regional-order-manage/regional-order-manage.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/api/regional-order-manage/regional-order-manage.js diff --git a/common/utils/common.js b/common/utils/common.js index 8eb1718..97fde66 100644 --- a/common/utils/common.js +++ b/common/utils/common.js @@ -55,4 +55,111 @@ export const buzStatusMap = { "230" : '养护组长验收不通过', "140" : '巡查员验收通过', "240" : '巡查员验收不通过', -} \ No newline at end of file +} + + +/** + * 计算两个时间的时间差,返回格式化字符串(天/小时/分钟/秒,按需显示,无无效单位) + * @param {string | Date | number} startTime - 开始时间(时间字符串/Date对象/10位/13位时间戳) + * @param {string | Date | number} endTime - 结束时间(时间字符串/Date对象/10位/13位时间戳) + * @returns {string} - 格式化时间差字符串(如:3天5小时2分钟30秒、3小时2分钟30秒、2分钟30秒、30秒) + */ +export const calculateFormatTimeDiff = (startTime, endTime) => { + // 辅助函数:将任意合法时间格式转换为13位毫秒级时间戳 + const to13BitTimestamp = (time) => { + let timestamp = 0; + + // 情况1:数字类型(时间戳) + if (typeof time === 'number') { + const timeStr = time.toString(); + if (timeStr.length === 10) { + timestamp = time * 1000; // 10位秒级转13位毫秒级 + } else if (timeStr.length === 13) { + timestamp = time; // 13位毫秒级直接使用 + } else { + console.error('非法时间戳:仅支持10位/13位数字', time); + return 0; + } + return timestamp; + } + + // 情况2:Date对象 + if (time instanceof Date) { + timestamp = time.getTime(); + if (isNaN(timestamp)) { + console.error('无效的Date对象', time); + return 0; + } + return timestamp; + } + + // 情况3:字符串类型 + if (typeof time === 'string') { + const timeStr = time.trim().replace(/\//g, '-'); // 统一分隔符,兼容YYYY/MM/DD + const date = new Date(timeStr); + timestamp = date.getTime(); + if (isNaN(timestamp)) { + console.error('无效的时间字符串', time); + return 0; + } + return timestamp; + } + + // 非法类型 + console.error('不支持的时间类型:仅支持string/Date/number', time); + return 0; + }; + + // 1. 统一转换为13位时间戳 + const startTimestamp = to13BitTimestamp(startTime); + const endTimestamp = to13BitTimestamp(endTime); + + // 2. 校验时间戳有效性 + if (startTimestamp === 0 || endTimestamp === 0) { + return '0秒'; + } + + // 3. 计算总毫秒差(取绝对值,确保时间差为正数,不影响单位计算) + const totalMsDiff = Math.abs(endTimestamp - startTimestamp); + + // 4. 定义时间单位换算(毫秒) + const oneDayMs = 24 * 60 * 60 * 1000; + const oneHourMs = 60 * 60 * 1000; + const oneMinuteMs = 60 * 1000; + const oneSecondMs = 1000; + + // 5. 计算各单位的差值(向下取整,获取整数单位) + const days = Math.floor(totalMsDiff / oneDayMs); + const remainingMsAfterDay = totalMsDiff % oneDayMs; // 扣除天数后剩余的毫秒数 + + const hours = Math.floor(remainingMsAfterDay / oneHourMs); + const remainingMsAfterHour = remainingMsAfterDay % oneHourMs; // 扣除小时后剩余的毫秒数 + + const minutes = Math.floor(remainingMsAfterHour / oneMinuteMs); + const remainingMsAfterMinute = remainingMsAfterHour % oneMinuteMs; // 扣除分钟后剩余的毫秒数 + + const seconds = Math.floor(remainingMsAfterMinute / oneSecondMs); + + // 6. 组装格式化字符串(按需添加单位,无无效单位) + const timeParts = []; + if (days > 0) { + timeParts.push(`${days}天`); + } + if (hours > 0 || (days > 0 && hours === 0)) { // 有天数时,小时即使为0也可保留(可选:删除 || 后的条件则不显示0小时) + timeParts.push(`${hours}小时`); + } + if (minutes > 0 || (timeParts.length > 0 && minutes === 0)) { // 有天/小时时,分钟即使为0也可保留(可选:删除 || 后的条件则不显示0分钟) + timeParts.push(`${minutes}分钟`); + } + // 秒数始终保留(即使为0,保证最后有一个有效单位) + timeParts.push(`${seconds}秒`); + + // 7. 过滤掉可能存在的「0单位」(可选优化:避免出现“0小时”等无效字段) + const validTimeParts = timeParts.filter(part => { + const num = parseInt(part); + return num > 0 || (timeParts.length === 1 && num === 0); // 仅当只有秒数时,允许0秒 + }); + + // 8. 拼接并返回结果 + return validTimeParts.join(''); +}; \ No newline at end of file diff --git a/common/utils/useUploadImgs.js b/common/utils/useUploadImgs.js index 638881c..384e229 100644 --- a/common/utils/useUploadImgs.js +++ b/common/utils/useUploadImgs.js @@ -17,6 +17,8 @@ export function useUploadImgs(config) { // 核心修复:初始化为纯数组,且格式适配u-upload const imgList = ref([]) + // 确保 rawImgList 响应式对象的初始值也是空数组 + // const rawImgList = ref([]); /** * 新增:清空所有图片 diff --git a/pages-sub/daily/patrol-manage/add-patrol-record.vue b/pages-sub/daily/patrol-manage/add-patrol-record.vue index 0610b23..70b49b4 100644 --- a/pages-sub/daily/patrol-manage/add-patrol-record.vue +++ b/pages-sub/daily/patrol-manage/add-patrol-record.vue @@ -1,14 +1,14 @@ \ No newline at end of file diff --git a/pages-sub/daily/quick-order/add-order.vue b/pages-sub/daily/quick-order/add-order.vue index 73cd81a..8dcbaaa 100644 --- a/pages-sub/daily/quick-order/add-order.vue +++ b/pages-sub/daily/quick-order/add-order.vue @@ -89,6 +89,8 @@ @after-read="(event) => uploadImgs(event, 'problemImgsList')" @delete="(event) => deleteImg(event, 'problemImgsList')" multiple + width="70" + height="70" :max-count="3" upload-text="选择问题照片" > @@ -101,6 +103,8 @@ @after-read="(event) => uploadImgs(event, 'completeImgsList')" @delete="(event) => deleteImg(event, 'completeImgsList')" multiple + width="70" + height="70" :max-count="3" :sizeType="['compressed']" upload-text="选择完成照片" diff --git a/pages-sub/daily/quick-order/order-detail.vue b/pages-sub/daily/quick-order/order-detail.vue index 764e42f..0e626a7 100644 --- a/pages-sub/daily/quick-order/order-detail.vue +++ b/pages-sub/daily/quick-order/order-detail.vue @@ -65,11 +65,11 @@ 暂无问题照片 @@ -81,9 +81,10 @@