bill 2 tháng trước cách đây
mục cha
commit
596186165c
2 tập tin đã thay đổi với 42 bổ sung2 xóa
  1. 7 2
      src/example/fuse/enter-shared.ts
  2. 35 0
      src/utils/shared.ts

+ 7 - 2
src/example/fuse/enter-shared.ts

@@ -3,7 +3,7 @@ import type { Scene } from "../../example/platform/platform-resource";
 import type { StoreData } from "@/core/store/store";
 import { token, params, urlUpdateQuery, urlGetQuery } from "../env";
 import { genLoading } from "../loadding";
-import { tempStrFill } from "@/utils/shared";
+import { formatDate, tempStrFill } from "@/utils/shared";
 import {
   type LatLng,
   latlngStrTransform,
@@ -344,6 +344,8 @@ export let getTableTemp = async () => {
       console.log("tableTemp模板解析失败");
     }
   }
+
+
   if (!table!) {
     table = {
       案发时间: "",
@@ -362,7 +364,10 @@ export let getTableTemp = async () => {
         table.案发地点 = item.caseLocation;
         table.绘图单位 = item.orgName;
         table.绘图人 = item.investigatorName;
-        table.绘图时间 = item.caseTypeName;
+        table.绘图时间 = formatDate(new Date(), 'yyyy.mm.dd hh:MM:ss')
+      }
+      if (!title) {
+        title = `“${item.crimeTimeBegin}”${item.caseLocation}${item.caseTypeName}现场平面示意图`
       }
     }
   }

+ 35 - 0
src/utils/shared.ts

@@ -549,4 +549,39 @@ export const pickPromise = <T>() => {
     resolve: resolve!,
     reject: reject!
   }
+}
+
+// 日期格式化
+export const formatDate = (date: Date, fmt: string = 'yyyy-MM-dd hh:mm') => {
+  const map = {
+    'M+': date.getMonth() + 1, //月份
+    'd+': date.getDate(), //日
+    'h+': date.getHours(), //小时
+    'm+': date.getMinutes(), //分
+    's+': date.getSeconds(), //秒
+    'q+': Math.floor((date.getMonth() + 3) / 3), //季度
+    S: date.getMilliseconds() //毫秒
+  }
+
+  if (/(y+)/.test(fmt)) {
+    fmt = fmt.replace(
+      RegExp.$1,
+      date
+        .getFullYear()
+        .toString()
+        .substr(4 - RegExp.$1.length)
+    )
+  }
+
+  ;(Object.keys(map) as Array<keyof typeof map>).forEach(k => {
+    if (new RegExp('(' + k + ')').test(fmt)) {
+      const val = map[k].toString()
+      fmt = fmt.replace(
+        RegExp.$1,
+        RegExp.$1.length === 1 ? val : ('00' + val).substr(val.length)
+      )
+    }
+  })
+
+  return fmt
 }