nav-bar.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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.userInfo.nickName?props.userInfo.nickName:"调配药师"}}</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, saveReview } from "@/static/js/api.js"
  43. import debounce from 'lodash.debounce'
  44. const props = defineProps({
  45. userInfo: {
  46. default: function() {
  47. return {}
  48. },
  49. type: Object
  50. },
  51. workStatus: {
  52. default:'0',
  53. type: String
  54. }
  55. })
  56. const {proxy} = getCurrentInstance()
  57. const emit = defineEmits(['updateUser'])
  58. console.log("prop.workStatus", props.workStatus)
  59. onMounted(() => {
  60. // userInfo.value = props.userInfo
  61. console.log("props.userInfo", props.userInfo)
  62. console.log("props.userInfo.nickName", props.userInfo.nickName)
  63. })
  64. const dialogToggle = ()=>{
  65. proxy.$refs.alertDialog.open()
  66. }
  67. const dialogConfirm = ()=>{
  68. handleChange()
  69. }
  70. const dialogClose = ()=>{
  71. console.log('guanbi')
  72. }
  73. const emitclose =()=>{
  74. proxy.$refs.alertPrint.close()
  75. }
  76. const handleChange = debounce(async()=>{
  77. const params = {
  78. token: uni.getStorageSync('token'),
  79. data: {
  80. pharmacistUserId: uni.getStorageSync('userId'),
  81. workStatus: props.workStatus ==='1'?'0':'1'
  82. }
  83. }
  84. // console.log('params.data.workStatus', params)
  85. const {data:res} = await updateWorkStatus(params)
  86. if (res.code === 200) {
  87. uni.setStorageSync('workStatus', params.data.workStatus);
  88. emit('updateUser', params.data.workStatus)
  89. if(params.data.workStatus==0){
  90. uni.$emit('login',{userId:uni.getStorageSync('userId')})
  91. } else {
  92. uni.$off('login', (data)=>{
  93. websocket.closeSocket()
  94. })
  95. }
  96. } else {
  97. emit('updateUser', props.workStatus)
  98. }
  99. },500)
  100. const handleScanbara = ()=>{
  101. uni.scanCode({
  102. scanType: ['barCode'],
  103. success: async(res) => {
  104. const data = JSON.stringify({
  105. userId:uni.getStorageSync('userId'),
  106. preNo: parseInt(res.result)
  107. })
  108. const {data:res1} = await saveReview({
  109. token: uni.getStorageSync('token'),
  110. data: data
  111. })
  112. if(res1.code===500){
  113. if(res1.msg=='未查询到有效数据'){
  114. uni.$showMsg(res1.msg, 2000)
  115. }
  116. else if(res1.msg=='处方已复核,无需重复操作!'){
  117. uni.$showMsg(res1.msg, 2000)
  118. } else {
  119. uni.navigateTo({
  120. url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
  121. })
  122. }
  123. }
  124. },
  125. fail: (res) => {
  126. console.log('扫码结果:' + res);
  127. }
  128. });
  129. }
  130. const handleLogout = async()=>{
  131. const params1 = {
  132. token: uni.getStorageSync('token'),
  133. data: {
  134. pharmacistUserId: uni.getStorageSync('userId'),
  135. workStatus: '1'
  136. }
  137. }
  138. const {data:res1} = await updateWorkStatus(params1)
  139. if (res1.code === 200) {
  140. uni.setStorageSync('workStatus', '1');
  141. emit('updateUser', params1.data.workStatus)
  142. } else {
  143. emit('updateUser', props.workStatus)
  144. }
  145. const params = {
  146. token: uni.getStorageSync('token'),
  147. data: {
  148. pharmacistUserId: uni.getStorageSync('userId'),
  149. onlineStatus: '1'
  150. }
  151. }
  152. const {data:res} = await updateOnlineStatus(params)
  153. uni.redirectTo({
  154. url:"/pages/login/login"
  155. })
  156. }
  157. const gotoPrint = ()=>{
  158. proxy.$refs.alertPrint.open()
  159. }
  160. </script>
  161. <style lang="scss">
  162. :deep(.uni-button-color){
  163. color: #18c7b0!important;
  164. }
  165. .nav{
  166. display:flex;
  167. justify-content:space-between;
  168. align-items:flex-end;
  169. width: 750rpx;
  170. align-items: center;
  171. height: 75rpx;
  172. background-color: #18C7B0;
  173. padding-top: 43rpx;
  174. .navbar{
  175. width: 750rpx;
  176. display: flex;
  177. align-items: center;
  178. justify-content: space-between;
  179. .scanbara{
  180. display: flex;
  181. justify-content:center;
  182. align-items: center;
  183. width: 91rpx;
  184. height: 32.8rpx;
  185. font-size: 15rpx;
  186. color:#18C7B0;
  187. margin-left: 20.1rpx;
  188. }
  189. .scanbara1{
  190. display: flex;
  191. justify-content:center;
  192. align-items: center;
  193. width: 91rpx;
  194. height: 32.8rpx;
  195. font-size: 15rpx;
  196. color:#18C7B0;
  197. margin-left: 30rpx;
  198. }
  199. .status{
  200. font-size: 18.75rpx;
  201. color:#fff;
  202. margin-right: 110.47rpx;
  203. }
  204. .userinfo{
  205. display: flex;
  206. justify-content: space-between;
  207. align-items: center;
  208. margin-right: 22.19rpx;
  209. .lef{
  210. height: 33.75rpx;
  211. width: 91rpx;
  212. // padding: 14rpx;
  213. margin-right: 17.5rpx;
  214. font-size: 15rpx;
  215. color:#18C7B0;
  216. // margin: 0 20px;
  217. }
  218. .mid{
  219. height: 43.75rpx;
  220. width: 43.75rpx;
  221. margin-right: 5.94rpx;
  222. border-radius: 50%;
  223. }
  224. .rig{
  225. // margin-right: 40px;
  226. display: flex;
  227. flex-direction: column;
  228. align-items: center;
  229. .name{
  230. // margin-bottom: 10px;
  231. // width: 50rpx;
  232. font-size: 17.5rpx;
  233. color: #fff;
  234. text-align: center;
  235. }
  236. .logout{
  237. // width: 50rpx;
  238. background-color: #18C7B0;
  239. font-size: 15rpx;
  240. color: #fff;
  241. border: 1px solid #18C7B0;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. }
  246. }
  247. }
  248. }
  249. }
  250. </style>