index.vue 18 KB

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