index.vue 18 KB

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