index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <view class="uni-column" style="height: 100%; background-color: #f5f5f5;position: absolute;
  3. left: 0;
  4. right: 0;">
  5. <view class="box-bg uni-row">
  6. <view class="input-view uni-row">
  7. <uni-icons class="input-uni-icon" type="search" size="18" color="#999" />
  8. <input class="nav-bar-input" type="text" v-model="keywords" placeholder="请输入批次号" />
  9. </view>
  10. <view class="search" @click="handleSearch">
  11. 搜索
  12. </view>
  13. </view>
  14. <scroll-view class="scroll-container" scroll-y @scrolltolower="handleScrollToLower"
  15. style="padding-bottom: 150rpx">
  16. <view v-if="listData.length == 0" style="text-align: center;
  17. font-size: 12px;
  18. color: #666;
  19. padding-top: 16px;">
  20. <text>暂无批次</text>
  21. </view>
  22. <!-- 批次列表 -->
  23. <view v-else v-for="(item, index) in listData" :key="index" class="list-item">
  24. <view class="title-container uni-row" style="justify-content: flex-start;">
  25. <view class="title uni-row">
  26. <text class="label">批次号:</text>
  27. <text class="label code">{{ item['lotCode'] }}</text>
  28. </view>
  29. <view class=" uni-row" style="margin-left: 16rpx;">
  30. <view v-if="item['isTaksStock'] == 0" class="tag finished"><text class="label">未盘点</text></view>
  31. <view v-else type="default finished" class="tag turnover"><text class="label">已盘点</text></view>
  32. </view>
  33. </view>
  34. <view class="item-info uni-row">
  35. <text class="label">产品描述</text>
  36. <text class="label right">{{ item['productDescription'] }}</text>
  37. </view>
  38. <view class="item-info uni-row">
  39. <text class="label">工序</text>
  40. <text class="label right">{{ item['processAlias'] ? item['processAlias'] : '-' }}</text>
  41. </view>
  42. <view class="item-info uni-row">
  43. <text class="label">投产数</text>
  44. <text class="label right">{{ item['prodNum']}}</text>
  45. </view>
  46. <view class="item-info uni-row">
  47. <text class="label">盘点数量</text>
  48. <text class="label right">{{ item['taksStockNum']}}</text>
  49. </view>
  50. </view>
  51. </scroll-view>
  52. <view class="bottom uni-row">
  53. <button class="add" type="primary" v-if="listData.length != 0" @click="handleScanCode">扫码盘点批次</button>
  54. </view>
  55. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  56. </view>
  57. </template>
  58. <script setup>
  59. import {
  60. normalizeProps,
  61. reactive,
  62. onMounted,
  63. ref
  64. } from 'vue'
  65. import {
  66. onLoad,
  67. onReady,
  68. onUnload,
  69. onShow,
  70. onReachBottom
  71. } from '@dcloudio/uni-app'
  72. import {
  73. getTakesStockList,
  74. getTakesStockByCarrierCode
  75. } from '@/api/business/taksStackLot.js'
  76. import {
  77. store
  78. } from '@/store/index.js'
  79. import {
  80. toHHmmss
  81. } from '@/utils/common.js'
  82. import {
  83. onPullDownRefresh
  84. } from "@dcloudio/uni-app"
  85. import QrScanner from '../vueQrCode/index.vue'
  86. const listData = ref([])
  87. const keywords = ref(null)
  88. const pageSize = ref(10)
  89. const pageNum = ref(1)
  90. const status = ref(true)
  91. const showQrCodeReader = ref(false);
  92. // 页面下拉刷新操作
  93. onPullDownRefresh(() => {
  94. uni.stopPullDownRefresh();
  95. reflush();
  96. })
  97. onShow(() => {
  98. reflush();
  99. })
  100. function handleScrollToLower() {
  101. console.log(status.value)
  102. if (status.value) {
  103. pageNum.value += 1
  104. getTakesStockList({
  105. deptId: store.curDeptDetails.deptId,
  106. keywords: keywords.value,
  107. pageSize: pageSize.value,
  108. pageNum: pageNum.value
  109. }).then(res => {
  110. const existingIds = new Set(listData.value.map(item => item.id));
  111. // 过滤出那些不在 existingIds 中的项,即新数据
  112. const newRows = res.rows.filter(row => !existingIds.has(row.id));
  113. // 如果有新数据,将其添加到 listData
  114. if (newRows.length > 0) {
  115. listData.value = listData.value.concat(newRows);
  116. } else {
  117. // 如果没有新数据,更新状态表示没有更多数据
  118. status.value = false;
  119. }
  120. })
  121. }
  122. }
  123. function reflush() {
  124. init(store.curDeptDetails.deptId);
  125. }
  126. function init(id) {
  127. uni.showLoading({
  128. title: '加载中'
  129. });
  130. getTakesStockList({
  131. deptId: id,
  132. keywords: keywords.value,
  133. pageSize: pageSize.value,
  134. pageNum: pageNum.value
  135. }).then(res => {
  136. listData.value = res.rows
  137. uni.hideLoading();
  138. })
  139. }
  140. function handleSearch() {
  141. init(store.curDeptDetails.deptId);
  142. }
  143. //H5扫码器回调
  144. function onDecodeHandler(data) {
  145. showQrCodeReader.value = false;
  146. let vehicleObj = {
  147. carrierCode: data
  148. };
  149. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  150. uni.showToast({
  151. icon: "none",
  152. title: "请扫载具码",
  153. duration: 1000
  154. })
  155. return;
  156. }
  157. getTakesStockByCarrierCode({
  158. carrierCode: vehicleObj.carrierCode
  159. }).then(response => {
  160. if (response.code == 200) {
  161. // if (response.data[0].deptId !== store.curDeptDetails.deptId) {
  162. // uni.showToast({
  163. // icon: 'none',
  164. // title: '该批次不在当前工段',
  165. // duration: 2000
  166. // })
  167. // return
  168. // }
  169. handleTurnToDetailsPages(response.data)
  170. } else {
  171. uni.showToast({
  172. icon: 'none',
  173. title: response.msg,
  174. duration: 2000
  175. })
  176. }
  177. })
  178. }
  179. //H5扫码器关闭
  180. function qrReaderClose() {
  181. showQrCodeReader.value = false;
  182. }
  183. function handleScanCode() {
  184. showQrCodeReader.value = true;
  185. // 引入原生插件
  186. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  187. // if (mpaasScanModule) {
  188. // // 调用插件的 mpaasScan 方法
  189. // mpaasScanModule.mpaasScan({
  190. // // 扫码识别类型,参数可多选,qrCode、barCode,
  191. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  192. // scanType: ["qrCode", "barCode"],
  193. // // 是否隐藏相册,默认false不隐藏
  194. // hideAlbum: false,
  195. // },
  196. // (ret) => {
  197. // console.log(ret);
  198. // /* 原有代码,之前二维码中存的信息比较多,用一个JSON格式存储。
  199. // let vehicleObj = JSON.parse(ret.resp_result);
  200. // if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  201. // uni.showToast({
  202. // icon: "none",
  203. // title: "请扫载具码",
  204. // duration: 1000
  205. // })
  206. // return;
  207. // }
  208. // */
  209. // let vehicleObj = {
  210. // carrierCode: ret.resp_result
  211. // };
  212. // if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  213. // uni.showToast({
  214. // icon: "none",
  215. // title: "请扫载具码",
  216. // duration: 1000
  217. // })
  218. // return;
  219. // }
  220. // getTakesStockByCarrierCode({
  221. // carrierCode: vehicleObj.carrierCode
  222. // }).then(response => {
  223. // if (response.code == 200) {
  224. // // if (response.data[0].deptId !== store.curDeptDetails.deptId) {
  225. // // uni.showToast({
  226. // // icon: 'none',
  227. // // title: '该批次不在当前工段',
  228. // // duration: 2000
  229. // // })
  230. // // return
  231. // // }
  232. // handleTurnToDetailsPages(response.data)
  233. // } else {
  234. // uni.showToast({
  235. // icon: 'none',
  236. // title: response.msg,
  237. // duration: 2000
  238. // })
  239. // }
  240. // })
  241. // }
  242. // );
  243. // } else {
  244. // // 测试时用
  245. // getTakesStockByCarrierCode({
  246. // carrierCode: '000033',
  247. // }).then(response => {
  248. // if (response.code == 200) {
  249. // // if (response.data[0].deptId !== store.curDeptDetails.deptId) {
  250. // // uni.showToast({
  251. // // icon: 'none',
  252. // // title: '该批次不在当前工段',
  253. // // duration: 2000
  254. // // })
  255. // // return
  256. // // }
  257. // handleTurnToDetailsPages(response.data)
  258. // } else {
  259. // uni.showToast({
  260. // icon: 'none',
  261. // title: response.msg,
  262. // duration: 2000
  263. // })
  264. // }
  265. // })
  266. // }
  267. }
  268. //跳转
  269. function handleTurnToDetailsPages(data) {
  270. store.takeStockDetails = data
  271. uni.navigateTo({
  272. url: "/pages/takeStock/details"
  273. })
  274. }
  275. </script>
  276. <style lang="scss">
  277. $nav-height: 60rpx;
  278. .box-bg {
  279. width: 94%;
  280. background-color: #F5F5F5;
  281. padding: 5rpx 16rpx;
  282. justify-content: space-around;
  283. align-items: center;
  284. margin: 24rpx auto 0;
  285. .input-view {
  286. width: 100%;
  287. flex: 4;
  288. background-color: #f8f8f8;
  289. height: $nav-height;
  290. border: 1rpx solid #999;
  291. border-radius: 15rpx;
  292. padding: 0 15rpx;
  293. flex-wrap: nowrap;
  294. margin: 0 10rpx 0;
  295. line-height: $nav-height;
  296. .input-uni-icon {
  297. line-height: $nav-height;
  298. }
  299. .nav-bar-input {
  300. width: 80%;
  301. height: $nav-height;
  302. line-height: $nav-height;
  303. padding: 0 5rpx;
  304. background-color: #f8f8f8;
  305. }
  306. }
  307. .search {
  308. width: 20%;
  309. text-align: center;
  310. color: #808080;
  311. }
  312. }
  313. .list-title {
  314. width: 100%;
  315. margin-top: 16rpx;
  316. height: 64rpx;
  317. line-height: 64rpx;
  318. align-items: center;
  319. margin-left: 32rpx;
  320. .label {
  321. font-size: 32rpx;
  322. margin-right: 24rpx;
  323. }
  324. .icon-gear {
  325. font-size: 56rpx;
  326. }
  327. }
  328. .switch {
  329. margin-top: -8rpx;
  330. transform: scale(0.7);
  331. }
  332. .scroll-container {
  333. width: 92%;
  334. margin: 24rpx auto 0 auto;
  335. height: calc(87% - 90rpx);
  336. // overflow: auto;
  337. }
  338. .list-item {
  339. background-color: #fff;
  340. position: relative;
  341. padding: 16rpx;
  342. padding-bottom: 24rpx;
  343. margin-bottom: 24rpx;
  344. border-radius: 24rpx;
  345. .title-container {
  346. margin-top: 8rpx;
  347. margin-bottom: 16rpx;
  348. .title {
  349. height: 48rpx;
  350. align-items: center;
  351. .label {
  352. font-size: 32rpx;
  353. font-weight: bold;
  354. &.code {
  355. margin-left: 8rpx;
  356. }
  357. }
  358. }
  359. .tag {
  360. border: 1px solid #1CE5B0;
  361. background-color: #F6FFFD;
  362. padding: 8rpx;
  363. border-radius: 8rpx;
  364. .label {
  365. color: #1CE5B0;
  366. font-size: 24rpx;
  367. }
  368. &.finished {
  369. border: 1px solid #BBBBBB;
  370. background-color: #F5F5F5;
  371. .label {
  372. color: #BBBBBB;
  373. }
  374. }
  375. &.turnover {
  376. border: 1px solid #FF7901;
  377. background-color: #F6FFFD;
  378. .label {
  379. color: #FF7901;
  380. }
  381. }
  382. }
  383. }
  384. .item-info {
  385. margin-bottom: 8rpx;
  386. .label {
  387. font-size: 28rpx;
  388. width: 220rpx;
  389. color: #808080;
  390. &.right {
  391. flex: 1;
  392. color: #000000;
  393. }
  394. }
  395. }
  396. .status-btn {
  397. justify-content: flex-end;
  398. align-items: center;
  399. .turnover-tag {
  400. padding-right: 12rpx;
  401. padding-left: 12rpx;
  402. border-radius: 8rpx;
  403. border: 1rpx solid #FF7901;
  404. background-color: #FF7901;
  405. font-size: 28rpx;
  406. color: #FFFFFF;
  407. }
  408. .reporting-tag {
  409. padding-right: 12rpx;
  410. padding-left: 12rpx;
  411. border-radius: 8rpx;
  412. margin-left: 16rpx;
  413. border: 1rpx solid #1684fc;
  414. background-color: #1684fc;
  415. font-size: 28rpx;
  416. color: #FFFFFF;
  417. }
  418. }
  419. }
  420. .page {
  421. background-color: white;
  422. width: 100%;
  423. position: fixed;
  424. bottom: 90rpx;
  425. align-items: center;
  426. background-color: #ffffff;
  427. padding: 16rpx 0;
  428. }
  429. .bottom {
  430. background-color: white;
  431. width: 100%;
  432. position: fixed;
  433. bottom: 0;
  434. align-items: center;
  435. background-color: #ffffff;
  436. padding: 16rpx 0;
  437. .add {
  438. margin: 0 auto;
  439. width: 80%;
  440. height: 80rpx;
  441. }
  442. }
  443. </style>