index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <template>
  2. <view class="mask" v-if="isLoading"></view>
  3. <view class="uni-column" style="height: 100%;padding: 8px;position: fixed;left: 0;right: 0;">
  4. <view v-if="allData.length>0" style="margin-bottom: 20rpx;">
  5. <view>
  6. <view class="item-info uni-row" style="height: 80rpx;">
  7. <view style="flex: 2;">
  8. <button :class="[ checkAll ? 'active' : 'select' ]" @click="handleAll"
  9. style="margin-left: 0px;display: flex; align-items: center; justify-content: center;">全选</button>
  10. </view>
  11. <button @click="handleSearch" style="margin-right: 20rpx ;">搜索</button>
  12. <uni-data-select v-model="workshopId" :localdata="workshopList" @change="handleChangeWorkshop"
  13. :clear="false" class="label right"
  14. style=" margin-right: 20rpx; outline: 2rpx solid #999999;border-radius: 10rpx;flex: 1;"></uni-data-select>
  15. </view>
  16. </view>
  17. </view>
  18. <view v-if="allData.length>0" style="overflow: auto; margin-bottom: 200rpx;height: calc(90% - 100rpx);">
  19. <view v-for="(item, index) in listData" :key="index" :class="{'list-item':true,'selected':isSelected(item)}"
  20. @click="handleSelection(item)">
  21. <view class="title-container uni-row">
  22. <view class="title uni-row"><text class="label">{{item.lotCode}}</text></view>
  23. <view><button class="start-batch-btn uni-row"
  24. style="height: 70rpx; display: flex; align-items: center; justify-content: center;"
  25. type=primary @click.stop='handleChangeCarrier(item)'>换箱</button>
  26. </view>
  27. </view>
  28. <view class="item-info uni-row">
  29. <text class="label">产品描述</text>
  30. <text class="label right">{{item['productDescription']}}</text>
  31. </view>
  32. <view class="item-info uni-row">
  33. <text class="label">关联箱号</text>
  34. <text class="label right">{{item['carrierName']}}</text>
  35. </view>
  36. <view class="item-info uni-row">
  37. <view class="label">设备</view>
  38. <text class="label right">{{item['equipmentDetailCode']}}</text>
  39. </view>
  40. <!-- <view class="item-info uni-row">
  41. <text class="label">下序</text>
  42. <text class="label right">{{item['process']}}</text>
  43. </view> -->
  44. <view class="item-info uni-row">
  45. <text class="label">当前序</text>
  46. <text class="label right">{{item['process'].processAlias}}</text>
  47. </view>
  48. <view class="item-info uni-row">
  49. <text class="label">下序</text>
  50. <text class="label right">{{item['nextProcess'].processAlias}}</text>
  51. </view>
  52. <view class="item-info uni-row">
  53. <text class="label">下序工段</text>
  54. <text class="label right">{{item.quickInfo.deptName}}</text>
  55. </view>
  56. </view>
  57. </view>
  58. <view v-if="allData.length==0" style="color: #999;">
  59. <image style="width: 420rpx; height: 420rpx; padding-top: 30% ; margin: auto;"
  60. src="../../static/images/fastProductionPlan.png" />
  61. </view>
  62. <view v-if="allData.length==0" class='bottom-btn-container'>
  63. <text style="margin: auto; padding-bottom: 10%;">扫箱码开始快速报工</text>
  64. <button class="start-batch-btn uni-row" type=primary @click='handleAdd'>扫码开始报工</button>
  65. </view>
  66. <view v-if="allData.length>0" class='btn uni-row'>
  67. <button class='bottom-btn left-btn' type="warn" @click="handleEnd">结束报工</button>
  68. <button class='bottom-btn right-btn' type="primary" @click="handleContinue">继续扫码</button>
  69. </view>
  70. <dialog-lotReporting ref="lotReporting" :getList="init" @scan="handleAdd"></dialog-lotReporting>
  71. <dialog-Search ref="searchRef" @search="refreshSearch"></dialog-Search>
  72. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  73. </view>
  74. <view
  75. style="background-color: #99999999; z-index: 5; position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;"
  76. v-if="loading">
  77. </view>
  78. </template>
  79. <script setup>
  80. import {
  81. getPlanDetailsList
  82. } from '@/api/business/planDetails.js'
  83. import {
  84. store
  85. } from '@/store/index.js'
  86. import {
  87. onShow
  88. } from '@dcloudio/uni-app'
  89. import {
  90. getDayWorkList,
  91. showDaywork,
  92. showDayworkSave,
  93. turnoverDelete
  94. } from '@/api/business/dayWork.js'
  95. import QrScanner from '../vueQrCode/index.vue'
  96. import {
  97. getQuickDayworkList,
  98. finishQuick,
  99. getDayworkByCarrierId,
  100. getDayworkByCarrierCode,
  101. reportDaywork
  102. } from '@/api/business/quickDaywork'
  103. import {
  104. isTakeStock
  105. } from '@/api/business/taksStackLot.js'
  106. import {
  107. ref
  108. } from 'vue'
  109. import path from '@/api/base/path.js'
  110. const lotReporting = ref(null)
  111. const workshopId = ref(null);
  112. const searchRef = ref(null);
  113. const keyword = ref('')
  114. const loading = ref(false)
  115. const showQrCodeReader = ref(false);
  116. const form = ref([]); //表单数据true
  117. const checkAll = ref(false); //是否全选
  118. // 创建一个引用来存储最后一次请求的时间戳
  119. const lastRequestTimestamp = ref(0);
  120. const isLoading = ref(false)
  121. const listData = ref([]);
  122. const allData = ref([])
  123. const selection = ref([]); //选中数据
  124. const workshopList = ref([]); //车间数据
  125. onShow(() => {
  126. init()
  127. })
  128. //初始化
  129. function init() {
  130. // console.log(store.curDeptDetails)
  131. uni.showLoading({
  132. title: '加载中'
  133. });
  134. checkAll.value = false
  135. getQuickDayworkList({
  136. deptId: store.curDeptDetails.deptId,
  137. }).then(res => {
  138. isLoading.value = false;
  139. // console.log(res)
  140. if (res.code == 200) {
  141. allData.value = res.rows
  142. if (allData.value.length == 0) {
  143. listData.value = []
  144. }
  145. uni.hideLoading();
  146. }
  147. if (res.other.workShops != null) {
  148. workshopList.value = res.other.workShops.map(v => ({
  149. value: v.id,
  150. text: v.name,
  151. depts: v.depts
  152. }))
  153. if ((workshopId.value == null || !workshopList.value.some(e => e.value === workshopId.value)) &&
  154. workshopList.value.length > 0) {
  155. workshopId.value = workshopList.value[0].value
  156. handleChangeWorkshop(workshopId.value)
  157. } else {
  158. handleChangeWorkshop(workshopId.value)
  159. }
  160. } else {
  161. workshopList.value = []
  162. }
  163. uni.hideLoading();
  164. loading.value = false
  165. })
  166. }
  167. // 搜索按钮操作
  168. function handleSearch() {
  169. searchRef.value.open();
  170. }
  171. function refreshSearch(input) {
  172. // console.log(input)
  173. keyword.value = input
  174. handleChangeWorkshop(workshopId.value)
  175. }
  176. /* 【原有代码】
  177. function handleAdd() {
  178. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  179. if (mpaasScanModule) {
  180. // 调用插件的 mpaasScan 方法
  181. mpaasScanModule.mpaasScan({
  182. // 扫码识别类型,参数可多选,qrCode、barCode,
  183. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  184. scanType: ["qrCode", "barCode"],
  185. // 是否隐藏相册,默认false不隐藏
  186. hideAlbum: false,
  187. },
  188. (ret) => {
  189. let vehicleObj = JSON.parse(ret.resp_result);
  190. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  191. uni.showToast({
  192. icon: "none",
  193. title: "请扫载具码",
  194. duration: 1000
  195. })
  196. return;
  197. }
  198. getDayworkByCarrierId({
  199. carrierId: vehicleObj.carrierId,
  200. deptId: store.curDeptDetails.deptId,
  201. status: 7
  202. }).then(response => {
  203. if (response.code == 200) {
  204. // console.log(response.data.items.length)
  205. // console.log(response.data)
  206. // if (response.data.items[0].deptId !== store.curDeptDetails.deptId) {
  207. // uni.showToast({
  208. // icon: 'none',
  209. // title: '该批次不在当前工段',
  210. // duration: 2000
  211. // })
  212. // return
  213. // }
  214. if (response.data.items.length > 0) {
  215. lotReporting.value.open(response.data);
  216. } else {
  217. uni.showToast({
  218. icon: 'none',
  219. title: '该批次不在此计划单内, 或不在当前工段',
  220. duration: 2000
  221. })
  222. }
  223. } else {
  224. uni.showToast({
  225. icon: 'none',
  226. title: response.msg,
  227. duration: 2000
  228. })
  229. }
  230. })
  231. }
  232. );
  233. } else {
  234. // 测试时用
  235. getDayworkByCarrierId({
  236. carrierId: '1747500987688890381',
  237. status: 7,
  238. deptId: store.curDeptDetails.deptId,
  239. }).then(response => {
  240. console.log(response)
  241. if (response.code == 200) {
  242. //
  243. // if (response.data.items[0].deptId !== store.curDeptDetails.deptId) {
  244. // uni.showToast({
  245. // icon: 'none',
  246. // title: '该批次不在当前工段',
  247. // duration: 2000
  248. // })
  249. // return
  250. // }
  251. if (response.data.items.length > 0) {
  252. // console.log(response.data)
  253. lotReporting.value.open(response.data);
  254. } else {
  255. uni.showToast({
  256. icon: 'none',
  257. title: '该批次不在此计划单内, 或不在当前工段',
  258. duration: 2000
  259. })
  260. }
  261. } else {
  262. uni.showToast({
  263. icon: 'none',
  264. title: response.msg,
  265. duration: 2000
  266. })
  267. }
  268. })
  269. }
  270. // lotReporting.value.open(data);
  271. }
  272. */
  273. //H5扫码器回调
  274. function onDecodeHandler(data) {
  275. showQrCodeReader.value = false;
  276. let vehicleObj = {
  277. carrierCode: data
  278. };
  279. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  280. uni.showToast({
  281. icon: "none",
  282. title: "请扫载具码",
  283. duration: 1000
  284. })
  285. return;
  286. }
  287. getDayworkByCarrierCode({
  288. carrierCode: vehicleObj.carrierCode,
  289. deptId: store.curDeptDetails.deptId,
  290. status: 7
  291. }).then(response => {
  292. if (response.code == 200) {
  293. if (response.data.items.length > 0) {
  294. lotReporting.value.open(response.data);
  295. } else {
  296. uni.showToast({
  297. icon: 'none',
  298. title: '该批次不在此计划单内, 或不在当前工段',
  299. duration: 2000
  300. })
  301. }
  302. } else {
  303. uni.showToast({
  304. icon: 'none',
  305. title: response.msg,
  306. duration: 2000
  307. })
  308. }
  309. })
  310. }
  311. //H5扫码器关闭
  312. function qrReaderClose() {
  313. showQrCodeReader.value = false;
  314. }
  315. function handleAdd() {
  316. showQrCodeReader.value = true;
  317. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  318. // if (mpaasScanModule) {
  319. // // 调用插件的 mpaasScan 方法
  320. // mpaasScanModule.mpaasScan({
  321. // // 扫码识别类型,参数可多选,qrCode、barCode,
  322. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  323. // scanType: ["qrCode", "barCode"],
  324. // // 是否隐藏相册,默认false不隐藏
  325. // hideAlbum: false,
  326. // },
  327. // (ret) => {
  328. // let vehicleObj = {
  329. // carrierCode: ret.resp_result
  330. // };
  331. // if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  332. // uni.showToast({
  333. // icon: "none",
  334. // title: "请扫载具码",
  335. // duration: 1000
  336. // })
  337. // return;
  338. // }
  339. // getDayworkByCarrierCode({
  340. // carrierCode: vehicleObj.carrierCode,
  341. // deptId: store.curDeptDetails.deptId,
  342. // status: 7
  343. // }).then(response => {
  344. // if (response.code == 200) {
  345. // if (response.data.items.length > 0) {
  346. // lotReporting.value.open(response.data);
  347. // } else {
  348. // uni.showToast({
  349. // icon: 'none',
  350. // title: '该批次不在此计划单内, 或不在当前工段',
  351. // duration: 2000
  352. // })
  353. // }
  354. // } else {
  355. // uni.showToast({
  356. // icon: 'none',
  357. // title: response.msg,
  358. // duration: 2000
  359. // })
  360. // }
  361. // })
  362. // }
  363. // );
  364. // } else {
  365. // // 测试时用
  366. // getDayworkByCarrierCode({
  367. // carrierCode: '900005',
  368. // status: 7,
  369. // deptId: store.curDeptDetails.deptId,
  370. // }).then(response => {
  371. // console.log(response)
  372. // if (response.code == 200) {
  373. // //
  374. // // if (response.data.items[0].deptId !== store.curDeptDetails.deptId) {
  375. // // uni.showToast({
  376. // // icon: 'none',
  377. // // title: '该批次不在当前工段',
  378. // // duration: 2000
  379. // // })
  380. // // return
  381. // // }
  382. // if (response.data.items.length > 0) {
  383. // // console.log(response.data)
  384. // lotReporting.value.open(response.data);
  385. // } else {
  386. // uni.showToast({
  387. // icon: 'none',
  388. // title: '该批次不在此计划单内, 或不在当前工段',
  389. // duration: 2000
  390. // })
  391. // }
  392. // } else {
  393. // uni.showToast({
  394. // icon: 'none',
  395. // title: response.msg,
  396. // duration: 2000
  397. // })
  398. // }
  399. // })
  400. // }
  401. // lotReporting.value.open(data);
  402. }
  403. function handleContinue() {
  404. // lotReporting.value.open('test')
  405. handleAdd()
  406. }
  407. // 全选按钮操作
  408. function handleAll() {
  409. //清空选中数据
  410. selection.value.length = 0;
  411. if (checkAll.value) {
  412. //变更选中状态
  413. checkAll.value = false;
  414. } else {
  415. checkAll.value = true;
  416. listData.value.findIndex(item => handleSelection(item))
  417. }
  418. }
  419. function handleChangeWorkshop(arg) {
  420. const workshop = workshopList.value.find(v => v.value === arg)
  421. // console.log(allData.value)
  422. // console.log(workshop)
  423. // console.log()
  424. listData.value = allData.value.filter(v => workshop.depts.some(e => e.deptId === v.quickInfo.deptId) && (v.lotCode
  425. .includes(keyword.value) || v.productDescription.includes(keyword.value) || (v.carrierName != null && v
  426. .carrierName.includes(keyword.value))))
  427. selection.value = []
  428. }
  429. function isSelected(item) {
  430. return selection.value.includes(item);
  431. }
  432. //
  433. function handleSelection(item) {
  434. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  435. if (buttonIndex > -1) {
  436. selection.value.splice(buttonIndex, 1); // 取消选中
  437. } else {
  438. selection.value.push(item); // 选中
  439. }
  440. if (selection.value.length == listData.value.length) {
  441. checkAll.value = true;
  442. } else {
  443. checkAll.value = false;
  444. }
  445. }
  446. function handleChangeCarrier(item) {
  447. uni.$once('refreshQuickReport', () => {
  448. init()
  449. })
  450. store.dayworkInfo = null
  451. uni.navigateTo({
  452. url: "/pages/changeBox/index",
  453. success: function(res) {
  454. // 通过eventChannel向被打开页面传送数据
  455. res.eventChannel.emit('acceptDataFromOpenerPage', {
  456. data: item
  457. })
  458. }
  459. })
  460. }
  461. function handleEnd() {
  462. if (selection.value.length === 0) {
  463. uni.showToast({
  464. icon: 'none',
  465. title: '请选择完成报工批次'
  466. })
  467. return
  468. }
  469. isTakeStock().then(response => {
  470. if (response.data) {
  471. uni.showToast({
  472. icon: 'none',
  473. title: '正在盘点,不能结束报工',
  474. duration: 2000
  475. })
  476. } else {
  477. isLoading.value = true; // 显示遮罩层
  478. loading.value = true
  479. uni.showLoading({
  480. title: '加载中'
  481. });
  482. selection.value.forEach(item => {
  483. item.tenantId = !store.tenantId ? store.userInfo.tenantId : store.tenantId
  484. })
  485. finishQuick(selection.value).then(res => {
  486. uni.hideLoading();
  487. // console.log(res)
  488. if (res.code === 200) {
  489. init()
  490. } else {
  491. // loading.value = false
  492. // uni.hideLoading()
  493. uni.showToast({
  494. icon: 'none',
  495. title: res.msg,
  496. duration: 2000
  497. });
  498. setTimeout(() => {
  499. init()
  500. }, 1500);
  501. }
  502. })
  503. }
  504. })
  505. }
  506. // init();
  507. </script>
  508. <style lang="scss">
  509. $nav-height: 60rpx;
  510. .bottom-btn-container {
  511. position: fixed;
  512. top: 80%;
  513. right: 20rpx;
  514. left: 20rpx;
  515. .start-batch-btn {
  516. margin-bottom: 24rpx;
  517. border-radius: 8rpx;
  518. background-color: #00e2a6;
  519. width: 80%;
  520. }
  521. }
  522. .active {
  523. flex: 1;
  524. height: 40rpx;
  525. background-color: #5e6eff;
  526. border: 1px solid #5e6eff;
  527. color: #000000;
  528. }
  529. .select {
  530. flex: 1;
  531. height: 40rpx;
  532. // font-size: 20rpx;
  533. background-color: #5e6eff;
  534. border: 1px solid #5e6eff;
  535. color: #ffffff;
  536. }
  537. .btn {
  538. position: fixed;
  539. right: 0;
  540. bottom: 0;
  541. left: 0;
  542. height: 100rpx;
  543. padding: 16rpx 24rpx;
  544. align-items: center;
  545. background-color: #FFFFFF;
  546. justify-content: space-between;
  547. .bottom-btn {
  548. flex: 1;
  549. font-size: 28rpx;
  550. color: #FFFFFF;
  551. &.left-btn {
  552. // background-color: #a4adb3;
  553. }
  554. &.right-btn {
  555. background-color: #1684fc;
  556. margin-left: 24rpx;
  557. }
  558. }
  559. }
  560. .box-bg {
  561. width: 100%;
  562. background-color: #F5F5F5;
  563. padding: 5rpx 0;
  564. justify-content: space-around;
  565. align-items: center;
  566. .input-view {
  567. width: 100%;
  568. flex: 4;
  569. background-color: #f8f8f8;
  570. height: $nav-height;
  571. border: 1rpx solid #999;
  572. border-radius: 15rpx;
  573. padding: 0 15rpx;
  574. flex-wrap: nowrap;
  575. margin: 0 10rpx 20rpx;
  576. line-height: $nav-height;
  577. .input-uni-icon {
  578. line-height: $nav-height;
  579. }
  580. .nav-bar-input {
  581. width: 80%;
  582. height: $nav-height;
  583. line-height: $nav-height;
  584. padding: 0 5rpx;
  585. background-color: #f8f8f8;
  586. }
  587. }
  588. .search {
  589. width: 20%;
  590. text-align: center;
  591. color: #808080;
  592. margin-top: -20rpx;
  593. }
  594. }
  595. .list-item {
  596. background-color: #fff;
  597. position: relative;
  598. padding: 16rpx;
  599. padding-bottom: 24rpx;
  600. border-radius: 24rpx;
  601. margin-bottom: 24rpx;
  602. .title-container {
  603. justify-content: space-between;
  604. margin-top: 8rpx;
  605. margin-bottom: 16rpx;
  606. .title {
  607. height: 48rpx;
  608. align-items: center;
  609. .label {
  610. font-size: 32rpx;
  611. font-weight: bold;
  612. &.code {
  613. margin-left: 8rpx;
  614. }
  615. }
  616. }
  617. .tag {
  618. border: 1px solid #1ce5b0;
  619. background-color: #f6fffd;
  620. padding: 8rpx;
  621. border-radius: 8rpx;
  622. .label {
  623. color: #1ce5b0;
  624. font-size: 24rpx;
  625. }
  626. &.not-start {
  627. border: 1px solid #bbbbbb;
  628. background-color: #f5f5f5;
  629. .label {
  630. color: #bbbbbb;
  631. }
  632. }
  633. }
  634. }
  635. .item-info {
  636. margin-bottom: 8rpx;
  637. .label {
  638. font-size: 28rpx;
  639. width: 150rpx;
  640. color: #808080;
  641. &.right {
  642. flex: 1;
  643. color: #000000;
  644. }
  645. }
  646. }
  647. }
  648. .selected {
  649. border: 1rpx solid #c0c4fc;
  650. background-color: #c0c4fc;
  651. /* 选中之后样式 */
  652. }
  653. .mask {
  654. position: fixed;
  655. top: 0;
  656. left: 0;
  657. right: 0;
  658. bottom: 0;
  659. background-color: rgba(0, 0, 0, 0.5);
  660. z-index: 20;
  661. display: flex;
  662. justify-content: center;
  663. align-items: center;
  664. }
  665. .mask .loading-text {
  666. color: #fff;
  667. font-size: 36rpx;
  668. }
  669. </style>