index.vue 18 KB

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