QRCode.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <view class="qr-container">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="扫码列表" background-color="#157A2C" color="#fff"
  4. @clickLeft="back" right-icon="scan" @clickRight="HandlScanCode" height="88rpx">
  5. </uni-nav-bar>
  6. <view class="main">
  7. <view class="wrapper">
  8. <u-list class="listContent">
  9. <checkbox-group v-for="(item, index) in listData" :key="index"
  10. @change.stop="e => selectVal(e, item, index)">
  11. <label>
  12. <view class="listBox">
  13. <view class="listBox-sel">
  14. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  15. :checked="item.checked" />
  16. </view>
  17. <view class="listBox-con">
  18. <view style="display: flex;">
  19. <view class="listBox-top" style="justify-content: left;">
  20. <view class="round">{{Number(index)+1}}</view>
  21. <view class="listBox-name">
  22. {{ item.categoryName }}
  23. </view>
  24. </view>
  25. <view class="listBox-top">
  26. <view class="listBox-code">
  27. {{ item.packageNo }}
  28. </view>
  29. </view>
  30. </view>
  31. <view class="listBox-bottom">
  32. <view>批次号:{{ item.batchNo }}</view>
  33. <view>规格:{{ item.specification }}</view>
  34. <view>
  35. 单件数量:{{ item.measureQuantity }}{{ item.measureUnit }}/{{ item.packingQuantity }}{{ item.packingUnit }}
  36. </view>
  37. <view>重量:{{ item.weight }}({{ item.weightUnit }})</view>
  38. <view>生产日期:{{ item.productionDate?item.productionDate.slice(0,10):'' }}</view>
  39. <view>供应商:{{ item.supplierName }}</view>
  40. <view v-if="dimension == 3">发货条码:{{ item.barcodes }}</view>
  41. <view v-if="dimension == 3">物料代号:{{ item.materielDesignation }}</view>
  42. <view v-if="dimension == 3">客户代号:{{ item.clientCode }}</view>
  43. <view v-if="dimension == 3">刻码:{{ item.engrave }}</view>
  44. <view v-if="dimension == 3">仓库:{{ item.warehouseName }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. </label>
  49. </checkbox-group>
  50. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  51. </u-list>
  52. </view>
  53. <view class="footer">
  54. <view class="bottom">
  55. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  56. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  57. </checkbox>
  58. </view>
  59. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  60. <view class="selBtn">选择( {{ checkListLen }} )</view>
  61. </u-button>
  62. </view>
  63. </view>
  64. <u-toast ref="uToast"></u-toast>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. getTreeByIds,
  70. getPackingList,
  71. getWarehouseList,
  72. getProductList,
  73. getBatchList,
  74. getHierarchyList,
  75. getHierarchyFifo
  76. } from '@/api/warehouseManagement'
  77. import {
  78. uniqueByProperty
  79. } from '@/utils/utils.js'
  80. export default {
  81. data() {
  82. return {
  83. dimension: 3,
  84. listData: [],
  85. seletedAll: false, //全选状态
  86. ids: [],
  87. assetType: []
  88. }
  89. },
  90. computed: {
  91. checkListLen() {
  92. console.log(
  93. 'this.listData.filter(el => el.checked)---',
  94. this.listData.filter(el => el.checked)
  95. )
  96. return this.listData.filter(el => el?.checked).length
  97. },
  98. },
  99. methods: {
  100. HandlScanCode() {
  101. let _this = this
  102. let obj = {}
  103. // let kk = {
  104. // "inoutType": "in",
  105. // "inId": "1956166290880073730",
  106. // "packageNo": "55408270001",
  107. // "assetType": "1,9",
  108. // 'batchNo': '827'
  109. // }
  110. // _this.getCodeProduct(kk)
  111. uni.scanCode({
  112. success: (res) => {
  113. res.result.split('&').forEach(
  114. (item) =>
  115. (obj[item.split('=')[0]] = decodeURIComponent(
  116. item.split('=')[1]
  117. ))
  118. );
  119. console.log(obj);
  120. if (obj.inoutType === 'in') {
  121. _this.getCodeProduct(obj)
  122. }
  123. },
  124. complete: (res) => {}
  125. })
  126. },
  127. async getCodeProduct({
  128. packageNo,
  129. batchNo,
  130. assetType
  131. }) {
  132. let params = {
  133. pageNum: 1,
  134. size: -1
  135. }
  136. if (!packageNo) {
  137. params.batchNo = batchNo
  138. }
  139. params.packageNo = packageNo
  140. console.log(params);
  141. const res = await getPackingList(params)
  142. // 已经出库了,查不到数据
  143. if (!res.list.length) {
  144. return this.$refs.uToast.show({
  145. message: "该单已失效",
  146. duration: 1000
  147. })
  148. }
  149. let data = res.list
  150. if (!this.ids.length) {
  151. this.assetType = assetType.split(',')
  152. this.ids = data.map(item => item.id)
  153. this.listData = res.list.map(item => ({
  154. ...item,
  155. checked: true
  156. }))
  157. return
  158. }
  159. // 已经有数据的时候,新扫描的数据的ids
  160. this.assetType = [...new Set(this.assetType.concat(assetType.split(',')))]
  161. let ids = data.map(item => item.id)
  162. let addIds = ids.filter(item => !this.ids.includes(item));
  163. this.ids = this.ids.concat(addIds)
  164. this.listData = this.listData.concat(data.filter(item => addIds.includes(item.id)).map(k => ({
  165. ...k,
  166. checked: true
  167. })))
  168. },
  169. selectVal(e, val, index) {
  170. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  171. // this.listData[index].checked = !this.listData[index].checked
  172. this.seletedAll = !this.listData.some(item => !item.checked)
  173. },
  174. //全选按钮
  175. _seletedAll() {
  176. if (!this.seletedAll) {
  177. this.seletedAll = true
  178. this.listData.map(item => {
  179. this.$set(item, 'checked', true)
  180. })
  181. } else {
  182. this.seletedAll = false
  183. //this.checkListLen = 0;
  184. this.listData.map(item => {
  185. this.$set(item, 'checked', false)
  186. })
  187. }
  188. },
  189. //跳转回添加页面
  190. async jumpAdd() {
  191. let selectionList = this.listData.filter(item => item.checked)
  192. if (this.dimension == 1) {
  193. let boolen = selectionList.every(item => item.outboundNum > 0)
  194. if (!boolen) {
  195. uni.showToast({
  196. icon: 'none',
  197. title: '请输入出库数量',
  198. duration: 2000
  199. })
  200. return
  201. }
  202. }
  203. let data = null
  204. if (this.dimension != 1) {
  205. data = await getHierarchyList({
  206. ids: selectionList.map(item => item.id).join(','),
  207. type: this.dimension
  208. })
  209. } else {
  210. data = await getHierarchyFifo({
  211. type: this.dimension,
  212. builders: selectionList.map(item => {
  213. return {
  214. categoryId: item.categoryId,
  215. num: item.outboundNum
  216. }
  217. })
  218. })
  219. }
  220. console.log('data-------------------', data)
  221. uni.$emit('setSelectList', data)
  222. uni.$emit('setCategory', this.assetType)
  223. uni.navigateBack()
  224. },
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. .qr-container {
  230. height: 100vh;
  231. .main {
  232. position: relative;
  233. height: calc(100% - 88rpx - 100rpx);
  234. display: flex;
  235. flex-direction: column;
  236. }
  237. .wrapper {
  238. flex: 1;
  239. overflow: hidden;
  240. padding-bottom: 60rpx;
  241. }
  242. .listContent {
  243. height: 100% !important;
  244. .listBox {
  245. display: flex;
  246. // height: 180rpx;
  247. padding: 20rpx 0;
  248. border-bottom: 2rpx solid #e5e5e5;
  249. .listBox-sel {
  250. height: 90rpx;
  251. width: 80rpx;
  252. // line-height: 90rpx;
  253. text-align: center;
  254. checkbox {
  255. transform: scale(1.2);
  256. }
  257. }
  258. .listBox-con {
  259. width: 100%;
  260. // display: flex;
  261. // flex-wrap: wrap;
  262. // justify-content: space-between;
  263. align-items: center;
  264. padding: 0 18rpx 0 0;
  265. .round {
  266. width: 40rpx;
  267. height: 40rpx;
  268. line-height: 40rpx;
  269. border-radius: 50%;
  270. background: $theme-color;
  271. color: #fff;
  272. text-align: center;
  273. font-size: 20rpx;
  274. }
  275. .listBox-top {
  276. width: 100%;
  277. display: flex;
  278. justify-content: space-between;
  279. padding-bottom: 10rpx;
  280. .listBox-name,
  281. .listBox-code {
  282. display: inline-block;
  283. font-size: $uni-font-size-sm;
  284. font-weight: bold;
  285. }
  286. }
  287. .listBox-bottom {
  288. width: 100%;
  289. display: flex;
  290. justify-content: space-between;
  291. font-size: $uni-font-size-sm;
  292. flex-wrap: wrap;
  293. >view {
  294. width: 50%;
  295. overflow: hidden;
  296. white-space: nowrap;
  297. text-overflow: ellipsis;
  298. }
  299. .input_view {
  300. display: flex;
  301. align-items: center;
  302. justify-content: center;
  303. .u-input {
  304. height: 36rpx;
  305. padding: 0 !important;
  306. margin-right: 10rpx;
  307. border: 1px solid #ddd;
  308. }
  309. }
  310. .w100 {
  311. width: 100%;
  312. }
  313. }
  314. }
  315. }
  316. .noDate {
  317. height: 100%;
  318. }
  319. }
  320. //底部按钮
  321. .footer {
  322. width: 100%;
  323. height: 100rpx;
  324. position: fixed;
  325. display: flex;
  326. justify-content: space-between;
  327. align-items: center;
  328. bottom: 0;
  329. border-top: 1rpx solid #eeecec;
  330. background-color: #ffffff;
  331. z-index: 999;
  332. .bottom {
  333. margin-left: 10rpx;
  334. }
  335. .u-reset-button {
  336. position: absolute;
  337. right: 10rpx;
  338. top: 20rpx;
  339. width: 150rpx;
  340. }
  341. }
  342. .search_list {
  343. min-height: 100rpx;
  344. /deep/ .baseForm {
  345. padding: 0 20rpx;
  346. }
  347. }
  348. .operate_box {
  349. padding: 10rpx 32rpx;
  350. /deep/ .u-button {
  351. width: 40%;
  352. }
  353. }
  354. }
  355. </style>