Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-gjjs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fukai
vue-gjjs
Commits
ee49135e
Commit
ee49135e
authored
Nov 25, 2022
by
fukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配套优化前端pageId刷新
parent
6a5f5673
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
127 additions
and
7 deletions
+127
-7
main.js
src/main.js
+15
-0
commonApi.js
src/mixin/commonApi.js
+15
-1
Api.js
src/service/Api.js
+30
-6
EventService.js
src/service/EventService.js
+54
-0
index.vue
src/views/Business/Ditopn/index.vue
+8
-0
Header.vue
src/views/Layout/Header.vue
+2
-0
index.vue
src/views/Login/index.vue
+3
-0
No files found.
src/main.js
View file @
ee49135e
...
@@ -15,6 +15,7 @@ import i18n from "./lang";
...
@@ -15,6 +15,7 @@ import i18n from "./lang";
import
CustomComponent
from
"./components"
;
import
CustomComponent
from
"./components"
;
import
vuefunc
from
"./utils/vuefunc"
;
import
vuefunc
from
"./utils/vuefunc"
;
import
"./permission"
;
import
"./permission"
;
import
EventService
,{
LOGIN
,
LOGOUT
}
from
"~/service/EventService"
;
window
.
SUCCESS
=
"AAAAAA"
;
window
.
SUCCESS
=
"AAAAAA"
;
...
@@ -22,6 +23,20 @@ Vue.use(ElementUI, { size: "small", i18n: (key, value) => i18n.t(key, value) });
...
@@ -22,6 +23,20 @@ Vue.use(ElementUI, { size: "small", i18n: (key, value) => i18n.t(key, value) });
Vue
.
use
(
CustomComponent
);
Vue
.
use
(
CustomComponent
);
Vue
.
use
(
vuefunc
);
Vue
.
use
(
vuefunc
);
function
resetCache
(){
window
.
GLOBAL_CACHE
=
{
PAGEID_CACHE
:
new
Set
()};
}
//初始化cache
resetCache
();
//登录后重置
EventService
.
on
(
LOGIN
,()
=>
{
resetCache
();
});
//退出后重置
EventService
.
on
(
LOGOUT
,()
=>
{
resetCache
();
});
new
Vue
({
new
Vue
({
el
:
"#app"
,
el
:
"#app"
,
store
,
store
,
...
...
src/mixin/commonApi.js
View file @
ee49135e
...
@@ -90,9 +90,16 @@ export default {
...
@@ -90,9 +90,16 @@ export default {
},
},
async
init
(
params
)
{
async
init
(
params
)
{
const
loading
=
this
.
loading
(
"交易加载中"
)
const
loading
=
this
.
loading
(
"交易加载中"
)
let
rtnmsg
=
await
Api
.
post
(
this
.
requestPrefix
+
"/init"
,
{
params
})
let
prePageId
=
this
.
$route
.
params
.
prePageId
||
""
;
console
.
log
(
"init/prePageId:"
+
prePageId
);
let
data
=
{
params
,
prePageId
};
let
rtnmsg
=
await
Api
.
post
(
this
.
requestPrefix
+
"/init"
,
data
)
if
(
rtnmsg
.
respCode
==
SUCCESS
)
{
if
(
rtnmsg
.
respCode
==
SUCCESS
)
{
this
.
updateValueSet
(
rtnmsg
.
codeSet
)
this
.
updateValueSet
(
rtnmsg
.
codeSet
)
//添加pageId
if
(
rtnmsg
.
data
.
pageId
)
window
.
GLOBAL_CACHE
.
PAGEID_CACHE
.
add
(
rtnmsg
.
data
.
pageId
);
}
}
loading
.
close
()
loading
.
close
()
return
rtnmsg
return
rtnmsg
...
@@ -203,5 +210,11 @@ export default {
...
@@ -203,5 +210,11 @@ export default {
}
}
});
});
}
}
},
async
beforeDestroy
(){
if
(
!
this
.
root
&&
this
.
model
&&
this
.
model
.
pageId
){
//回收pageId
window
.
GLOBAL_CACHE
.
PAGEID_CACHE
.
delete
(
this
.
model
.
pageId
);
}
}
}
}
}
\ No newline at end of file
src/service/Api.js
View file @
ee49135e
...
@@ -5,11 +5,25 @@ import RequestManager from './RequestManager.js';
...
@@ -5,11 +5,25 @@ import RequestManager from './RequestManager.js';
export
const
BASE_HOST
=
"/gjjs"
export
const
BASE_HOST
=
"/gjjs"
export
const
BASE_URI
=
BASE_HOST
+
""
;
export
const
BASE_URI
=
BASE_HOST
+
""
;
const
instance
=
axios
.
create
({
export
const
AxiosInstance
=
axios
.
create
({
baseURL
:
BASE_URI
,
timeout
:
5000
,
method
:
'post'
,
});
});
//对全局的业务数据请求使用拦截器
AxiosInstance
.
interceptors
.
request
.
use
(
function
(
config
){
if
(
window
.
GLOBAL_CACHE
&&
window
.
GLOBAL_CACHE
.
PAGEID_CACHE
){
const
key
=
"CUR-PAGE-IDS"
;
let
pageIds
=
[...
window
.
GLOBAL_CACHE
.
PAGEID_CACHE
].
join
(
","
);
if
(
!
config
.
headers
){
config
.
headers
=
{
key
:
pageIds
};
}
else
if
(
!
config
.
headers
[
key
]){
config
.
headers
[
key
]
=
pageIds
;
}
}
return
config
;
},
function
(
error
){
return
Promise
.
reject
(
error
);
})
const
CODE_KEY
=
"respCode"
const
CODE_KEY
=
"respCode"
const
MESSAGE_KEY
=
"respMsg"
const
MESSAGE_KEY
=
"respMsg"
...
@@ -26,7 +40,7 @@ export default class Api
...
@@ -26,7 +40,7 @@ export default class Api
if
(
url
!=
`
${
BASE_URI
}
login`
&&
token
)
if
(
url
!=
`
${
BASE_URI
}
login`
&&
token
)
headers
.
token
=
token
;
headers
.
token
=
token
;
return
new
Promise
(
(
resolve
,
reject
)
=>
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
axios
.
get
(
url
,
data
,{
AxiosInstance
.
get
(
url
,
data
,{
headers
,
headers
,
timeout
:
50000
,
timeout
:
50000
,
...
@@ -74,8 +88,13 @@ export default class Api
...
@@ -74,8 +88,13 @@ export default class Api
if
(
typeof
data
===
"function"
)
{
if
(
typeof
data
===
"function"
)
{
data
=
await
data
()
data
=
await
data
()
}
}
let
curPid
=
data
.
pageId
||
""
;
let
prePid
=
data
.
prePageId
||
""
;
//设置PAGEID
headers
[
"CUR-PID"
]
=
curPid
;
headers
[
"PRE-PID"
]
=
prePid
;
return
new
Promise
(
(
resolve
,
reject
)
=>
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
axios
.
post
(
url
,
data
,{
AxiosInstance
.
post
(
url
,
data
,{
headers
,
headers
,
method
,
method
,
timeout
:
120000
,
timeout
:
120000
,
...
@@ -139,4 +158,8 @@ export default class Api
...
@@ -139,4 +158,8 @@ export default class Api
{
{
return
this
.
_get
(
BASE_HOST
+
url
,
data
)
return
this
.
_get
(
BASE_HOST
+
url
,
data
)
}
}
static
postAsync
(
url
,
data
){
return
this
.
_post
.
call
(
url
,
data
);
}
}
}
\ No newline at end of file
src/service/EventService.js
0 → 100644
View file @
ee49135e
/**
* 自定义的事件触发器
*/
export
default
class
EventService
{
static
on
(
key
,
fn
){
if
(
!
this
.
events
[
key
]){
this
.
events
[
key
]
=
[];
}
for
(
let
originFn
of
this
.
events
[
key
]){
if
(
originFn
===
fn
){
return
;
}
}
this
.
events
[
key
].
push
(
fn
);
return
()
=>
{
this
.
off
(
key
,
fn
);
}
}
static
off
(
key
,
fn
){
if
(
!
this
.
events
[
key
]){
return
;
}
const
fns
=
this
.
events
[
key
];
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
){
if
(
fns
[
i
]
==
fn
){
fns
.
splice
(
i
,
1
);
return
;
}
}
}
static
async
emit
(
key
,
arg
){
if
(
!
this
.
events
[
key
]){
return
;
}
const
results
=
[];
const
fns
=
this
.
events
[
key
];
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
){
let
result
;
try
{
result
=
await
fns
[
i
](
arg
);
}
catch
(
error
){
}
results
.
push
(
result
);
}
return
results
;
}
}
EventService
.
events
=
{}
const
LOGIN
=
"LOGIN"
const
LOGOUT
=
"LOGOUT"
export
{
LOGIN
,
LOGOUT
}
\ No newline at end of file
src/views/Business/Ditopn/index.vue
View file @
ee49135e
...
@@ -13,6 +13,10 @@
...
@@ -13,6 +13,10 @@
</c-function-btn>
</c-function-btn>
<el-form
:model=
"model"
:rules=
"rules"
ref=
"modelForm"
label-width=
"120px"
label-position=
"right"
size=
"small"
<el-form
:model=
"model"
:rules=
"rules"
ref=
"modelForm"
label-width=
"120px"
label-position=
"right"
size=
"small"
:validate-on-rule-change=
"false"
>
:validate-on-rule-change=
"false"
>
<el-form-item
label=
"test"
>
<c-mul-row-input
v-model=
"testVal"
v-on:input=
"onInput"
:rows=
"3"
:cols=
"5"
:charmod=
"0"
></c-mul-row-input>
<pre>
{{
testVal
}}
</pre>
</el-form-item>
<c-tabs
:value=
"tabVal"
ref=
"elment"
type=
"card"
@
tab-click=
"tabClick"
>
<c-tabs
:value=
"tabVal"
ref=
"elment"
type=
"card"
@
tab-click=
"tabClick"
>
<el-tab-pane
label=
"基本信息"
name=
"ovwp"
>
<el-tab-pane
label=
"基本信息"
name=
"ovwp"
>
<!--PD000001 -->
<!--PD000001 -->
...
@@ -167,6 +171,7 @@ export default {
...
@@ -167,6 +171,7 @@ export default {
data
()
{
data
()
{
return
{
return
{
tabVal
:
"ovwp"
,
tabVal
:
"ovwp"
,
testVal
:
""
,
trnName
:
"ditopn"
,
trnName
:
"ditopn"
,
model
:
new
Ditopn
().
data
,
model
:
new
Ditopn
().
data
,
customModel
:
new
customDitopn
().
data
,
customModel
:
new
customDitopn
().
data
,
...
@@ -184,6 +189,9 @@ export default {
...
@@ -184,6 +189,9 @@ export default {
};
};
},
},
methods
:
{
methods
:
{
onInput
(
val
){
console
.
log
(
val
)
}
},
},
created
:
async
function
()
{
created
:
async
function
()
{
console
.
log
(
"进入ditopn交易"
);
console
.
log
(
"进入ditopn交易"
);
...
...
src/views/Layout/Header.vue
View file @
ee49135e
...
@@ -222,6 +222,7 @@
...
@@ -222,6 +222,7 @@
<
script
>
<
script
>
import
cPage
from
"../../components/c-page.vue"
;
import
cPage
from
"../../components/c-page.vue"
;
import
Api
from
"~/service/Api"
;
import
Api
from
"~/service/Api"
;
import
EventService
,
{
LOGOUT
}
from
"~/service/EventService"
;
import
{
changeLang
}
from
"~/service/business/lang"
;
import
{
changeLang
}
from
"~/service/business/lang"
;
export
default
{
export
default
{
...
@@ -281,6 +282,7 @@ export default {
...
@@ -281,6 +282,7 @@ export default {
},
},
methods
:
{
methods
:
{
logout
()
{
logout
()
{
EventService
.
emit
(
LOGOUT
);
this
.
$store
.
commit
(
"UserContext/setLogout"
);
this
.
$store
.
commit
(
"UserContext/setLogout"
);
this
.
$router
.
push
(
"/login"
);
this
.
$router
.
push
(
"/login"
);
// window.location.href = "/#/login"
// window.location.href = "/#/login"
...
...
src/views/Login/index.vue
View file @
ee49135e
...
@@ -65,6 +65,8 @@
...
@@ -65,6 +65,8 @@
import
Utils
from
"~/utils"
;
import
Utils
from
"~/utils"
;
import
{
createNamespacedHelpers
}
from
"vuex"
;
import
{
createNamespacedHelpers
}
from
"vuex"
;
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
EventService
,
{
LOGIN
}
from
"~/service/EventService"
;
const
{
mapState
,
mapMutations
,
mapActions
}
=
const
{
mapState
,
mapMutations
,
mapActions
}
=
createNamespacedHelpers
(
"UserContext"
);
createNamespacedHelpers
(
"UserContext"
);
...
@@ -96,6 +98,7 @@ export default {
...
@@ -96,6 +98,7 @@ export default {
userId
:
this
.
loginForm
.
username
,
userId
:
this
.
loginForm
.
username
,
token
:
Utils
.
generateUUID
(),
token
:
Utils
.
generateUUID
(),
});
});
EventService
.
emit
(
LOGIN
)
// 电证登录
// 电证登录
const
dzUsr
=
usrMap
[
this
.
loginForm
.
username
===
"ZL"
?
"ZL"
:
"MBF"
];
const
dzUsr
=
usrMap
[
this
.
loginForm
.
username
===
"ZL"
?
"ZL"
:
"MBF"
];
const
headers
=
{
const
headers
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment