Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-system
/
system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f70ef5b0
authored
Oct 27, 2020
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
组件和接口修改
1 parent
d334480b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
97 deletions
src/components/basic-table/index.vue
src/config/config.js
src/utils/http.js
src/views/user/index.vue
src/components/basic-table/index.vue
View file @
f70ef5b
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
width=
"60px"
width=
"60px"
label=
"序号"
label=
"序号"
type=
'index'
type=
'index'
:index=
"index=>index+(pag
ination.pageSize - 1) * pagination.pageNum
+ 1"
:index=
"index=>index+(pag
e.pageNumber - 1) * page.pageSize
+ 1"
></el-table-column>
></el-table-column>
<el-table-column
<el-table-column
v-for=
"(item, index) in tableParams.tableColumns"
v-for=
"(item, index) in tableParams.tableColumns"
...
@@ -99,7 +99,7 @@
...
@@ -99,7 +99,7 @@
background
background
@
size-change=
"handleSizeChange"
@
size-change=
"handleSizeChange"
@
current-change=
"handleCurrentChange"
@
current-change=
"handleCurrentChange"
:current-page=
"page.pageNum"
:current-page=
"page.pageNum
ber
"
:page-sizes=
"[10,20,30,40]"
:page-sizes=
"[10,20,30,40]"
:page-size=
"page.pageSize"
:page-size=
"page.pageSize"
:total=
"getListApi ? total : tableTotal"
:total=
"getListApi ? total : tableTotal"
...
@@ -118,14 +118,14 @@ export default {
...
@@ -118,14 +118,14 @@ export default {
oldValue
:
{},
oldValue
:
{},
data
:
[],
data
:
[],
page
:
{
page
:
{
page
Num
:
10
,
page
Size
:
10
,
page
Size
:
1
page
Number
:
1
},
},
total
:
10
,
total
:
10
,
// 排序
// 排序
sortColum
:
''
,
sortColum
:
''
,
sort
:
''
,
sort
:
''
,
pagination
:
{},
//
pagination: {},
// 多选数组
// 多选数组
mutiSelectArr
:
{}
mutiSelectArr
:
{}
}
}
...
@@ -296,11 +296,14 @@ export default {
...
@@ -296,11 +296,14 @@ export default {
// 页码
// 页码
handleSizeChange
(
value
)
{
handleSizeChange
(
value
)
{
this
.
page
.
pageSize
=
value
this
.
page
.
pageSize
=
value
console
.
log
(
'handleSizeChange'
,
value
)
this
.
getListApi
?
this
.
refreshTable
(
false
)
:
this
.
$emit
(
'refreshTable'
,
this
.
page
)
this
.
getListApi
?
this
.
refreshTable
(
false
)
:
this
.
$emit
(
'refreshTable'
,
this
.
page
)
},
},
handleCurrentChange
(
value
)
{
handleCurrentChange
(
value
)
{
this
.
page
.
pageNum
=
value
console
.
log
(
'handleCurrentChange'
,
value
)
this
.
page
.
pageNumber
=
value
this
.
getListApi
?
this
.
refreshTable
(
false
)
:
this
.
$emit
(
'refreshTable'
,
this
.
page
)
this
.
getListApi
?
this
.
refreshTable
(
false
)
:
this
.
$emit
(
'refreshTable'
,
this
.
page
)
}
}
}
}
...
...
src/config/config.js
View file @
f70ef5b
...
@@ -46,7 +46,7 @@ const ORGINIZA_API = {
...
@@ -46,7 +46,7 @@ const ORGINIZA_API = {
ORGINIZA_SEARCH
:
BASE_URL
+
'/usercenter/organization/rootList'
,
ORGINIZA_SEARCH
:
BASE_URL
+
'/usercenter/organization/rootList'
,
ORGINIZA_CHILDREN
:
BASE_URL
+
'/usercenter/organization/children'
,
ORGINIZA_CHILDREN
:
BASE_URL
+
'/usercenter/organization/children'
,
ORGINIZA_SIMPLElIST
:
BASE_URL
+
'/usercenter/organization/simpleList'
,
ORGINIZA_SIMPLElIST
:
BASE_URL
+
'/usercenter/organization/simpleList'
,
ORGINIZA_TREEORY
:
BASE_URL
+
'/usercenter/organization/
treeOrg
'
,
ORGINIZA_TREEORY
:
BASE_URL
+
'/usercenter/organization/
orgtree
'
,
ORGINIZA_ADD
:
BASE_URL
+
'/usercenter/organization/add'
,
ORGINIZA_ADD
:
BASE_URL
+
'/usercenter/organization/add'
,
ORGINIZA_EDIT
:
BASE_URL
+
'/usercenter/organization/edit'
,
ORGINIZA_EDIT
:
BASE_URL
+
'/usercenter/organization/edit'
,
ORGINIZA_DELETE
:
BASE_URL
+
'/usercenter/organization/delete'
ORGINIZA_DELETE
:
BASE_URL
+
'/usercenter/organization/delete'
...
...
src/utils/http.js
View file @
f70ef5b
import
axios
from
'axios'
;
import
axios
from
'axios'
// import store from '@/store'
;
// import store from '@/store'
// import { checkStatus } from './checkStatus'
;
// import { checkStatus } from './checkStatus'
const
instance
=
axios
.
create
({
//创建axios实例,在这里可以设置请求的默认配置
const
instance
=
axios
.
create
({
//
创建axios实例,在这里可以设置请求的默认配置
timeout
:
60000
,
// 设置超时时间60s
timeout
:
60000
,
// 设置超时时间60s
retry
:
3
,
retry
:
3
,
retryDelay
:
1000
retryDelay
:
1000
})
})
// 统一设置post请求头
// 统一设置post请求头
instance
.
defaults
.
headers
.
post
[
'Content-Type'
]
=
'application/json'
;
instance
.
defaults
.
headers
.
post
[
'Content-Type'
]
=
'application/json'
/** 添加请求拦截器 **/
/** 添加请求拦截器 **/
instance
.
interceptors
.
request
.
use
(
config
=>
{
instance
.
interceptors
.
request
.
use
(
config
=>
{
config
.
headers
[
'Authorization'
]
=
localStorage
.
getItem
(
'token'
)
||
''
;
config
.
headers
[
'Authorization'
]
=
localStorage
.
getItem
(
'token'
)
||
''
// store.dispatch('app/showLoading', true);
// store.dispatch('app/showLoading', true)
return
config
return
config
},
error
=>
{
},
error
=>
{
console
.
log
(
'请求错误,原因:'
,
error
)
console
.
log
(
'请求错误,原因:'
,
error
)
// store.dispatch('app/showLoading', false);
// store.dispatch('app/showLoading', false)
return
Promise
.
reject
(
error
)
return
Promise
.
reject
(
error
)
})
})
/** 添加响应拦截器 **/
/** 添加响应拦截器 **/
instance
.
interceptors
.
response
.
use
(
response
=>
{
instance
.
interceptors
.
response
.
use
(
response
=>
{
// store.dispatch('app/showLoading', false);
// store.dispatch('app/showLoading', false)
const
serverCode
=
response
.
data
.
code
;
const
serverCode
=
response
.
data
.
code
if
(
serverCode
===
200
||
response
.
status
===
200
)
{
if
(
serverCode
===
200
||
response
.
status
===
200
)
{
if
(
serverCode
!==
200
)
{
if
(
serverCode
!==
200
)
{
// checkStatus(serverCode);
// checkStatus(serverCode)
}
}
if
(
response
.
status
)
{
if
(
response
.
status
)
{
return
Promise
.
resolve
(
response
);
return
Promise
.
resolve
(
response
)
}
return
Promise
.
resolve
(
response
.
data
);
}
else
{
// checkStatus(serverCode);
return
Promise
.
reject
(
response
.
data
.
message
)
}
}
return
Promise
.
resolve
(
response
.
data
)
}
else
{
// checkStatus(serverCode)
return
Promise
.
reject
(
response
.
data
.
message
)
}
},
error
=>
{
},
error
=>
{
// store.dispatch('app/showLoading', false);
// store.dispatch('app/showLoading', false)
const
errRes
=
error
.
response
;
const
errRes
=
error
.
response
if
(
errRes
)
{
if
(
errRes
)
{
const
{
data
,
config
,
status
,
statusText
}
=
errRes
;
const
{
data
,
config
,
status
,
statusText
}
=
errRes
// checkStatus(status);
// checkStatus(status)
console
.
log
(
`
${
config
.
url
}
接口请求出错,状态码
${
status
}
`
);
console
.
log
(
`
${
config
.
url
}
接口请求出错,状态码
${
status
}
`
)
return
Promise
.
reject
(
error
);
return
Promise
.
reject
(
error
)
}
else
{
}
else
{
// checkStatus('fail');
// checkStatus('fail')
console
.
log
(
'http request fail 请求失败'
);
console
.
log
(
'http request fail 请求失败'
)
return
Promise
.
reject
(
new
Error
(
'请求失败'
))
return
Promise
.
reject
(
new
Error
(
'请求失败'
))
}
}
//
超时处理
//
超时处理
var
config
=
error
.
config
;
var
config
=
error
.
config
if
(
!
config
||
!
config
.
retry
)
return
Promise
.
reject
(
error
);
if
(
!
config
||
!
config
.
retry
)
return
Promise
.
reject
(
error
)
// 设置用于跟踪重试次数的变量
// 设置用于跟踪重试次数的变量
config
.
__retryCount
=
config
.
__retryCount
||
0
;
config
.
__retryCount
=
config
.
__retryCount
||
0
// 检查我们是否已将重试总数最大化
// 检查我们是否已将重试总数最大化
if
(
config
.
__retryCount
>=
config
.
retry
)
{
if
(
config
.
__retryCount
>=
config
.
retry
)
{
// 错误拒绝
// 错误拒绝
return
Promise
.
reject
(
error
);
return
Promise
.
reject
(
error
)
}
}
// 增加重试次数
// 增加重试次数
config
.
__retryCount
+=
1
;
config
.
__retryCount
+=
1
// 创造新的承诺来处理指数退避
// 创造新的承诺来处理指数退避
var
backoff
=
new
Promise
(
function
(
resolve
)
{
var
backoff
=
new
Promise
(
function
(
resolve
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
resolve
();
resolve
()
},
config
.
retryDelay
||
1
);
},
config
.
retryDelay
||
1
)
});
})
// 返回承诺,其中将撤回axios以重试请求
// 返回承诺,其中将撤回axios以重试请求
return
backoff
.
then
(
function
()
{
return
backoff
.
then
(
function
()
{
return
axios
(
config
);
return
axios
(
config
)
});
})
})
})
export
default
class
HTTP
{
export
default
class
HTTP
{
axiosPost
(
options
)
{
axiosPost
(
options
)
{
instance
({
instance
({
url
:
options
.
url
,
url
:
options
.
url
,
method
:
'post'
,
method
:
'post'
,
data
:
JSON
.
stringify
(
options
.
data
)
data
:
JSON
.
stringify
(
options
.
data
)
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
);
options
.
success
(
res
.
data
)
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
options
.
error
(
err
);
options
.
error
(
err
)
})
})
}
}
axiosGet
(
options
)
{
instance
({
url
:
options
.
url
,
method
:
'get'
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
);
}).
catch
((
err
)
=>
{
options
.
error
(
err
);
})
}
}
\ No newline at end of file
\ No newline at end of file
axiosGet
(
options
)
{
instance
({
url
:
options
.
url
,
method
:
'get'
,
params
:
options
.
data
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
)
}).
catch
((
err
)
=>
{
options
.
error
(
err
)
})
}
}
src/views/user/index.vue
View file @
f70ef5b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
</div>
</div>
<el-input
size=
"mini"
></el-input>
<el-input
size=
"mini"
></el-input>
<el-tree
<el-tree
:data=
"data"
:data=
"
tree
data"
accordion
accordion
node-key=
"id"
node-key=
"id"
@
node-click=
"handleNodeClick"
@
node-click=
"handleNodeClick"
...
@@ -197,7 +197,7 @@ export default {
...
@@ -197,7 +197,7 @@ export default {
},
},
getListApi
:
getUserList
,
getListApi
:
getUserList
,
// 折叠菜单数据
// 折叠菜单数据
data
:
[],
tree
data
:
[],
// 弹窗数据
// 弹窗数据
userDialogTitle
:
'新增用户'
,
userDialogTitle
:
'新增用户'
,
userVisible
:
false
,
userVisible
:
false
,
...
@@ -453,7 +453,7 @@ export default {
...
@@ -453,7 +453,7 @@ export default {
getTreeOrg
()
{
getTreeOrg
()
{
getTreeOrg
().
then
(
res
=>
{
getTreeOrg
().
then
(
res
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
this
.
data
=
res
.
data
.
list
this
.
treedata
=
res
.
data
})
})
},
},
// 角色下拉列表
// 角色下拉列表
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment