From 62ef92c5cc62f78f80f51658ba3546c0a08d5f8d Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Mon, 12 Dec 2022 10:01:11 +0000
Subject: [PATCH] 节日管理

---
 eladmin-web-master/src/components/Crud/crud.js |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/eladmin-web-master/src/components/Crud/crud.js b/eladmin-web-master/src/components/Crud/crud.js
index b5bd398..23f6fe4 100644
--- a/eladmin-web-master/src/components/Crud/crud.js
+++ b/eladmin-web-master/src/components/Crud/crud.js
@@ -529,6 +529,53 @@
           })
         }
       })
+    },
+    /**
+     * 日期格式化
+     * @param {Object} timestamp 时间戳
+     */
+    toDate(timestamp) {
+      if (timestamp == null) {
+        return
+      } else {
+        const system = new Date(timestamp)
+        const year = system.getFullYear()
+        const month = system.getMonth() + 1 < 10 ? '0' + (system.getMonth() + 1) : system.getMonth() + 1
+        const date = system.getDate() < 10 ? '0' + system.getDate() : system.getDate()
+        return year + '-' + month + '-' + date
+      }
+    },
+    /**
+     * 时间格式化
+     * @param {Object} timestamp
+     */
+    toTime(timestamp) {
+      if (timestamp == null) {
+        return
+      } else {
+        const system = new Date(timestamp)
+        const hours = system.getHours() < 10 ? '0' + system.getHours() : system.getHours()
+        const minutes = system.getMinutes() < 10 ? '0' + system.getMinutes() : system.getMinutes()
+        const seconds = system.getSeconds() < 10 ? '0' + system.getSeconds() : system.getSeconds()
+        return hours + ':' + minutes + ':' + seconds
+      }
+    },
+    /**
+     * 金额格式
+     * @param {Object} num
+     */
+    toMoney(num) {
+      let sign = ''
+      let cents = 0
+      if (num != null) { num = num.toString().replace(/\$|\,/g, '') }
+      if (isNaN(num) || num == null) { num = '0' }
+      sign = (Number(num) === (num = Math.abs(num)))
+      num = Math.floor(num * 100 + 0.50000000001)
+      cents = num % 100
+      num = Math.floor(num / 100).toString()
+      if (cents < 10) { cents = '0' + cents }
+      for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) { num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3)) }
+      return (((sign) ? '' : '-') + num + '.' + cents)
     }
   }
   const crud = Object.assign({}, data)

--
Gitblit v1.9.3