diff --git a/web/public/js/components/common/time-duration-box.js b/web/public/js/components/common/time-duration-box.js index 19891a6f..8446b04a 100644 --- a/web/public/js/components/common/time-duration-box.js +++ b/web/public/js/components/common/time-duration-box.js @@ -1,5 +1,5 @@ Vue.component("time-duration-box", { - props: ["name", "v-name", "v-value", "v-count", "v-unit"], + props: ["v-name", "v-value", "v-count", "v-unit", "placeholder", "v-min-unit", "maxlength"], mounted: function () { this.change() }, @@ -15,17 +15,52 @@ Vue.component("time-duration-box", { v["count"] = -1 } - let realName = "" - if (typeof this.name == "string" && this.name.length > 0) { - realName = this.name - } else if (typeof this.vName == "string" && this.vName.length > 0) { - realName = this.vName + let minUnit = this.vMinUnit + let units = [ + { + code: "ms", + name: "毫秒" + }, + { + code: "second", + name: "秒" + }, + { + code: "minute", + name: "分钟" + }, + { + code: "hour", + name: "小时" + }, + { + code: "day", + name: "天" + } + ] + let minUnitIndex = -1 + if (minUnit != null && typeof minUnit == "string" && minUnit.length > 0) { + for (let i = 0; i < units.length; i++) { + if (units[i].code == minUnit) { + minUnitIndex = i + break + } + } + } + if (minUnitIndex > -1) { + units = units.slice(minUnitIndex) + } + + let maxLength = parseInt(this.maxlength) + if (typeof maxLength != "number") { + maxLength = 10 } return { duration: v, countString: (v.count >= 0) ? v.count.toString() : "", - realName: realName + units: units, + realMaxLength: maxLength } }, watch: { @@ -48,19 +83,37 @@ Vue.component("time-duration-box", { } }, template: `
用来区分不同缓存内容的唯一Key。