nav-bar.vue 6.4 KB

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