From 3f9d0cf2eaef80a745788e7fb2fa92a37eef853f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 14 Oct 2020 14:38:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A5=E6=9C=9F=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/js/ry-ui.js | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 485d8c8f5..ce6ee6954 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -994,7 +994,6 @@ var table = { $.operate.submit(url, "post", "json", data); } }); - }, // 批量删除信息 removeAll: function() { @@ -1503,6 +1502,39 @@ var table = { }); return flag ? str : ''; }, + // 日期格式化 时间戳 -> yyyy-MM-dd HH-mm-ss + dateFormat: function(date, format) { + var that = this; + if (that.isEmpty(date)) return ""; + if (!date) return; + if (!format) format = "yyyy-MM-dd"; + switch (typeof date) { + case "string": + date = new Date(date.replace(/-/, "/")); + break; + case "number": + date = new Date(date); + break; + } + if (!date instanceof Date) return; + var dict = { + "yyyy": date.getFullYear(), + "M": date.getMonth() + 1, + "d": date.getDate(), + "H": date.getHours(), + "m": date.getMinutes(), + "s": date.getSeconds(), + "MM": ("" + (date.getMonth() + 101)).substr(1), + "dd": ("" + (date.getDate() + 100)).substr(1), + "HH": ("" + (date.getHours() + 100)).substr(1), + "mm": ("" + (date.getMinutes() + 100)).substr(1), + "ss": ("" + (date.getSeconds() + 100)).substr(1) + }; + return format.replace(/(yyyy|MM?|dd?|HH?|ss?|mm?)/g, + function() { + return dict[arguments[0]]; + }); + }, // 获取节点数据,支持多层级访问 getItemField: function (item, field) { var value = item;