index.vue 8.6 KB

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