field-formatter.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. /**
  2. * H5版本的字段格式化工具函数
  3. * 基于小程序版本改造,适配H5环境
  4. */
  5. const normalizeObjpResultEntries = (result) => {
  6. if (!result) return [];
  7. if (Array.isArray(result)) {
  8. return result
  9. .map((item) => {
  10. if (!item || typeof item !== "object") return null;
  11. const entry = Object.entries(item)[0];
  12. if (!entry) return null;
  13. return { value: entry[0], label: entry[1] };
  14. })
  15. .filter(Boolean);
  16. }
  17. if (typeof result === "object") {
  18. return Object.entries(result).map(([value, label]) => ({ value, label }));
  19. }
  20. return [];
  21. };
  22. const findObjpResultLabel = (result, value) => {
  23. const targetValue = String(value);
  24. const item = normalizeObjpResultEntries(result).find(
  25. (entry) => String(entry.value) === targetValue
  26. );
  27. return item ? item.label : undefined;
  28. };
  29. /**
  30. * 获取字典翻译 - H5版本
  31. * @param {string} cbName - 字典名称
  32. * @param {string|number} value - 值
  33. * @param {string} cacheKey - 缓存键
  34. * @param {Map} dictCache - 字典缓存
  35. * @param {Function} updateCallback - 更新回调函数
  36. */
  37. const getDictTranslation = async (
  38. cbName,
  39. value,
  40. cacheKey,
  41. dictCache,
  42. updateCallback
  43. ) => {
  44. try {
  45. console.log(`🔍 获取字典翻译 [${cbName}:${value}]`);
  46. // 使用 loadObjpOpt 接口调用字典
  47. const result = await request.post(
  48. "/service?ssServ=loadObjpOpt&objectpickerdropdown1=1",
  49. {
  50. objectpickerparam: JSON.stringify({
  51. input: "false",
  52. codebook: cbName,
  53. }),
  54. objectpickertype: 2, // 2表示获取要回显的一项
  55. objectpickervalue: value, // 需回显的值
  56. },
  57. { loading: false, formData: true }
  58. );
  59. console.log(`字典翻译 [${cbName}:${value}] API返回:`, result);
  60. // 兼容旧版 {"result":{"622182":"会议室A"}} 和新版 {"result":[{"622182":"会议室A"}]}
  61. let translatedValue = value; // 默认返回原值
  62. if (result && result.data && result.data.result) {
  63. translatedValue = findObjpResultLabel(result.data.result, value) || value;
  64. console.log(`字典翻译结果: ${value} -> ${translatedValue}`);
  65. }
  66. dictCache.set(cacheKey, translatedValue);
  67. // 触发页面更新
  68. if (updateCallback) {
  69. updateCallback();
  70. }
  71. } catch (error) {
  72. console.error(`字典翻译失败 [${cbName}:${value}]:`, error);
  73. dictCache.set(cacheKey, value);
  74. }
  75. };
  76. /**
  77. * 格式化字段值(处理字典翻译、日期格式等)- H5版本
  78. * @param {Object} fieldObj - 字段对象 {field, value}
  79. * @param {Map} dictCache - 字典缓存
  80. * @param {Function} getDictTranslationFn - 字典翻译函数
  81. * @returns {string} 格式化后的值
  82. */
  83. const formatFieldValue = (fieldObj, dictCache, getDictTranslationFn) => {
  84. if (!fieldObj || !fieldObj.field || fieldObj.value === undefined) {
  85. return "";
  86. }
  87. const { field, value } = fieldObj;
  88. // 空值处理
  89. if (value === null || value === undefined || value === "") {
  90. return "";
  91. }
  92. // 如果字段有字典配置,进行字典翻译
  93. if (field.cbName) {
  94. const cacheKey = `${field.cbName}_${value}`;
  95. // 先从缓存中查找
  96. if (dictCache.has(cacheKey)) {
  97. return dictCache.get(cacheKey);
  98. }
  99. // 缓存中没有,异步获取翻译
  100. if (getDictTranslationFn) {
  101. getDictTranslationFn(field.cbName, value, cacheKey, dictCache);
  102. }
  103. // 返回原值作为临时显示
  104. return value;
  105. }
  106. // 时间格式化(优先检查fmt字段)
  107. if (field.fmt) {
  108. return h5FormatDate(value, field.fmt);
  109. }
  110. // 日期格式化(兼容旧逻辑)
  111. if (
  112. field.type === "date" ||
  113. field.name.toLowerCase().includes("date") ||
  114. field.name.toLowerCase().includes("time")
  115. ) {
  116. return h5FormatDate(value);
  117. }
  118. // 数字格式化
  119. if (field.type === "number" && typeof value === "number") {
  120. return value.toLocaleString();
  121. }
  122. // 布尔值格式化
  123. if (field.type === "boolean" || typeof value === "boolean") {
  124. return value ? "是" : "否";
  125. }
  126. // 默认返回字符串
  127. return String(value);
  128. };
  129. /**
  130. * 规范化日期字符串,兼容异常空白符和乱码分隔符
  131. * @param {string|Date|number} value - 原始日期值
  132. * @returns {string} 规范化后的日期字符串
  133. */
  134. const normalizeDateInput = (value) => {
  135. if (value === null || value === undefined) return "";
  136. return (
  137. String(value)
  138. // 功能说明:兼容接口里被错误转码的窄空格(如  PM),避免标题时间无法格式化 by xu 2026-03-06
  139. .replace(/ /g, " ")
  140. .replace(/[\u00A0\u1680\u180E\u2000-\u200D\u202F\u205F\u3000]/g, " ")
  141. .replace(/(\d)(AM|PM)$/i, "$1 $2")
  142. .replace(/\s+/g, " ")
  143. .trim()
  144. );
  145. };
  146. /**
  147. * 解析特殊日期格式:Jul 4, 2025, 6:00:00 AM
  148. * @param {string} dateStr - 日期字符串
  149. * @returns {object|null} 解析后的日期对象或null
  150. */
  151. const parseSpecialDateFormat = (dateStr) => {
  152. try {
  153. const normalizedDateStr = normalizeDateInput(dateStr);
  154. // 匹配格式:Jul 4, 2025, 6:00:00 AM
  155. const regex =
  156. /^(\w{3})\s+(\d{1,2}),\s+(\d{4}),\s+(\d{1,2}):(\d{2}):(\d{2})\s+(AM|PM)$/i;
  157. const match = normalizedDateStr.match(regex);
  158. if (!match) return null;
  159. const [, monthStr, day, year, hour, minute, second, ampmRaw] = match;
  160. const ampm = String(ampmRaw).toUpperCase();
  161. // 月份映射
  162. const months = {
  163. Jan: 0,
  164. Feb: 1,
  165. Mar: 2,
  166. Apr: 3,
  167. May: 4,
  168. Jun: 5,
  169. Jul: 6,
  170. Aug: 7,
  171. Sep: 8,
  172. Oct: 9,
  173. Nov: 10,
  174. Dec: 11,
  175. };
  176. const month = months[monthStr];
  177. if (month === undefined) return null;
  178. // 处理12小时制
  179. let hour24 = parseInt(hour);
  180. if (ampm === "PM" && hour24 !== 12) {
  181. hour24 += 12;
  182. } else if (ampm === "AM" && hour24 === 12) {
  183. hour24 = 0;
  184. }
  185. return {
  186. year: parseInt(year),
  187. month: month,
  188. day: parseInt(day),
  189. hour: hour24,
  190. minute: parseInt(minute),
  191. second: parseInt(second),
  192. };
  193. } catch (error) {
  194. console.warn("解析特殊日期格式失败:", dateStr, error);
  195. return null;
  196. }
  197. };
  198. /**
  199. * 格式化日期对象
  200. * @param {object} dateObj - 日期对象 {year, month, day, hour, minute, second}
  201. * @param {string} format - 格式字符串
  202. * @returns {string} 格式化后的字符串
  203. */
  204. const formatDateObject = (dateObj, format) => {
  205. const { year, month, day, hour, minute, second } = dateObj;
  206. return format
  207. .replace(/YYYY/g, year)
  208. .replace(/yyyy/g, year)
  209. .replace(/MM/g, String(month + 1).padStart(2, "0"))
  210. .replace(/DD/g, String(day).padStart(2, "0"))
  211. .replace(/dd/g, String(day).padStart(2, "0"))
  212. .replace(/HH/g, String(hour).padStart(2, "0"))
  213. .replace(/hh/g, String(hour).padStart(2, "0"))
  214. .replace(/mm/g, String(minute).padStart(2, "0"))
  215. .replace(/ss/g, String(second).padStart(2, "0"));
  216. };
  217. /**
  218. * 增强的日期格式化函数 - H5版本
  219. * @param {string|Date} date - 日期,支持多种格式如 "Jul 4, 2025, 6:00:00 AM"
  220. * @param {string} format - 格式,如 'YYYY-MM-DD HH:mm:ss'
  221. * @returns {string} 格式化后的日期
  222. */
  223. const h5FormatDate = (date, format = "YYYY-MM-DD HH:mm:ss") => {
  224. if (!date) return "";
  225. try {
  226. const normalizedDate = normalizeDateInput(date);
  227. console.log(
  228. `🔧 h5FormatDate 开始处理:`,
  229. normalizedDate,
  230. "目标格式:",
  231. format
  232. );
  233. // 手动解析特殊格式:Jul 4, 2025, 6:00:00 AM
  234. const parseResult = parseSpecialDateFormat(normalizedDate);
  235. if (parseResult) {
  236. console.log(`🔧 手动解析成功:`, parseResult);
  237. const result = formatDateObject(parseResult, format);
  238. console.log(`✅ 手动格式化结果:`, result);
  239. return result;
  240. }
  241. // 使用 Day.js 解析日期(更强大的日期解析能力)
  242. if (typeof window !== "undefined" && window.dayjs) {
  243. const dayObj = window.dayjs(normalizedDate);
  244. console.log(`🔧 使用 Day.js 解析:`, dayObj.isValid(), dayObj.toString());
  245. if (dayObj.isValid()) {
  246. const result = dayObj.format(format);
  247. console.log(`✅ Day.js 格式化结果:`, result);
  248. return result;
  249. }
  250. }
  251. // 降级到原生 Date(如果 Day.js 未加载)
  252. console.log(`🔧 Day.js 未加载,使用原生 Date`);
  253. const d = new Date(normalizedDate);
  254. console.log(`🔧 解析后的日期对象:`, d, "是否有效:", !isNaN(d.getTime()));
  255. // 检查日期是否有效
  256. if (isNaN(d.getTime())) {
  257. console.warn("❌ 无效日期格式:", normalizedDate);
  258. return normalizedDate; // 无效日期返回原值
  259. }
  260. const year = d.getFullYear();
  261. const month = String(d.getMonth() + 1).padStart(2, "0");
  262. const day = String(d.getDate()).padStart(2, "0");
  263. const hours = String(d.getHours()).padStart(2, "0");
  264. const minutes = String(d.getMinutes()).padStart(2, "0");
  265. const seconds = String(d.getSeconds()).padStart(2, "0");
  266. // 支持多种格式模式
  267. let result = format
  268. .replace(/YYYY/g, year)
  269. .replace(/yyyy/g, year)
  270. .replace(/MM/g, month)
  271. .replace(/DD/g, day)
  272. .replace(/dd/g, day)
  273. .replace(/HH/g, hours)
  274. .replace(/hh/g, hours)
  275. .replace(/mm/g, minutes)
  276. .replace(/ss/g, seconds);
  277. console.log(`日期格式化: ${date} -> ${result} (格式: ${format})`);
  278. return result;
  279. } catch (error) {
  280. console.error("日期格式化异常:", date, format, error);
  281. return date; // 异常时返回原值
  282. }
  283. };
  284. /**
  285. * 异步格式化字段值 - 支持字典转换
  286. * @param {object} fieldData - 字段数据 {field, value}
  287. * @param {Map} dictCache - 字典缓存
  288. * @returns {Promise<string>} 格式化后的值
  289. */
  290. const formatFieldValueAsync = async (fieldData, dictCache) => {
  291. if (!fieldData || !fieldData.field) {
  292. return fieldData?.value || "";
  293. }
  294. const { field, value } = fieldData;
  295. // 空值处理
  296. if (value === null || value === undefined || value === "") {
  297. return "";
  298. }
  299. // 优先处理时间格式化(如果字段有fmt属性)
  300. if (field.fmt) {
  301. try {
  302. console.log(
  303. `🕐 格式化时间字段 [${field.name}]:`,
  304. value,
  305. "格式:",
  306. field.fmt
  307. );
  308. console.log(`🔧 调用 h5FormatDate 前...`);
  309. const formattedTime = h5FormatDate(value, field.fmt);
  310. console.log(`🔧 调用 h5FormatDate 后,结果:`, formattedTime);
  311. console.log(`✅ 时间格式化结果:`, formattedTime);
  312. return formattedTime;
  313. } catch (error) {
  314. console.error("❌ 时间格式化失败:", field.name, value, error);
  315. // 格式化失败,返回原值
  316. return value;
  317. }
  318. }
  319. // 如果字段有字典配置,进行字典转换
  320. if (field.cbName) {
  321. const cacheKey = `${field.cbName}_${value}`;
  322. // 先从缓存中查找
  323. if (dictCache && dictCache.has(cacheKey)) {
  324. return dictCache.get(cacheKey);
  325. }
  326. // 缓存中没有,异步获取翻译
  327. try {
  328. const result = await request.post(
  329. `/service?ssServ=loadObjpOpt&objectpickerdropdown1=1`,
  330. {
  331. objectpickerparam: JSON.stringify({
  332. input: "false",
  333. codebook: field.cbName,
  334. }),
  335. objectpickertype: 2,
  336. objectpickervalue: value,
  337. },
  338. {
  339. loading: false,
  340. formData: true,
  341. }
  342. );
  343. if (result && result.data && result.data.result) {
  344. const translatedValue = findObjpResultLabel(result.data.result, value);
  345. if (!translatedValue) return value;
  346. // 缓存结果
  347. if (dictCache) {
  348. dictCache.set(cacheKey, translatedValue);
  349. }
  350. return translatedValue;
  351. }
  352. } catch (error) {
  353. console.warn("字典转换失败:", field.cbName, value, error);
  354. }
  355. // 转换失败,返回原值
  356. return value;
  357. }
  358. // 日期格式化
  359. if (field.type === 3 && field.fmt) {
  360. return h5FormatDate(value, field.fmt);
  361. }
  362. // 数字格式化
  363. if (field.type === 2 && typeof value === "number") {
  364. return value.toLocaleString();
  365. }
  366. // 默认返回字符串
  367. return value.toString();
  368. };
  369. /**
  370. * 获取字典所有选项 - 用于下拉菜单
  371. * @param {string} cbName - 字典名称
  372. * @param {Map} dictCache - 字典缓存
  373. * @returns {Promise<Array>} 选项列表 [{n: '显示名', v: '值'}]
  374. */
  375. const getDictOptions = async (cbName, dictCache) => {
  376. const cacheKey = `options_${cbName}`;
  377. // 检查缓存
  378. if (dictCache && dictCache.has(cacheKey)) {
  379. return dictCache.get(cacheKey);
  380. }
  381. try {
  382. console.log(`🔍 获取字典选项 [${cbName}]`);
  383. const result = await request.post(
  384. `/service?ssServ=loadObjpOpt&objectpickerdropdown1=1`,
  385. {
  386. objectpickerparam: JSON.stringify({
  387. input: "false",
  388. codebook: cbName,
  389. }),
  390. objectpickertype: 1,
  391. objectpickersearchAll: 1,
  392. },
  393. {
  394. loading: false,
  395. formData: true,
  396. }
  397. );
  398. console.log(`字典选项 [${cbName}] API返回:`, result);
  399. if (result && result.data && result.data.result) {
  400. const options = normalizeObjpResultEntries(result.data.result).map(
  401. ({ value, label }) => ({
  402. n: label,
  403. v: value,
  404. })
  405. );
  406. // 缓存结果
  407. if (dictCache) {
  408. dictCache.set(cacheKey, options);
  409. }
  410. return options;
  411. }
  412. return [];
  413. } catch (error) {
  414. console.error(`❌ 获取字典选项失败 [${cbName}]:`, error);
  415. return [];
  416. }
  417. };
  418. const DEFAULT_LIST_THUMB = "skin/easy/image/default-personalPhoto.png";
  419. const IMAGE_FIELD_NAME_SET = new Set([
  420. "thn",
  421. "zjzwj",
  422. "yszwj",
  423. "yzjzwj",
  424. "sltwj",
  425. "tpwj",
  426. "thumb",
  427. "image",
  428. ]);
  429. const isImageField = (field) => {
  430. if (!field || typeof field !== "object") return false;
  431. const fieldType = String(field.type || "").toLowerCase();
  432. const fieldName = String(field.name || "").toLowerCase();
  433. return fieldType === "img" || IMAGE_FIELD_NAME_SET.has(fieldName);
  434. };
  435. const readImagePath = (value) => {
  436. if (value === null || value === undefined) return "";
  437. if (typeof value === "string") return value.trim();
  438. return String(value).trim();
  439. };
  440. const resolveListImageUrl = (path) => {
  441. const imagePath = readImagePath(path);
  442. if (!imagePath) {
  443. return window.SS.utils?.getImageUrl?.(DEFAULT_LIST_THUMB) || DEFAULT_LIST_THUMB;
  444. }
  445. if (imagePath.startsWith("http") || imagePath.startsWith("blob:")) {
  446. return imagePath;
  447. }
  448. return window.SS.utils?.getImageUrl?.(imagePath) || imagePath;
  449. };
  450. const pickObjectThumbPath = (item) => {
  451. if (!item || typeof item !== "object") return "";
  452. const directKeys = ["thn", "thumb", "image", "zjzwj", "yszwj", "yzjzwj", "sltwj", "tpwj"];
  453. for (const key of directKeys) {
  454. const path = readImagePath(item[key]);
  455. if (path) return path;
  456. }
  457. const singleFields = [item.first, item.second];
  458. for (const fieldData of singleFields) {
  459. if (!fieldData || !fieldData.field) continue;
  460. if (isImageField(fieldData.field)) {
  461. const path = readImagePath(fieldData.value);
  462. if (path) return path;
  463. }
  464. }
  465. if (Array.isArray(item.third)) {
  466. for (const group of item.third) {
  467. if (!Array.isArray(group)) continue;
  468. for (const fieldData of group) {
  469. if (!fieldData || !fieldData.field) continue;
  470. if (isImageField(fieldData.field)) {
  471. const path = readImagePath(fieldData.value);
  472. if (path) return path;
  473. }
  474. }
  475. }
  476. }
  477. return "";
  478. };
  479. /**
  480. * 格式化对象列表数据 - 处理API返回的objectList
  481. * @param {Array} objectList - 原始对象列表
  482. * @param {Map} dictCache - 字典缓存
  483. * @returns {Promise<Array>} 格式化后的列表
  484. */
  485. const formatObjectList = async (objectList, dictCache) => {
  486. if (!Array.isArray(objectList)) return [];
  487. const formattedList = [];
  488. for (const item of objectList) {
  489. const formattedItem = { ...item };
  490. let thumbPath = pickObjectThumbPath(item);
  491. // 格式化 first 字段
  492. if (item.first) {
  493. if (isImageField(item.first.field)) {
  494. thumbPath = thumbPath || readImagePath(item.first.value);
  495. } else {
  496. formattedItem.firstDisplay = await formatFieldValueAsync(
  497. item.first,
  498. dictCache
  499. );
  500. }
  501. } else if (
  502. item.title &&
  503. typeof item.title === "object" &&
  504. item.title.val !== undefined
  505. ) {
  506. // 功能说明:兼容 title={val,fmt} 结构,标题字段为日期时间时按 fmt 格式化,避免卡片标题直接显示原始时间串 by xu 2026-03-06
  507. if (item.title.fmt) {
  508. formattedItem.firstDisplay = h5FormatDate(
  509. item.title.val,
  510. item.title.fmt
  511. );
  512. } else {
  513. formattedItem.firstDisplay =
  514. item.title.val === undefined || item.title.val === null
  515. ? ""
  516. : String(item.title.val);
  517. }
  518. } else if (typeof item.title === "string") {
  519. // 兼容 title 直出字符串结构 by xu 2026-03-03
  520. formattedItem.firstDisplay = item.title;
  521. }
  522. // 格式化 second 字段
  523. if (item.second) {
  524. if (isImageField(item.second.field)) {
  525. thumbPath = thumbPath || readImagePath(item.second.value);
  526. } else {
  527. formattedItem.secondDisplay = await formatFieldValueAsync(
  528. item.second,
  529. dictCache
  530. );
  531. }
  532. } else {
  533. // 兼容 abs/desc/summary 结构(移动端接口常见) by xu 2026-03-03
  534. const secondFallback = item.abs ?? item.desc ?? item.summary;
  535. if (secondFallback !== undefined && secondFallback !== null) {
  536. formattedItem.secondDisplay = String(secondFallback);
  537. }
  538. }
  539. // 格式化 third 字段组
  540. if (item.third && Array.isArray(item.third)) {
  541. formattedItem.thirdDisplay = [];
  542. for (const group of item.third) {
  543. const formattedGroup = [];
  544. for (const fieldData of group) {
  545. if (isImageField(fieldData?.field)) {
  546. thumbPath = thumbPath || readImagePath(fieldData.value);
  547. continue;
  548. }
  549. const displayValue = await formatFieldValueAsync(
  550. fieldData,
  551. dictCache
  552. );
  553. formattedGroup.push({
  554. ...fieldData,
  555. displayValue,
  556. });
  557. }
  558. formattedItem.thirdDisplay.push(formattedGroup);
  559. }
  560. formattedItem.thirdDisplay = formattedItem.thirdDisplay.filter(
  561. (group) => Array.isArray(group) && group.length > 0
  562. );
  563. } else if (Array.isArray(item.catList)) {
  564. // 功能说明:兼容 catList 结构,若有 fmt 则按日期格式化,避免列表属性时间字段直接显示 Oracle 原始串 by xu 2026-03-06
  565. const formattedCatList = [];
  566. for (const catItem of item.catList) {
  567. const fieldData = {
  568. field: {
  569. desc: String(catItem?.desc || ""),
  570. fmt: catItem?.fmt || "",
  571. },
  572. value: catItem?.val,
  573. };
  574. const displayValue = await formatFieldValueAsync(fieldData, dictCache);
  575. formattedCatList.push({
  576. field: {
  577. desc: String(catItem?.desc || ""),
  578. },
  579. value: catItem?.val,
  580. displayValue,
  581. });
  582. }
  583. formattedItem.thirdDisplay = [formattedCatList];
  584. }
  585. formattedItem.thumbPath = thumbPath;
  586. formattedItem.thumbUrl = thumbPath ? resolveListImageUrl(thumbPath) : "";
  587. formattedList.push(formattedItem);
  588. }
  589. return formattedList;
  590. };
  591. // 导出到全局
  592. window.H5FieldFormatter = {
  593. getDictTranslation,
  594. formatFieldValue,
  595. formatFieldValueAsync,
  596. formatDate: h5FormatDate,
  597. getDictOptions,
  598. formatObjectList,
  599. pickObjectThumbPath,
  600. resolveListImageUrl,
  601. };
  602. // 兼容性:也导出为全局函数
  603. window.getDictTranslation = getDictTranslation;
  604. window.formatFieldValue = formatFieldValue;
  605. window.formatFieldValueAsync = formatFieldValueAsync;
  606. window.getDictOptions = getDictOptions;
  607. window.formatObjectList = formatObjectList;
  608. window.pickObjectThumbPath = pickObjectThumbPath;
  609. window.resolveListImageUrl = resolveListImageUrl;
  610. console.log("✅ H5字段格式化工具加载完成");