nav-bar.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. } else {
  115. uni.navigateTo({
  116. url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
  117. })
  118. }
  119. }
  120. }
  121. });
  122. }
  123. const handleLogout = async()=>{
  124. console.log("handleLogout", 555)
  125. const params1 = {
  126. token: uni.getStorageSync('token'),
  127. data: {
  128. pharmacistUserId: uni.getStorageSync('userId'),
  129. workStatus: '1'
  130. }
  131. }
  132. console.log('params1.data.workStatus', params1)
  133. const {data:res1} = await updateWorkStatus(params1)
  134. if (res1.code === 200) {
  135. uni.setStorageSync('workStatus', '1');
  136. emit('updateUser', params1.data.workStatus)
  137. } else {
  138. emit('updateUser', props.workStatus)
  139. }
  140. const params = {
  141. token: uni.getStorageSync('token'),
  142. data: {
  143. pharmacistUserId: uni.getStorageSync('userId'),
  144. onlineStatus: '1'
  145. }
  146. }
  147. const {data:res} = await updateOnlineStatus(params)
  148. uni.redirectTo({
  149. url:"/pages/login/login"
  150. })
  151. }
  152. const gotoPrint = ()=>{
  153. proxy.$refs.alertPrint.open()
  154. }
  155. </script>
  156. <style lang="scss">
  157. :deep(.uni-button-color){
  158. color: #18c7b0!important;
  159. }
  160. .nav{
  161. display:flex;
  162. justify-content:space-between;
  163. align-items:flex-end;
  164. width: 750rpx;
  165. align-items: center;
  166. height: 75rpx;
  167. background-color: #18C7B0;
  168. padding-top: 43rpx;
  169. .navbar{
  170. width: 750rpx;
  171. display: flex;
  172. align-items: center;
  173. justify-content: space-between;
  174. .scanbara{
  175. display: flex;
  176. justify-content:center;
  177. align-items: center;
  178. width: 91rpx;
  179. height: 32.8rpx;
  180. font-size: 15rpx;
  181. color:#18C7B0;
  182. margin-left: 20.1rpx;
  183. }
  184. .scanbara1{
  185. display: flex;
  186. justify-content:center;
  187. align-items: center;
  188. width: 91rpx;
  189. height: 32.8rpx;
  190. font-size: 15rpx;
  191. color:#18C7B0;
  192. margin-left: 10rpx;
  193. }
  194. .status{
  195. font-size: 18.75rpx;
  196. color:#fff;
  197. margin-right: 110.47rpx;
  198. }
  199. .userinfo{
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. margin-right: 22.19rpx;
  204. .lef{
  205. height: 33.75rpx;
  206. width: 91rpx;
  207. // padding: 14rpx;
  208. margin-right: 17.5rpx;
  209. font-size: 15rpx;
  210. color:#18C7B0;
  211. // margin: 0 20px;
  212. }
  213. .mid{
  214. height: 43.75rpx;
  215. width: 43.75rpx;
  216. margin-right: 5.94rpx;
  217. border-radius: 50%;
  218. }
  219. .rig{
  220. // margin-right: 40px;
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. .name{
  225. // margin-bottom: 10px;
  226. // width: 50rpx;
  227. font-size: 17.5rpx;
  228. color: #fff;
  229. text-align: center;
  230. }
  231. .logout{
  232. // width: 50rpx;
  233. background-color: #18C7B0;
  234. font-size: 15rpx;
  235. color: #fff;
  236. border: 1px solid #18C7B0;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. }
  241. }
  242. }
  243. }
  244. }
  245. </style>