index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view class="uni-column" style="position: absolute;left: 0px;right: 0px;height: 100%;">
  3. <view class="box-bg uni-row" style="height: 6%;">
  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">搜索</view>
  9. </view>
  10. <view v-if="listData.length == 0" style="color: #999;margin: 100% auto;
  11. height: 100%;
  12. position: relative;
  13. bottom: 0;
  14. left: 0;
  15. right: 0;">
  16. <text>暂无批次</text>
  17. </view>
  18. <view v-else style="height: 82%; overflow: auto;padding-left: 12px;padding-right: 12px;">
  19. <view v-for="(item, index) in listData" :key="index" @click="handleToBatchReporting(item)"
  20. class="list-item">
  21. <view class="title-container uni-row">
  22. <view class="title uni-row">
  23. <text class="label">生产计划单号</text>
  24. <text class="label code">{{ item['productionPlanNo'] }}</text>
  25. <text class="label" style="margin-left: 20px;">序号</text>
  26. <text class="label code">{{ item['lineNumber'] }}</text>
  27. </view>
  28. <view v-if="item['dayWorkList'].length > 0" class="tag"><text class="label">进行中</text></view>
  29. <view v-else type="default" class="tag not-start"><text class="label">未开始</text></view>
  30. </view>
  31. <view class="item-info uni-row">
  32. <text class="label">产品描述</text>
  33. <text class="label right">{{ item['productDescription'] }}</text>
  34. </view>
  35. <view class="item-info uni-row">
  36. <text class="label">总批数</text>
  37. <text class="label right">{{ item['totalLotNumber'] }}</text>
  38. </view>
  39. <!-- <view class="item-info uni-row">
  40. <text class="label">完成批数</text>
  41. <text class="label right">{{ item['equiment'] }}</text>
  42. </view> -->
  43. <view class="item-info uni-row">
  44. <text class="label">投产数</text>
  45. <text class="label right">{{ item['productionQuantity'] }}</text>
  46. </view>
  47. <view class="item-info uni-row">
  48. <text class="label">单批量</text>
  49. <text class="label right">{{ item['oneLotQuantity'] }}</text>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="bottom uni-row">
  54. <button class="start-batch-btn" style="margin-right: 10rpx;background-color: #67c337;"
  55. @click="handleScanCode">扫码报工</button>
  56. <button class="start-batch-btn" type="primary" @click="handleSearchCode">查箱号</button>
  57. </view>
  58. <dialog-selectDaywork ref='selectDaywork' @handleSelectDaywork='handleSelectDaywork'></dialog-selectDaywork>
  59. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  60. </view>
  61. </template>
  62. <script setup>
  63. import {
  64. getPlanDetailsList,
  65. selectByCarrierCode,
  66. selectInfoByLotCode
  67. } from '@/api/business/planDetails.js'
  68. import {
  69. ref
  70. } from 'vue'
  71. import {
  72. onReady,
  73. onLoad,
  74. onUnload,
  75. onPullDownRefresh,
  76. onShow
  77. } from '@dcloudio/uni-app'
  78. import QrScanner from '../vueQrCode/index.vue'
  79. import {
  80. getToken
  81. } from '@/utils/auth'
  82. import {
  83. store
  84. } from '@/store/index.js'
  85. import {
  86. getUserProcess
  87. } from '@/api/process/process.js'
  88. const listData = ref([])
  89. const keywords = ref('')
  90. const selectDaywork = ref(null)
  91. const carrierCode = ref(null)
  92. const showQrCodeReader = ref(false);
  93. onLoad(() => {
  94. // dayworkItem数据更改后刷新数据
  95. // uni.$on('dayworkItemUpdate', reflush);
  96. })
  97. onShow(() => {
  98. reflush();
  99. })
  100. onUnload(() => {
  101. console.log(store.curDeptDetails)
  102. // uni.$off('dayworkItemUpdate', reflush)
  103. })
  104. /**
  105. * 监听下拉刷新
  106. */
  107. onPullDownRefresh(() => {
  108. uni.stopPullDownRefresh();
  109. reflush();
  110. // getPlanDetailsList({
  111. // deptId: Number(store.curDeptDetails.deptId),
  112. // keywords: keywords.value
  113. // }).then(res => {
  114. // if (res.code == 200) {
  115. // listData.value = res.data;
  116. // uni.stopPullDownRefresh();
  117. // }
  118. // uni.stopPullDownRefresh();
  119. // })
  120. })
  121. function reflush() {
  122. keywords.value = ''
  123. init();
  124. }
  125. function init(data) {
  126. uni.showLoading({
  127. title: '加载中'
  128. });
  129. getPlanDetailsList({
  130. deptId: Number(store.curDeptDetails.deptId),
  131. keywords: keywords.value
  132. }).then(res => {
  133. if (res.code == 200) {
  134. listData.value = res.data;
  135. uni.hideLoading();
  136. }
  137. uni.hideLoading();
  138. })
  139. }
  140. function handleToBatchReporting(item) {
  141. store.planDetails = item
  142. uni.navigateTo({
  143. url: '/pages/sortBatchReporting/index'
  144. })
  145. }
  146. //查箱号
  147. function handleSearchCode() {
  148. uni.navigateTo({
  149. url: '/pages/sortProductionPlan/details'
  150. })
  151. }
  152. //带回
  153. function handleSelectDaywork(data) {
  154. console.log(data)
  155. //查询计划单信息跳转
  156. selectInfoByLotCode({
  157. lotCode: data
  158. }).then(res => {
  159. store.planDetails = res.data
  160. var code = encodeURIComponent(carrierCode.value);
  161. // 构建查询参数字符串
  162. var queryParam =
  163. `param1=${code}`;
  164. // 使用模板字符串构建完整的URL
  165. var navigateUrl = `/pages/sortBatchReporting/index?${queryParam}`;
  166. uni.navigateTo({
  167. url: navigateUrl
  168. });
  169. })
  170. }
  171. function handleSearch() {
  172. let reqParam = {
  173. keywords: keywords.value
  174. }
  175. reqParam.tenantId = !store.tenantId ? store.userInfo.tenantId : store.tenantId;
  176. init(reqParam)
  177. }
  178. //H5扫码器回调
  179. function onDecodeHandler(data) {
  180. showQrCodeReader.value = false;
  181. let vehicleObj = {
  182. carrierCode: data
  183. };
  184. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  185. uni.showToast({
  186. icon: "none",
  187. title: "请扫载具码",
  188. duration: 1000
  189. })
  190. return;
  191. }
  192. selectByCarrierCode({
  193. carrierCode: vehicleObj.carrierCode,
  194. deptId: Number(store.curDeptDetails.deptId)
  195. }).then(response => {
  196. carrierCode.value = vehicleObj.carrierCode
  197. if (response.code == 200) {
  198. if (response.data.length > 1) {
  199. selectDaywork.value.open(response.data)
  200. } else {
  201. handleSelectDaywork(response.data[0].lotCode)
  202. }
  203. } else {
  204. uni.showToast({
  205. icon: 'none',
  206. title: response.msg,
  207. duration: 2000
  208. })
  209. }
  210. })
  211. }
  212. //H5扫码器关闭
  213. function qrReaderClose() {
  214. showQrCodeReader.value = false;
  215. }
  216. function handleScanCode() {
  217. showQrCodeReader.value = true;
  218. // 引入原生插件
  219. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  220. // // const mpaasScanModule = null
  221. // if (mpaasScanModule) {
  222. // // 调用插件的 mpaasScan 方法
  223. // mpaasScanModule.mpaasScan({
  224. // // 扫码识别类型,参数可多选,qrCode、barCode,
  225. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  226. // scanType: ["qrCode", "barCode"],
  227. // // 是否隐藏相册,默认false不隐藏
  228. // hideAlbum: false,
  229. // },
  230. // (ret) => {
  231. // console.log(ret);
  232. // let vehicleObj = {
  233. // carrierCode: ret.resp_result
  234. // };
  235. // if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  236. // uni.showToast({
  237. // icon: "none",
  238. // title: "请扫载具码",
  239. // duration: 1000
  240. // })
  241. // return;
  242. // }
  243. // selectByCarrierCode({
  244. // carrierCode: vehicleObj.carrierCode,
  245. // deptId:Number(store.curDeptDetails.deptId)
  246. // }).then(response => {
  247. // carrierCode.value = vehicleObj.carrierCode
  248. // if (response.code == 200) {
  249. // if (response.data.length > 1) {
  250. // selectDaywork.value.open(response.data)
  251. // } else {
  252. // handleSelectDaywork(response.data[0].lotCode)
  253. // }
  254. // } else {
  255. // uni.showToast({
  256. // icon: 'none',
  257. // title: response.msg,
  258. // duration: 2000
  259. // })
  260. // }
  261. // })
  262. // }
  263. // );
  264. // } else {
  265. // // 测试时用
  266. // selectByCarrierCode({
  267. // carrierCode: '000745',
  268. // deptId:Number(store.curDeptDetails.deptId)
  269. // }).then(response => {
  270. // if (response.code == 200) {
  271. // carrierCode.value = '000745'
  272. // if (response.data.length > 1) {
  273. // selectDaywork.value.open(response.data)
  274. // } else {
  275. // handleSelectDaywork(response.data[0].lotCode)
  276. // }
  277. // } else {
  278. // uni.showToast({
  279. // icon: 'none',
  280. // title: response.msg,
  281. // duration: 2000
  282. // })
  283. // }
  284. // })
  285. // }
  286. }
  287. </script>
  288. <style lang="scss">
  289. $nav-height: 60rpx;
  290. .box-bg {
  291. width: 100%;
  292. background-color: #F5F5F5;
  293. padding: 10rpx 0;
  294. justify-content: space-around;
  295. align-items: center;
  296. .input-view {
  297. width: 100%;
  298. flex: 4;
  299. background-color: #f8f8f8;
  300. height: $nav-height;
  301. border: 1rpx solid #999;
  302. border-radius: 15rpx;
  303. padding: 0 15rpx;
  304. flex-wrap: nowrap;
  305. margin: 0 10rpx 20rpx;
  306. line-height: $nav-height;
  307. .input-uni-icon {
  308. line-height: $nav-height;
  309. }
  310. .nav-bar-input {
  311. width: 80%;
  312. height: $nav-height;
  313. line-height: $nav-height;
  314. padding: 0 5rpx;
  315. background-color: #f8f8f8;
  316. }
  317. }
  318. .search {
  319. width: 20%;
  320. text-align: center;
  321. color: #808080;
  322. margin-top: -20rpx;
  323. }
  324. }
  325. .uni-column {
  326. background-color: rgba(245, 245, 245, 1);
  327. // height: calc(100% - 40rpx);
  328. }
  329. .list-item {
  330. background-color: #fff;
  331. position: relative;
  332. padding: 16rpx;
  333. padding-bottom: 24rpx;
  334. border-radius: 24rpx;
  335. margin-bottom: 24rpx;
  336. .title-container {
  337. justify-content: space-between;
  338. margin-top: 8rpx;
  339. margin-bottom: 16rpx;
  340. .title {
  341. height: 48rpx;
  342. align-items: center;
  343. .label {
  344. font-size: 32rpx;
  345. font-weight: bold;
  346. &.code {
  347. margin-left: 8rpx;
  348. }
  349. }
  350. }
  351. .tag {
  352. border: 1px solid #1ce5b0;
  353. background-color: #f6fffd;
  354. padding: 8rpx;
  355. border-radius: 8rpx;
  356. .label {
  357. color: #1ce5b0;
  358. font-size: 24rpx;
  359. }
  360. &.not-start {
  361. border: 1px solid #bbbbbb;
  362. background-color: #f5f5f5;
  363. .label {
  364. color: #bbbbbb;
  365. }
  366. }
  367. }
  368. }
  369. .item-info {
  370. margin-bottom: 8rpx;
  371. .label {
  372. font-size: 28rpx;
  373. width: 220rpx;
  374. color: #808080;
  375. &.right {
  376. flex: 1;
  377. color: #000000;
  378. }
  379. }
  380. }
  381. }
  382. .bottom {
  383. height: 10%;
  384. position: fixed;
  385. right: 0;
  386. bottom: 0;
  387. left: 0;
  388. height: 100rpx;
  389. border-top: 1px solid #999999;
  390. padding: 16rpx 32rpx;
  391. align-items: center;
  392. background-color: #fff;
  393. justify-content: space-evenly;
  394. .start-batch-btn {
  395. flex: 1;
  396. height: 80rpx;
  397. line-height: 80rpx;
  398. border-radius: 8rpx;
  399. color: #FFFFFF;
  400. font-size: 28rpx;
  401. }
  402. .view-end-btn {
  403. flex: 1;
  404. height: 80rpx;
  405. line-height: 80rpx;
  406. border-radius: 8rpx;
  407. color: #FFFFFF;
  408. font-size: 28rpx;
  409. }
  410. }
  411. </style>