nav-bar.vue 6.1 KB

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