Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-composition-api
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
宁路鹏
vue-composition-api
Commits
c94be8df
Commit
c94be8df
authored
Jun 07, 2022
by
nlp97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路由 hooks
parent
bcc4e31b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
84 deletions
+132
-84
src/utils/http.js
+64
-63
src/utils/useVueRouter.js
+38
-0
src/views/outseeQualityControl.vue
+30
-21
No files found.
src/utils/http.js
View file @
c94be8df
...
...
@@ -14,8 +14,8 @@ axios.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8'
var
domain
=
'/api/api'
function
createHeader
()
{
const
token
=
getItem
(
'svToken'
);
return
token
?
{
Authorization
:
`Bearer
${
token
}
`
}
:
{};
const
token
=
getItem
(
'svToken'
);
return
token
?
{
Authorization
:
`Bearer
${
token
}
`
}
:
{};
}
function
errorMsg
(
d
)
{
...
...
@@ -54,71 +54,71 @@ let loadingOption = { //加载loading
background
:
'rgba(0, 0, 0, 0.5)'
}
axios
.
interceptors
.
response
.
use
(
(
response
)
=>
{
if
(
response
.
status
===
200
)
{
return
Promise
.
resolve
(
response
);
}
else
{
return
Promise
.
reject
(
response
);
}
},
(
error
)
=>
{
if
(
error
.
response
.
status
==
401
)
{
window
.
sessionStorage
.
clear
();
window
.
location
.
href
=
'/'
;
}
return
Promise
.
reject
(
error
);
}
(
response
)
=>
{
if
(
response
.
status
===
200
)
{
return
Promise
.
resolve
(
response
);
}
else
{
return
Promise
.
reject
(
response
);
}
},
(
error
)
=>
{
if
(
error
.
response
.
status
==
401
)
{
window
.
sessionStorage
.
clear
();
window
.
location
.
href
=
'/'
;
}
return
Promise
.
reject
(
error
);
}
);
export
default
{
post
(
url
,
params
,
option
)
{
if
(
getItem
(
'svtoken'
))
{
loadingInstance
=
Vue
.
prototype
.
$loading
(
loadingOption
);
}
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
post
(
domain
+
url
,
params
,
{
...{
headers
:
createHeader
()
},
...
option
})
.
then
((
res
)
=>
{
if
(
res
.
status
!==
200
)
{
errorMsg
(
res
.
data
);
reject
(
res
.
data
);
return
;
}
if
(
getItem
(
'token'
))
{
loadingInstance
.
close
();
}
resolve
(
res
.
data
.
data
||
res
.
data
);
})
.
catch
((
error
)
=>
{
if
(
getItem
(
'token'
))
{
loadingInstance
.
close
();
}
errorMsg
(
error
);
reject
(
error
);
});
});
},
loadingInstance
=
Vue
.
prototype
.
$loading
(
loadingOption
);
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
post
(
domain
+
url
,
params
,
{
...{
headers
:
createHeader
()
},
...
option
})
.
then
((
res
)
=>
{
if
(
res
.
status
!==
200
)
{
errorMsg
(
res
.
data
);
reject
(
res
.
data
);
return
;
}
loadingInstance
.
close
();
resolve
(
res
.
data
.
data
||
res
.
data
);
})
.
catch
((
error
)
=>
{
loadingInstance
.
close
();
errorMsg
(
error
);
reject
(
error
);
});
});
},
get
(
url
,
option
)
{
loadingInstance
=
Vue
.
prototype
.
$loading
(
loadingOption
);
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
domain
+
url
,
{
...{
headers
:
createHeader
()
},
...
option
})
.
then
((
res
)
=>
{
if
(
res
.
status
!==
200
)
{
errorMsg
(
res
.
data
);
reject
(
res
.
data
);
return
;
}
loadingInstance
.
close
();
resolve
(
res
.
data
.
data
||
res
.
data
);
})
.
catch
((
error
)
=>
{
loadingInstance
.
close
();
errorMsg
(
error
);
reject
(
error
);
});
});
},
loadingInstance
=
Vue
.
prototype
.
$loading
(
loadingOption
);
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
domain
+
url
,
{
...{
headers
:
createHeader
()
},
...
option
})
.
then
((
res
)
=>
{
if
(
res
.
status
!==
200
)
{
errorMsg
(
res
.
data
);
reject
(
res
.
data
);
return
;
}
loadingInstance
.
close
();
resolve
(
res
.
data
.
data
||
res
.
data
);
})
.
catch
((
error
)
=>
{
loadingInstance
.
close
();
errorMsg
(
error
);
reject
(
error
);
});
});
},
}
\ No newline at end of file
src/utils/useVueRouter.js
0 → 100644
View file @
c94be8df
/*
* @Author: ninglupeng
* @Date: 2022-06-07 11:37:20
* @LastEditors: ninglupeng
* @LastEditTime: 2022-06-07 11:48:40
* @Description:
*/
import
{
ComponentInternalInstance
,
computed
,
getCurrentInstance
,
Ref
,
}
from
'@vue/composition-api'
;
import
VueRouter
,
{
Route
}
from
'vue-router'
;
export
function
getVueInstance
()
{
const
instance
=
getCurrentInstance
();
if
(
instance
)
{
return
instance
;
}
throw
new
Error
(
'Vue instance is missing'
);
}
export
function
useRoute
()
{
const
{
proxy
}
=
getVueInstance
();
return
computed
(()
=>
proxy
.
$route
);
}
export
function
useRouter
()
{
const
{
proxy
}
=
getVueInstance
();
return
proxy
.
$router
;
}
export
default
{
getVueInstance
,
useRoute
,
useRouter
,
};
src/views/outseeQualityControl.vue
View file @
c94be8df
...
...
@@ -2,16 +2,16 @@
* @Author: wsq
* @Date: 2022-04-22 14:21:50
* @LastEditors: ninglupeng
* @LastEditTime: 2022-06-07 1
0:06:2
0
* @LastEditTime: 2022-06-07 1
1:50:0
0
* @Description:
-->
<
template
>
<!-- 查看质控 -->
<div
class=
"outseeQualityControl"
>
<div
class=
"outseeQualityControl_box"
>
<div
class=
"outseeQualityControl_box_btn"
>
<el-button
size=
"mini"
type=
"primary"
@
click=
"getSynchronous"
>
同步数据
</el-button>
</div
>
<
!--
<
div
class=
"outseeQualityControl_box_btn"
>
<el-button
size=
"mini"
type=
"primary"
@
click=
"getSynchronous"
>
同步数据
</el-button>
</div>
--
>
<div
class=
"outseeQualityControl_box_header"
>
<div
class=
"outseeQualityControl_box_header_text"
></div>
</div>
...
...
@@ -115,9 +115,10 @@
<
script
>
import
http
from
'../utils/http'
;
import
{
reactive
,
toRefs
,
onMounted
,
nextTick
,
computed
}
from
'@vue/composition-api'
;
import
$
from
'jquery'
;
import
{
setItem
}
from
'../utils/auth'
;
import
medicalRecordHomepage
from
'../components/medicalRecordHomepage/index.vue'
;
import
{
useRoute
,
useRouter
}
from
'../utils/useVueRouter'
;
import
$
from
'jquery'
;
import
{
setItem
,
getItem
}
from
'../utils/auth'
;
export
default
{
components
:
{
medicalRecordHomepage
,
...
...
@@ -146,19 +147,24 @@ export default {
keys
:
[],
//获取所有的问卷key
values
:
[],
//
});
// var route = useRoute();
var
route
=
useRoute
();
onMounted
(()
=>
{
console
.
log
(
route
.
value
);
});
//同步数据
const
getSynchronous
=
(
id
)
=>
{
// var loadingInstance1 = ElLoading.service(loadingOption1);
http
.
post
(
`/medical/get/Synchronization?id=
${
'3606b7a5-de50-11ec-9998-9016ba5908d0'
}
`
)
.
post
(
`/medical/get/Synchronization?id=
${
route
.
value
.
query
.
id
}
`
)
.
then
((
data
)
=>
{
// loadingInstance1.close();
// ElMessage.success(data.message);
})
.
catch
((
error
)
=>
{
// loadingInstance1.close();
// ElMessage.error(error);
});
};
...
...
@@ -189,6 +195,13 @@ export default {
);
}
}
const
loadingOption1
=
{
// 加载loading
fullscreen
:
true
,
text
:
'正在加载...'
,
spinner
:
'el-icon-loading'
,
background
:
'rgba(0, 0, 0, 0.5)'
,
};
// 获取病案首页数据
...
...
@@ -226,10 +239,11 @@ export default {
};
onMounted
(()
=>
{
if
(
'3606b7a5-de50-11ec-9998-9016ba5908d0'
)
{
getHomePage
(
'3606b7a5-de50-11ec-9998-9016ba5908d0'
);
getScoringDetails
(
'3606b7a5-de50-11ec-9998-9016ba5908d0'
);
setItem
(
'outpid'
,
'3606b7a5-de50-11ec-9998-9016ba5908d0'
)
if
(
route
.
value
.
query
.
id
)
{
getHomePage
(
route
.
value
.
query
.
id
);
getScoringDetails
(
route
.
value
.
query
.
id
);
setItem
(
'outpid'
,
route
.
value
.
query
.
id
)
}
});
...
...
@@ -246,15 +260,10 @@ export default {
<
style
lang=
"scss"
>
@import
'../styles/mixin.scss'
;
@import
'../styles/media/components/outpatientDetails
.scss'
;
//
@import
'styles/media/components/outseeQualityControl
.scss'
;
.outseeQualityControl
{
//
height
:
calc
(
100%
-
50px
);
//
padding
:
10px
;
//
overflow
:
hidden
;
//
background-color
:
#fff
;
height
:
100%
;
background-color
:
white
;
padding
:
20px
;
...
...
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