index.vue 16 KB

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