index.vue 16 KB

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