imeik-bizui 2.8.3 → 2.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,13 +141,16 @@ export default {
141
141
  budgetNum() {
142
142
  return parseAmount(this.overview && this.overview.budgetAmount)
143
143
  },
144
+ /** 有有效总预算才算占比;否则不展示假的 100% 剩余 */
145
+ hasBudgetRatio() {
146
+ return Number.isFinite(this.usedNum) && Number.isFinite(this.budgetNum) && this.budgetNum > 0
147
+ },
144
148
  usagePercent() {
145
- const used = this.usedNum
146
- const budget = this.budgetNum
147
- if (!Number.isFinite(used) || !Number.isFinite(budget) || budget <= 0) return 0
148
- return (used / budget) * 100
149
+ if (!this.hasBudgetRatio) return NaN
150
+ return (this.usedNum / this.budgetNum) * 100
149
151
  },
150
152
  fillWidth() {
153
+ if (!this.hasBudgetRatio) return '0'
151
154
  return Math.min(Math.max(this.usagePercent, 0), 100).toFixed(2)
152
155
  },
153
156
  warnAmount() {
@@ -171,6 +174,7 @@ export default {
171
174
  return 'is-mid'
172
175
  },
173
176
  barLabel() {
177
+ if (!this.hasBudgetRatio) return '剩余 —'
174
178
  const remain = 100 - this.usagePercent
175
179
  if (remain < 0) return `已超 ${formatPercent(this.usagePercent - 100)}`
176
180
  return `剩余 ${formatPercent(remain)}`