Bläddra i källkod

1、回滚空数值不再显示0问题

iggy 6 dagar sedan
förälder
incheckning
04ce6d7f44
1 ändrade filer med 6 tillägg och 10 borttagningar
  1. 6 10
      JLHWEB/src/utils/index.ts

+ 6 - 10
JLHWEB/src/utils/index.ts

@@ -374,17 +374,13 @@ export function formatValue(callValue: any) {
  * @param {String} prop 当前 prop
  * @returns {*}
  * */
-export function handleRowAccordingToProp(row: { [key: string]: any }, prop: string, ...args: any[]) {
-  const format = args[0];
-
-  if (format) {
-    const val = row[prop];
-    const hasValue = val !== null && val !== undefined && val !== "";
-
-    return hasValue && formatFn[format] ? formatFn[format]({ val, format }) : val ?? "";
+export function handleRowAccordingToProp(row: { [key: string]: any }, prop: string, ...args: any) {
+  if (args[0]) {
+    return row[prop] && formatFn[args[0]] ? formatFn[args[0]]({ val: row[prop], format: args[0] }) : "";
   }
-
-  return row[prop];
+  if (!prop.includes(".")) return row[prop] ?? "";
+  prop.split(".").forEach(item => (row = row[item] ?? ""));
+  return row;
 }
 
 // 工具函数:解析 formatType