|
@@ -43,7 +43,7 @@ export function dateFormat(date, format) {
|
|
|
if (new RegExp("(" + k + ")").test(format))
|
|
|
format = format.replace(RegExp.$1,
|
|
|
RegExp.$1.length === 1 ? o[k] :
|
|
|
- ("00" + o[k]).substr(("" + o[k]).length));
|
|
|
+ ("00" + o[k]).substr(("" + o[k]).length));
|
|
|
return format;
|
|
|
}
|
|
|
return '';
|
|
@@ -66,17 +66,17 @@ export function defaultDate(type) {
|
|
|
dateFormat(startDate, "yyyy-MM-dd"),
|
|
|
dateFormat(endDate, "yyyy-MM-dd")
|
|
|
];
|
|
|
- }else if (type == 3){
|
|
|
- return[
|
|
|
- dateFormat(new Date(date.getFullYear(), date.getMonth()-1, 1), "yyyy-MM-dd"),
|
|
|
- dateFormat(new Date((date.getMonth() + 1) === 12?date.getFullYear()+1:date.getFullYear(), (date.getMonth() + 1), date.getDate()), "yyyy-MM-dd")
|
|
|
+ } else if (type == 3) {
|
|
|
+ return [
|
|
|
+ dateFormat(new Date(date.getFullYear(), date.getMonth() - 1, 1), "yyyy-MM-dd"),
|
|
|
+ dateFormat(new Date((date.getMonth() + 1) === 12 ? date.getFullYear() + 1 : date.getFullYear(), (date.getMonth() + 1), date.getDate()), "yyyy-MM-dd")
|
|
|
];
|
|
|
- } else if (type == 4){
|
|
|
- return[
|
|
|
+ } else if (type == 4) {
|
|
|
+ return [
|
|
|
dateFormat(new Date(date.getFullYear(), date.getMonth(), 1), "yyyy-MM-dd"),
|
|
|
dateFormat(new Date(date.getFullYear(), date.getMonth() + 1, 0), "yyyy-MM-dd")
|
|
|
];
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return [
|
|
|
dateFormat(startDate, "yyyy-MM-dd") + " 00:00:00",
|
|
|
dateFormat(endDate, "yyyy-MM-dd") + " 23:59:59"
|
|
@@ -87,7 +87,7 @@ export function defaultDate(type) {
|
|
|
* 获取当天
|
|
|
* [yyyy-MM-dd,yyyy-MM-dd]
|
|
|
*/
|
|
|
- export function defaultDate2() {
|
|
|
+export function defaultDate2() {
|
|
|
const date = new Date();
|
|
|
return [
|
|
|
dateFormat(date, "yyyy-MM-dd"),
|
|
@@ -101,7 +101,7 @@ export function defaultDate(type) {
|
|
|
export function defaultDate3() {
|
|
|
const date = new Date();
|
|
|
const startDate = new Date(date.getFullYear(), date.getMonth(), 1);
|
|
|
- const endDate = new Date(date.getFullYear(), date.getMonth()+1, 0);
|
|
|
+ const endDate = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
|
return [
|
|
|
dateFormat(startDate, "yyyy-MM-dd"),
|
|
|
dateFormat(endDate, "yyyy-MM-dd")
|
|
@@ -122,21 +122,21 @@ export function startDate() {
|
|
|
*/
|
|
|
export function endDate() {
|
|
|
const date = new Date();
|
|
|
- const endDate = new Date(date.getFullYear(), date.getMonth()+1, 0);
|
|
|
+ const endDate = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
|
return dateFormat(endDate, "yyyy-MM-dd");
|
|
|
}
|
|
|
/**
|
|
|
* 获取当年
|
|
|
* [yyyy-MM-dd,yyyy-MM-dd]
|
|
|
*/
|
|
|
- export function defaultDate4() {
|
|
|
+export function defaultDate4() {
|
|
|
const date = new Date();
|
|
|
return dateFormat(date, "yyyy");
|
|
|
}
|
|
|
/**
|
|
|
* 获取本年上个月
|
|
|
*/
|
|
|
-export function CurrentMonth(date,format = 'yyyy-MM-dd hh:mm:ss') {
|
|
|
+export function CurrentMonth(date, format = 'yyyy-MM-dd hh:mm:ss') {
|
|
|
format = format || 'yyyy-MM-dd hh:mm:ss';
|
|
|
if (date !== 'Invalid Date') {
|
|
|
let o = {
|
|
@@ -168,9 +168,9 @@ export function CurrentMonth(date,format = 'yyyy-MM-dd hh:mm:ss') {
|
|
|
* 获取上月第一天和上月最后一天
|
|
|
* [yyyy-MM-dd,yyyy-MM-dd]
|
|
|
*/
|
|
|
- export function defaultDate5() {
|
|
|
+export function defaultDate5() {
|
|
|
const date = new Date();
|
|
|
- const startDate = new Date(date.getFullYear(), date.getMonth()-1, 1);
|
|
|
+ const startDate = new Date(date.getFullYear(), date.getMonth() - 1, 1);
|
|
|
const endDate = new Date(date.getFullYear(), date.getMonth(), 0);
|
|
|
return [
|
|
|
dateFormat(startDate, "yyyy-MM-dd") + " 00:00:00",
|
|
@@ -187,7 +187,7 @@ export function getCurrentDate(type = 'dateTime') {
|
|
|
return dateFormat(date, 'yyyy-MM-dd hh:mm:ss')
|
|
|
}
|
|
|
}
|
|
|
-export function getYearDate(){
|
|
|
+export function getYearDate() {
|
|
|
const date = new Date();
|
|
|
return date.getFullYear()
|
|
|
}
|
|
@@ -214,3 +214,8 @@ function addZero(num) {
|
|
|
}
|
|
|
return num;
|
|
|
}
|
|
|
+
|
|
|
+export function verifyEnglish(str) {
|
|
|
+ const regex = /^[A-Za-z0-9\n .,!?:()|/+-_;'"$&@%*]+$/;
|
|
|
+ return regex.test(str?str:null);
|
|
|
+}
|