timeRules(v, row, field) { if (!v) return; let arr = v.split("").filter((item) => /^[0-9]*$/.test(item)); let len = arr.length; arr.length = 8; arr.fill("", len, 8); if (arr[0] > 2) { arr[1] = arr[0]; arr[0] = 0; } if (arr[2] > 5) { arr[3] = arr[2]; arr[2] = 0; } if (arr[4] > 2) { arr[5] = arr[4]; arr[4] = 0; } if (arr[6] > 5) { arr[7] = arr[6]; arr[6] = 0; } let s = arr[0] + arr[1] > 23 ? "" : arr[0] + arr[1], e = s && (arr[2] + arr[3] > 59 ? "" : arr[2] + arr[3]), s1 = e && (arr[4] + arr[5] > 23 ? "" : arr[4] + arr[5]), e1 = s1 && (arr[6] + arr[7] > 59 ? "" : arr[6] + arr[7]); if (s1 && s1.length === 2 && s1 < s) { s1 = ""; e1 = ""; } if (e1 && e1.length === 2 && s === s1 && e1 <= e) { e1 = ""; } if (e) s += ":"; if (s1) e += "-"; if (e1) s1 += ":"; row[field] = s + e + s1 + e1; }
标签:10,00,12,s1,arr,length,&&,e1 From: https://www.cnblogs.com/turkey-Rabbit/p/16642218.html