Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcsjsb-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
58208073
authored
2023-07-27 14:21:11 +0800
by
yuanbo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加注释
1 parent
3bcc3c6b
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
448 additions
and
16 deletions
src/store/modules/dict.js
src/store/modules/permission.js
src/store/modules/user.js
src/utils/LodopFuncs.js
src/utils/asyncRouter.js
src/utils/drawMixin.js
src/utils/filter.js
src/utils/get-page-title.js
src/utils/index.js
src/utils/mixin/table.js
src/utils/operation.js
src/utils/popup.js
src/utils/proDomStr.js
src/utils/request.js
src/utils/requestLoading.js
src/utils/tool.js
src/utils/tools.js
src/utils/util.cookies.js
src/utils/util.js
src/utils/validate.js
src/store/modules/dict.js
View file @
5820807
...
...
@@ -15,6 +15,11 @@ const mutations = {
}
const
actions
=
{
/**
* @description: generateDic
* @param {*} commit
* @author: renchao
*/
generateDic
({
commit
})
{
return
new
Promise
(
async
(
resolve
)
=>
{
let
{
result
:
res
}
=
await
getAllDict
()
...
...
@@ -22,6 +27,11 @@ const actions = {
resolve
(
true
)
})
},
/**
* @description: resetdict
* @param {*} commit
* @author: renchao
*/
resetdict
({
commit
})
{
commit
(
'RESET_DICT'
)
}
...
...
src/store/modules/permission.js
View file @
5820807
...
...
@@ -25,6 +25,12 @@ const mutations = {
}
const
actions
=
{
// 添加全部菜单
/**
* @description: 添加全部菜单
* @param {*} commit
* @param {*} getMenuInfo
* @author: renchao
*/
generateRoutes
({
commit
},
getMenuInfo
)
{
let
Layout
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/layout`
)))
function
asyncRouter
(
routers
)
{
...
...
@@ -63,11 +69,22 @@ const actions = {
})
},
// 重置路由
/**
* @description: 重置路由
* @param {*} commit
* @author: renchao
*/
resetRoutes
({
commit
})
{
commit
(
'RESET_ROUTE'
)
}
}
// 树转数组
/**
* @description: 树转数组
* @param {*} root
* @param {*} fVisit
* @author: renchao
*/
function
dfs
(
root
,
fVisit
)
{
let
stack
=
Array
.
isArray
(
root
)
?
[...
root
]
:
[
root
];
while
(
stack
.
length
)
{
...
...
@@ -81,6 +98,12 @@ function dfs (root, fVisit) {
}
// 数组转树
//需要插入父节点id,pid为null或'',就是找root节点,然后root节点再去找自己的子节点
/**
* @description: 数组转树
* @param {*} data
* @param {*} pid
* @author: renchao
*/
function
array2Tree
(
data
,
pid
)
{
let
res
=
[];
data
.
forEach
(
item
=>
{
...
...
src/store/modules/user.js
View file @
5820807
/*
* @Description:
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-07 09:38:47
*/
...
...
@@ -20,6 +20,11 @@ const mutations = {
};
const
actions
=
{
/**
* @description: getUserInfo
* @param {*} commit
* @author: renchao
*/
getUserInfo
({
commit
})
{
return
new
Promise
(
async
(
resolve
)
=>
{
let
{
result
:
res
}
=
await
getUserInfo
();
...
...
@@ -27,6 +32,11 @@ const actions = {
resolve
(
true
);
});
},
/**
* @description: resetState
* @param {*} commit
* @author: renchao
*/
resetState
({
commit
})
{
commit
(
"RESET_USER"
);
},
...
...
src/utils/LodopFuncs.js
View file @
5820807
...
...
@@ -3,6 +3,10 @@
var
CreatedOKLodopObject
,
CLodopIsLocal
,
CLodopJsState
;
//==判断是否需要CLodop(那些不支持插件的浏览器):==
/**
* @description: ==判断是否需要CLodop(那些不支持插件的浏览器):==
* @author: renchao
*/
function
needCLodop
()
{
try
{
var
ua
=
navigator
.
userAgent
;
...
...
@@ -45,6 +49,10 @@ function needCLodop () {
}
//==加载引用CLodop的主JS,用双端口8000和18000(以防其中一个被占):==
/**
* @description: ==加载引用CLodop的主JS,用双端口8000和18000(以防其中一个被占):==
* @author: renchao
*/
function
loadCLodop
()
{
if
(
CLodopJsState
==
"loading"
||
CLodopJsState
==
"complete"
)
return
;
CLodopJsState
=
"loading"
;
...
...
@@ -63,7 +71,12 @@ function loadCLodop () {
if
(
needCLodop
())
{
loadCLodop
();
}
//加载
//==获取LODOP对象主过程,判断是否安装、需否升级:==
/**
* @description: ==获取LODOP对象主过程,判断是否安装、需否升级:==
* @param {*} oOBJECT
* @param {*} oEMBED
* @author: renchao
*/
export
function
getLodop
(
oOBJECT
,
oEMBED
)
{
var
strHtmInstall
=
"<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='install_lodop32.zip' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>"
;
var
strHtmUpdate
=
"<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='install_lodop32.zip' target='_self'>执行升级</a>,升级后请重新进入。</font>"
;
...
...
src/utils/asyncRouter.js
View file @
5820807
/*
* @Description:
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-05-11 16:31:01
*/
...
...
@@ -7,6 +7,11 @@
var
Layout
;
let
ApiUrl
=
localStorage
.
getItem
(
'ApiUrl'
)
Layout
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/layout1`
)))
/**
* @description: filterAsyncRouter
* @param {*} routers
* @author: renchao
*/
export
default
function
filterAsyncRouter
(
routers
)
{
routers
.
forEach
(
item
=>
{
if
(
!
item
.
children
)
{
...
...
@@ -27,6 +32,11 @@ export default function filterAsyncRouter (routers) {
})
return
routers
}
/**
* @description: loadView
* @param {*} view
* @author: renchao
*/
function
loadView
(
view
)
{
return
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/views
${
view
}
.vue`
)))
}
...
...
src/utils/drawMixin.js
View file @
5820807
...
...
@@ -28,6 +28,10 @@ export default {
window
.
removeEventListener
(
'resize'
,
this
.
resize
)
},
methods
:
{
/**
* @description: calcRate
* @author: renchao
*/
calcRate
()
{
const
appRef
=
this
.
$refs
[
"appRef"
]
if
(
!
appRef
)
return
...
...
@@ -47,6 +51,10 @@ export default {
}
}
},
/**
* @description: resize
* @author: renchao
*/
resize
()
{
clearTimeout
(
this
.
drawTiming
)
this
.
drawTiming
=
setTimeout
(()
=>
{
...
...
src/utils/filter.js
View file @
5820807
...
...
@@ -2,17 +2,33 @@ import store from '@/store'
// table 内部过滤器 由于过滤器只能在模板中使用 所以 就有了 jsx内部方法过滤器
export
default
class
filter
{
// 业务来源
/**
* @description: 业务来源
* @param {*} val
* @author: renchao
*/
busSource
(
val
)
{
let
status
=
{
1
:
'办事大厅'
,
2
:
'微信小程序'
}
return
status
[
val
]
}
//申请分类(1:正常申请,2:一并申请,3:补录申请)
/**
* @description: 申请分类(1:正常申请,2:一并申请,3:补录申请)
* @param {*} val
* @author: renchao
*/
sqfls
(
val
)
{
let
status
=
{
1
:
'正常申请'
,
2
:
'一并申请'
,
3
:
'补录申请'
}
return
status
[
val
]
}
// 字典
/**
* @description: 字典
* @param {*} val
* @param {*} code
* @author: renchao
*/
dicStatus
(
val
,
code
)
{
let
data
=
store
.
getters
.
dicData
[
code
],
name
=
''
...
...
@@ -25,6 +41,11 @@ export default class filter {
return
name
}
}
/**
* @description: stateStatus
* @param {*} val
* @author: renchao
*/
stateStatus
(
val
)
{
let
index
=
val
+
1
;
// -1 : 不存在 ,0 : 待激活,1:正常,2:暂停,3 : 出错, 4:阻塞
...
...
src/utils/get-page-title.js
View file @
5820807
/*
* @Description:
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-16 13:31:27
*/
...
...
@@ -7,6 +7,11 @@
import
Vue
from
'vue'
const
title
=
Vue
.
prototype
.
BASE_API
.
TITLE
/**
* @description: getPageTitle
* @param {*} pageTitle
* @author: renchao
*/
export
default
function
getPageTitle
(
pageTitle
)
{
if
(
pageTitle
)
{
return
`
${
pageTitle
}
-
${
title
}
`
...
...
src/utils/index.js
View file @
5820807
/**
* @description: debounce
* @param {Function} fn 防抖函数
* @param {Number} delay 延迟时间
* @author: renchao
*/
export
function
debounce
(
fn
,
delay
)
{
var
timer
;
...
...
@@ -15,8 +17,10 @@ export function debounce(fn, delay) {
}
/**
* @description: formatTime
* @param {date} time 需要转换的时间
* @param {String} fmt 需要转换的格式 如 yyyy-MM-dd、yyyy-MM-dd HH:mm:ss
* @author: renchao
*/
export
function
formatTime
(
time
,
fmt
)
{
if
(
!
time
)
return
''
;
...
...
src/utils/mixin/table.js
View file @
5820807
...
...
@@ -18,23 +18,41 @@ export default {
}
},
methods
:
{
/**
* @description: handleSizeChange
* @param {*} val
* @author: renchao
*/
handleSizeChange
(
val
)
{
this
.
pageData
.
currentPage
=
1
this
.
pageData
.
pageSize
=
val
this
.
queryClick
()
},
/**
* @description: handleCurrentChange
* @param {*} val
* @author: renchao
*/
handleCurrentChange
(
val
)
{
this
.
pageData
.
currentPage
=
val
if
(
this
.
queryClick
)
{
this
.
queryClick
()
}
},
/**
* @description: handleDel
* @author: renchao
*/
handleDel
()
{
let
deleteAfterPage
=
Math
.
ceil
((
this
.
tableData
.
total
-
1
)
/
this
.
pageData
.
pageSize
)
let
currentPage
=
this
.
pageData
.
currentPage
>
deleteAfterPage
?
deleteAfterPage
:
this
.
pageData
.
currentPage
this
.
pageData
.
currentPage
=
currentPage
<
1
?
1
:
currentPage
},
// 重置表单
/**
* @description: 重置表单
* @author: renchao
*/
resetForm
()
{
if
(
!
this
.
form
)
return
Object
.
keys
(
this
.
form
).
forEach
((
key
)
=>
{
...
...
src/utils/operation.js
View file @
5820807
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-05-11 16:31:01
*/
import
{
Message
}
from
"element-ui"
;
/**
* @description: removeTreeListItem
* @param {*} treeList
* @param {*} dictId
* @param {*} idName
* @author: renchao
*/
export
function
removeTreeListItem
(
treeList
,
dictId
,
idName
=
'dictid'
)
{
if
(
!
treeList
||
!
treeList
.
length
)
{
return
...
...
@@ -12,6 +24,12 @@ export function removeTreeListItem (treeList, dictId, idName = 'dictid') {
}
}
// 创造id
/**
* @description: 创造id
* @param {*} len
* @param {*} radix
* @author: renchao
*/
export
function
getUuid
(
len
,
radix
)
{
var
chars
=
"0123456789abcdefghijklmnopqrstuvwxyz"
.
split
(
""
...
...
@@ -34,6 +52,11 @@ export function getUuid (len, radix) {
}
return
uuid
.
join
(
""
);
}
/**
* @description: judgeSort
* @param {*} arr
* @author: renchao
*/
export
function
judgeSort
(
arr
)
{
if
(
arr
.
length
)
{
for
(
let
i
in
arr
)
{
...
...
@@ -47,6 +70,13 @@ export function judgeSort (arr) {
return
arr
}
// 上下移动
/**
* @description: 上下移动
* @param {*} bsmDict
* @param {*} operate
* @param {*} data
* @author: renchao
*/
export
function
realMove
(
bsmDict
,
operate
,
data
)
{
function
changeSort
(
arr
,
bsmDict
)
{
if
(
arr
.
length
)
{
...
...
@@ -72,6 +102,12 @@ export function realMove (bsmDict, operate, data) {
data
=
judgeSort
(
changeSort
(
data
,
bsmDict
));
}
// 获取所有父节点
/**
* @description: 获取所有父节点
* @param {*} treeData
* @param {*} bsmDict
* @author: renchao
*/
export
function
findParents
(
treeData
,
bsmDict
)
{
if
(
treeData
.
length
==
0
)
return
for
(
let
i
=
0
;
i
<
treeData
.
length
;
i
++
)
{
...
...
@@ -88,6 +124,12 @@ export function findParents (treeData, bsmDict) {
}
}
// 上移下移
/**
* @description: 上移下移
* @param {*} index
* @param {*} data
* @author: renchao
*/
export
function
upward
(
index
,
data
)
{
if
(
index
>
0
)
{
let
upData
=
data
[
index
-
1
];
...
...
@@ -99,6 +141,12 @@ export function upward (index, data) {
});
}
}
/**
* @description: down
* @param {*} index
* @param {*} data
* @author: renchao
*/
export
function
down
(
index
,
data
)
{
if
((
index
+
1
)
==
data
.
length
)
{
Message
({
...
...
@@ -111,6 +159,12 @@ export function down (index, data) {
}
}
/**
* @description: timeFormat
* @param {*} date
* @param {*} end
* @author: renchao
*/
export
function
timeFormat
(
date
,
end
)
{
if
(
!
date
||
typeof
(
date
)
===
"string"
)
{
this
.
error
(
"参数异常,请检查..."
);
...
...
@@ -126,6 +180,11 @@ export function timeFormat (date, end) {
return
y
+
"-"
+
m
+
"-"
+
d
+
' 00:00:00'
;
}
}
/**
* @description: getFirstDayOfSeason
* @param {*} d
* @author: renchao
*/
export
function
getFirstDayOfSeason
(
d
)
{
let
date
=
d
||
new
Date
()
var
month
=
date
.
getMonth
();
...
...
src/utils/popup.js
View file @
5820807
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-05-11 16:31:01
*/
import
Popup
from
'@/components/Popup/index'
/**
* @description: popupDialog
* @param {*} title
* @param {*} url
* @param {*} params
* @param {*} width
* @param {*} height
* @param {*} btnShow
* @param {*} callback
* @author: renchao
*/
export
function
popupDialog
(
title
,
url
,
params
,
width
=
'75%'
,
height
,
btnShow
=
false
,
callback
)
{
// Popup.install
Popup
(
title
,
url
,
{
...
...
@@ -15,6 +31,10 @@ export function popupDialog (title, url, params, width = '75%', height, btnShow
})
}
/**
* @description: popupCacel
* @author: renchao
*/
export
function
popupCacel
()
{
Popup1
().
close
()
}
\ No newline at end of file
}
...
...
src/utils/proDomStr.js
View file @
5820807
/**
* @description: deleteDomStr
* @author: renchao
*/
const
deleteDomStr
=
content
=>
{
return
`<div class="customer-message-wrapper"><h5 class="title">您确认要执行该操作用于以下信息:</h5><p class="content">
${
content
}
</p><p class="result">执行后,数据将<span >无法恢复</span></p></div>`
}
...
...
src/utils/request.js
View file @
5820807
...
...
@@ -95,6 +95,11 @@ service.interceptors.response.use(
}
)
//对错误信息的处理函数
/**
* @description: 对错误信息的处理函数
* @param {*} errMes
* @author: renchao
*/
function
handleErrorData
(
errMes
)
{
if
(
errMes
.
message
)
{
Message
.
error
(
errMes
.
message
);
...
...
src/utils/requestLoading.js
View file @
5820807
/**
* @description: deleteDomStr
* @author: renchao
*/
import
Loading
from
'@/components/Loading/index.js'
;
// 定义 loading
// 定义 loading
let
loading
// loading开始 方法
/**
* @description: loading开始 方法
* @param {*} loadingText
* @author: renchao
*/
function
startLoading
(
loadingText
=
'正在加载中...'
)
{
loading
=
Loading
.
service
({
text
:
loadingText
,
...
...
@@ -13,6 +22,10 @@ function startLoading (loadingText = '正在加载中...') {
}
// loading结束 方法
/**
* @description: loading开始 方法
* @author: renchao
*/
function
endLoading
()
{
loading
.
close
()
}
...
...
@@ -23,6 +36,13 @@ let loadingCount = 0
* 调用一次startLoadingAddCount() 方法 开启Loading 并 loadingCount + 1
* 调用一次endLoadingSubCount() 方法 loadingCount - 1 直到为0 关闭loading
*/
/**
* @description: 调用一次startLoadingAddCount() 方法 开启Loading 并 loadingCount + 1
* 调用一次endLoadingSubCount() 方法 loadingCount - 1 直到为0 关闭loading
* @param {*} LoadingText
* @param {*} target
* @author: renchao
*/
export
function
startLoadingAddCount
(
LoadingText
,
target
)
{
if
(
loadingCount
===
0
)
{
startLoading
(
LoadingText
,
target
)
...
...
@@ -30,9 +50,13 @@ export function startLoadingAddCount (LoadingText, target) {
loadingCount
++
}
/**
* @description: endLoadingSubCount
* @author: renchao
*/
export
function
endLoadingSubCount
()
{
loadingCount
--
if
(
loadingCount
===
0
)
{
endLoading
()
}
}
\ No newline at end of file
}
...
...
src/utils/tool.js
View file @
5820807
/**
* @description: deleteDomStr
* @author: renchao
*/
import
Vue
from
'vue'
// 下载,导出
/**
* @description: 下载,导出
* @param {*} name
* @param {*} href
* @author: renchao
*/
Vue
.
prototype
.
$download
=
function
(
name
,
href
)
{
var
a
=
document
.
createElement
(
'a'
)
// 创建a标签
var
e
=
document
.
createEvent
(
'MouseEvents'
)
// 创建鼠标事件对象
...
...
@@ -10,6 +20,12 @@ Vue.prototype.$download = function (name, href) {
a
.
dispatchEvent
(
e
)
// 给指定的元素,执行事件click事件
}
// 导出json文件
/**
* @description: 导出json文件
* @param {*} data
* @param {*} name
* @author: renchao
*/
Vue
.
prototype
.
$downloadJson
=
function
(
data
,
name
)
{
// 1 生成文件的 blob 对象
const
blobData
=
new
Blob
([
JSON
.
stringify
(
data
)],
{
...
...
@@ -46,6 +62,13 @@ const validConfig = [
}
]
// 校验手机号
/**
* @description: 校验手机号
* @param {*} rule
* @param {*} value
* @param {*} callback
* @author: renchao
*/
const
checkTel
=
(
rule
,
value
,
callback
)
=>
{
const
phoneReg
=
/^
[
1
][
3,4,5,6,7,8,9
][
0-9
]{9}
$/
const
rel
=
/^
[
0
]\d{2,3}
-
[
1-9
]\d{7}
$/
...
...
@@ -57,6 +80,13 @@ const checkTel = (rule, value, callback) => {
},
500
)
}
// 检验系统代码
/**
* @description: 检验系统代码
* @param {*} rule
* @param {*} value
* @param {*} callback
* @author: renchao
*/
const
checkCode
=
(
rule
,
value
,
callback
)
=>
{
const
rel
=
/^
[
0-9A-Z
]
+$/
if
(
!
value
)
return
callback
(
new
Error
(
'请输入代码'
))
...
...
@@ -84,6 +114,11 @@ const checkCode = (rule, value, callback) => {
// }
// }
// 日期格式转换 "yyyy-MM-dd HH:mm:ss"
/**
* @description: 日期格式转换 "yyyy-MM-dd HH:mm:ss"
* @param {*} date
* @author: renchao
*/
Vue
.
prototype
.
$formdate
=
function
(
date
)
{
if
(
!
date
)
{
return
""
...
...
@@ -98,18 +133,39 @@ Vue.prototype.$formdate = function (date) {
return
YY
+
MM
+
DD
+
" "
+
hh
+
mm
+
ss
}
// 时间格式过滤
/**
* @description: 时间格式过滤
* @param {*} timeStr
* @author: renchao
*/
Vue
.
filter
(
'timeFilter'
,
function
(
timeStr
)
{
if
(
timeStr
)
{
return
timeStr
.
substring
(
0
,
10
)
}
})
/**
* @description: getType
* @param {*} o
* @author: renchao
*/
export
function
getType
(
o
)
{
return
Object
.
prototype
.
toString
.
call
(
o
).
slice
(
8
,
-
1
)
}
/**
* @description: isKeyType
* @param {*} o
* @param {*} type
* @author: renchao
*/
export
function
isKeyType
(
o
,
type
)
{
return
getType
(
o
).
toLowerCase
()
===
type
.
toLowerCase
()
}
// 深拷贝全局挂载
/**
* @description: 深拷贝全局挂载
* @param {*} sth
* @author: renchao
*/
Vue
.
prototype
.
$deepCopy
=
function
(
sth
)
{
// 深度复制数组
// if (Object.prototype.toString.call(obj) === "[object Array]") {
...
...
@@ -153,6 +209,10 @@ Vue.prototype.$deepCopy = function (sth) {
return
null
}
// 递归处理树形数据children为空数组
/**
* @description: 递归处理树形数据children为空数组
* @author: renchao
*/
Vue
.
prototype
.
$dealArrChildren
=
arr
=>
{
if
(
arr
.
length
)
{
for
(
const
i
in
arr
)
{
...
...
@@ -166,6 +226,10 @@ Vue.prototype.$dealArrChildren = arr => {
return
arr
}
// 过滤对象中为空的属性
/**
* @description: 过滤对象中为空的属性
* @author: renchao
*/
Vue
.
prototype
.
$filterNullObj
=
obj
=>
{
if
(
!
(
typeof
obj
===
'object'
))
{
return
...
...
@@ -181,6 +245,10 @@ Vue.prototype.$filterNullObj = obj => {
return
obj
}
// 递归处理树形数据可选择项
/**
* @description: 递归处理树形数据可选择项
* @author: renchao
*/
Vue
.
prototype
.
$dealArrNotDisabled
=
arr
=>
{
if
(
arr
.
length
)
{
for
(
const
i
in
arr
)
{
...
...
@@ -207,6 +275,12 @@ Vue.prototype.$dealArrNotDisabled = arr => {
return
arr
}
// 递归处理树形数据不可选择项
/**
* @description: 递归处理树形数据不可选择项
* @param {*} arr
* @param {*} id
* @author: renchao
*/
Vue
.
prototype
.
$dealArrDisabled
=
(
arr
,
id
)
=>
{
if
(
arr
.
length
)
{
for
(
const
i
in
arr
)
{
...
...
@@ -233,6 +307,12 @@ Vue.prototype.$dealArrDisabled = (arr, id) => {
return
arr
}
// 根据子节点id递归获取子节点路径id数组
/**
* @description: 根据子节点id递归获取子节点路径id数组
* @param {*} val
* @param {*} id
* @author: renchao
*/
Vue
.
prototype
.
$getNodeRoute
=
(
val
,
id
)
=>
{
let
cid_list
=
[]
val
.
forEach
((
item
,
index
)
=>
{
...
...
@@ -279,6 +359,10 @@ Vue.prototype.$getNodeRoute = (val, id) => {
return
result
(
cid_list
)
}
// 扁平化树形数组
/**
* @description: 扁平化树形数组
* @author: renchao
*/
Vue
.
prototype
.
$treeConvertToArr
=
tree
=>
{
let
arrs
=
[]
const
result
=
[]
...
...
@@ -446,6 +530,11 @@ Vue.prototype.$setChildArr = (
}
}
// 处理localStorage获取值转换boolean为string问题 json字符串转为json
/**
* @description: 对错误信息的处理函数
* @param {*} errMes
* @author: renchao
*/
Vue
.
prototype
.
$getLocalStorage
=
(
name
,
type
)
=>
{
let
data
=
localStorage
.
getItem
(
name
)
if
(
type
===
'boolean'
)
{
...
...
src/utils/tools.js
View file @
5820807
/**
* @description: deleteDomStr
* @author: renchao
*/
import
XLSX2
from
"xlsx"
;
import
XLSX
from
"xlsx-style"
;
/**
...
...
@@ -18,6 +21,11 @@ export function getType (o) {
export
function
isKeyType
(
o
,
type
)
{
return
getType
(
o
).
toLowerCase
()
===
type
.
toLowerCase
();
}
/**
* @description: deepCopy
* @param {*} sth
* @author: renchao
*/
export
function
deepCopy
(
sth
)
{
let
copy
;
if
(
null
==
sth
||
"object"
!=
typeof
sth
)
return
sth
;
...
...
@@ -58,7 +66,11 @@ export function hideCode (str, frontLen, endLen = 0) {
return
str
.
substring
(
0
,
frontLen
)
+
xing
+
str
.
substring
(
str
.
length
-
endLen
);
};
// 数组去重
/**
* @description: 数组去重
* @param {*} arr
* @author: renchao
*/
export
function
unique
(
arr
)
{
var
obj
=
{};
return
arr
.
filter
(
function
(
item
,
index
,
arr
)
{
...
...
@@ -66,7 +78,12 @@ export function unique (arr) {
})
}
// 创造id
/**
* @description: 创造id
* @param {*} len
* @param {*} radix
* @author: renchao
*/
export
function
getUuid
(
len
,
radix
)
{
var
chars
=
"0123456789abcdefghijklmnopqrstuvwxyz"
.
split
(
""
...
...
@@ -91,6 +108,12 @@ export function getUuid (len, radix) {
}
//js计算两个时间戳之间的时间差 (月)
/**
* @description: js计算两个时间戳之间的时间差 (月)
* @param {*} startTime
* @param {*} endTime
* @author: renchao
*/
export
function
intervalTime
(
startTime
,
endTime
)
{
// var timestamp=new Date().getTime(); //计算当前时间戳
var
timestamp
=
(
Date
.
parse
(
new
Date
()))
/
1000
;
//计算当前时间戳 (毫秒级)
...
...
@@ -109,12 +132,22 @@ export function intervalTime (startTime, endTime) {
return
mon
}
// 日期转时间戳
/**
* @description: 日期转时间戳
* @param {*} str_time
* @author: renchao
*/
export
function
js_strto_time
(
str_time
)
{
var
str
=
str_time
.
replace
(
/-/g
,
'/'
)
// 将-替换成/,因为下面这个构造函数只支持/分隔的日期字符串
var
date
=
new
Date
(
str
)
// 构造一个日期型数据,值为传入的字符串
return
date
.
getTime
()
}
// 时间戳转日期
/**
* @description: 时间戳转日期
* @param {*} timestamp
* @author: renchao
*/
export
function
timestampToTime
(
timestamp
)
{
var
date
=
new
Date
(
timestamp
)
//时间戳为10位需*1000,时间戳为13位的话不需乘1000
var
Y
=
date
.
getFullYear
()
+
'-'
...
...
@@ -123,7 +156,11 @@ export function timestampToTime (timestamp) {
return
Y
+
M
+
D
}
/**
* @description: formatDate
* @param {*} value
* @author: renchao
*/
function
formatDate
(
value
)
{
var
date
=
new
Date
(
value
);
var
y
=
date
.
getFullYear
(),
...
...
@@ -135,6 +172,11 @@ function formatDate (value) {
return
t
;
}
/**
* @description: getCurrentDate
* @param {*} date
* @author: renchao
*/
export
function
getCurrentDate
(
date
=
'firstDay'
)
{
var
now
=
new
Date
()
// 当前日期
var
nowYear
=
now
.
getFullYear
()
//当前年
...
...
@@ -147,6 +189,11 @@ export function getCurrentDate (date = 'firstDay') {
}
}
/**
* @description: setExport2Excel
* @param {*} exportName
* @author: renchao
*/
export
function
setExport2Excel
(
exportName
)
{
/* generate workbook object from table */
var
wb
=
XLSX2
.
utils
.
table_to_sheet
(
document
.
querySelector
(
"#mytable"
),
{
raw
:
true
});
//mytable为表格的id名
...
...
@@ -210,6 +257,12 @@ export function setExport2Excel (exportName) {
openDownloadDialog
(
filedata
,
exportName
+
".xlsx"
)
}
//为合并项添加边框
/**
* @description: 为合并项添加边框
* @param {*} range
* @param {*} ws
* @author: renchao
*/
function
addRangeBorder
(
range
,
ws
)
{
let
arr
=
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
];
...
...
@@ -226,6 +279,12 @@ function addRangeBorder (range, ws) {
return
ws
;
}
//将一个sheet转成最终的excel文件的blob对象,然后利用URL.createObjectURL下载
/**
* @description: 将一个sheet转成最终的excel文件的blob对象,然后利用URL.createObjectURL下载
* @param {*} sheet
* @param {*} sheetName
* @author: renchao
*/
function
sheet2blob
(
sheet
,
sheetName
)
{
sheetName
=
sheetName
||
'sheet1'
;
var
workbook
=
{
...
...
@@ -251,6 +310,12 @@ function sheet2blob (sheet, sheetName) {
}
return
blob
;
}
/**
* @description: openDownloadDialog
* @param {*} url
* @param {*} saveName
* @author: renchao
*/
function
openDownloadDialog
(
url
,
saveName
)
{
if
(
typeof
url
==
'object'
&&
url
instanceof
Blob
)
{
url
=
URL
.
createObjectURL
(
url
);
// 创建blob地址
...
...
@@ -267,9 +332,11 @@ function openDownloadDialog (url, saveName) {
aLink
.
dispatchEvent
(
event
);
}
/**
* @description: judgeListComplete
* @param {*} list
* @author: renchao
*/
export
function
judgeListComplete
(
list
)
{
function
judgeObjectComplete
(
obj
)
{
let
flag
=
false
...
...
src/utils/util.cookies.js
View file @
5820807
/**
* @description: deleteDomStr
* @author: renchao
*/
import
Cookies
from
'js-cookie'
const
cookies
=
{}
...
...
src/utils/util.js
View file @
5820807
/**
* @description: deleteDomStr
* @author: renchao
*/
import
cookies
from
'./util.cookies'
/**
* @description: getUrlParam
* @param {*} paraName
* @author: renchao
*/
export
function
getUrlParam
(
paraName
)
{
let
url
=
document
.
location
.
toString
();
let
arrObj
=
url
.
split
(
'?'
);
...
...
@@ -21,7 +30,11 @@ export function getUrlParam(paraName) {
return
''
;
}
}
/**
* @description: setToken
* @param {*} token
* @author: renchao
*/
export
function
setToken
(
token
)
{
if
(
token
===
undefined
)
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
...
...
@@ -37,7 +50,10 @@ export function setToken(token) {
}
}
}
/**
* @description: getToken
* @author: renchao
*/
export
function
getToken
()
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
return
sessionStorage
.
getItem
(
'token'
)
...
...
src/utils/validate.js
View file @
5820807
/**
* @description: isExternal
* @param {string} path
* @returns {Boolean}
*/
...
...
@@ -7,16 +8,37 @@ export function isExternal (path) {
}
// ex: {validator:validateCode,trigger:'blur'}
// 验证code
/**
* @description: 验证code
* @param {*} rule
* @param {*} value
* @param {*} callback
* @author: renchao
*/
export
const
validateCode
=
(
rule
,
value
,
callback
)
=>
{
const
reg
=
/^
[
A-Z
]{1}[
A-Za-z0-9
]
*$/
!
reg
.
test
(
value
)
?
callback
(
'字母开头、数字和字母组成'
)
:
callback
()
}
// 验证 网址
/**
* @description: 验证 网址
* @param {*} rule
* @param {*} value
* @param {*} callback
* @author: renchao
*/
export
const
validateUrl
=
(
rule
,
value
,
callback
)
=>
{
const
reg
=
/^
(((
ht|f
)
tps
?)
:
\/\/)?[\w
-
]
+
(\.[\w
-
]
+
)
+
([\w
.,@?^=%&:
/
~+#-
]
*
[\w
@?^=%&
/
~+#-
])?
$/
!
reg
.
test
(
value
)
?
callback
(
'URL格式不正确'
)
:
callback
()
}
// 验证 电话
/**
* @description: 验证 电话
* @param {*} rule
* @param {*} value
* @param {*} callback
* @author: renchao
*/
export
const
validatePhone
=
(
rule
,
value
,
callback
)
=>
{
const
phoneReg
=
/^
[
1
][
3,4,5,6,7,8,9
][
0-9
]{9}
$/
const
rel
=
/^
[
0
]\d{2,3}
-
[
1-9
]\d{7}
$/
...
...
Please
register
or
sign in
to post a comment