diff --git a/dist.7z b/dist.7z new file mode 100644 index 0000000..888ab27 Binary files /dev/null and b/dist.7z differ diff --git a/src/api/system/Inspection/index.ts b/src/api/system/Inspection/index.ts new file mode 100644 index 0000000..86842cc --- /dev/null +++ b/src/api/system/Inspection/index.ts @@ -0,0 +1,68 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; + +/** + * 查询巡检数据 + * @param query + * @returns {*} + */ + +export const listItem = (query?: Request): AxiosPromise => { + return request({ + url: '/inspection/data/list', + method: 'get', + params: query + }); +}; +export interface Request { + /** + * 进行中的任务数 + */ + activeTask?: string; + /** + * 按时完成任务数 + */ + completedTask?: string; + /** + * 创建时间 + */ + createTime?: string; + /** + * 详细数据 + */ + dataContent?: string; + /** + * 数据类型:0-概况/1-日报/2-周报/3-月报/4-统计 + */ + dataType?: string; + /** + * 巡检人员id + */ + inspectorId?: string; + /** + * 完成率 + */ + onTimeRate?: string; + /** + * 超时完成数 + */ + outCompletedTasks?: string; + /** + * 超时未完成数 + */ + outUncompletedTasks?: string; + /** + * 未开始的任务数 + */ + pendingTask?: string; + statDate?: string; + /** + * 总任务数 + */ + totalTasks?: string; + /** + * 更新时间 + */ + updateTime?: string; + [property: string]: any; +} diff --git a/src/api/system/InspectionTask/type.ts b/src/api/system/InspectionTask/type.ts index 70d1c13..0291f82 100644 --- a/src/api/system/InspectionTask/type.ts +++ b/src/api/system/InspectionTask/type.ts @@ -29,31 +29,11 @@ export interface TaskVO { */ taskTime: string; - /** - * 巡检设置:0-必须拍照,1-可以跳检 - */ - inspectSetting: number; - - /** - * 费用单位 - */ - costUnit: string; - /** * 状态:0-待执行,1-执行中,2-已完成,3-已超时 */ status: string; - /** - * 实际开始时间 - */ - actualStartTime: string; - - /** - * 实际结束时间 - */ - actualEndTime: string; - /** * 备注 */ @@ -96,31 +76,11 @@ export interface TaskForm extends BaseEntity { */ taskTime?: string; - /** - * 巡检设置:0-必须拍照,1-可以跳检 - */ - inspectSetting?: number; - - /** - * 费用单位 - */ - costUnit?: string; - /** * 状态:0-待执行,1-执行中,2-已完成,3-已超时 */ status?: string; - /** - * 实际开始时间 - */ - actualStartTime?: string; - - /** - * 实际结束时间 - */ - actualEndTime?: string; - /** * 备注 */ @@ -158,11 +118,6 @@ export interface TaskQuery extends PageQuery { */ taskTime?: string; - /** - * 巡检设置:0-必须拍照,1-可以跳检 - */ - inspectSetting?: number; - /** * 费用单位 */ @@ -173,16 +128,6 @@ export interface TaskQuery extends PageQuery { */ status?: string; - /** - * 实际开始时间 - */ - actualStartTime?: string; - - /** - * 实际结束时间 - */ - actualEndTime?: string; - /** * 提醒时间 */ diff --git a/src/utils/time.ts b/src/utils/time.ts index 1f92b95..dbc096c 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -4,7 +4,7 @@ * @param date2 结束日期 * @returns 相差天数(绝对值) */ -export function diffDays(date1: string | Date, date2: string | Date): number { +export function diffDays(date1: string | Date = new Date(), date2: string | Date = new Date()): number { const d1 = new Date(date1); const d2 = new Date(date2); // 转为时间戳并取绝对值 @@ -12,6 +12,28 @@ export function diffDays(date1: string | Date, date2: string | Date): number { // 一天的毫秒数 return Math.floor(diff / (1000 * 60 * 60 * 24)); } +/** + * 计算两个日期之间的自然日相差天数 + * 规则:同一天 = 0,昨天 = 1,前天 = 2,以此类推 + * 忽略时分秒,纯日期对比 + * @param date1 日期1,默认为当前日期 + * @param date2 日期2,默认为当前日期 + * @returns 自然日相差天数(非负整数) + * @example getNaturalDayDiff(今日, 今日) => 0 + * @example getNaturalDayDiff(今日, 昨日) => 1 + */ +export function getNaturalDayDiff(date1: string | Date = new Date(), date2: string | Date = new Date()): number { + const getDateTimestamp = (date: string | Date) => { + const d = new Date(date); + d.setHours(0, 0, 0, 0); + return d.getTime(); + }; + + const time1 = getDateTimestamp(date1); + const time2 = getDateTimestamp(date2); + + return Math.floor(Math.abs(time1 - time2) / (1000 * 60 * 60 * 24)); +} /** * 格式化两个时间的差值,自动显示 年/月/天/时/分/秒 @@ -134,3 +156,108 @@ export const getLast7Days = (days = 7) => { } return dates; }; + +/** + * 高性能生成从指定结束日期向前追溯 N 天的连续日期数组 + * 规则:0=今天,1=昨天,2=前天,以此类推 + * 支持自定义日期格式(YYYY/MM/DD/HH/mm/ss)或传入格式化函数 + * 优化:正则模板仅编译1次、时间戳计算、数组预分配,无性能损耗 + * @category 日期工具 + * @param days 向前追溯天数,0=今天,1=昨天,默认 30 天 + * @param endDate 结束日期,支持 Date 对象 / 日期字符串,默认当前日期 + * @param format 日期格式化规则,支持模板字符串或自定义格式化函数,默认 'YYYY-MM-DD' + * 支持模板占位符:YYYY(年)、MM(月)、DD(日)、HH(时)、mm(分)、ss(秒) + * @returns 格式化后的日期字符串数组(按时间正序排列) + * @example + * // 获取今天 + * getLastNDays(0) + * @example + * // 获取昨天 + * getLastNDays(1) + * @example + * // 最近7天(含今天) + * getLastNDays(7) + */ +export function getLastNDays( + days: number = 30, + endDate: Date | string = new Date(), + format: string | ((date: Date) => string) = 'YYYY-MM-DD' +): string[] { + // 非法天数校验 + if (!Number.isInteger(days) || days < 0) { + console.warn('getLastNDays: days 必须是大于等于 0 的整数'); + return []; + } + + // 安全解析结束日期,并【重置时分秒为 00:00:00】— 关键修复 + const end = new Date(endDate); + if (isNaN(end.getTime())) { + console.warn('getLastNDays: 无效日期,已自动使用当前时间'); + end.setTime(Date.now()); + } + // ✅ 修复:统一把时间设为 00:00:00,避免跨天计算错误 + end.setHours(0, 0, 0, 0); + const endTime = end.getTime(); + const oneDay = 86400000; + + // 提前编译格式化函数(核心性能优化:正则只编译一次) + let formatter: (date: Date) => string; + if (typeof format === 'function') { + formatter = format; + } else { + formatter = (date: Date) => { + const YYYY = date.getFullYear().toString(); + const MM = String(date.getMonth() + 1).padStart(2, '0'); + const DD = String(date.getDate()).padStart(2, '0'); + const HH = String(date.getHours()).padStart(2, '0'); + const mm = String(date.getMinutes()).padStart(2, '0'); + const ss = String(date.getSeconds()).padStart(2, '0'); + + return format.replace(/YYYY/g, YYYY).replace(/MM/g, MM).replace(/DD/g, DD).replace(/HH/g, HH).replace(/mm/g, mm).replace(/ss/g, ss); + }; + } + + // 生成日期 + const result: string[] = []; + for (let i = 0; i <= days; i++) { + const currentDate = new Date(endTime - i * oneDay); + result.push(formatter(currentDate)); + } + + // 正序返回 + return result.reverse(); +} +/** + * 格式化 Date 对象为指定格式的字符串 + * 高性能正则解析,支持任意分隔符,仅编译一次模板 + * @param date 要格式化的日期,默认:当前时间 new Date() + * @param format 格式化模板,默认:YYYY-MM-DD + * 支持占位符:YYYY(年)、MM(月)、DD(日)、HH(时)、mm(分)、ss(秒) + * @returns 格式化后的日期字符串 + * @category 日期工具 + * @example + * formatDate() // 今天 → 2025-12-20 + * @example + * formatDate(new Date(), 'YYYY年MM月DD日') + * @example + * formatDate(new Date(), 'YYYY-MM-DD HH:mm:ss') + */ +export function formatDate(date: Date | string = new Date(), format: string = 'YYYY-MM-DD'): string { + // 解析并校验日期 + const d = new Date(date); + if (isNaN(d.getTime())) { + console.warn('formatDate: 无效日期,返回空字符串'); + return ''; + } + + // 获取并补零 + const YYYY = d.getFullYear().toString(); + const MM = String(d.getMonth() + 1).padStart(2, '0'); + const DD = String(d.getDate()).padStart(2, '0'); + const HH = String(d.getHours()).padStart(2, '0'); + const mm = String(d.getMinutes()).padStart(2, '0'); + const ss = String(d.getSeconds()).padStart(2, '0'); + + // 正则替换(通用、无需穷举) + return format.replace(/YYYY/g, YYYY).replace(/MM/g, MM).replace(/DD/g, DD).replace(/HH/g, HH).replace(/mm/g, mm).replace(/ss/g, ss); +} diff --git a/src/views/community/AddCommunity.vue b/src/views/community/AddCommunity.vue index 16d741c..0625523 100644 --- a/src/views/community/AddCommunity.vue +++ b/src/views/community/AddCommunity.vue @@ -5,7 +5,6 @@
-
基本信息
@@ -112,7 +111,6 @@ - + diff --git a/src/views/system/inspection/Monthly/index.vue b/src/views/system/inspection/Monthly/index.vue index ae6056c..79ccf28 100644 --- a/src/views/system/inspection/Monthly/index.vue +++ b/src/views/system/inspection/Monthly/index.vue @@ -1,12 +1,110 @@ - - + diff --git a/src/views/system/inspection/Overview/index.vue b/src/views/system/inspection/Overview/index.vue index f315429..d2abd07 100644 --- a/src/views/system/inspection/Overview/index.vue +++ b/src/views/system/inspection/Overview/index.vue @@ -1,13 +1,367 @@ - - + diff --git a/src/views/system/inspection/Plan/addInspectionPlan.vue b/src/views/system/inspection/Plan/addInspectionPlan.vue index 0acb309..01b0cfa 100644 --- a/src/views/system/inspection/Plan/addInspectionPlan.vue +++ b/src/views/system/inspection/Plan/addInspectionPlan.vue @@ -10,24 +10,6 @@ - -
-
-
{{ item.nickName }}
- - - -
- - - -
-
-