123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <template>
- <view class="nav">
- <view class="navbar">
- <button class="scanbara" @click="handleScanbara">复核扫码</button>
- <button class="scanbara" @click="gotoPrint">打印设置</button>
- <view class="status">{{props.userInfo.workStatus === '0'?"接单中":"暂停接单"}}</view>
- <view class="userinfo">
- <button class="lef" @click="dialogToggle">{{props.userInfo.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.name?props.userInfo.name:"张三三"}}</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.userInfo.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 } from "@/static/js/api.js"
- const props = defineProps({
- userInfo: {
- default: function() {
- return {
- workStatus: '0'
- }
- },
- type: Object
- }
- })
- const {proxy} = getCurrentInstance()
- const emit = defineEmits(['updateUser'])
- console.log("props.userInfo.workStatus", props.userInfo.workStatus)
- onMounted(() => {
- // userInfo.value = props.userInfo
- // console.log("props.userInfo.name", props.userInfo.name)
- })
- const dialogToggle = ()=>{
- proxy.$refs.alertDialog.open()
- }
- const dialogConfirm = ()=>{
- handleChange()
- }
- const dialogClose = ()=>{
- console.log('guanbi')
- }
- const emitclose =()=>{
- proxy.$refs.alertPrint.close()
- }
- const handleChange =async()=>{
-
- console.log("props.userInfo.workStatus》》》", props.userInfo.workStatus)
- const token = uni.getStorageSync('token')
- const userId = uni.getStorageSync('userId')
- if(props.userInfo.workStatus){
- const params = {
- token: uni.getStorageSync('token'),
- data: {
- pharmacistUserId: userId,
- workStatus: props.userInfo.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)
-
- }
- emit('updateUser', props.userInfo.workStatus)
- }
- }
- const handleScanbara = ()=>{
- uni.scanCode({
- scanType: ['barCode'],
- success: function (res) {
- console.log('条码类型:' + res.scanType);
- console.log('条码内容:' + res.result);
- if(res.result) {
- uni.navigateTo({
- url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
- })
- }
- }
- });
- }
- const handleLogout = async()=>{
- console.log("handleLogout", 555)
- const tokens = uni.getStorageSync('token')
- const userId = uni.getStorageSync('userId')
- const params = {
- token: tokens,
- data: {
- pharmacistUserId: 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;
- }
- .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>
|