index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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. <uni-data-select clase="select-view" style="min-width: 70px" @change="handleSearch" v-model="taksStatus"
  9. :localdata="statusList" :clear="false"></uni-data-select>
  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. </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 taksStatus = ref(0);
  86. const keywords = ref(null)
  87. const pageSize = ref(10)
  88. const pageNum = ref(1)
  89. const status = ref(true)
  90. const statusList = [{
  91. value: 0,
  92. text: '未盘点'
  93. }, {
  94. value: 1,
  95. text: '已盘点'
  96. }, {
  97. value: 2,
  98. text: '全 部'
  99. }]
  100. // 页面下拉刷新操作
  101. onPullDownRefresh(() => {
  102. uni.stopPullDownRefresh();
  103. reflush();
  104. })
  105. onShow(() => {
  106. reflush();
  107. })
  108. function handleScrollToLower() {
  109. console.log(status.value)
  110. if (status.value) {
  111. pageNum.value += 1
  112. getTakesStockList({
  113. deptId: store.curDeptDetails.deptId,
  114. keywords: keywords.value,
  115. isTaksStock: taksStatus.value,
  116. pageSize: pageSize.value,
  117. pageNum: pageNum.value
  118. }).then(res => {
  119. const existingIds = new Set(listData.value.map(item => item.id));
  120. // 过滤出那些不在 existingIds 中的项,即新数据
  121. const newRows = res.rows.filter(row => !existingIds.has(row.id));
  122. // 如果有新数据,将其添加到 listData
  123. if (newRows.length > 0) {
  124. listData.value = listData.value.concat(newRows);
  125. } else {
  126. // 如果没有新数据,更新状态表示没有更多数据
  127. status.value = false;
  128. }
  129. })
  130. }
  131. }
  132. function reflush() {
  133. init(store.curDeptDetails.deptId);
  134. }
  135. function init(id) {
  136. uni.showLoading({
  137. title: '加载中'
  138. });
  139. getTakesStockList({
  140. deptId: id,
  141. keywords: keywords.value,
  142. isTaksStock: taksStatus.value,
  143. pageSize: pageSize.value,
  144. pageNum: pageNum.value
  145. }).then(res => {
  146. listData.value = res.rows
  147. uni.hideLoading();
  148. })
  149. }
  150. function handleSearch() {
  151. init(store.curDeptDetails.deptId);
  152. }
  153. function handleScanCode() {
  154. // 引入原生插件
  155. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  156. if (mpaasScanModule) {
  157. // 调用插件的 mpaasScan 方法
  158. mpaasScanModule.mpaasScan({
  159. // 扫码识别类型,参数可多选,qrCode、barCode,
  160. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  161. scanType: ["qrCode", "barCode"],
  162. // 是否隐藏相册,默认false不隐藏
  163. hideAlbum: false,
  164. },
  165. (ret) => {
  166. console.log(ret);
  167. /* 原有代码,之前二维码中存的信息比较多,用一个JSON格式存储。
  168. let vehicleObj = JSON.parse(ret.resp_result);
  169. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  170. uni.showToast({
  171. icon: "none",
  172. title: "请扫载具码",
  173. duration: 1000
  174. })
  175. return;
  176. }
  177. */
  178. let vehicleObj = {
  179. carrierCode: ret.resp_result
  180. };
  181. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  182. uni.showToast({
  183. icon: "none",
  184. title: "请扫载具码",
  185. duration: 1000
  186. })
  187. return;
  188. }
  189. getTakesStockByCarrierCode({
  190. carrierCode: vehicleObj.carrierCode
  191. }).then(response => {
  192. if (response.code == 200) {
  193. // if (response.data[0].deptId !== store.curDeptDetails.deptId) {
  194. // uni.showToast({
  195. // icon: 'none',
  196. // title: '该批次不在当前工段',
  197. // duration: 2000
  198. // })
  199. // return
  200. // }
  201. handleTurnToDetailsPages(response.data)
  202. } else {
  203. uni.showToast({
  204. icon: 'none',
  205. title: response.msg,
  206. duration: 2000
  207. })
  208. }
  209. })
  210. }
  211. );
  212. } else {
  213. // 测试时用
  214. getTakesStockByCarrierCode({
  215. carrierCode: '000033',
  216. }).then(response => {
  217. if (response.code == 200) {
  218. // if (response.data[0].deptId !== store.curDeptDetails.deptId) {
  219. // uni.showToast({
  220. // icon: 'none',
  221. // title: '该批次不在当前工段',
  222. // duration: 2000
  223. // })
  224. // return
  225. // }
  226. handleTurnToDetailsPages(response.data)
  227. } else {
  228. uni.showToast({
  229. icon: 'none',
  230. title: response.msg,
  231. duration: 2000
  232. })
  233. }
  234. })
  235. }
  236. }
  237. //跳转
  238. function handleTurnToDetailsPages(data) {
  239. store.takeStockDetails = data
  240. uni.navigateTo({
  241. url: "/pages/takeStock/details"
  242. })
  243. }
  244. </script>
  245. <style lang="scss">
  246. $nav-height: 60rpx;
  247. .box-bg {
  248. width: 94%;
  249. background-color: #F5F5F5;
  250. padding: 5rpx 16rpx;
  251. justify-content: space-around;
  252. align-items: center;
  253. margin: 24rpx auto 0;
  254. .input-view {
  255. width: 100%;
  256. flex: 4;
  257. background-color: #f8f8f8;
  258. height: $nav-height;
  259. border: 1rpx solid #999;
  260. border-radius: 15rpx;
  261. padding: 0 15rpx;
  262. flex-wrap: nowrap;
  263. margin: 0 10rpx 0;
  264. line-height: $nav-height;
  265. .input-uni-icon {
  266. line-height: $nav-height;
  267. }
  268. .nav-bar-input {
  269. width: 80%;
  270. height: $nav-height;
  271. line-height: $nav-height;
  272. padding: 0 5rpx;
  273. background-color: #f8f8f8;
  274. }
  275. }
  276. .select-view {
  277. flex-shrink: 0;
  278. /* 防止压缩 */
  279. margin-left: 16rpx;
  280. }
  281. /* 防止下拉选项换行 */
  282. .uni-data-select-dropdown .uni-data-select__list {
  283. white-space: nowrap !important;
  284. min-width: fit-content !important;
  285. }
  286. .uni-data-select__text {
  287. white-space: nowrap !important;
  288. overflow: hidden !important;
  289. text-overflow: ellipsis !important;
  290. }
  291. .search {
  292. width: 20%;
  293. text-align: center;
  294. color: #808080;
  295. }
  296. }
  297. .list-title {
  298. width: 100%;
  299. margin-top: 16rpx;
  300. height: 64rpx;
  301. line-height: 64rpx;
  302. align-items: center;
  303. margin-left: 32rpx;
  304. .label {
  305. font-size: 32rpx;
  306. margin-right: 24rpx;
  307. }
  308. .icon-gear {
  309. font-size: 56rpx;
  310. }
  311. }
  312. .switch {
  313. margin-top: -8rpx;
  314. transform: scale(0.7);
  315. }
  316. .scroll-container {
  317. width: 92%;
  318. margin: 24rpx auto 0 auto;
  319. height: calc(87% - 90rpx);
  320. // overflow: auto;
  321. }
  322. .list-item {
  323. background-color: #fff;
  324. position: relative;
  325. padding: 16rpx;
  326. padding-bottom: 24rpx;
  327. margin-bottom: 24rpx;
  328. border-radius: 24rpx;
  329. .title-container {
  330. margin-top: 8rpx;
  331. margin-bottom: 16rpx;
  332. .title {
  333. height: 48rpx;
  334. align-items: center;
  335. .label {
  336. font-size: 32rpx;
  337. font-weight: bold;
  338. &.code {
  339. margin-left: 8rpx;
  340. }
  341. }
  342. }
  343. .tag {
  344. border: 1px solid #1CE5B0;
  345. background-color: #F6FFFD;
  346. padding: 8rpx;
  347. border-radius: 8rpx;
  348. .label {
  349. color: #1CE5B0;
  350. font-size: 24rpx;
  351. }
  352. &.finished {
  353. border: 1px solid #BBBBBB;
  354. background-color: #F5F5F5;
  355. .label {
  356. color: #BBBBBB;
  357. }
  358. }
  359. &.turnover {
  360. border: 1px solid #FF7901;
  361. background-color: #F6FFFD;
  362. .label {
  363. color: #FF7901;
  364. }
  365. }
  366. }
  367. }
  368. .item-info {
  369. margin-bottom: 8rpx;
  370. .label {
  371. font-size: 28rpx;
  372. width: 220rpx;
  373. color: #808080;
  374. &.right {
  375. flex: 1;
  376. color: #000000;
  377. }
  378. }
  379. }
  380. .status-btn {
  381. justify-content: flex-end;
  382. align-items: center;
  383. .turnover-tag {
  384. padding-right: 12rpx;
  385. padding-left: 12rpx;
  386. border-radius: 8rpx;
  387. border: 1rpx solid #FF7901;
  388. background-color: #FF7901;
  389. font-size: 28rpx;
  390. color: #FFFFFF;
  391. }
  392. .reporting-tag {
  393. padding-right: 12rpx;
  394. padding-left: 12rpx;
  395. border-radius: 8rpx;
  396. margin-left: 16rpx;
  397. border: 1rpx solid #1684fc;
  398. background-color: #1684fc;
  399. font-size: 28rpx;
  400. color: #FFFFFF;
  401. }
  402. }
  403. }
  404. .page {
  405. background-color: white;
  406. width: 100%;
  407. position: fixed;
  408. bottom: 90rpx;
  409. align-items: center;
  410. background-color: #ffffff;
  411. padding: 16rpx 0;
  412. }
  413. .bottom {
  414. background-color: white;
  415. width: 100%;
  416. position: fixed;
  417. bottom: 0;
  418. align-items: center;
  419. background-color: #ffffff;
  420. padding: 16rpx 0;
  421. .add {
  422. margin: 0 auto;
  423. width: 80%;
  424. height: 80rpx;
  425. }
  426. }
  427. </style>