From e713b378b01d189f972cfb5b9eae749ee95a8b51 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期六, 29 十月 2022 13:48:00 +0800
Subject: [PATCH] 1.解决两个账号登录,是否被挤掉的问题
---
src/utils/global.js | 83 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 1 deletions(-)
diff --git a/src/utils/global.js b/src/utils/global.js
index f636c90..3c23e76 100644
--- a/src/utils/global.js
+++ b/src/utils/global.js
@@ -1,3 +1,5 @@
+import { NewEncodingRules } from '@/api/xtsz'
+
// 鍏ㄥ眬涓昏棰滆壊
export function getGlobalColor() {
return { globalColor: `#42b983` }
@@ -6,14 +8,93 @@
// 澶勭悊琛ㄥご鍗曞厓鏍兼牱寮�
export function headerCellStyle() {
const option = {
- background: '#eee', padding: '5px 0'
+ // background: '#a7a7a7', padding: '0'
+ background: '#f8f8fa', padding: '0', color: '#000', fontWeight: 500
}
return option
}
+
// 澶勭悊琛ㄦ牸鍗曞厓鏍兼牱寮�
export function cellStyle() {
const option = {
+ // padding: '5px 0'
padding: '5px 0'
+
}
return option
}
+
+// 鏃堕棿澶勭悊鍑芥暟 骞存湀鏃�
+export function handleDatetime(value) {
+ const data = new Date(value)
+ const month = data.getMonth() < 9 ? '0' + (data.getMonth() + 1) : data.getMonth() + 1
+ const date = data.getDate() <= 9 ? '0' + data.getDate() : data.getDate()
+ return data.getFullYear() + '-' + month + '-' + date
+}
+
+// 浜嬩欢澶勭悊鍑芥暟 鏃跺垎绉�
+// 鑾峰彇褰撳墠鏃堕棿
+export function handleDatetime2(value) {
+ const dt = new Date(value)
+ const wk = dt.getDay()
+ const y = dt.getFullYear()
+ const m = (dt.getMonth() + 1 + '').padStart(2, '0')
+ const d = (dt.getDate() + '').padStart(2, '0')
+
+ const hh = (dt.getHours() + '').padStart(2, '0')
+ const mm = (dt.getMinutes() + '').padStart(2, '0')
+ const ss = (dt.getSeconds() + '').padStart(2, '0')
+ const weeks = ['鏄熸湡鏃�', '鏄熸湡涓�', '鏄熸湡浜�', '鏄熸湡涓�', '鏄熸湡鍥�', '鏄熸湡浜�', '鏄熸湡鍏�']
+ const week = weeks[wk]
+
+ // return `${y}-${m}-${d} ${hh}:${mm}:${ss} ${week}`
+ return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
+}
+// 鏃堕棿澶勭悊鍑芥暟 杩斿洖 鏃跺垎
+export function handleDatetime3(value) {
+ const dt = new Date(value)
+ const hh = (dt.getHours() + '').padStart(2, '0')
+ const mm = (dt.getMinutes() + '').padStart(2, '0')
+ return `${hh}:${mm}`
+}
+
+// 鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�
+export async function getNewEncodingRules(encode) {
+ const res = await NewEncodingRules({ rightcode: encode })
+ if (res.code === '200') {
+ return { RightCode: res.data[0], numvalue: res.data[1] }
+ }
+}
+
+// 閫掑綊娓呴櫎鏁扮粍姣忎釜鍏冪礌涓嬬殑children涓虹┖鐨勬暟缁�
+const clearAllChildren = (items, childrenName = 'children') => {
+ for (let i = 0; i < items.length; i++) {
+ const item = items[i]
+ // 褰撳墠瀵硅薄瀛樺湪children
+ if (item && item[childrenName]) {
+ // children涓虹┖鏁扮粍鏃跺垹闄�
+ if (item[childrenName].length === 0) {
+ delete item[childrenName]
+ } else {
+ // 閫掑綊褰撳墠children鏁扮粍
+ clearAllChildren(item[childrenName], childrenName)
+ }
+ }
+ }
+ return items
+}
+export default clearAllChildren
+
+// 姝e垯琛ㄨ揪寮� 缂栫爜涓嶈兘鍚湁涓枃鎴栫壒娈婂瓧绗�
+const SER_HZ = /^[a-zA-Z0-9_\-;,.<>() ]{0,}$/
+export const validateCode = (rule, value, callback) => {
+ if (!value) {
+ return callback(new Error('璇疯緭鍏ョ紪鐮�'))
+ } else {
+ if (!SER_HZ.test(value)) {
+ return callback(new Error('缂栫爜涓嶈兘鍚湁涓枃鎴栫壒娈婂瓧绗�'))
+ } else {
+ callback()
+ }
+ }
+}
--
Gitblit v1.9.3