From 569fe06982b5bf9fd3331aa69d2d6e1b5569c2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Thu, 18 Jul 2024 17:40:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/date.js | 35 ++++++++++++++++++ src/utils/index.js | 6 ++++ src/views/ss/suit/index.vue | 28 +++++++++++---- src/views/ss/time/index.vue | 36 ++++++++++++++----- .../device/components/rechargeRecord.vue | 12 ++++++- src/views/system/device/detail.vue | 27 +++++++------- src/views/system/recharge/detail.vue | 32 ++++++++++++++++- 7 files changed, 144 insertions(+), 32 deletions(-) create mode 100644 src/utils/date.js diff --git a/src/utils/date.js b/src/utils/date.js new file mode 100644 index 0000000..5b83535 --- /dev/null +++ b/src/utils/date.js @@ -0,0 +1,35 @@ +/** + * 将秒钟转为描述 + */ +export function toDescriptionFromSecond(data) { + let seconds = data; + if (data instanceof String) { + seconds = parseInt(data) + } + let positive = true; + if (seconds < 0) { + positive =false; + seconds = -seconds; + } + + let desc = { + day: parseInt(seconds / 86400), + hour: parseInt((seconds % 86400) / 3600), + minute: parseInt((seconds % 3600) / 60), + second: parseInt(seconds % 60), + positive: positive, + } + + desc.text = `${positive ? '' : '-'} `; + if (desc.day > 0) { + desc.text += desc.day + ' 天 '; + } + if (desc.day > 0 || desc.hour > 0) { + desc.text += desc.hour + ' 时 '; + } + if (desc.day > 0 || desc.hour > 0 || desc.minute > 0) { + desc.text += desc.minute + ' 分 '; + } + desc.text += desc.second + ' 秒'; + return desc; +} diff --git a/src/utils/index.js b/src/utils/index.js index 8e495bf..08b75d1 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -454,3 +454,9 @@ export function escapeHtml(text, allowScript = false) { export function isEmpty(str) { return str == null || str.length === 0; } + +// 获取列表label +export function findLabel(options, value, prop = 'value', propLabel = 'label') { + let obj = options.find(item => item[prop] === value); + return obj == null ? null : obj[propLabel] +} diff --git a/src/views/ss/suit/index.vue b/src/views/ss/suit/index.vue index a7d7b79..6f307b5 100644 --- a/src/views/ss/suit/index.vue +++ b/src/views/ss/suit/index.vue @@ -85,7 +85,7 @@ - + @@ -130,7 +130,18 @@ - 分钟 + + + 元 @@ -150,13 +161,17 @@