index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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="list-title uni-row">
  13. <text class="label">是否正常批次</text><text>是</text>
  14. <switch class="switch" @change="switchChange" color="rgba(255,85,85,1)" />
  15. <text>否</text>
  16. </view>
  17. <view class="scroll-container">
  18. <view v-if="listData.length == 0" style="color: #999;margin: 50% auto;">
  19. <text>暂无批次</text>
  20. </view>
  21. <!-- 批次列表 -->
  22. <view v-else v-for="(item, index) in listData" :key="index" class="list-item"
  23. @click="handleToreportingForWork(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['status'] == 1" class="tag"><text class="label">进行中</text></view>
  31. <view v-else-if="item['status'] == 3" class="tag turnover "><text class="label">周转中</text>
  32. </view>
  33. <view v-else-if="item['status'] == 2" class="tag turnover "><text class="label">待周转</text>
  34. </view>
  35. <view v-else-if="item['status'] == 0" class="tag finished "><text class="label">未开始</text>
  36. </view>
  37. <view v-else-if="item['status'] == 4" type="default finished" class="tag finished"><text
  38. class="label">已完成</text></view>
  39. </view>
  40. </view>
  41. <view class="item-info uni-row">
  42. <text class="label">产品描述</text>
  43. <text class="label right">{{ curPlan['productDescription'] }}</text>
  44. </view>
  45. <view class="item-info uni-row">
  46. <text class="label">材质</text>
  47. <text
  48. class="label right">{{ item['furnaceNoInfo'] ? item['furnaceNoInfo'].firstTechnicalRequirement + ";" + item['furnaceNoInfo'].secondTechnicalRequirement : '-' }}</text>
  49. </view>
  50. <view class="item-info uni-row">
  51. <text class="label">箱号</text>
  52. <text class="label right">{{ item['carrierName'] ? item['carrierName'] : '-' }}</text>
  53. </view>
  54. <!-- <view class="item-info uni-row">
  55. <text class="label">总工时</text>
  56. <text class="label right">{{ item['totalWorkingHours']}}</text>
  57. </view> -->
  58. <view class="item-info uni-row">
  59. <text class="label">投入数</text>
  60. <text
  61. class="label right">{{item['processQualifiedNum'] == 0 ? item['productionQuantity'] : item['processQualifiedNum']}}</text>
  62. </view>
  63. <view class="item-info uni-row">
  64. <text class="label">上道工序</text>
  65. <text class="label right">{{ item.prevProcess ? item['prevProcess'].processAlias : '-'}}</text>
  66. </view>
  67. <view class="item-info uni-row">
  68. <text class="label">当前工序</text>
  69. <text
  70. class="label right">{{ item.currentProcess ? item.prevProcess && item['currentProcess'].processAlias == item['prevProcess'].processAlias ? '-' : item['currentProcess'].processAlias : '-'}}</text>
  71. </view>
  72. <view class="item-info uni-row">
  73. <text class="label">下道工序</text>
  74. <view class="label right uni-row">{{ item.nextProcess ? item['nextProcess'].processAlias : '-' }}
  75. (<view style="color: #1684fc;" @click.stop="handleClickProcessList(item)">&nbsp;工艺列表&nbsp;
  76. </view>)
  77. </view>
  78. </view>
  79. <!-- <view class="item-info uni-row">
  80. <text class="label">设备</text>
  81. <text class="label right">{{ curPlan['equipmentName'] }}</text>
  82. </view> -->
  83. <view v-if="notPreProcess" class="item-info uni-row">
  84. <text class="label">所在区域</text>
  85. <text class="label right">{{ item['place'] ? item['place'] : '-' }}</text>
  86. </view>
  87. <view class="status-btn uni-row">
  88. <view v-if="item['status'] == 2" class=" uni-row">
  89. <button class="turnover-tag" size="mini"
  90. @click.stop="handleShowTurnoverApplication(item)">周转申请</button>
  91. <!-- <button class="reporting-tag" size="mini" @click="handleToreportingForWork">去报工</button> -->
  92. </view>
  93. <view v-else-if="item['status'] == 3" class=" uni-row">
  94. <button class="turnover-tag" size="mini" @click.stop="handleCancelTurnover(item)"
  95. style="background-color: rgba(255, 85, 85, 1);">取消周转</button>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- 抽屉 -->
  101. <uni-drawer ref="showRight" mode="right" :mask-click="true">
  102. <view style="text-align: center; font-size: 48rpx; padding: 48rpx 0 24rpx 0;">工艺列表</view>
  103. <view style="font-size: 24rpx;text-align: center;color: red; margin-bottom: 16rpx;">
  104. 仅显示当前工序后面工艺
  105. </view>
  106. <scroll-view scroll-y="true" style="height: 82%;" @touchmove.stop>
  107. <view v-for="(item,index) in curProcessAfte" :key="index"
  108. style="padding: 8rpx 5% 8rpx 14%; border-top: 1px solid #cccccc">
  109. <text>{{ index + 1 }}.{{item.processAlias}}</text>
  110. </view>
  111. </scroll-view>
  112. </uni-drawer>
  113. <!-- <view v-if="bottomStatus" class="bottom uni-row">
  114. <button class="start-batch-btn" type="primary" @click="handleStartNewBatch">开始新批次</button>
  115. </view>
  116. <view v-if="!bottomStatus" class="bottom uni-row">
  117. <button class="start-batch-btn" type="primary" @click="handleScanCode">扫一扫开始新批次</button>
  118. </view> -->
  119. <view class="bottom uni-row">
  120. <button class="start-batch-btn" style="margin-right: 10rpx;" type="primary"
  121. @click="handleScanCode">扫码开始批次</button>
  122. <button class="start-batch-btn" type="primary" @click="handleSearchCode">查箱号</button>
  123. </view>
  124. <dialog-lot ref="lotDialog" @submit="handleDoIt" />
  125. <dialog-turnoverApplication ref="turnoverApplicationDialog" @reflushDaywork="handleDoTurnoverAfter" />
  126. <dialog-selectProduction ref="selectProduction"></dialog-selectProduction>
  127. </view>
  128. </template>
  129. <script setup>
  130. import {
  131. reactive,
  132. ref
  133. } from 'vue'
  134. import {
  135. onLoad,
  136. onReady,
  137. onUnload,
  138. onShow
  139. } from '@dcloudio/uni-app'
  140. import {
  141. getDayWorkList,
  142. showDaywork,
  143. showDayworkSave,
  144. turnoverDelete
  145. } from '@/api/business/dayWork.js'
  146. import {
  147. getAbnormalityLot
  148. } from '@/api/business/lot.js'
  149. import {
  150. carrierFinishedCheck
  151. } from '@/api/business/carrier.js'
  152. import {
  153. store
  154. } from '@/store/index.js'
  155. import {
  156. toHHmmss
  157. } from '@/utils/common.js'
  158. const turnoverApplicationDialog = ref(null)
  159. const selectProduction = ref(null)
  160. const lotDialog = ref(null)
  161. const listData = ref([])
  162. const curPlan = ref(null)
  163. const bizDayworkObj = ref({})
  164. const bottomStatus = ref(false) // 底部按钮显示
  165. const reqParam = ref(null);
  166. const normalStatus = ref(0)
  167. const curDayworkItem = ref({}) // 当前报工记录,回显是否显示取消周转的状态
  168. const keywords = ref(null)
  169. const tempList = ref([])
  170. const wasteRecyclingList = ref([]) //废品回用批次
  171. const notPreProcess = ref(true)
  172. const curProcessAfte = ref([])
  173. const showRight = ref(null) // 抽屉
  174. onLoad(() => {
  175. curPlan.value = store.planDetails;
  176. normalStatus.value = 0
  177. console.log(curPlan.value)
  178. //废品回用的领料部门如果是当前工段,也要可以开始新批次
  179. //查找当前计划单下的批次废品回用是当前工段
  180. getAbnormalityLot({
  181. productionPlanDetailId: store.planDetails.id,
  182. requisitionDepartmentId: store.curDeptDetails.deptId
  183. }).then(res => {
  184. wasteRecyclingList.value = res.rows
  185. console.log(wasteRecyclingList.value.length)
  186. if (store.planDetails.requisitionDepartmentId == store.curDeptDetails.deptId ||
  187. wasteRecyclingList.value.length > 0) {
  188. bottomStatus.value = true;
  189. store.isPreProcess = true;
  190. } else {
  191. bottomStatus.value = false;
  192. store.isPreProcess = false;
  193. }
  194. })
  195. console.log(wasteRecyclingList.value.length)
  196. })
  197. onShow(() => {
  198. reflush();
  199. })
  200. function reflush() {
  201. init(store.planDetails.id);
  202. }
  203. function handleShowTurnoverApplication(data) {
  204. let _data = data ?? {}
  205. carrierFinishedCheck(data).then(res => {
  206. if (res.code === 200) {
  207. // 调用子组件中的方法
  208. turnoverApplicationDialog.value.open(_data)
  209. } else {
  210. uni.showToast({
  211. icon: 'none',
  212. title: res.msg
  213. })
  214. }
  215. })
  216. // .catch(err => {
  217. // uri.showToast({
  218. // icon: "fail",
  219. // title: "网络请求失败。"
  220. // })
  221. // })
  222. }
  223. function handleStartNewBatch() {
  224. uni.navigateTo({
  225. url: "/pages/addNewBatch/index"
  226. })
  227. }
  228. function init(id) {
  229. uni.showLoading({
  230. title: '加载中'
  231. });
  232. let reqData = {
  233. productionPlanDetailId: id,
  234. deptId: store.curDeptDetails.deptId,
  235. keywords: keywords.value
  236. };
  237. getDayWorkList(reqData).then(res => {
  238. if (res.code == 200) {
  239. tempList.value = res.data
  240. listData.value = res.data.filter(item => {
  241. return item.isWasteRecycling == 0 && item.isAmend == 0;
  242. });
  243. for (let i = 0; i < listData.value.length; i++) {
  244. if (listData.value[i].prevProcess) {
  245. let sum = 0;
  246. for (let j = 0; j < listData.value[i].dayworkItemList.length; j++) {
  247. if (listData.value[i].dayworkItemList[j].processId == listData.value[i].prevProcess
  248. .id && (listData.value[i].dayworkItemList[j].status == 2 || listData.value[i]
  249. .dayworkItemList[j].status == 3)) {
  250. sum += listData.value[i].dayworkItemList[j].qualifiedNum;
  251. }
  252. }
  253. listData.value[i].processQualifiedNum = sum;
  254. }
  255. }
  256. }
  257. uni.hideLoading();
  258. })
  259. }
  260. function handleSearch() {
  261. init(store.planDetails.id);
  262. }
  263. function handleToreportingForWork(item) {
  264. uni.navigateTo({
  265. url: "/pages/sorting/form",
  266. success: function(res) {
  267. // 通过eventChannel向被打开页面传送数据
  268. res.eventChannel.emit('acceptDataFromOpenerPage', {
  269. data: item
  270. })
  271. }
  272. })
  273. }
  274. function handleClickProcessList(item) {
  275. let curProcessAfterList = [];
  276. console.log(item)
  277. let nextIndex = 0;
  278. for (let i = 0; i < item.processSequence.length; i++) {
  279. if (item.nextProcess.id == item.processSequence[i].id) {
  280. nextIndex = i;
  281. }
  282. }
  283. for (let i = 0; i < item.processSequence.length; i++) {
  284. if (i >= nextIndex) {
  285. curProcessAfterList.push(item.processSequence[i]);
  286. }
  287. }
  288. if (item.status == 3) {
  289. curProcessAfterList.splice(0, 1)
  290. }
  291. console.log(curProcessAfterList)
  292. curProcessAfte.value = curProcessAfterList;
  293. showRight.value.open();
  294. }
  295. function handleSearchCode() {
  296. selectProduction.value.open(normalStatus.value);
  297. }
  298. function switchChange(event) {
  299. //异常批
  300. if (event.detail.value) {
  301. listData.value = tempList.value.filter(item => {
  302. return item.isWasteRecycling == 1 || item.isAmend == 1;
  303. });
  304. normalStatus.value = 1
  305. } else {
  306. listData.value = tempList.value.filter(item => {
  307. return item.isWasteRecycling == 0 && item.isAmend == 0;
  308. });
  309. normalStatus.value = 0
  310. }
  311. }
  312. function handleScanCode() {
  313. // 引入原生插件
  314. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  315. // const mpaasScanModule = null
  316. if (mpaasScanModule) {
  317. // 调用插件的 mpaasScan 方法
  318. mpaasScanModule.mpaasScan({
  319. // 扫码识别类型,参数可多选,qrCode、barCode,
  320. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  321. scanType: ["qrCode", "barCode"],
  322. // 是否隐藏相册,默认false不隐藏
  323. hideAlbum: false,
  324. },
  325. (ret) => {
  326. console.log(ret);
  327. let vehicleObj = JSON.parse(ret.resp_result);
  328. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  329. uni.showToast({
  330. icon: "none",
  331. title: "请扫载具码",
  332. duration: 1000
  333. })
  334. return;
  335. }
  336. showDaywork({
  337. carrierId: vehicleObj.carrierId,
  338. status: 7
  339. }).then(response => {
  340. if (response.code == 200) {
  341. // console.log(response)
  342. // console.log(response.data[0].productionPlanDetailId)
  343. // console.log(store.planDetails.id)
  344. if (response.data[0].productionPlanDetailId == store.planDetails.id) {
  345. // console.log(response.data)
  346. lotDialog.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. showDaywork({
  367. carrierId: '1770342949090017283',
  368. status: 7
  369. }).then(response => {
  370. if (response.code == 200) {
  371. if (response.data[0].productionPlanDetailId == store.planDetails.id) {
  372. console.log(response.data)
  373. lotDialog.value.open(response.data);
  374. } else {
  375. uni.showToast({
  376. icon: 'none',
  377. title: '该批次不在此计划单内',
  378. duration: 2000
  379. })
  380. }
  381. } else {
  382. console.log(response)
  383. uni.showToast({
  384. icon: 'none',
  385. title: response.msg,
  386. duration: 2000
  387. })
  388. }
  389. })
  390. }
  391. }
  392. // function handleScanCode() {
  393. // uni.scanCode({
  394. // onlyFromCamera: true,
  395. // success: function (res) {
  396. // if (res.scanType !== 'QR_CODE') {
  397. // uni.showToast({
  398. // icon: 'none',
  399. // title: '二维码未识别成功',
  400. // duration: 2000
  401. // })
  402. // }
  403. // console.log('条码类型:' + res.scanType);
  404. // console.log('条码内容:' + res.result);
  405. // }
  406. // });
  407. // }
  408. function handleAddDaywork(data) {
  409. console.log(data)
  410. let reqParam = [];
  411. for (var i = 0; i < data.length; i++) {
  412. reqParam.push(data[i].daywork)
  413. }
  414. console.log(data)
  415. showDayworkSave(data).then(res => {
  416. console.log(res)
  417. init(store.planDetails.id);
  418. })
  419. }
  420. function handleDoIt(data) {
  421. handleAddDaywork(data);
  422. }
  423. function handleDoTurnoverAfter() {
  424. reflush();
  425. }
  426. function handleCancelTurnover(data) {
  427. turnoverDelete(data).then(res => {
  428. if (res.code == 200) {
  429. uni.showToast({
  430. icon: "success",
  431. title: "取消成功",
  432. duration: 2000
  433. })
  434. init(store.planDetails.id);
  435. } else {
  436. uni.showToast({
  437. icon: "none",
  438. title: "取消失败",
  439. duration: 2000
  440. })
  441. }
  442. })
  443. }
  444. </script>
  445. <style lang="scss">
  446. $nav-height: 60rpx;
  447. .box-bg {
  448. width: 94%;
  449. background-color: #F5F5F5;
  450. padding: 5rpx 16rpx;
  451. justify-content: space-around;
  452. align-items: center;
  453. margin: 24rpx auto 0;
  454. .input-view {
  455. width: 100%;
  456. flex: 4;
  457. background-color: #f8f8f8;
  458. height: $nav-height;
  459. border: 1rpx solid #999;
  460. border-radius: 15rpx;
  461. padding: 0 15rpx;
  462. flex-wrap: nowrap;
  463. margin: 0 10rpx 0;
  464. line-height: $nav-height;
  465. .input-uni-icon {
  466. line-height: $nav-height;
  467. }
  468. .nav-bar-input {
  469. width: 80%;
  470. height: $nav-height;
  471. line-height: $nav-height;
  472. padding: 0 5rpx;
  473. background-color: #f8f8f8;
  474. }
  475. }
  476. .search {
  477. width: 20%;
  478. text-align: center;
  479. color: #808080;
  480. }
  481. }
  482. .list-title {
  483. width: 100%;
  484. margin-top: 16rpx;
  485. height: 64rpx;
  486. line-height: 64rpx;
  487. align-items: center;
  488. margin-left: 32rpx;
  489. .label {
  490. font-size: 32rpx;
  491. margin-right: 24rpx;
  492. }
  493. .icon-gear {
  494. font-size: 56rpx;
  495. }
  496. }
  497. .switch {
  498. margin-top: -8rpx;
  499. transform: scale(0.7);
  500. }
  501. .scroll-container {
  502. width: 92%;
  503. margin: 24rpx auto 0 auto;
  504. height: calc(90% - 100rpx);
  505. overflow: auto;
  506. }
  507. .list-item {
  508. background-color: #fff;
  509. position: relative;
  510. padding: 16rpx;
  511. padding-bottom: 24rpx;
  512. margin-bottom: 24rpx;
  513. border-radius: 24rpx;
  514. .title-container {
  515. margin-top: 8rpx;
  516. margin-bottom: 16rpx;
  517. .title {
  518. height: 48rpx;
  519. align-items: center;
  520. .label {
  521. font-size: 32rpx;
  522. font-weight: bold;
  523. &.code {
  524. margin-left: 8rpx;
  525. }
  526. }
  527. }
  528. .tag {
  529. border: 1px solid #1CE5B0;
  530. background-color: #F6FFFD;
  531. padding: 8rpx;
  532. border-radius: 8rpx;
  533. .label {
  534. color: #1CE5B0;
  535. font-size: 24rpx;
  536. }
  537. &.finished {
  538. border: 1px solid #BBBBBB;
  539. background-color: #F5F5F5;
  540. .label {
  541. color: #BBBBBB;
  542. }
  543. }
  544. &.turnover {
  545. border: 1px solid #FF7901;
  546. background-color: #F6FFFD;
  547. .label {
  548. color: #FF7901;
  549. }
  550. }
  551. }
  552. }
  553. .item-info {
  554. margin-bottom: 8rpx;
  555. .label {
  556. font-size: 28rpx;
  557. width: 220rpx;
  558. color: #808080;
  559. &.right {
  560. flex: 1;
  561. color: #000000;
  562. }
  563. }
  564. }
  565. .status-btn {
  566. justify-content: flex-end;
  567. align-items: center;
  568. .turnover-tag {
  569. padding-right: 12rpx;
  570. padding-left: 12rpx;
  571. border-radius: 8rpx;
  572. border: 1rpx solid #FF7901;
  573. background-color: #FF7901;
  574. font-size: 28rpx;
  575. color: #FFFFFF;
  576. }
  577. .reporting-tag {
  578. padding-right: 12rpx;
  579. padding-left: 12rpx;
  580. border-radius: 8rpx;
  581. margin-left: 16rpx;
  582. border: 1rpx solid #1684fc;
  583. background-color: #1684fc;
  584. font-size: 28rpx;
  585. color: #FFFFFF;
  586. }
  587. }
  588. }
  589. .bottom {
  590. height: 10%;
  591. position: fixed;
  592. right: 0;
  593. bottom: 0;
  594. left: 0;
  595. height: 100rpx;
  596. border-top: 1px solid #999999;
  597. padding: 16rpx 32rpx;
  598. align-items: center;
  599. background-color: #fff;
  600. justify-content: space-evenly;
  601. .start-batch-btn {
  602. flex: 1;
  603. height: 80rpx;
  604. line-height: 80rpx;
  605. border-radius: 8rpx;
  606. color: #FFFFFF;
  607. font-size: 28rpx;
  608. }
  609. }
  610. </style>