indexPage.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <gui-page :custom-header="true" :header-class="['gui-theme-background-color']">
  3. <template #gHeader>
  4. <view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
  5. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  6. <text
  7. style="font-size:44rpx;"
  8. class="gui-header-leader-btns gui-color-white font-icons"
  9. @tap="goHome"
  10. >&#xe6c5;</text>
  11. <!-- 导航文本此处也可以是其他自定义内容 -->
  12. <text
  13. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text"
  14. >出入库操作</text>
  15. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  16. <!-- 实际宽度请根据自己情况设置 -->
  17. <view style="width:40px;" />
  18. </view>
  19. </template>
  20. <template #gBody>
  21. <view class="card-list-flexbox">
  22. <view class="card">
  23. <div class="card-panel" style="background-color: #00a0e9;" @click="handleTriggerMpaas('回冷库')">
  24. <text class="font-icons">&#xe660;</text>
  25. <text>回冷库</text>
  26. </div>
  27. </view>
  28. <view class="card">
  29. <div class="card-panel" style="background-color: #55aa7f;" @click="handleTriggerMpaas('出冷库')">
  30. <text class="font-icons">&#xe660;</text>
  31. <text>出冷库</text>
  32. </div>
  33. </view>
  34. </view>
  35. <uni-popup ref="errorTip" type="dialog">
  36. <uni-popup-dialog
  37. type="error"
  38. cancel-text="关闭"
  39. confirm-text="确认"
  40. title="提示"
  41. :content="errorTipMessage"
  42. @confirm="handleCloseErrorTipsModal"
  43. @close="handleCloseErrorTipsModal"
  44. />
  45. </uni-popup>
  46. </template>
  47. </gui-page>
  48. </template>
  49. <script>
  50. import {
  51. ref,
  52. defineComponent
  53. } from 'vue'
  54. export default defineComponent({
  55. setup() {
  56. // #ifdef APP-PLUS
  57. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  58. // #endif
  59. const errorTip = ref('')
  60. const errorTipMessage = ref('')
  61. const goHome = function() {
  62. uni.$goHome()
  63. }
  64. const handleTriggerMpaas = function(state) {
  65. switch (state) {
  66. case '回冷库':
  67. // #ifdef APP-PLUS
  68. mpaasScanModule.mpaasScan({
  69. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  70. 'scanType': ['qrCode', 'barCode'],
  71. // 是否隐藏相册,默认false不隐藏
  72. 'hideAlbum': false
  73. },
  74. (ret) => {
  75. if (ret.resp_code === 1000) {
  76. uni.$reqPost('scanMaterialReturnColdStorage', {
  77. batchNumber: ret.resp_result
  78. })
  79. .then(({
  80. code,
  81. data,
  82. msg
  83. }) => {
  84. if (code === 0) {
  85. uni.showToast({
  86. title: '回冷库成功',
  87. icon: 'none',
  88. duration: 2000
  89. })
  90. } else {
  91. // #ifdef APP-PLUS
  92. plus.device.beep(2)
  93. // #endif
  94. errorTipMessage.value = msg
  95. errorTip.value.open()
  96. }
  97. })
  98. }
  99. })
  100. // #endif
  101. break
  102. case '出冷库':
  103. // #ifdef APP-PLUS
  104. mpaasScanModule.mpaasScan({
  105. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  106. 'scanType': ['qrCode', 'barCode'],
  107. // 是否隐藏相册,默认false不隐藏
  108. 'hideAlbum': false
  109. },
  110. (ret) => {
  111. if (ret.resp_code === 1000) {
  112. uni.$reqPost('scanMaterialOutColdStorage', {
  113. batchNumber: ret.resp_result
  114. })
  115. .then(({
  116. code,
  117. data,
  118. msg
  119. }) => {
  120. if (code === 0) {
  121. uni.showToast({
  122. title: '出冷库成功',
  123. icon: 'none',
  124. duration: 2000
  125. })
  126. } else {
  127. // #ifdef APP-PLUS
  128. plus.device.beep(2)
  129. // #endif
  130. errorTipMessage.value = msg
  131. errorTip.value.open()
  132. }
  133. })
  134. }
  135. })
  136. // #endif
  137. break
  138. }
  139. }
  140. // 关闭错误信息弹窗
  141. const handleCloseErrorTipsModal = async function() {
  142. errorTip.value.close()
  143. }
  144. return {
  145. goHome,
  146. errorTip,
  147. errorTipMessage,
  148. handleCloseErrorTipsModal,
  149. handleTriggerMpaas
  150. }
  151. }
  152. })
  153. </script>
  154. <style lang="scss" scoped>
  155. .gui-header-leader-btns {
  156. color: black;
  157. font-size: 24px !important;
  158. margin-left: 24rpx;
  159. }
  160. .card-list-flexbox {
  161. margin-top: 100px;
  162. display: grid;
  163. grid-template-columns: 1fr 1fr 1fr;
  164. .card {
  165. display: flex;
  166. justify-content: center;
  167. align-items: center;
  168. .card-panel {
  169. width: 85px;
  170. height: 85px;
  171. display: flex;
  172. flex-direction: column;
  173. justify-content: center;
  174. align-items: center;
  175. border-radius: 8px;
  176. box-shadow: 1px 1px 2px 3px #e9e9e9;
  177. text:nth-of-type(2) {
  178. margin-top: 4px;
  179. font-size: 12px;
  180. font-weight: bold;
  181. color: white;
  182. }
  183. }
  184. }
  185. }
  186. .font-icons {
  187. font-size: 36px;
  188. color: white;
  189. }
  190. </style>