boxMerge.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <gui-page :custom-header="true" :is-header-sized="false" :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="goBack"
  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. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  19. </view>
  20. </template>
  21. <template #gBody>
  22. <view class="list-content">
  23. <view class="row-1">
  24. <view class="row-1-card">
  25. <text
  26. class="gui-form-input input-200 gui-color-gray"
  27. >{{ materialCode? materialCode:"请扫描物料条码" }}</text>
  28. <view style="display: flex; flex-direction: row;">
  29. <text class="font-icons" @click="handleMapass('row1')">&#xe6b7;</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="card">
  34. <view v-if="materialList.length > 0">
  35. <view v-for="item in materialList" :key="item.id" class="card-list-flexbox">
  36. <uni-swipe-action>
  37. <!-- 基础用法 -->
  38. <uni-swipe-action-item
  39. :right-options="options"
  40. :left-options="options"
  41. @click="handleDeleteRow(item)"
  42. >
  43. <template #left>
  44. <view />
  45. </template>
  46. <view class="flex-row">
  47. <view class="card-list-item">
  48. <text class="text-1 gui-color-gray">成品SN码</text>
  49. <text class="text-2 gui-color-gray">{{ item.materialSerinalNo }}</text>
  50. </view>
  51. <view class="card-list-item">
  52. <text class="text-1 gui-color-gray">生产时间</text>
  53. <text
  54. class="text-2 gui-color-gray"
  55. >{{ $parseTime(item.createTime) }}</text>
  56. </view>
  57. </view>
  58. </uni-swipe-action-item>
  59. </uni-swipe-action>
  60. </view>
  61. </view>
  62. <view v-else>
  63. <view class="bg-image">
  64. <image src="@/static/empty.png" mode="heightFix" />
  65. <text>这里什么都没有...</text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <gui-right-menus>
  71. <!-- 扩展按钮 -->
  72. <template #menus-more>
  73. <view
  74. hover-class="gui-tap"
  75. class="menu-items gui-bg-green gui-flex gui-columns gui-justify-content-center"
  76. @click="handleMerge"
  77. >
  78. <text class="menu-text gui-block gui-text-center gui-color-white">装箱</text>
  79. </view>
  80. </template>
  81. <!-- 核心按钮 -->
  82. <template #menus-primary>
  83. <view class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center">
  84. <text class="menu-icon gui-color-white gui-block gui-text-center gui-icons">&#xe614;</text>
  85. <text class="menu-text gui-color-white gui-block gui-text-center">功能</text>
  86. </view>
  87. </template>
  88. </gui-right-menus>
  89. </template>
  90. </gui-page>
  91. </template>
  92. <script>
  93. import {
  94. computed,
  95. defineComponent,
  96. ref
  97. } from 'vue'
  98. export default defineComponent({
  99. setup() {
  100. const options = ref([{
  101. text: '删除',
  102. style: {
  103. backgroundColor: '#dd524d'
  104. }
  105. }])
  106. const materialCode = ref('')
  107. const materialList = ref([])
  108. const inputting = function(e) {
  109. console.log(e)
  110. }
  111. const goBack = function() {
  112. uni.$goBack('/pages/workbranch/warehouse/box/boxList')
  113. }
  114. const handleMapass = function(state) {
  115. // uni.$reqGet("scanWmsBoxSn", {
  116. // materialSerinalNo: "1633655975151833090"
  117. // })
  118. // .then(({
  119. // data
  120. // }) => {
  121. // if (data) {
  122. // materialCode.value = data?.materialSerinalNo;
  123. // materialList.value.push(data);
  124. // }
  125. // })
  126. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  127. mpaasScanModule.mpaasScan({
  128. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  129. 'scanType': ['qrCode', 'barCode'],
  130. // 是否隐藏相册,默认false不隐藏
  131. 'hideAlbum': false
  132. },
  133. (ret) => {
  134. if (ret.resp_code === 1000) {
  135. uni.$reqGet('scanWmsBoxSn', {
  136. qrCode: ret.resp_result
  137. })
  138. .then(({
  139. data
  140. }) => {
  141. if (data) {
  142. materialCode.value = data?.materialSerinalNo
  143. materialList.value.push(data)
  144. }
  145. })
  146. }
  147. })
  148. }
  149. // 装箱
  150. const handleMerge = function() {
  151. if (materialList.value.length > 0) {
  152. uni.$reqPost('boxRepacking', materialList.value)
  153. .then(({
  154. data
  155. }) => {
  156. uni.$grace.msg('装箱成功')
  157. // // 时间格式转换
  158. // data?.forEach(item => item.createTime = formatDateTime(item
  159. // .createTime));
  160. // let message = {
  161. // "ClientId": "webclient",
  162. // 'templateName': "http://192.168.1.156:9900/Upload/Tables/s_reportmodel/202302271114052667/WMS.btw",
  163. // 'DataList': data
  164. // }
  165. // uni.$useStore().mqttConfig.publish("adminS001", JSON.stringify(message), {
  166. // qos: 1
  167. // }, (err) => {});
  168. })
  169. }
  170. }
  171. const handleDeleteRow = function(data) {
  172. const fdIndex = materialList.value.findIndex(item => item.id === data.id)
  173. materialList.value.splice(fdIndex, 1)
  174. }
  175. return {
  176. goBack,
  177. options,
  178. materialCode,
  179. materialList,
  180. inputting,
  181. handleMapass,
  182. handleMerge,
  183. handleDeleteRow
  184. }
  185. }
  186. })
  187. </script>
  188. <style lang="scss" scoped>
  189. .gui-header-leader-btns {
  190. color: black;
  191. font-size: 24px !important;
  192. margin-left: 24rpx;
  193. }
  194. .gui-sbody {
  195. background-color: rgba(234, 239, 242, 1);
  196. }
  197. .list-content {
  198. margin-top: 80px;
  199. }
  200. .row-1 {
  201. height: 55px;
  202. display: flex;
  203. justify-content: center;
  204. background-color: white;
  205. .row-1-card {
  206. flex: 1;
  207. display: flex;
  208. flex-direction: row;
  209. justify-content: space-between;
  210. align-items: center;
  211. padding-left: 10px;
  212. padding-right: 10px;
  213. }
  214. }
  215. .input-200 {
  216. width: 200px;
  217. padding-left: 10px;
  218. }
  219. .input-300 {
  220. width: 300px;
  221. padding-left: 10px;
  222. }
  223. .font-icons {
  224. width: 40px;
  225. font-size: 20px;
  226. }
  227. .card {
  228. margin-top: 8px;
  229. .card-list-flexbox {
  230. display: flex;
  231. flex-direction: row;
  232. align-items: center;
  233. flex-wrap: wrap;
  234. .flex-row {
  235. display: flex;
  236. flex-wrap: wrap;
  237. margin-top: 2px;
  238. background-color: white;
  239. .card-list-item {
  240. width: 750rpx;
  241. height: 40px;
  242. display: flex;
  243. flex-direction: row;
  244. align-items: center;
  245. justify-content: space-between;
  246. uni-text {
  247. font-size: 14px;
  248. height: 50rpx;
  249. text-align: left;
  250. padding: 0 12px;
  251. display: flex;
  252. flex-direction: row;
  253. align-items: center;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. </style>