index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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>
  14. <text>{{ normalStatus ? '是' : '否' }}</text>
  15. <switch class="switch" :checked="normalStatus" @change="switchChange" color="rgba(255,85,85,1)" />
  16. </view>
  17. <view class="scroll-container" style="padding-bottom: 150rpx;">
  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. normalStatus.value = true;
  202. init(store.planDetails.id);
  203. }
  204. function handleShowTurnoverApplication(data) {
  205. let _data = data ?? {}
  206. carrierFinishedCheck(data).then(res => {
  207. if (res.code === 200) {
  208. // 调用子组件中的方法
  209. turnoverApplicationDialog.value.open(_data)
  210. } else {
  211. uni.showToast({
  212. icon: 'none',
  213. title: res.msg
  214. })
  215. }
  216. })
  217. // .catch(err => {
  218. // uri.showToast({
  219. // icon: "fail",
  220. // title: "网络请求失败。"
  221. // })
  222. // })
  223. }
  224. function handleStartNewBatch() {
  225. uni.navigateTo({
  226. url: "/pages/addNewBatch/index"
  227. })
  228. }
  229. function init(id) {
  230. uni.showLoading({
  231. title: '加载中'
  232. });
  233. let reqData = {
  234. productionPlanDetailId: id,
  235. deptId: store.curDeptDetails.deptId,
  236. keywords: keywords.value
  237. };
  238. getDayWorkList(reqData).then(res => {
  239. if (res.code == 200) {
  240. tempList.value = res.data
  241. listData.value = res.data.filter(item => {
  242. return item.isWasteRecycling == 0 && item.isAmend == 0;
  243. });
  244. for (let i = 0; i < listData.value.length; i++) {
  245. if (listData.value[i].prevProcess) {
  246. let sum = 0;
  247. for (let j = 0; j < listData.value[i].dayworkItemList.length; j++) {
  248. if (listData.value[i].dayworkItemList[j].processId == listData.value[i].prevProcess
  249. .id && (listData.value[i].dayworkItemList[j].status == 2 || listData.value[i]
  250. .dayworkItemList[j].status == 3)) {
  251. sum += listData.value[i].dayworkItemList[j].qualifiedNum;
  252. }
  253. }
  254. listData.value[i].processQualifiedNum = sum;
  255. }
  256. }
  257. }
  258. uni.hideLoading();
  259. })
  260. }
  261. function handleSearch() {
  262. init(store.planDetails.id);
  263. }
  264. function handleToreportingForWork(item) {
  265. uni.$once("formBack", () => handleSearch())
  266. uni.navigateTo({
  267. url: "/pages/sorting/form",
  268. success: function(res) {
  269. // 通过eventChannel向被打开页面传送数据
  270. res.eventChannel.emit('acceptDataFromOpenerPage', {
  271. data: item
  272. })
  273. }
  274. })
  275. }
  276. function handleClickProcessList(item) {
  277. let curProcessAfterList = [];
  278. console.log(item)
  279. let nextIndex = 0;
  280. for (let i = 0; i < item.processSequence.length; i++) {
  281. if (item.nextProcess.id == item.processSequence[i].id) {
  282. nextIndex = i;
  283. }
  284. }
  285. for (let i = 0; i < item.processSequence.length; i++) {
  286. if (i >= nextIndex) {
  287. curProcessAfterList.push(item.processSequence[i]);
  288. }
  289. }
  290. if (item.status == 3) {
  291. curProcessAfterList.splice(0, 1)
  292. }
  293. console.log(curProcessAfterList)
  294. curProcessAfte.value = curProcessAfterList;
  295. showRight.value.open();
  296. }
  297. function handleSearchCode() {
  298. selectProduction.value.open(normalStatus.value);
  299. }
  300. // function switchChange(event) {
  301. // //异常批
  302. // if (event.detail.value) {
  303. // listData.value = tempList.value.filter(item => {
  304. // return item.isWasteRecycling == 1 || item.isAmend == 1;
  305. // });
  306. // normalStatus.value = 1
  307. // } else {
  308. // listData.value = tempList.value.filter(item => {
  309. // return item.isWasteRecycling == 0 && item.isAmend == 0;
  310. // });
  311. // normalStatus.value = 0
  312. // }
  313. // }
  314. function handleScanCode() {
  315. // 引入原生插件
  316. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  317. // const mpaasScanModule = null
  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. console.log(ret);
  329. let vehicleObj = JSON.parse(ret.resp_result);
  330. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  331. uni.showToast({
  332. icon: "none",
  333. title: "请扫载具码",
  334. duration: 1000
  335. })
  336. return;
  337. }
  338. showDaywork({
  339. carrierId: vehicleObj.carrierId,
  340. status: 7
  341. }).then(response => {
  342. if (response.code == 200) {
  343. // console.log(response)
  344. // console.log(response.data[0].productionPlanDetailId)
  345. // console.log(store.planDetails.id)
  346. if (response.data[0].productionPlanDetailId == store.planDetails.id) {
  347. // console.log(response.data)
  348. lotDialog.value.open(response.data);
  349. } else {
  350. uni.showToast({
  351. icon: 'none',
  352. title: '该批次不在此计划单内',
  353. duration: 2000
  354. })
  355. }
  356. } else {
  357. uni.showToast({
  358. icon: 'none',
  359. title: response.msg,
  360. duration: 2000
  361. })
  362. }
  363. })
  364. }
  365. );
  366. } else {
  367. // 测试时用
  368. showDaywork({
  369. carrierId: '1770342949090017283',
  370. status: 7
  371. }).then(response => {
  372. if (response.code == 200) {
  373. if (response.data[0].productionPlanDetailId == store.planDetails.id) {
  374. console.log(response.data)
  375. lotDialog.value.open(response.data);
  376. } else {
  377. uni.showToast({
  378. icon: 'none',
  379. title: '该批次不在此计划单内',
  380. duration: 2000
  381. })
  382. }
  383. } else {
  384. console.log(response)
  385. uni.showToast({
  386. icon: 'none',
  387. title: response.msg,
  388. duration: 2000
  389. })
  390. }
  391. })
  392. }
  393. }
  394. // function handleScanCode() {
  395. // uni.scanCode({
  396. // onlyFromCamera: true,
  397. // success: function (res) {
  398. // if (res.scanType !== 'QR_CODE') {
  399. // uni.showToast({
  400. // icon: 'none',
  401. // title: '二维码未识别成功',
  402. // duration: 2000
  403. // })
  404. // }
  405. // console.log('条码类型:' + res.scanType);
  406. // console.log('条码内容:' + res.result);
  407. // }
  408. // });
  409. // }
  410. function handleAddDaywork(data) {
  411. console.log(data)
  412. let reqParam = [];
  413. for (var i = 0; i < data.length; i++) {
  414. reqParam.push(data[i].daywork)
  415. }
  416. console.log(data)
  417. showDayworkSave(data).then(res => {
  418. console.log(res)
  419. init(store.planDetails.id);
  420. })
  421. }
  422. function handleDoIt(data) {
  423. handleAddDaywork(data);
  424. }
  425. function handleDoTurnoverAfter() {
  426. reflush();
  427. }
  428. function switchChange(event) {
  429. console.log(event)
  430. //异常批
  431. if (normalStatus.value) {
  432. listData.value = tempList.value.filter(item => {
  433. return item.isWasteRecycling == 1 || item.isAmend == 1;
  434. });
  435. normalStatus.value = false
  436. } else {
  437. listData.value = tempList.value.filter(item => {
  438. return item.isWasteRecycling == 0 && item.isAmend == 0;
  439. });
  440. normalStatus.value = true
  441. }
  442. }
  443. function handleCancelTurnover(data) {
  444. turnoverDelete(data).then(res => {
  445. if (res.code == 200) {
  446. uni.showToast({
  447. icon: "success",
  448. title: "取消成功",
  449. duration: 2000
  450. })
  451. init(store.planDetails.id);
  452. } else {
  453. uni.showToast({
  454. icon: "none",
  455. title: "取消失败",
  456. duration: 2000
  457. })
  458. }
  459. })
  460. }
  461. </script>
  462. <style lang="scss">
  463. $nav-height: 60rpx;
  464. .box-bg {
  465. width: 94%;
  466. background-color: #F5F5F5;
  467. padding: 5rpx 16rpx;
  468. justify-content: space-around;
  469. align-items: center;
  470. margin: 24rpx auto 0;
  471. .input-view {
  472. width: 100%;
  473. flex: 4;
  474. background-color: #f8f8f8;
  475. height: $nav-height;
  476. border: 1rpx solid #999;
  477. border-radius: 15rpx;
  478. padding: 0 15rpx;
  479. flex-wrap: nowrap;
  480. margin: 0 10rpx 0;
  481. line-height: $nav-height;
  482. .input-uni-icon {
  483. line-height: $nav-height;
  484. }
  485. .nav-bar-input {
  486. width: 80%;
  487. height: $nav-height;
  488. line-height: $nav-height;
  489. padding: 0 5rpx;
  490. background-color: #f8f8f8;
  491. }
  492. }
  493. .search {
  494. width: 20%;
  495. text-align: center;
  496. color: #808080;
  497. }
  498. }
  499. .list-title {
  500. width: 100%;
  501. margin-top: 16rpx;
  502. height: 64rpx;
  503. line-height: 64rpx;
  504. align-items: center;
  505. margin-left: 32rpx;
  506. .label {
  507. font-size: 32rpx;
  508. margin-right: 24rpx;
  509. }
  510. .icon-gear {
  511. font-size: 56rpx;
  512. }
  513. }
  514. .switch {
  515. margin-top: -8rpx;
  516. transform: scale(0.7);
  517. }
  518. .scroll-container {
  519. width: 92%;
  520. margin: 24rpx auto 0 auto;
  521. height: calc(90% - 100rpx);
  522. overflow: auto;
  523. }
  524. .list-item {
  525. background-color: #fff;
  526. position: relative;
  527. padding: 16rpx;
  528. padding-bottom: 24rpx;
  529. margin-bottom: 24rpx;
  530. border-radius: 24rpx;
  531. .title-container {
  532. margin-top: 8rpx;
  533. margin-bottom: 16rpx;
  534. .title {
  535. height: 48rpx;
  536. align-items: center;
  537. .label {
  538. font-size: 32rpx;
  539. font-weight: bold;
  540. &.code {
  541. margin-left: 8rpx;
  542. }
  543. }
  544. }
  545. .tag {
  546. border: 1px solid #1CE5B0;
  547. background-color: #F6FFFD;
  548. padding: 8rpx;
  549. border-radius: 8rpx;
  550. .label {
  551. color: #1CE5B0;
  552. font-size: 24rpx;
  553. }
  554. &.finished {
  555. border: 1px solid #BBBBBB;
  556. background-color: #F5F5F5;
  557. .label {
  558. color: #BBBBBB;
  559. }
  560. }
  561. &.turnover {
  562. border: 1px solid #FF7901;
  563. background-color: #F6FFFD;
  564. .label {
  565. color: #FF7901;
  566. }
  567. }
  568. }
  569. }
  570. .item-info {
  571. margin-bottom: 8rpx;
  572. .label {
  573. font-size: 28rpx;
  574. width: 220rpx;
  575. color: #808080;
  576. &.right {
  577. flex: 1;
  578. color: #000000;
  579. }
  580. }
  581. }
  582. .status-btn {
  583. justify-content: flex-end;
  584. align-items: center;
  585. .turnover-tag {
  586. padding-right: 12rpx;
  587. padding-left: 12rpx;
  588. border-radius: 8rpx;
  589. border: 1rpx solid #FF7901;
  590. background-color: #FF7901;
  591. font-size: 28rpx;
  592. color: #FFFFFF;
  593. }
  594. .reporting-tag {
  595. padding-right: 12rpx;
  596. padding-left: 12rpx;
  597. border-radius: 8rpx;
  598. margin-left: 16rpx;
  599. border: 1rpx solid #1684fc;
  600. background-color: #1684fc;
  601. font-size: 28rpx;
  602. color: #FFFFFF;
  603. }
  604. }
  605. }
  606. .bottom {
  607. height: 10%;
  608. position: fixed;
  609. right: 0;
  610. bottom: 0;
  611. left: 0;
  612. height: 100rpx;
  613. border-top: 1px solid #999999;
  614. padding: 16rpx 32rpx;
  615. align-items: center;
  616. background-color: #fff;
  617. justify-content: space-evenly;
  618. .start-batch-btn {
  619. flex: 1;
  620. height: 80rpx;
  621. line-height: 80rpx;
  622. border-radius: 8rpx;
  623. color: #FFFFFF;
  624. font-size: 28rpx;
  625. }
  626. }
  627. </style>