index.vue 12 KB

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