index.vue 9.4 KB

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