nav-bar.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="nav">
  3. <view class="navbar">
  4. <button class="scanbara" @click="handleScanbara">复核扫码</button>
  5. <button class="scanbara1" @click="gotoPrint">打印设置</button>
  6. <view class="status">{{props.workStatus === '0'?"接单中":"暂停接单"}}</view>
  7. <view class="userinfo">
  8. <button class="lef" @click="dialogToggle">{{props.workStatus === '0'?"暂停接单":"开始接单"}}</button>
  9. <image class="mid" aspectFill src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/cat-1.png" />
  10. <view class="rig">
  11. <text class="name">{{props.name?props.userInfo.name:"张三三"}}</text>
  12. <view size="mini" @click="handleLogout" class="logout">退出<uni-icons class="item" type="forward" color="#ff" size="16"></uni-icons></view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view v-if="props.workStatus==='0'">
  18. <uni-popup ref="alertDialog" type="dialog">
  19. <uni-popup-dialog type="center" cancelText="取消" confirmText="同意" title="温馨提示" content="你确定要暂停接单吗?" @confirm="dialogConfirm"
  20. @close="dialogClose"></uni-popup-dialog>
  21. </uni-popup>
  22. </view>
  23. <view v-else>
  24. <uni-popup ref="alertDialog" type="dialog">
  25. <uni-popup-dialog type="center" cancelText="取消" confirmText="同意" title="温馨提示" content="你确定要开始接单吗?" @confirm="dialogConfirm"
  26. @close="dialogClose"></uni-popup-dialog>
  27. </uni-popup>
  28. </view>
  29. <view class="print">
  30. <uni-popup ref="alertPrint" type="dialog">
  31. <print-config @emit-close="emitclose"></print-config>
  32. </uni-popup>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'NavBar'
  38. }
  39. </script>
  40. <script setup>
  41. import { onMounted,ref, getCurrentInstance } from 'vue'
  42. import {updateWorkStatus, updateOnlineStatus } from "@/static/js/api.js"
  43. const props = defineProps({
  44. userInfo: {
  45. default: function() {
  46. return {}
  47. },
  48. type: Object
  49. },
  50. workStatus: {
  51. default:true,
  52. type: String
  53. }
  54. })
  55. const {proxy} = getCurrentInstance()
  56. const emit = defineEmits(['updateUser'])
  57. console.log("prop.workStatus", props.workStatus)
  58. onMounted(() => {
  59. // userInfo.value = props.userInfo
  60. // console.log("props.userInfo.name", props.userInfo.name)
  61. })
  62. const dialogToggle = ()=>{
  63. proxy.$refs.alertDialog.open()
  64. }
  65. const dialogConfirm = ()=>{
  66. handleChange()
  67. }
  68. const dialogClose = ()=>{
  69. console.log('guanbi')
  70. }
  71. const emitclose =()=>{
  72. proxy.$refs.alertPrint.close()
  73. }
  74. const handleChange =async()=>{
  75. console.log("props.userInfo.workStatus》》》", props.workStatus)
  76. const token = uni.getStorageSync('token')
  77. const userId = uni.getStorageSync('userId')
  78. if(props.workStatus=='1'){
  79. const params = {
  80. token: uni.getStorageSync('token'),
  81. data: {
  82. pharmacistUserId: userId,
  83. workStatus: props.workStatus ==='1'?'0':'1'
  84. }
  85. }
  86. console.log('params.data.workStatus', params)
  87. const {data:res} = await updateWorkStatus(params)
  88. if (res.code === 200) {
  89. uni.setStorageSync('workStatus', params.data.workStatus);
  90. emit('updateUser', params.data.workStatus)
  91. } else {
  92. emit('updateUser', props.workStatus)
  93. }
  94. }
  95. }
  96. const handleScanbara = ()=>{
  97. uni.scanCode({
  98. scanType: ['barCode'],
  99. success: function (res) {
  100. console.log('条码类型:' + res.scanType);
  101. console.log('条码内容:' + res.result);
  102. if(res.result) {
  103. uni.navigateTo({
  104. url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
  105. })
  106. }
  107. }
  108. });
  109. }
  110. const handleLogout = async()=>{
  111. console.log("handleLogout", 555)
  112. const tokens = uni.getStorageSync('token')
  113. const userId = uni.getStorageSync('userId')
  114. const params = {
  115. token: tokens,
  116. data: {
  117. pharmacistUserId: userId,
  118. onlineStatus: 1
  119. }
  120. }
  121. const {data:res} = await updateOnlineStatus(params)
  122. uni.redirectTo({
  123. url:"/pages/login/login"
  124. })
  125. }
  126. const gotoPrint = ()=>{
  127. proxy.$refs.alertPrint.open()
  128. }
  129. </script>
  130. <style lang="scss">
  131. :deep(.uni-button-color){
  132. color: #18c7b0!important;
  133. }
  134. .nav{
  135. display:flex;
  136. justify-content:space-between;
  137. align-items:flex-end;
  138. width: 750rpx;
  139. align-items: center;
  140. height: 75rpx;
  141. background-color: #18C7B0;
  142. padding-top: 43rpx;
  143. .navbar{
  144. width: 750rpx;
  145. display: flex;
  146. align-items: center;
  147. justify-content: space-between;
  148. .scanbara{
  149. display: flex;
  150. justify-content:center;
  151. align-items: center;
  152. width: 91rpx;
  153. height: 32.8rpx;
  154. font-size: 15rpx;
  155. color:#18C7B0;
  156. margin-left: 20.1rpx;
  157. }
  158. .scanbara1{
  159. display: flex;
  160. justify-content:center;
  161. align-items: center;
  162. width: 91rpx;
  163. height: 32.8rpx;
  164. font-size: 15rpx;
  165. color:#18C7B0;
  166. margin-left: 10rpx;
  167. }
  168. .status{
  169. font-size: 18.75rpx;
  170. color:#fff;
  171. margin-right: 110.47rpx;
  172. }
  173. .userinfo{
  174. display: flex;
  175. justify-content: space-between;
  176. align-items: center;
  177. margin-right: 22.19rpx;
  178. .lef{
  179. height: 33.75rpx;
  180. width: 91rpx;
  181. // padding: 14rpx;
  182. margin-right: 17.5rpx;
  183. font-size: 15rpx;
  184. color:#18C7B0;
  185. // margin: 0 20px;
  186. }
  187. .mid{
  188. height: 43.75rpx;
  189. width: 43.75rpx;
  190. margin-right: 5.94rpx;
  191. border-radius: 50%;
  192. }
  193. .rig{
  194. // margin-right: 40px;
  195. display: flex;
  196. flex-direction: column;
  197. align-items: center;
  198. .name{
  199. // margin-bottom: 10px;
  200. // width: 50rpx;
  201. font-size: 17.5rpx;
  202. color: #fff;
  203. text-align: center;
  204. }
  205. .logout{
  206. // width: 50rpx;
  207. background-color: #18C7B0;
  208. font-size: 15rpx;
  209. color: #fff;
  210. border: 1px solid #18C7B0;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. }
  215. }
  216. }
  217. }
  218. }
  219. </style>