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. console.log(event.detail.value)
  300. //异常批
  301. if (event.detail.value) {
  302. listData.value = tempList.value.filter(item => {
  303. return item.isWasteRecycling == 1 || item.isAmend == 1;
  304. });
  305. normalStatus.value = 1
  306. } else {
  307. listData.value = tempList.value.filter(item => {
  308. return item.isWasteRecycling == 0 && item.isAmend == 0;
  309. });
  310. normalStatus.value = 0
  311. }
  312. }
  313. function handleScanCode() {
  314. // 引入原生插件
  315. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  316. // const mpaasScanModule = null
  317. if (mpaasScanModule) {
  318. // 调用插件的 mpaasScan 方法
  319. mpaasScanModule.mpaasScan({
  320. // 扫码识别类型,参数可多选,qrCode、barCode,
  321. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  322. scanType: ["qrCode", "barCode"],
  323. // 是否隐藏相册,默认false不隐藏
  324. hideAlbum: false,
  325. },
  326. (ret) => {
  327. console.log(ret);
  328. let vehicleObj = JSON.parse(ret.resp_result);
  329. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  330. uni.showToast({
  331. icon: "none",
  332. title: "请扫载具码",
  333. duration: 1000
  334. })
  335. return;
  336. }
  337. showDaywork({
  338. carrierId: vehicleObj.carrierId,
  339. status: 7
  340. }).then(response => {
  341. if (response.code == 200) {
  342. console.log(response)
  343. console.log(response.data[0].productionPlanDetailId)
  344. console.log(store.planDetails.id)
  345. if (response.data[0].productionPlanDetailId == store.planDetails.id) {
  346. console.log(response.data)
  347. lotDialog.value.open(response.data);
  348. } else {
  349. uni.showToast({
  350. icon: 'none',
  351. title: '该批次不在此计划单内',
  352. duration: 2000
  353. })
  354. }
  355. } else {
  356. uni.showToast({
  357. icon: 'none',
  358. title: response.msg,
  359. duration: 2000
  360. })
  361. }
  362. })
  363. }
  364. );
  365. } else {
  366. // 测试时用
  367. showDaywork({
  368. carrierId: '1770342949090017283',
  369. status: 7
  370. }).then(response => {
  371. if (response.code == 200) {
  372. if (response.data[0].productionPlanDetailId == store.planDetails.id) {
  373. console.log(response.data)
  374. lotDialog.value.open(response.data);
  375. } else {
  376. uni.showToast({
  377. icon: 'none',
  378. title: '该批次不在此计划单内',
  379. duration: 2000
  380. })
  381. }
  382. } else {
  383. console.log(response)
  384. uni.showToast({
  385. icon: 'none',
  386. title: response.msg,
  387. duration: 2000
  388. })
  389. }
  390. })
  391. }
  392. }
  393. // function handleScanCode() {
  394. // uni.scanCode({
  395. // onlyFromCamera: true,
  396. // success: function (res) {
  397. // if (res.scanType !== 'QR_CODE') {
  398. // uni.showToast({
  399. // icon: 'none',
  400. // title: '二维码未识别成功',
  401. // duration: 2000
  402. // })
  403. // }
  404. // console.log('条码类型:' + res.scanType);
  405. // console.log('条码内容:' + res.result);
  406. // }
  407. // });
  408. // }
  409. function handleAddDaywork(data) {
  410. console.log(data)
  411. let reqParam = [];
  412. for (var i = 0; i < data.length; i++) {
  413. reqParam.push(data[i].daywork)
  414. }
  415. console.log(data)
  416. showDayworkSave(data).then(res => {
  417. console.log(res)
  418. init(store.planDetails.id);
  419. })
  420. }
  421. function handleDoIt(data) {
  422. handleAddDaywork(data);
  423. }
  424. function handleDoTurnoverAfter() {
  425. reflush();
  426. }
  427. function handleCancelTurnover(data) {
  428. turnoverDelete(data).then(res => {
  429. if (res.code == 200) {
  430. uni.showToast({
  431. icon: "success",
  432. title: "取消成功",
  433. duration: 2000
  434. })
  435. init(store.planDetails.id);
  436. } else {
  437. uni.showToast({
  438. icon: "none",
  439. title: "取消失败",
  440. duration: 2000
  441. })
  442. }
  443. })
  444. }
  445. </script>
  446. <style lang="scss">
  447. $nav-height: 60rpx;
  448. .box-bg {
  449. width: 94%;
  450. background-color: #F5F5F5;
  451. padding: 5rpx 16rpx;
  452. justify-content: space-around;
  453. align-items: center;
  454. margin: 24rpx auto 0;
  455. .input-view {
  456. width: 100%;
  457. flex: 4;
  458. background-color: #f8f8f8;
  459. height: $nav-height;
  460. border: 1rpx solid #999;
  461. border-radius: 15rpx;
  462. padding: 0 15rpx;
  463. flex-wrap: nowrap;
  464. margin: 0 10rpx 0;
  465. line-height: $nav-height;
  466. .input-uni-icon {
  467. line-height: $nav-height;
  468. }
  469. .nav-bar-input {
  470. width: 80%;
  471. height: $nav-height;
  472. line-height: $nav-height;
  473. padding: 0 5rpx;
  474. background-color: #f8f8f8;
  475. }
  476. }
  477. .search {
  478. width: 20%;
  479. text-align: center;
  480. color: #808080;
  481. }
  482. }
  483. .list-title {
  484. width: 100%;
  485. margin-top: 16rpx;
  486. height: 64rpx;
  487. line-height: 64rpx;
  488. align-items: center;
  489. margin-left: 32rpx;
  490. .label {
  491. font-size: 32rpx;
  492. margin-right: 24rpx;
  493. }
  494. .icon-gear {
  495. font-size: 56rpx;
  496. }
  497. }
  498. .switch {
  499. margin-top: -8rpx;
  500. transform: scale(0.7);
  501. }
  502. .scroll-container {
  503. width: 92%;
  504. margin: 24rpx auto 0 auto;
  505. height: calc(90% - 100rpx);
  506. overflow: auto;
  507. }
  508. .list-item {
  509. background-color: #fff;
  510. position: relative;
  511. padding: 16rpx;
  512. padding-bottom: 24rpx;
  513. margin-bottom: 24rpx;
  514. border-radius: 24rpx;
  515. .title-container {
  516. margin-top: 8rpx;
  517. margin-bottom: 16rpx;
  518. .title {
  519. height: 48rpx;
  520. align-items: center;
  521. .label {
  522. font-size: 32rpx;
  523. font-weight: bold;
  524. &.code {
  525. margin-left: 8rpx;
  526. }
  527. }
  528. }
  529. .tag {
  530. border: 1px solid #1CE5B0;
  531. background-color: #F6FFFD;
  532. padding: 8rpx;
  533. border-radius: 8rpx;
  534. .label {
  535. color: #1CE5B0;
  536. font-size: 24rpx;
  537. }
  538. &.finished {
  539. border: 1px solid #BBBBBB;
  540. background-color: #F5F5F5;
  541. .label {
  542. color: #BBBBBB;
  543. }
  544. }
  545. &.turnover {
  546. border: 1px solid #FF7901;
  547. background-color: #F6FFFD;
  548. .label {
  549. color: #FF7901;
  550. }
  551. }
  552. }
  553. }
  554. .item-info {
  555. margin-bottom: 8rpx;
  556. .label {
  557. font-size: 28rpx;
  558. width: 220rpx;
  559. color: #808080;
  560. &.right {
  561. flex: 1;
  562. color: #000000;
  563. }
  564. }
  565. }
  566. .status-btn {
  567. justify-content: flex-end;
  568. align-items: center;
  569. .turnover-tag {
  570. padding-right: 12rpx;
  571. padding-left: 12rpx;
  572. border-radius: 8rpx;
  573. border: 1rpx solid #FF7901;
  574. background-color: #FF7901;
  575. font-size: 28rpx;
  576. color: #FFFFFF;
  577. }
  578. .reporting-tag {
  579. padding-right: 12rpx;
  580. padding-left: 12rpx;
  581. border-radius: 8rpx;
  582. margin-left: 16rpx;
  583. border: 1rpx solid #1684fc;
  584. background-color: #1684fc;
  585. font-size: 28rpx;
  586. color: #FFFFFF;
  587. }
  588. }
  589. }
  590. .bottom {
  591. height: 10%;
  592. position: fixed;
  593. right: 0;
  594. bottom: 0;
  595. left: 0;
  596. height: 100rpx;
  597. border-top: 1px solid #999999;
  598. padding: 16rpx 32rpx;
  599. align-items: center;
  600. background-color: #fff;
  601. justify-content: space-evenly;
  602. .start-batch-btn {
  603. flex: 1;
  604. height: 80rpx;
  605. line-height: 80rpx;
  606. border-radius: 8rpx;
  607. color: #FFFFFF;
  608. font-size: 28rpx;
  609. }
  610. }
  611. </style>