index.vue 10 KB

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