123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <template>
- <view class="nav">
- <view class="navbar">
- <!-- <button class="scanbara" @click="handleScanbara">复核扫码</button> -->
- <button class="scanbara1" @click="gotoPrint">打印设置</button>
- <view class="status">{{props.workStatus === '0'?"接单中":"暂停接单"}}</view>
- <view class="userinfo">
- <button class="lef" @click="dialogToggle">{{props.workStatus === '0'?"暂停接单":"开始接单"}}</button>
- <image class="mid" aspectFill src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/cat-1.png" />
- <view class="rig">
- <text class="name">{{props.userInfo.nickName?props.userInfo.nickName:"调配药师"}}</text>
- <view size="mini" @click="handleLogout" class="logout">退出<uni-icons class="item" type="forward" color="#ff" size="16"></uni-icons></view>
- </view>
- </view>
- </view>
- </view>
-
- <view v-if="props.workStatus==='0'">
- <uni-popup ref="alertDialog" type="dialog">
- <uni-popup-dialog type="center" cancelText="取消" confirmText="同意" title="温馨提示" content="你确定要暂停接单吗?" @confirm="dialogConfirm"
- @close="dialogClose"></uni-popup-dialog>
- </uni-popup>
- </view>
- <view v-else>
- <uni-popup ref="alertDialog" type="dialog">
- <uni-popup-dialog type="center" cancelText="取消" confirmText="同意" title="温馨提示" content="你确定要开始接单吗?" @confirm="dialogConfirm"
- @close="dialogClose"></uni-popup-dialog>
- </uni-popup>
- </view>
- <view class="print">
- <uni-popup ref="alertPrint" type="dialog">
- <print-config @emit-close="emitclose"></print-config>
- </uni-popup>
- </view>
- </template>
- <script>
- export default {
- name: 'NavBar'
- }
- </script>
- <script setup>
- import { onMounted,ref, getCurrentInstance } from 'vue'
- import {updateWorkStatus, updateOnlineStatus, saveReview } from "@/static/js/api.js"
- import debounce from 'lodash.debounce'
- const props = defineProps({
- userInfo: {
- default: function() {
- return {}
- },
- type: Object
- },
- workStatus: {
- default:'0',
- type: String
- }
- })
- const {proxy} = getCurrentInstance()
- const emit = defineEmits(['updateUser'])
- console.log("prop.workStatus", props.workStatus)
- onMounted(() => {
- // userInfo.value = props.userInfo
- console.log("props.userInfo", props.userInfo)
- console.log("props.userInfo.nickName", props.userInfo.nickName)
- })
- const dialogToggle = ()=>{
- proxy.$refs.alertDialog.open()
- }
- const dialogConfirm = ()=>{
- handleChange()
- }
- const dialogClose = ()=>{
- console.log('guanbi')
- }
- const emitclose =()=>{
-
- proxy.$refs.alertPrint.close()
- }
- const handleChange = debounce(async()=>{
-
- const params = {
- token: uni.getStorageSync('token'),
- data: {
- pharmacistUserId: uni.getStorageSync('userId'),
- workStatus: props.workStatus ==='1'?'0':'1'
- }
- }
- // console.log('params.data.workStatus', params)
-
- const {data:res} = await updateWorkStatus(params)
- if (res.code === 200) {
- uni.setStorageSync('workStatus', params.data.workStatus);
- emit('updateUser', params.data.workStatus)
- if(params.data.workStatus==0){
- uni.$emit('login',{userId:uni.getStorageSync('userId')})
- } else {
- uni.$off('login', (data)=>{
- websocket.closeSocket()
- })
- }
-
-
- } else {
- emit('updateUser', props.workStatus)
- }
-
-
- },500)
- const handleScanbara = ()=>{
-
- uni.scanCode({
- scanType: ['barCode'],
- success: async(res) => {
-
- const data = JSON.stringify({
- userId:uni.getStorageSync('userId'),
- preNo: parseInt(res.result)
- })
-
- const {data:res1} = await saveReview({
- token: uni.getStorageSync('token'),
- data: data
- })
- if(res1.code===500){
- if(res1.msg=='未查询到有效数据'){
- uni.$showMsg(res1.msg, 2000)
- }
- else if(res1.msg=='处方已复核,无需重复操作!'){
- uni.$showMsg(res1.msg, 2000)
- } else {
- uni.navigateTo({
- url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
- })
- }
- }
- },
- fail: (res) => {
- console.log('扫码结果:' + res);
- }
- });
- }
- const handleLogout = async()=>{
-
-
- const params1 = {
- token: uni.getStorageSync('token'),
- data: {
- pharmacistUserId: uni.getStorageSync('userId'),
- workStatus: '1'
- }
- }
-
-
- const {data:res1} = await updateWorkStatus(params1)
- if (res1.code === 200) {
- uni.setStorageSync('workStatus', '1');
- emit('updateUser', params1.data.workStatus)
-
- } else {
- emit('updateUser', props.workStatus)
- }
-
-
- const params = {
- token: uni.getStorageSync('token'),
- data: {
- pharmacistUserId: uni.getStorageSync('userId'),
- onlineStatus: '1'
- }
- }
- const {data:res} = await updateOnlineStatus(params)
- uni.redirectTo({
- url:"/pages/login/login"
- })
-
- }
- const gotoPrint = ()=>{
- proxy.$refs.alertPrint.open()
- }
- </script>
- <style lang="scss">
- :deep(.uni-button-color){
- color: #18c7b0!important;
- }
- .nav{
- display:flex;
- justify-content:space-between;
- align-items:flex-end;
- width: 750rpx;
- align-items: center;
- height: 75rpx;
- background-color: #18C7B0;
- padding-top: 43rpx;
- .navbar{
- width: 750rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .scanbara{
- display: flex;
- justify-content:center;
- align-items: center;
-
- width: 91rpx;
- height: 32.8rpx;
- font-size: 15rpx;
- color:#18C7B0;
- margin-left: 20.1rpx;
- }
- .scanbara1{
- display: flex;
- justify-content:center;
- align-items: center;
-
- width: 91rpx;
- height: 32.8rpx;
- font-size: 15rpx;
- color:#18C7B0;
- margin-left: 30rpx;
- }
- .status{
- font-size: 18.75rpx;
- color:#fff;
- margin-right: 110.47rpx;
- }
- .userinfo{
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-right: 22.19rpx;
- .lef{
- height: 33.75rpx;
- width: 91rpx;
- // padding: 14rpx;
- margin-right: 17.5rpx;
- font-size: 15rpx;
- color:#18C7B0;
- // margin: 0 20px;
- }
- .mid{
- height: 43.75rpx;
- width: 43.75rpx;
- margin-right: 5.94rpx;
- border-radius: 50%;
- }
- .rig{
- // margin-right: 40px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .name{
- // margin-bottom: 10px;
- // width: 50rpx;
- font-size: 17.5rpx;
- color: #fff;
- text-align: center;
- }
- .logout{
- // width: 50rpx;
- background-color: #18C7B0;
- font-size: 15rpx;
- color: #fff;
- border: 1px solid #18C7B0;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- }
- }
- }
- </style>
|