|
@@ -1,35 +1,36 @@
|
|
// Parse the time to string
|
|
// Parse the time to string
|
|
-import Keys from '@/constant/key'
|
|
|
|
-import { store } from '@/store'
|
|
|
|
-import Cookies from 'js-cookie'
|
|
|
|
-import any = jasmine.any
|
|
|
|
|
|
+import Keys from '@/constant/key';
|
|
|
|
+import { store } from '@/store';
|
|
|
|
+import Cookies from 'js-cookie';
|
|
|
|
+import { type } from 'os';
|
|
|
|
+import any = jasmine.any;
|
|
|
|
|
|
export const parseTime = (
|
|
export const parseTime = (
|
|
time?: object | string | number | null,
|
|
time?: object | string | number | null,
|
|
cFormat?: string
|
|
cFormat?: string
|
|
): string | null => {
|
|
): string | null => {
|
|
if (time === undefined || !time) {
|
|
if (time === undefined || !time) {
|
|
- return null
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
|
|
|
|
- let date: Date
|
|
|
|
|
|
+ const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}';
|
|
|
|
+ let date: Date;
|
|
if (typeof time === 'object') {
|
|
if (typeof time === 'object') {
|
|
- date = time as Date
|
|
|
|
|
|
+ date = time as Date;
|
|
} else {
|
|
} else {
|
|
if (typeof time === 'string') {
|
|
if (typeof time === 'string') {
|
|
if (/^[0-9]+$/.test(time)) {
|
|
if (/^[0-9]+$/.test(time)) {
|
|
// support "1548221490638"
|
|
// support "1548221490638"
|
|
- time = parseInt(time)
|
|
|
|
|
|
+ time = parseInt(time);
|
|
} else {
|
|
} else {
|
|
// support safari
|
|
// support safari
|
|
// https://stackoverflow.com/questions/4310953/invalid-date-in-safari
|
|
// https://stackoverflow.com/questions/4310953/invalid-date-in-safari
|
|
- time = time.replace(new RegExp(/-/gm), '/')
|
|
|
|
|
|
+ time = time.replace(new RegExp(/-/gm), '/');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (typeof time === 'number' && time.toString().length === 10) {
|
|
if (typeof time === 'number' && time.toString().length === 10) {
|
|
- time = time * 1000
|
|
|
|
|
|
+ time = time * 1000;
|
|
}
|
|
}
|
|
- date = new Date(time)
|
|
|
|
|
|
+ date = new Date(time);
|
|
}
|
|
}
|
|
const formatObj: { [key: string]: number } = {
|
|
const formatObj: { [key: string]: number } = {
|
|
y: date.getFullYear(),
|
|
y: date.getFullYear(),
|
|
@@ -38,197 +39,198 @@ export const parseTime = (
|
|
h: date.getHours(),
|
|
h: date.getHours(),
|
|
i: date.getMinutes(),
|
|
i: date.getMinutes(),
|
|
s: date.getSeconds(),
|
|
s: date.getSeconds(),
|
|
- a: date.getDay()
|
|
|
|
- }
|
|
|
|
|
|
+ a: date.getDay(),
|
|
|
|
+ };
|
|
const timeStr = format.replace(/{([ymdhisa])+}/g, (result, key) => {
|
|
const timeStr = format.replace(/{([ymdhisa])+}/g, (result, key) => {
|
|
- const value = formatObj[key]
|
|
|
|
|
|
+ const value = formatObj[key];
|
|
// Note: getDay() returns 0 on Sunday
|
|
// Note: getDay() returns 0 on Sunday
|
|
if (key === 'a') {
|
|
if (key === 'a') {
|
|
- return ['日', '一', '二', '三', '四', '五', '六'][value]
|
|
|
|
|
|
+ return ['日', '一', '二', '三', '四', '五', '六'][value];
|
|
}
|
|
}
|
|
- return value.toString().padStart(2, '0')
|
|
|
|
- })
|
|
|
|
- return timeStr
|
|
|
|
-}
|
|
|
|
|
|
+ return value.toString().padStart(2, '0');
|
|
|
|
+ });
|
|
|
|
+ return timeStr;
|
|
|
|
+};
|
|
|
|
|
|
// Format and filter json data using filterKeys array
|
|
// Format and filter json data using filterKeys array
|
|
export const formatJson = (filterKeys: any, jsonData: any) =>
|
|
export const formatJson = (filterKeys: any, jsonData: any) =>
|
|
- jsonData.map((data: any) => filterKeys.map((key: string) => {
|
|
|
|
- if (key === 'timestamp') {
|
|
|
|
- return parseTime(data[key])
|
|
|
|
- } else {
|
|
|
|
- return data[key]
|
|
|
|
- }
|
|
|
|
- }))
|
|
|
|
|
|
+ jsonData.map((data: any) =>
|
|
|
|
+ filterKeys.map((key: string) => {
|
|
|
|
+ if (key === 'timestamp') {
|
|
|
|
+ return parseTime(data[key]);
|
|
|
|
+ } else {
|
|
|
|
+ return data[key];
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
|
|
// Check if an element has a class
|
|
// Check if an element has a class
|
|
export const hasClass = (ele: HTMLElement, className: string) => {
|
|
export const hasClass = (ele: HTMLElement, className: string) => {
|
|
- return !!ele.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'))
|
|
|
|
-}
|
|
|
|
|
|
+ return !!ele.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
|
|
|
|
+};
|
|
|
|
|
|
// Add class to element
|
|
// Add class to element
|
|
export const addClass = (ele: HTMLElement, className: string) => {
|
|
export const addClass = (ele: HTMLElement, className: string) => {
|
|
- if (!hasClass(ele, className)) ele.className += ' ' + className
|
|
|
|
-}
|
|
|
|
|
|
+ if (!hasClass(ele, className)) ele.className += ' ' + className;
|
|
|
|
+};
|
|
|
|
|
|
// Remove class from element
|
|
// Remove class from element
|
|
export const removeClass = (ele: HTMLElement, className: string) => {
|
|
export const removeClass = (ele: HTMLElement, className: string) => {
|
|
if (hasClass(ele, className)) {
|
|
if (hasClass(ele, className)) {
|
|
- const reg = new RegExp('(\\s|^)' + className + '(\\s|$)')
|
|
|
|
- ele.className = ele.className.replace(reg, ' ')
|
|
|
|
|
|
+ const reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
|
|
|
|
+ ele.className = ele.className.replace(reg, ' ');
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
// Toggle class for the selected element
|
|
// Toggle class for the selected element
|
|
export const toggleClass = (ele: HTMLElement, className: string) => {
|
|
export const toggleClass = (ele: HTMLElement, className: string) => {
|
|
if (!ele || !className) {
|
|
if (!ele || !className) {
|
|
- return
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- let classString = ele.className
|
|
|
|
- const nameIndex = classString.indexOf(className)
|
|
|
|
|
|
+ let classString = ele.className;
|
|
|
|
+ const nameIndex = classString.indexOf(className);
|
|
if (nameIndex === -1) {
|
|
if (nameIndex === -1) {
|
|
- classString += '' + className
|
|
|
|
|
|
+ classString += '' + className;
|
|
} else {
|
|
} else {
|
|
classString =
|
|
classString =
|
|
- classString.substr(0, nameIndex) +
|
|
|
|
- classString.substr(nameIndex + className.length)
|
|
|
|
|
|
+ classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length);
|
|
}
|
|
}
|
|
- ele.className = classString
|
|
|
|
-}
|
|
|
|
|
|
+ ele.className = classString;
|
|
|
|
+};
|
|
export const setQueryConfig = function (queryConfig: any) {
|
|
export const setQueryConfig = function (queryConfig: any) {
|
|
- let _str = ''
|
|
|
|
|
|
+ let _str = '';
|
|
for (const o in queryConfig) {
|
|
for (const o in queryConfig) {
|
|
if (queryConfig[o] !== -1) {
|
|
if (queryConfig[o] !== -1) {
|
|
- _str += o + '=' + queryConfig[o] + '&'
|
|
|
|
|
|
+ _str += o + '=' + queryConfig[o] + '&';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- _str = _str.substring(0, _str.length - 1) // 末尾是&
|
|
|
|
- return _str
|
|
|
|
-}
|
|
|
|
|
|
+ _str = _str.substring(0, _str.length - 1); // 末尾是&
|
|
|
|
+ return _str;
|
|
|
|
+};
|
|
|
|
|
|
// 获取用户信息
|
|
// 获取用户信息
|
|
export const getUserInfo = function () {
|
|
export const getUserInfo = function () {
|
|
// debugger
|
|
// debugger
|
|
- let userInfo = store.state.user
|
|
|
|
|
|
+ let userInfo = store.state.user;
|
|
const paramsInfo: any = {
|
|
const paramsInfo: any = {
|
|
openid: userInfo.openid,
|
|
openid: userInfo.openid,
|
|
userId: userInfo.userId,
|
|
userId: userInfo.userId,
|
|
mac: userInfo.mac,
|
|
mac: userInfo.mac,
|
|
pubname: Keys.pubname,
|
|
pubname: Keys.pubname,
|
|
- projectId: userInfo.projectId
|
|
|
|
- }
|
|
|
|
|
|
+ projectId: userInfo.projectId,
|
|
|
|
+ };
|
|
if (userInfo.userName) {
|
|
if (userInfo.userName) {
|
|
- paramsInfo.userName = userInfo.userName
|
|
|
|
|
|
+ paramsInfo.userName = userInfo.userName;
|
|
}
|
|
}
|
|
if (userInfo.userPhone) {
|
|
if (userInfo.userPhone) {
|
|
- paramsInfo.userPhone = userInfo.userPhone
|
|
|
|
|
|
+ paramsInfo.userPhone = userInfo.userPhone;
|
|
}
|
|
}
|
|
- return paramsInfo
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
+ return paramsInfo;
|
|
|
|
+};
|
|
|
|
|
|
// 地址通用参赛携带
|
|
// 地址通用参赛携带
|
|
export const getComparams = function () {
|
|
export const getComparams = function () {
|
|
- let userInfo = store.state.user
|
|
|
|
|
|
+ let userInfo = store.state.user;
|
|
let paramsInfo: any = {
|
|
let paramsInfo: any = {
|
|
openid: Keys.openid,
|
|
openid: Keys.openid,
|
|
userId: userInfo.userId,
|
|
userId: userInfo.userId,
|
|
pubname: Keys.pubname,
|
|
pubname: Keys.pubname,
|
|
mac: userInfo.mac,
|
|
mac: userInfo.mac,
|
|
- projectId: userInfo.projectId
|
|
|
|
- }
|
|
|
|
|
|
+ projectId: userInfo.projectId,
|
|
|
|
+ };
|
|
if (userInfo.userName) {
|
|
if (userInfo.userName) {
|
|
- paramsInfo.userName = userInfo.userName
|
|
|
|
|
|
+ paramsInfo.userName = userInfo.userName;
|
|
}
|
|
}
|
|
if (userInfo.userPhone) {
|
|
if (userInfo.userPhone) {
|
|
- paramsInfo.userPhone = userInfo.userPhone
|
|
|
|
|
|
+ paramsInfo.userPhone = userInfo.userPhone;
|
|
}
|
|
}
|
|
- return paramsInfo
|
|
|
|
-}
|
|
|
|
|
|
+ return paramsInfo;
|
|
|
|
+};
|
|
|
|
|
|
export const formatDate = function (split: string = 'YYYYMMDD', date: any = new Date()) {
|
|
export const formatDate = function (split: string = 'YYYYMMDD', date: any = new Date()) {
|
|
//三目运算符
|
|
//三目运算符
|
|
- const dates = date ? date : new Date()
|
|
|
|
|
|
+ const dates = date ? date : new Date();
|
|
//年份
|
|
//年份
|
|
- const year: number = dates.getFullYear()
|
|
|
|
|
|
+ const year: number = dates.getFullYear();
|
|
//月份下标是0-11
|
|
//月份下标是0-11
|
|
- const month: any = (dates.getMonth() + 1) < 10 ? '0' + (dates.getMonth() + 1) : (dates.getMonth() + 1)
|
|
|
|
|
|
+ const month: any =
|
|
|
|
+ dates.getMonth() + 1 < 10 ? '0' + (dates.getMonth() + 1) : dates.getMonth() + 1;
|
|
//具体的天数
|
|
//具体的天数
|
|
- const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate()
|
|
|
|
|
|
+ const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate();
|
|
// //小时
|
|
// //小时
|
|
- const Hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours()
|
|
|
|
|
|
+ const Hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours();
|
|
// //分钟
|
|
// //分钟
|
|
- const Minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes()
|
|
|
|
|
|
+ const Minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes();
|
|
// //秒
|
|
// //秒
|
|
- const Seconds = dates.getSeconds() < 10 ? '0' + dates.getSeconds() : dates.getSeconds()
|
|
|
|
|
|
+ const Seconds = dates.getSeconds() < 10 ? '0' + dates.getSeconds() : dates.getSeconds();
|
|
//返回数据格式
|
|
//返回数据格式
|
|
if (split === 'YYYY年MM月DD日') {
|
|
if (split === 'YYYY年MM月DD日') {
|
|
- return year + '年' + month + '月' + day + '日'
|
|
|
|
|
|
+ return year + '年' + month + '月' + day + '日';
|
|
} else if (split === 'YYYY.MM') {
|
|
} else if (split === 'YYYY.MM') {
|
|
- return year + '.' + month
|
|
|
|
|
|
+ return year + '.' + month;
|
|
} else if (split === 'YYYYMM') {
|
|
} else if (split === 'YYYYMM') {
|
|
- return year + '' + month
|
|
|
|
|
|
+ return year + '' + month;
|
|
} else if (split === 'YYYY-MM-DD') {
|
|
} else if (split === 'YYYY-MM-DD') {
|
|
- return year + '-' + month + '-' + day
|
|
|
|
|
|
+ return year + '-' + month + '-' + day;
|
|
} else if (split === 'YYYY.MM.DD HH:mm') {
|
|
} else if (split === 'YYYY.MM.DD HH:mm') {
|
|
- return year + '.' + month + "." + day + " " + Hours + ":" + Minutes
|
|
|
|
|
|
+ return year + '.' + month + '.' + day + ' ' + Hours + ':' + Minutes;
|
|
} else if (split === 'YYYY.MM.DD HH:mm:ss') {
|
|
} else if (split === 'YYYY.MM.DD HH:mm:ss') {
|
|
- return year + '.' + month + "." + day + " " + Hours + ":" + Minutes + ":" + Seconds
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- return year + '' + month + '' + day
|
|
|
|
|
|
+ return year + '.' + month + '.' + day + ' ' + Hours + ':' + Minutes + ':' + Seconds;
|
|
|
|
+ } else {
|
|
|
|
+ return year + '' + month + '' + day;
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
// 把字符串 (yyyymmdd) 转换成日期格式(yyyy-mm-dd)
|
|
// 把字符串 (yyyymmdd) 转换成日期格式(yyyy-mm-dd)
|
|
export const formatDateStr = function (date: any) {
|
|
export const formatDateStr = function (date: any) {
|
|
if (date) {
|
|
if (date) {
|
|
- return date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3')
|
|
|
|
|
|
+ return date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3');
|
|
} else {
|
|
} else {
|
|
- return ''
|
|
|
|
|
|
+ return '';
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
export const getTomorrow = function (split: any = '') {
|
|
export const getTomorrow = function (split: any = '') {
|
|
- let dates = new Date()
|
|
|
|
- dates.setTime(dates.getTime() + 24 * 60 * 60 * 1000)
|
|
|
|
- const Year: number = dates.getFullYear()
|
|
|
|
|
|
+ let dates = new Date();
|
|
|
|
+ dates.setTime(dates.getTime() + 24 * 60 * 60 * 1000);
|
|
|
|
+ const Year: number = dates.getFullYear();
|
|
//月份下标是0-11
|
|
//月份下标是0-11
|
|
- const Months: any = (dates.getMonth() + 1) < 10 ? '0' + (dates.getMonth() + 1) : (dates.getMonth() + 1)
|
|
|
|
|
|
+ const Months: any =
|
|
|
|
+ dates.getMonth() + 1 < 10 ? '0' + (dates.getMonth() + 1) : dates.getMonth() + 1;
|
|
//具体的天数
|
|
//具体的天数
|
|
- const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate()
|
|
|
|
|
|
+ const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate();
|
|
//返回数据格式
|
|
//返回数据格式
|
|
- return Year + split + Months + split + day
|
|
|
|
-}
|
|
|
|
|
|
+ return Year + split + Months + split + day;
|
|
|
|
+};
|
|
|
|
|
|
export function getHours() {
|
|
export function getHours() {
|
|
- return new Date().getHours()
|
|
|
|
|
|
+ return new Date().getHours();
|
|
}
|
|
}
|
|
|
|
|
|
export function parseImgUrl(base: string, img: string) {
|
|
export function parseImgUrl(base: string, img: string) {
|
|
if (img) {
|
|
if (img) {
|
|
- return `${process.env.BASE_URL}images/${base}/${img}`
|
|
|
|
|
|
+ return `${process.env.BASE_URL}images/${base}/${img}`;
|
|
} else {
|
|
} else {
|
|
- return ''
|
|
|
|
|
|
+ return '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 判断舒服在当前公司
|
|
// 判断舒服在当前公司
|
|
export function isWithinLocation(companyConfig: any) {
|
|
export function isWithinLocation(companyConfig: any) {
|
|
- let targetLocationInfo, maxDistance
|
|
|
|
|
|
+ let targetLocationInfo, maxDistance;
|
|
// 是否有权限不限制距离 true-不限制,false-限制
|
|
// 是否有权限不限制距离 true-不限制,false-限制
|
|
- let remoteControl = store.state.user.remoteControl
|
|
|
|
|
|
+ let remoteControl = store.state.user.remoteControl;
|
|
// let companyConfig = store.state.company.companyConfig
|
|
// let companyConfig = store.state.company.companyConfig
|
|
|
|
|
|
if (companyConfig.sagaCare && companyConfig.sagaCareLimit) {
|
|
if (companyConfig.sagaCare && companyConfig.sagaCareLimit) {
|
|
- maxDistance = companyConfig.sagaCareDistance
|
|
|
|
- let location = companyConfig.sagaCareCoords.split(',')
|
|
|
|
|
|
+ maxDistance = companyConfig.sagaCareDistance;
|
|
|
|
+ let location = companyConfig.sagaCareCoords.split(',');
|
|
targetLocationInfo = {
|
|
targetLocationInfo = {
|
|
longitude: location[0],
|
|
longitude: location[0],
|
|
- latitude: location[1]
|
|
|
|
- }
|
|
|
|
|
|
+ latitude: location[1],
|
|
|
|
+ };
|
|
}
|
|
}
|
|
- maxDistance = maxDistance || 1
|
|
|
|
- let toastTip = '您好像不在公司'
|
|
|
|
|
|
+ maxDistance = maxDistance || 1;
|
|
|
|
+ let toastTip = '您好像不在公司';
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -236,11 +238,11 @@ export function isWithinLocation(companyConfig: any) {
|
|
* @param year
|
|
* @param year
|
|
*/
|
|
*/
|
|
export function getAddYear(year: number = 0) {
|
|
export function getAddYear(year: number = 0) {
|
|
- let time = new Date()
|
|
|
|
- time.setFullYear(time.getFullYear() + year)
|
|
|
|
- let y = time.getFullYear()
|
|
|
|
- let m = time.getMonth() + 1
|
|
|
|
- return new Date(y + '/' + m)
|
|
|
|
|
|
+ let time = new Date();
|
|
|
|
+ time.setFullYear(time.getFullYear() + year);
|
|
|
|
+ let y = time.getFullYear();
|
|
|
|
+ let m = time.getMonth() + 1;
|
|
|
|
+ return new Date(y + '/' + m);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -248,22 +250,22 @@ export function getAddYear(year: number = 0) {
|
|
* 获取上一个月,日期格式yyyyMM
|
|
* 获取上一个月,日期格式yyyyMM
|
|
*/
|
|
*/
|
|
export function getPreMonth(formatType: any = '') {
|
|
export function getPreMonth(formatType: any = '') {
|
|
- const nowdays = new Date()
|
|
|
|
- let year = nowdays.getFullYear()
|
|
|
|
- let month: any = nowdays.getMonth()
|
|
|
|
|
|
+ const nowdays = new Date();
|
|
|
|
+ let year = nowdays.getFullYear();
|
|
|
|
+ let month: any = nowdays.getMonth();
|
|
if (month === 0) {
|
|
if (month === 0) {
|
|
- month = 12
|
|
|
|
- year = year - 1
|
|
|
|
|
|
+ month = 12;
|
|
|
|
+ year = year - 1;
|
|
}
|
|
}
|
|
if (month < 10) {
|
|
if (month < 10) {
|
|
- month = '0' + month
|
|
|
|
|
|
+ month = '0' + month;
|
|
}
|
|
}
|
|
if (formatType === 'YYYY.MM') {
|
|
if (formatType === 'YYYY.MM') {
|
|
- return year + '.' + month
|
|
|
|
|
|
+ return year + '.' + month;
|
|
} else if (formatType === 'YYYY年MM月') {
|
|
} else if (formatType === 'YYYY年MM月') {
|
|
- return year + '年' + month + '月'
|
|
|
|
|
|
+ return year + '年' + month + '月';
|
|
} else {
|
|
} else {
|
|
- return year + '' + month
|
|
|
|
|
|
+ return year + '' + month;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -272,39 +274,36 @@ export function getPreMonth(formatType: any = '') {
|
|
*/
|
|
*/
|
|
export const formatEnergyDate = function (time: any) {
|
|
export const formatEnergyDate = function (time: any) {
|
|
//三目运算符
|
|
//三目运算符
|
|
- const dates = time ? new Date(time) : new Date()
|
|
|
|
|
|
+ const dates = time ? new Date(time) : new Date();
|
|
//月份下标是0-11
|
|
//月份下标是0-11
|
|
- const months: any = (dates.getMonth() + 1) < 10 ? '0' + (dates.getMonth() + 1) : (dates.getMonth() + 1)
|
|
|
|
|
|
+ const months: any =
|
|
|
|
+ dates.getMonth() + 1 < 10 ? '0' + (dates.getMonth() + 1) : dates.getMonth() + 1;
|
|
//具体的天数
|
|
//具体的天数
|
|
- const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate()
|
|
|
|
- const year: number = dates.getFullYear()
|
|
|
|
- const hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours()
|
|
|
|
|
|
+ const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate();
|
|
|
|
+ const year: number = dates.getFullYear();
|
|
|
|
+ const hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours();
|
|
// //分钟
|
|
// //分钟
|
|
- const minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes()
|
|
|
|
|
|
+ const minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes();
|
|
//返回数据格式
|
|
//返回数据格式
|
|
- return [
|
|
|
|
- year + '年' + months + '月',
|
|
|
|
- months + '月' + day + '日',
|
|
|
|
- hours + ':' + minutes
|
|
|
|
- ]
|
|
|
|
-}
|
|
|
|
|
|
+ return [year + '年' + months + '月', months + '月' + day + '日', hours + ':' + minutes];
|
|
|
|
+};
|
|
|
|
|
|
export const setSession = function (key: any = '', obj: any = '') {
|
|
export const setSession = function (key: any = '', obj: any = '') {
|
|
if (obj) {
|
|
if (obj) {
|
|
- let str = JSON.stringify(obj)
|
|
|
|
- sessionStorage.setItem(key, str)
|
|
|
|
|
|
+ let str = JSON.stringify(obj);
|
|
|
|
+ sessionStorage.setItem(key, str);
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
export const getSession = function (key: any = '') {
|
|
export const getSession = function (key: any = '') {
|
|
if (key) {
|
|
if (key) {
|
|
- let obj: any = sessionStorage.getItem(key)
|
|
|
|
|
|
+ let obj: any = sessionStorage.getItem(key);
|
|
if (obj) {
|
|
if (obj) {
|
|
- return JSON.parse(obj)
|
|
|
|
|
|
+ return JSON.parse(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return ''
|
|
|
|
-}
|
|
|
|
|
|
+ return '';
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 本地存储localStorage
|
|
* 本地存储localStorage
|
|
@@ -314,13 +313,13 @@ export const getSession = function (key: any = '') {
|
|
export const setLocalStorage = function (key: any = '', obj: any = '') {
|
|
export const setLocalStorage = function (key: any = '', obj: any = '') {
|
|
if (obj) {
|
|
if (obj) {
|
|
if (obj instanceof Object) {
|
|
if (obj instanceof Object) {
|
|
- let str = JSON.stringify(obj)
|
|
|
|
- localStorage.setItem(key, str)
|
|
|
|
|
|
+ let str = JSON.stringify(obj);
|
|
|
|
+ localStorage.setItem(key, str);
|
|
} else {
|
|
} else {
|
|
- localStorage.setItem(key, obj)
|
|
|
|
|
|
+ localStorage.setItem(key, obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取本地存储
|
|
* 获取本地存储
|
|
@@ -328,251 +327,253 @@ export const setLocalStorage = function (key: any = '', obj: any = '') {
|
|
*/
|
|
*/
|
|
export const getLocalStorage = function (key: any) {
|
|
export const getLocalStorage = function (key: any) {
|
|
if (key) {
|
|
if (key) {
|
|
- let obj: any = localStorage.getItem(key)
|
|
|
|
|
|
+ let obj: any = localStorage.getItem(key);
|
|
if (obj) {
|
|
if (obj) {
|
|
- return JSON.parse(obj)
|
|
|
|
|
|
+ return JSON.parse(obj);
|
|
} else {
|
|
} else {
|
|
- return ''
|
|
|
|
|
|
+ return '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return ''
|
|
|
|
-}
|
|
|
|
|
|
+ return '';
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 存储最新的空间信息
|
|
* 存储最新的空间信息
|
|
* @param spaceInfo
|
|
* @param spaceInfo
|
|
*/
|
|
*/
|
|
export const setLocalNewSpaceInfo = function (spaceInfo: any) {
|
|
export const setLocalNewSpaceInfo = function (spaceInfo: any) {
|
|
- setLocalStorage(Keys.storageSpaceInfoKey, spaceInfo)
|
|
|
|
-}
|
|
|
|
|
|
+ setLocalStorage(Keys.storageSpaceInfoKey, spaceInfo);
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取最新的空间信息
|
|
* 获取最新的空间信息
|
|
*/
|
|
*/
|
|
export const getLocalNewSpaceInfo = function () {
|
|
export const getLocalNewSpaceInfo = function () {
|
|
- let spaceInfo: any = getLocalStorage(Keys.storageSpaceInfoKey)
|
|
|
|
- return spaceInfo
|
|
|
|
-}
|
|
|
|
|
|
+ let spaceInfo: any = getLocalStorage(Keys.storageSpaceInfoKey);
|
|
|
|
+ return spaceInfo;
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 本地缓存建筑,楼层,空间
|
|
* 本地缓存建筑,楼层,空间
|
|
*/
|
|
*/
|
|
export const localStorageSpaceId = function (buildingId: any, floorId: any, spaceId: any) {
|
|
export const localStorageSpaceId = function (buildingId: any, floorId: any, spaceId: any) {
|
|
- let spaceMap: any = getLocalStorage(Keys.storageSpaceKey) ? getLocalStorage(Keys.storageSpaceKey) : {}
|
|
|
|
- let key: any = `${buildingId},${floorId}`
|
|
|
|
- spaceMap[key] = spaceId
|
|
|
|
- setLocalStorage(Keys.storageSpaceKey, spaceMap)
|
|
|
|
-}
|
|
|
|
-export const getStorageSpaceId = function () {
|
|
|
|
let spaceMap: any = getLocalStorage(Keys.storageSpaceKey)
|
|
let spaceMap: any = getLocalStorage(Keys.storageSpaceKey)
|
|
- return spaceMap
|
|
|
|
-}
|
|
|
|
|
|
+ ? getLocalStorage(Keys.storageSpaceKey)
|
|
|
|
+ : {};
|
|
|
|
+ let key: any = `${buildingId},${floorId}`;
|
|
|
|
+ spaceMap[key] = spaceId;
|
|
|
|
+ setLocalStorage(Keys.storageSpaceKey, spaceMap);
|
|
|
|
+};
|
|
|
|
+export const getStorageSpaceId = function () {
|
|
|
|
+ let spaceMap: any = getLocalStorage(Keys.storageSpaceKey);
|
|
|
|
+ return spaceMap;
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 本地缓存建筑对应的楼层
|
|
* 本地缓存建筑对应的楼层
|
|
*/
|
|
*/
|
|
export const localStorageFloor = function (buildingId: any, floorId: any) {
|
|
export const localStorageFloor = function (buildingId: any, floorId: any) {
|
|
- let floorMap: any = getLocalStorage(Keys.storageFloorKey) ? getLocalStorage(Keys.storageFloorKey) : {}
|
|
|
|
- floorMap[buildingId] = floorId
|
|
|
|
- setLocalStorage(Keys.storageFloorKey, floorMap)
|
|
|
|
-}
|
|
|
|
|
|
+ let floorMap: any = getLocalStorage(Keys.storageFloorKey)
|
|
|
|
+ ? getLocalStorage(Keys.storageFloorKey)
|
|
|
|
+ : {};
|
|
|
|
+ floorMap[buildingId] = floorId;
|
|
|
|
+ setLocalStorage(Keys.storageFloorKey, floorMap);
|
|
|
|
+};
|
|
/**
|
|
/**
|
|
* 获取本地存储的建筑对应的关系
|
|
* 获取本地存储的建筑对应的关系
|
|
* @param buildingId
|
|
* @param buildingId
|
|
* @param floorId
|
|
* @param floorId
|
|
*/
|
|
*/
|
|
export const getLocalStorageFloor = function () {
|
|
export const getLocalStorageFloor = function () {
|
|
- let floorMap: any = getLocalStorage(Keys.storageFloorKey)
|
|
|
|
- return floorMap
|
|
|
|
-}
|
|
|
|
|
|
+ let floorMap: any = getLocalStorage(Keys.storageFloorKey);
|
|
|
|
+ return floorMap;
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 缓存搜索页面最近查找的数据
|
|
* 缓存搜索页面最近查找的数据
|
|
* @param item
|
|
* @param item
|
|
*/
|
|
*/
|
|
export const setLocalSearchSpace = function (item: any) {
|
|
export const setLocalSearchSpace = function (item: any) {
|
|
- let historySearch: any = getLocalStorage(Keys.historySearchSpaceKey)
|
|
|
|
- let flag = false
|
|
|
|
- historySearch = historySearch ? historySearch : []
|
|
|
|
|
|
+ let historySearch: any = getLocalStorage(Keys.historySearchSpaceKey);
|
|
|
|
+ let flag = false;
|
|
|
|
+ historySearch = historySearch ? historySearch : [];
|
|
historySearch.map((historyItem: any) => {
|
|
historySearch.map((historyItem: any) => {
|
|
if (historyItem.id === item.id) {
|
|
if (historyItem.id === item.id) {
|
|
- flag = true
|
|
|
|
|
|
+ flag = true;
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
if (!flag) {
|
|
if (!flag) {
|
|
- historySearch.push(item)
|
|
|
|
|
|
+ historySearch.push(item);
|
|
}
|
|
}
|
|
- setLocalStorage(Keys.historySearchSpaceKey, historySearch)
|
|
|
|
-}
|
|
|
|
|
|
+ setLocalStorage(Keys.historySearchSpaceKey, historySearch);
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取搜索页面最近查找的数据
|
|
* 获取搜索页面最近查找的数据
|
|
*/
|
|
*/
|
|
export const getLocalSearchSpace = function () {
|
|
export const getLocalSearchSpace = function () {
|
|
- return getLocalStorage(Keys.historySearchSpaceKey) ? getLocalStorage(Keys.historySearchSpaceKey) : []
|
|
|
|
-}
|
|
|
|
|
|
+ return getLocalStorage(Keys.historySearchSpaceKey)
|
|
|
|
+ ? getLocalStorage(Keys.historySearchSpaceKey)
|
|
|
|
+ : [];
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
*存储当前项目id
|
|
*存储当前项目id
|
|
*/
|
|
*/
|
|
export const setLocalProjectId = function (projectId: any) {
|
|
export const setLocalProjectId = function (projectId: any) {
|
|
- setLocalStorage(Keys.projectId, projectId)
|
|
|
|
-}
|
|
|
|
|
|
+ setLocalStorage(Keys.projectId, projectId);
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取当前项目id
|
|
* 获取当前项目id
|
|
* @param projectId
|
|
* @param projectId
|
|
*/
|
|
*/
|
|
export const getLocalProjectId = function () {
|
|
export const getLocalProjectId = function () {
|
|
- return localStorage.getItem(Keys.projectId)
|
|
|
|
-}
|
|
|
|
|
|
+ return localStorage.getItem(Keys.projectId);
|
|
|
|
+};
|
|
/**
|
|
/**
|
|
* 清楚当前所有的存储数据
|
|
* 清楚当前所有的存储数据
|
|
*/
|
|
*/
|
|
export const clearAllLocalData = function () {
|
|
export const clearAllLocalData = function () {
|
|
- localStorage.clear()
|
|
|
|
- Cookies.remove('userInfo')
|
|
|
|
- Cookies.remove('projectId')
|
|
|
|
- Cookies.remove('accessToken')
|
|
|
|
-}
|
|
|
|
|
|
+ localStorage.clear();
|
|
|
|
+ Cookies.remove('userInfo');
|
|
|
|
+ Cookies.remove('projectId');
|
|
|
|
+ Cookies.remove('accessToken');
|
|
|
|
+};
|
|
|
|
|
|
export const doHandleMonth = function (month: any) {
|
|
export const doHandleMonth = function (month: any) {
|
|
- let m: any = month
|
|
|
|
|
|
+ let m: any = month;
|
|
if (month.toString().length == 1) {
|
|
if (month.toString().length == 1) {
|
|
- m = '0' + month
|
|
|
|
|
|
+ m = '0' + month;
|
|
}
|
|
}
|
|
- return m
|
|
|
|
-}
|
|
|
|
|
|
+ return m;
|
|
|
|
+};
|
|
|
|
|
|
export const getWeekDate = function (day: any) {
|
|
export const getWeekDate = function (day: any) {
|
|
- let weeks: any = new Array(
|
|
|
|
- '周日',
|
|
|
|
- '周一',
|
|
|
|
- '周二',
|
|
|
|
- '周三',
|
|
|
|
- '周四',
|
|
|
|
- '周五',
|
|
|
|
- '周六'
|
|
|
|
- )
|
|
|
|
- let week: any = weeks[day]
|
|
|
|
- return week
|
|
|
|
-}
|
|
|
|
|
|
+ let weeks: any = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周六');
|
|
|
|
+ let week: any = weeks[day];
|
|
|
|
+ return week;
|
|
|
|
+};
|
|
|
|
|
|
export const getNowWeek = function () {
|
|
export const getNowWeek = function () {
|
|
- let date: any = new Date()
|
|
|
|
- let day: any = date.getDay()
|
|
|
|
- let nowWeek: any = getWeekDate(day)
|
|
|
|
- return nowWeek
|
|
|
|
-}
|
|
|
|
|
|
+ let date: any = new Date();
|
|
|
|
+ let day: any = date.getDay();
|
|
|
|
+ let nowWeek: any = getWeekDate(day);
|
|
|
|
+ return nowWeek;
|
|
|
|
+};
|
|
|
|
|
|
export const getDate = function (date: any) {
|
|
export const getDate = function (date: any) {
|
|
- return date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
|
|
|
-}
|
|
|
|
|
|
+ return date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 初始化24:00
|
|
* 初始化24:00
|
|
*/
|
|
*/
|
|
export const getTimers = function () {
|
|
export const getTimers = function () {
|
|
- let timers: any = new Array()
|
|
|
|
|
|
+ let timers: any = new Array();
|
|
for (let i = 0; i <= 24; i++) {
|
|
for (let i = 0; i <= 24; i++) {
|
|
- let str: any = '00'
|
|
|
|
|
|
+ let str: any = '00';
|
|
if (i < 10) {
|
|
if (i < 10) {
|
|
- str = '0' + i
|
|
|
|
|
|
+ str = '0' + i;
|
|
} else {
|
|
} else {
|
|
- str = i
|
|
|
|
|
|
+ str = i;
|
|
}
|
|
}
|
|
- timers.push(str + ':00')
|
|
|
|
|
|
+ timers.push(str + ':00');
|
|
if (i < 24) {
|
|
if (i < 24) {
|
|
- timers.push(str + ':30')
|
|
|
|
|
|
+ timers.push(str + ':30');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log("timers====")
|
|
|
|
- console.log(timers)
|
|
|
|
- return timers
|
|
|
|
-}
|
|
|
|
|
|
+ console.log('timers====');
|
|
|
|
+ console.log(timers);
|
|
|
|
+ return timers;
|
|
|
|
+};
|
|
|
|
|
|
export const getNowTime = function () {
|
|
export const getNowTime = function () {
|
|
- let date: any = new Date()
|
|
|
|
- let hours: any = date.getHours()
|
|
|
|
- let minute: any = date.getMinutes()
|
|
|
|
- let index: any = date.getHours()
|
|
|
|
|
|
+ let date: any = new Date();
|
|
|
|
+ let hours: any = date.getHours();
|
|
|
|
+ let minute: any = date.getMinutes();
|
|
|
|
+ let index: any = date.getHours();
|
|
if (minute < 30) {
|
|
if (minute < 30) {
|
|
- hours = hours + ':' + '00'
|
|
|
|
- index = index * 2
|
|
|
|
|
|
+ hours = hours + ':' + '00';
|
|
|
|
+ index = index * 2;
|
|
} else {
|
|
} else {
|
|
- hours = hours + ':' + '30'
|
|
|
|
- index = index * 2 + 1
|
|
|
|
|
|
+ hours = hours + ':' + '30';
|
|
|
|
+ index = index * 2 + 1;
|
|
}
|
|
}
|
|
- return [hours, index]
|
|
|
|
-}
|
|
|
|
|
|
+ return [hours, index];
|
|
|
|
+};
|
|
|
|
|
|
// 获取当前真实时间
|
|
// 获取当前真实时间
|
|
export const getRelNowTime = function () {
|
|
export const getRelNowTime = function () {
|
|
- let date: any = new Date()
|
|
|
|
- let hours: any = date.getHours()
|
|
|
|
- let minute: any = date.getMinutes()
|
|
|
|
|
|
+ let date: any = new Date();
|
|
|
|
+ let hours: any = date.getHours();
|
|
|
|
+ let minute: any = date.getMinutes();
|
|
if (hours < 10) {
|
|
if (hours < 10) {
|
|
- hours = "0" + hours
|
|
|
|
|
|
+ hours = '0' + hours;
|
|
}
|
|
}
|
|
if (minute < 10) {
|
|
if (minute < 10) {
|
|
- minute = "0" + minute
|
|
|
|
|
|
+ minute = '0' + minute;
|
|
}
|
|
}
|
|
- return hours + "" + minute + "00"
|
|
|
|
-}
|
|
|
|
|
|
+ return hours + '' + minute + '00';
|
|
|
|
+};
|
|
|
|
|
|
/**
|
|
/**
|
|
* 19000转成19:00
|
|
* 19000转成19:00
|
|
*/
|
|
*/
|
|
export const formatTimerStr = function (timer: any) {
|
|
export const formatTimerStr = function (timer: any) {
|
|
if (timer) {
|
|
if (timer) {
|
|
- let str: any = (timer / 10000).toFixed(2)
|
|
|
|
- str = str.replace(".", ":")
|
|
|
|
- return str
|
|
|
|
|
|
+ let str: any = (timer / 10000).toFixed(2);
|
|
|
|
+ str = str.replace('.', ':');
|
|
|
|
+ return str;
|
|
} else {
|
|
} else {
|
|
- return ''
|
|
|
|
|
|
+ return '';
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
export const newNumber = function (start: any, end: any, masAddess: any) {
|
|
export const newNumber = function (start: any, end: any, masAddess: any) {
|
|
- return masAddess + "" + Math.round(Math.random() * (end - start) + start);//生成在[start,end]范围内的随机数值,只支持不小于0的合法范围
|
|
|
|
-}
|
|
|
|
|
|
+ return masAddess + '' + Math.round(Math.random() * (end - start) + start); //生成在[start,end]范围内的随机数值,只支持不小于0的合法范围
|
|
|
|
+};
|
|
|
|
|
|
-export const formateTimeContinuous: any = function (index: any = 1,
|
|
|
|
|
|
+export const formateTimeContinuous: any = function (
|
|
|
|
+ index: any = 1,
|
|
startTime: any,
|
|
startTime: any,
|
|
endTime: any,
|
|
endTime: any,
|
|
- type: any = 1, data: any = [], that: any) {
|
|
|
|
- let todayDate: any = new Date()
|
|
|
|
- let tomorrowData = new Date(todayDate.setTime(todayDate.getTime() + 24 * 60 * 60 * 1000))
|
|
|
|
- let nowDate: any = formatDate("YYYY-MM-DD");
|
|
|
|
- let tomorrowDate: any = formatDate("YYYY-MM-DD", tomorrowData);
|
|
|
|
|
|
+ type: any = 1,
|
|
|
|
+ data: any = [],
|
|
|
|
+ that: any
|
|
|
|
+) {
|
|
|
|
+ let todayDate: any = new Date();
|
|
|
|
+ let tomorrowData = new Date(todayDate.setTime(todayDate.getTime() + 24 * 60 * 60 * 1000));
|
|
|
|
+ let nowDate: any = formatDate('YYYY-MM-DD');
|
|
|
|
+ let tomorrowDate: any = formatDate('YYYY-MM-DD', tomorrowData);
|
|
data.map((item: any) => {
|
|
data.map((item: any) => {
|
|
// debugger
|
|
// debugger
|
|
let date: any = formatDateStr(item.date);
|
|
let date: any = formatDateStr(item.date);
|
|
let week: any = getWeekDate(new Date(date).getDay());
|
|
let week: any = getWeekDate(new Date(date).getDay());
|
|
if (date == nowDate) {
|
|
if (date == nowDate) {
|
|
- week = '今日'
|
|
|
|
|
|
+ week = '今日';
|
|
} else if (date == tomorrowDate) {
|
|
} else if (date == tomorrowDate) {
|
|
- week = '次日'
|
|
|
|
|
|
+ week = '次日';
|
|
}
|
|
}
|
|
item.week = week;
|
|
item.week = week;
|
|
});
|
|
});
|
|
// debugger
|
|
// debugger
|
|
- let text: any = "";
|
|
|
|
|
|
+ let text: any = '';
|
|
// 工作时间和第二天连续的问题
|
|
// 工作时间和第二天连续的问题
|
|
// 工作时间连续的问题
|
|
// 工作时间连续的问题
|
|
let cusStartTime: any = data[index].cusStartTime;
|
|
let cusStartTime: any = data[index].cusStartTime;
|
|
let cusEndTime: any = data[index].cusEndTime;
|
|
let cusEndTime: any = data[index].cusEndTime;
|
|
if (type === 1) {
|
|
if (type === 1) {
|
|
// debugger;
|
|
// debugger;
|
|
- if (endTime === "240000") {
|
|
|
|
|
|
+ if (endTime === '240000') {
|
|
// 处理时间连续的问题
|
|
// 处理时间连续的问题
|
|
let customSceneList: any = data[index]?.customSceneList ?? [];
|
|
let customSceneList: any = data[index]?.customSceneList ?? [];
|
|
- if (cusStartTime === "000000") {
|
|
|
|
|
|
+ if (cusStartTime === '000000') {
|
|
text = data[index].week;
|
|
text = data[index].week;
|
|
endTime = cusEndTime;
|
|
endTime = cusEndTime;
|
|
}
|
|
}
|
|
customSceneList.map((item: any) => {
|
|
customSceneList.map((item: any) => {
|
|
- if (item.startTime === "000000") {
|
|
|
|
|
|
+ if (item.startTime === '000000') {
|
|
text = data[index].week;
|
|
text = data[index].week;
|
|
endTime = item.endTime;
|
|
endTime = item.endTime;
|
|
} else if (endTime === item.startTime) {
|
|
} else if (endTime === item.startTime) {
|
|
@@ -586,7 +587,7 @@ export const formateTimeContinuous: any = function (index: any = 1,
|
|
});
|
|
});
|
|
if (text) {
|
|
if (text) {
|
|
let nowIndex: any = index + 1;
|
|
let nowIndex: any = index + 1;
|
|
- that.text = text
|
|
|
|
|
|
+ that.text = text;
|
|
if (nowIndex < data.length - 1) {
|
|
if (nowIndex < data.length - 1) {
|
|
return formateTimeContinuous(nowIndex, startTime, endTime, 1, data, that);
|
|
return formateTimeContinuous(nowIndex, startTime, endTime, 1, data, that);
|
|
} else {
|
|
} else {
|
|
@@ -612,51 +613,51 @@ export const formateTimeContinuous: any = function (index: any = 1,
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// 预约时候后找最近的一段预约时间
|
|
// 预约时候后找最近的一段预约时间
|
|
- let nowTime: any = (getNowTime()[0]).replace(":", "") + "00"
|
|
|
|
|
|
+ let nowTime: any = getNowTime()[0].replace(':', '') + '00';
|
|
let customSceneList: any = data[index]?.customSceneList ?? [];
|
|
let customSceneList: any = data[index]?.customSceneList ?? [];
|
|
customSceneList.map((item: any) => {
|
|
customSceneList.map((item: any) => {
|
|
if (index === 0) {
|
|
if (index === 0) {
|
|
if (nowTime < item.startTime) {
|
|
if (nowTime < item.startTime) {
|
|
if (!startTime || !endTime) {
|
|
if (!startTime || !endTime) {
|
|
- startTime = item.startTime
|
|
|
|
- endTime = item.endTime
|
|
|
|
- text = data[index].week
|
|
|
|
|
|
+ startTime = item.startTime;
|
|
|
|
+ endTime = item.endTime;
|
|
|
|
+ text = data[index].week;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (!startTime || !endTime) {
|
|
if (!startTime || !endTime) {
|
|
- startTime = item.startTime
|
|
|
|
- endTime = item.endTime
|
|
|
|
- text = data[index].week
|
|
|
|
|
|
+ startTime = item.startTime;
|
|
|
|
+ endTime = item.endTime;
|
|
|
|
+ text = data[index].week;
|
|
} else {
|
|
} else {
|
|
// debugger
|
|
// debugger
|
|
// debugger
|
|
// debugger
|
|
if (endTime == '240000') {
|
|
if (endTime == '240000') {
|
|
- if (item.startTime == "000000") {
|
|
|
|
- endTime = item.endTime
|
|
|
|
- text = data[index].week
|
|
|
|
|
|
+ if (item.startTime == '000000') {
|
|
|
|
+ endTime = item.endTime;
|
|
|
|
+ text = data[index].week;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (endTime === item.startTime) {
|
|
if (endTime === item.startTime) {
|
|
- endTime = item.endTime
|
|
|
|
- text = data[index].week
|
|
|
|
|
|
+ endTime = item.endTime;
|
|
|
|
+ text = data[index].week;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (that.text) {
|
|
if (that.text) {
|
|
- let startText: any = that.text.split("~")[0]
|
|
|
|
- that.text = startText
|
|
|
|
|
|
+ let startText: any = that.text.split('~')[0];
|
|
|
|
+ that.text = startText;
|
|
if (text && text != startText) {
|
|
if (text && text != startText) {
|
|
- that.text = startText + "~" + text
|
|
|
|
|
|
+ that.text = startText + '~' + text;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- that.text = text
|
|
|
|
|
|
+ that.text = text;
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
if (startTime && endTime) {
|
|
if (startTime && endTime) {
|
|
if (endTime == '240000') {
|
|
if (endTime == '240000') {
|
|
- let nowIndex: any = index + 1
|
|
|
|
|
|
+ let nowIndex: any = index + 1;
|
|
if (nowIndex < data.length - 1) {
|
|
if (nowIndex < data.length - 1) {
|
|
return formateTimeContinuous(nowIndex, startTime, endTime, 2, data, that);
|
|
return formateTimeContinuous(nowIndex, startTime, endTime, 2, data, that);
|
|
} else {
|
|
} else {
|
|
@@ -674,7 +675,7 @@ export const formateTimeContinuous: any = function (index: any = 1,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- let nowIndex: any = index + 1
|
|
|
|
|
|
+ let nowIndex: any = index + 1;
|
|
if (nowIndex < data.length - 1) {
|
|
if (nowIndex < data.length - 1) {
|
|
return formateTimeContinuous(nowIndex, startTime, endTime, 2, data, that);
|
|
return formateTimeContinuous(nowIndex, startTime, endTime, 2, data, that);
|
|
} else {
|
|
} else {
|
|
@@ -686,7 +687,7 @@ export const formateTimeContinuous: any = function (index: any = 1,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
export const fix: any = function (d: any) {
|
|
export const fix: any = function (d: any) {
|
|
if (parseInt(d) == d) return parseFloat(d);
|
|
if (parseInt(d) == d) return parseFloat(d);
|
|
@@ -709,11 +710,11 @@ export const fix: any = function (d: any) {
|
|
|
|
|
|
d1 = d1 / len;
|
|
d1 = d1 / len;
|
|
return d1;
|
|
return d1;
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
// 自定义四舍五入
|
|
// 自定义四舍五入
|
|
-export const customRound = (number: number) => {
|
|
|
|
- // 如果传入的是布尔值,直接返回
|
|
|
|
|
|
+export const customRound = (number: number, type: number = 10) => {
|
|
|
|
+ // 如果传入的是布尔值,直接返回
|
|
if (typeof number === 'boolean') {
|
|
if (typeof number === 'boolean') {
|
|
return number;
|
|
return number;
|
|
}
|
|
}
|
|
@@ -722,7 +723,7 @@ export const customRound = (number: number) => {
|
|
if (number > 100) return 100;
|
|
if (number > 100) return 100;
|
|
|
|
|
|
// 获取个位数
|
|
// 获取个位数
|
|
- const remainder = number % 10;
|
|
|
|
|
|
+ const remainder = number % type;
|
|
// 获取十位数的基数
|
|
// 获取十位数的基数
|
|
const base = number - remainder;
|
|
const base = number - remainder;
|
|
|
|
|
|
@@ -730,6 +731,6 @@ export const customRound = (number: number) => {
|
|
if (remainder <= 4) {
|
|
if (remainder <= 4) {
|
|
return base;
|
|
return base;
|
|
} else {
|
|
} else {
|
|
- return base + 10;
|
|
|
|
|
|
+ return base + type;
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|