index.vue 16 KB

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