index.vue 17 KB

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