|
@@ -1,4 +1,4 @@
|
|
|
-export const isValue = (val) => {
|
|
|
+module.exports.isValue = (val) => {
|
|
|
if (val === null || val === undefined || (typeof val === 'string' && val.trim() === '') || (typeof val === 'object' && val?.length === 0)) {
|
|
|
return false
|
|
|
}
|
|
@@ -6,7 +6,7 @@ export const isValue = (val) => {
|
|
|
}
|
|
|
|
|
|
// 对象转驼峰命名
|
|
|
-export const objToCamel = (obj) => {
|
|
|
+module.exports.objToCamel = (obj) => {
|
|
|
for (let key in obj) {
|
|
|
let newKey = key.replace(/_([a-z])/g, function($0, $1){ return $1.toUpperCase(); });
|
|
|
if (newKey !== key) {
|
|
@@ -16,7 +16,7 @@ export const objToCamel = (obj) => {
|
|
|
}
|
|
|
}
|
|
|
// 对象转下划线命名
|
|
|
-export const objToUnder = (obj) => {
|
|
|
+module.exports.objToUnder = (obj) => {
|
|
|
for (let key in obj) {
|
|
|
let newKey = key.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
|
if (newKey !== key) {
|
|
@@ -26,15 +26,15 @@ export const objToUnder = (obj) => {
|
|
|
}
|
|
|
}
|
|
|
// 参数转驼峰命名
|
|
|
-export const paramToCamel = (param) => {
|
|
|
+module.exports.paramToCamel = (param) => {
|
|
|
return param.replace(/_([a-z])/g, function($0, $1){ return $1.toUpperCase(); });
|
|
|
}
|
|
|
// 参数转下划线命名
|
|
|
-export const paramToUnder = (param) => {
|
|
|
+module.exports.paramToUnder = (param) => {
|
|
|
return param.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
|
}
|
|
|
|
|
|
-export const YMDHms = (date) => {
|
|
|
+module.exports.YMDHms = (date) => {
|
|
|
const _date = new Date(date)
|
|
|
const Y = `${_date.getFullYear()}`;
|
|
|
const M = `${_date.getMonth() + 1 < 10 ? `0${_date.getMonth() + 1}` : _date.getMonth() + 1}`;
|
|
@@ -45,7 +45,7 @@ export const YMDHms = (date) => {
|
|
|
return `${Y}-${M}-${D} ${H}:${m}:${s}`;
|
|
|
}
|
|
|
|
|
|
-export const YMD = (date, format = false) => {
|
|
|
+module.exports.YMD = (date, format = false) => {
|
|
|
const _date = new Date(date)
|
|
|
const Y = `${_date.getFullYear()}`;
|
|
|
const M = `${_date.getMonth() + 1 < 10 ? `0${_date.getMonth() + 1}` : _date.getMonth() + 1}`;
|
|
@@ -53,7 +53,7 @@ export const YMD = (date, format = false) => {
|
|
|
return format ? `${Y}年${M}月${D}日` : `${Y}-${M}-${D}`;
|
|
|
}
|
|
|
|
|
|
-export const Hms = (date, format = false) => {
|
|
|
+module.exports.Hms = (date, format = false) => {
|
|
|
const _date = new Date(date)
|
|
|
const H = `${_date.getHours() < 10 ? `0${_date.getHours()}` : _date.getHours()}`;
|
|
|
const m = `${_date.getMinutes() < 10 ? `0${_date.getMinutes()}` : _date.getMinutes()}`;
|