nav-bar.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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:'0',
  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. const params = {
  76. token: uni.getStorageSync('token'),
  77. data: {
  78. pharmacistUserId: uni.getStorageSync('userId'),
  79. workStatus: props.workStatus ==='1'?'0':'1'
  80. }
  81. }
  82. // console.log('params.data.workStatus', params)
  83. const {data:res} = await updateWorkStatus(params)
  84. if (res.code === 200) {
  85. uni.setStorageSync('workStatus', params.data.workStatus);
  86. emit('updateUser', params.data.workStatus)
  87. } else {
  88. emit('updateUser', props.workStatus)
  89. }
  90. }
  91. const handleScanbara = ()=>{
  92. uni.scanCode({
  93. scanType: ['barCode'],
  94. success: function (res) {
  95. console.log('条码类型:' + res.scanType);
  96. console.log('条码内容:' + res.result);
  97. if(res.result) {
  98. uni.navigateTo({
  99. url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
  100. })
  101. }
  102. }
  103. });
  104. }
  105. const handleLogout = async()=>{
  106. console.log("handleLogout", 555)
  107. const params1 = {
  108. token: uni.getStorageSync('token'),
  109. data: {
  110. pharmacistUserId: uni.getStorageSync('userId'),
  111. workStatus: '1'
  112. }
  113. }
  114. console.log('params1.data.workStatus', params1)
  115. const {data:res1} = await updateWorkStatus(params1)
  116. if (res1.code === 200) {
  117. uni.setStorageSync('workStatus', '1');
  118. emit('updateUser', params1.data.workStatus)
  119. } else {
  120. emit('updateUser', props.workStatus)
  121. }
  122. const params = {
  123. token: uni.getStorageSync('token'),
  124. data: {
  125. pharmacistUserId: uni.getStorageSync('userId'),
  126. onlineStatus: '1'
  127. }
  128. }
  129. const {data:res} = await updateOnlineStatus(params)
  130. uni.redirectTo({
  131. url:"/pages/login/login"
  132. })
  133. }
  134. const gotoPrint = ()=>{
  135. proxy.$refs.alertPrint.open()
  136. }
  137. </script>
  138. <style lang="scss">
  139. :deep(.uni-button-color){
  140. color: #18c7b0!important;
  141. }
  142. .nav{
  143. display:flex;
  144. justify-content:space-between;
  145. align-items:flex-end;
  146. width: 750rpx;
  147. align-items: center;
  148. height: 75rpx;
  149. background-color: #18C7B0;
  150. padding-top: 43rpx;
  151. .navbar{
  152. width: 750rpx;
  153. display: flex;
  154. align-items: center;
  155. justify-content: space-between;
  156. .scanbara{
  157. display: flex;
  158. justify-content:center;
  159. align-items: center;
  160. width: 91rpx;
  161. height: 32.8rpx;
  162. font-size: 15rpx;
  163. color:#18C7B0;
  164. margin-left: 20.1rpx;
  165. }
  166. .scanbara1{
  167. display: flex;
  168. justify-content:center;
  169. align-items: center;
  170. width: 91rpx;
  171. height: 32.8rpx;
  172. font-size: 15rpx;
  173. color:#18C7B0;
  174. margin-left: 10rpx;
  175. }
  176. .status{
  177. font-size: 18.75rpx;
  178. color:#fff;
  179. margin-right: 110.47rpx;
  180. }
  181. .userinfo{
  182. display: flex;
  183. justify-content: space-between;
  184. align-items: center;
  185. margin-right: 22.19rpx;
  186. .lef{
  187. height: 33.75rpx;
  188. width: 91rpx;
  189. // padding: 14rpx;
  190. margin-right: 17.5rpx;
  191. font-size: 15rpx;
  192. color:#18C7B0;
  193. // margin: 0 20px;
  194. }
  195. .mid{
  196. height: 43.75rpx;
  197. width: 43.75rpx;
  198. margin-right: 5.94rpx;
  199. border-radius: 50%;
  200. }
  201. .rig{
  202. // margin-right: 40px;
  203. display: flex;
  204. flex-direction: column;
  205. align-items: center;
  206. .name{
  207. // margin-bottom: 10px;
  208. // width: 50rpx;
  209. font-size: 17.5rpx;
  210. color: #fff;
  211. text-align: center;
  212. }
  213. .logout{
  214. // width: 50rpx;
  215. background-color: #18C7B0;
  216. font-size: 15rpx;
  217. color: #fff;
  218. border: 1px solid #18C7B0;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. </style>