index.vue 18 KB

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