index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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['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;">工艺列表</view>
  101. <view style="font-size: 24rpx;width: 100%;text-align: center;color: red;margin-bottom: 48rpx;">仅显示当前工序后面工艺</view>
  102. <view class="info-content" v-for="(item,index) in curProcessAfte" :key="index"
  103. style="width: 100%;margin: 8rpx 0 8rpx 14%;"
  104. >
  105. <text>{{ index + 1 }}.{{item.processAlias}}</text>
  106. </view>
  107. </scroll-view>
  108. </view>
  109. </uni-drawer>
  110. </view>
  111. <!-- <view v-if="bottomStatus" class="bottom uni-row">
  112. <button class="start-batch-btn" type="primary" @click="handleStartNewBatch">开始新批次</button>
  113. </view>
  114. <view v-if="!bottomStatus" class="bottom uni-row">
  115. <button class="start-batch-btn" type="primary" @click="handleScanCode">扫一扫开始新批次</button>
  116. </view> -->
  117. <view class="bottom uni-row">
  118. <button v-if="bottomStatus" class="start-batch-btn" style="margin-right: 10rpx;" type="primary"
  119. @click="handleStartNewBatch">开始新批次</button>
  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" @confirm="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. store
  148. } from '@/store/index.js'
  149. import {
  150. toHHmmss
  151. } from '@/utils/common.js'
  152. const turnoverApplicationDialog = ref(null)
  153. const selectProduction = ref(null)
  154. const lotDialog = ref(null)
  155. const listData = ref([])
  156. const curPlan = ref(null)
  157. const bizDayworkObj = ref({})
  158. const bottomStatus = ref(false) // 底部按钮显示
  159. const reqParam = ref(null);
  160. const curDayworkItem = ref({}) // 当前报工记录,回显是否显示取消周转的状态
  161. const keywords = ref(null)
  162. const notPreProcess = ref(true)
  163. const curProcessAfte = ref([])
  164. const showRight = ref(null) // 抽屉
  165. onLoad(() => {
  166. curPlan.value = store.planDetails;
  167. console.log(curPlan.value)
  168. if (store.planDetails.requisitionDepartmentId == store.curDeptDetails.deptId) {
  169. bottomStatus.value = true;
  170. store.isPreProcess = true;
  171. } else {
  172. bottomStatus.value = false;
  173. store.isPreProcess = false;
  174. }
  175. console.log(bottomStatus.value)
  176. //init(store.planDetails.id);
  177. // uni.$on('batchReporting-addBatch', () => {
  178. // init(store.planDetails.id);
  179. // })
  180. // uni.$on('dayworkItemUpdate', reflush)
  181. uni.$on('bathReportingReflush', reflush)
  182. })
  183. onUnload(() => {
  184. // uni.$off('dayworkItemUpdate', reflush);
  185. // uni.$off('bathReportingReflush', reflush);
  186. })
  187. onShow(() => {
  188. reflush();
  189. })
  190. function reflush() {
  191. init(store.planDetails.id);
  192. }
  193. function handleShowTurnoverApplication(data) {
  194. let _data = data ?? {}
  195. // 调用子组件中的方法
  196. turnoverApplicationDialog.value.open(_data)
  197. }
  198. function handleStartNewBatch() {
  199. uni.navigateTo({
  200. url: "/pages/addNewBatch/index"
  201. })
  202. }
  203. function init(id) {
  204. uni.showLoading({
  205. title: '加载中'
  206. });
  207. let reqData = {
  208. productionPlanDetailId: id,
  209. deptId: store.curDeptDetails.deptId,
  210. keywords: keywords.value
  211. };
  212. getDayWorkList(reqData).then(res => {
  213. if (res.code == 200) {
  214. listData.value = res.data;
  215. // 计算总工时
  216. // for (let i = 0; i < listData.value.length; i++) {
  217. // listData.value[i].totalWorkingHours = 0;
  218. // if (listData.value[i].dayworkItemList) {
  219. // for (let j = 0; j < listData.value[i].dayworkItemList.length; j++) {
  220. // if (listData.value[i].dayworkItemList[j].status == 2 || listData.value[i].dayworkItemList[
  221. // j].status == 3) {
  222. // listData.value[i].totalWorkingHours += Number(listData.value[i].dayworkItemList[j]
  223. // .workingHours);
  224. // }
  225. // }
  226. // listData.value[i].totalWorkingHours = toHHmmss(listData.value[i].totalWorkingHours);
  227. // }
  228. // }
  229. console.log(res)
  230. uni.hideLoading();
  231. } else {
  232. uni.hideLoading();
  233. }
  234. })
  235. }
  236. function handleSearch() {
  237. init(store.planDetails.id);
  238. }
  239. function handleToreportingForWork(item) {
  240. store.dayworkInfo = item
  241. uni.navigateTo({
  242. url: "/pages/reportingForWork/index"
  243. })
  244. }
  245. function handleClickProcessList(item) {
  246. let curProcessAfterList = [];
  247. let nextIndex = 0;
  248. for (let i = 0; i < item.processSequence.length; i++) {
  249. if (item.nextProcess.id == item.processSequence[i].id) {
  250. nextIndex = i;
  251. }
  252. }
  253. for (let i = 0; i < item.processSequence.length; i++) {
  254. if (i >= nextIndex) {
  255. curProcessAfterList.push(item.processSequence[i]);
  256. }
  257. }
  258. console.log(curProcessAfterList)
  259. curProcessAfte.value = curProcessAfterList;
  260. showRight.value.open();
  261. }
  262. function handleSearchCode() {
  263. selectProduction.value.open();
  264. }
  265. function handleScanCode() {
  266. uni.scanCode({
  267. scanType: ['qrCode'],
  268. onlyFromCamera: true, // 只允许相机扫码
  269. autoZoom: false,
  270. success: function(res) {
  271. console.log(res.result)
  272. let vehicleObj = JSON.parse(res.result);
  273. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  274. uni.showToast({
  275. icon: "error",
  276. title: "请扫载具码",
  277. duration: 1000
  278. })
  279. return;
  280. }
  281. showDaywork({
  282. carrierId: vehicleObj.carrierId,
  283. status: 7
  284. }).then(response => {
  285. if (response.code == 200) {
  286. console.log(response)
  287. console.log(response.data[0].productionPlanDetailId)
  288. console.log(store.planDetails.id)
  289. if (response.data[0].productionPlanDetailId == store.planDetails.id) {
  290. console.log(response.data)
  291. lotDialog.value.open(response.data);
  292. } else {
  293. uni.showToast({
  294. icon: 'none',
  295. title: '该批次不在此计划单内',
  296. duration: 2000
  297. })
  298. }
  299. }
  300. })
  301. }
  302. });
  303. }
  304. function handleAddDaywork(data) {
  305. console.log(data)
  306. let reqParam = [];
  307. for (var i = 0; i < data.length; i++) {
  308. reqParam.push(data[i].daywork)
  309. }
  310. console.log(data)
  311. showDayworkSave(reqParam).then(res => {
  312. console.log(res)
  313. init(store.planDetails.id);
  314. })
  315. }
  316. function handleDoIt(data) {
  317. handleAddDaywork(data);
  318. }
  319. function handleDoTurnoverAfter() {
  320. init(store.planDetails.id);
  321. }
  322. function handleCancelTurnover(data) {
  323. turnoverDelete(data).then(res => {
  324. if (res.code == 200) {
  325. uni.showToast({
  326. icon: "success",
  327. title: "取消成功",
  328. duration: 2000
  329. })
  330. init(store.planDetails.id);
  331. } else {
  332. uni.showToast({
  333. icon: "fail",
  334. title: "取消失败",
  335. duration: 2000
  336. })
  337. }
  338. })
  339. }
  340. </script>
  341. <style lang="scss">
  342. $nav-height: 60rpx;
  343. .box-bg {
  344. width: 94%;
  345. background-color: #F5F5F5;
  346. padding: 5rpx 16rpx;
  347. justify-content: space-around;
  348. align-items: center;
  349. margin: 24rpx auto 0;
  350. .input-view {
  351. width: 100%;
  352. flex: 4;
  353. background-color: #f8f8f8;
  354. height: $nav-height;
  355. border: 1rpx solid #999;
  356. border-radius: 15rpx;
  357. padding: 0 15rpx;
  358. flex-wrap: nowrap;
  359. margin: 0 10rpx 0;
  360. line-height: $nav-height;
  361. .input-uni-icon {
  362. line-height: $nav-height;
  363. }
  364. .nav-bar-input {
  365. width: 80%;
  366. height: $nav-height;
  367. line-height: $nav-height;
  368. padding: 0 5rpx;
  369. background-color: #f8f8f8;
  370. }
  371. }
  372. .search {
  373. width: 20%;
  374. text-align: center;
  375. color: #808080;
  376. }
  377. }
  378. .scroll-container {
  379. width: 92%;
  380. margin: 24rpx auto 0 auto;
  381. height: calc(90% - 100rpx);
  382. overflow: auto;
  383. }
  384. .list-item {
  385. background-color: #fff;
  386. position: relative;
  387. padding: 16rpx;
  388. padding-bottom: 24rpx;
  389. margin-bottom: 24rpx;
  390. border-radius: 24rpx;
  391. .title-container {
  392. margin-top: 8rpx;
  393. margin-bottom: 16rpx;
  394. .title {
  395. height: 48rpx;
  396. align-items: center;
  397. .label {
  398. font-size: 32rpx;
  399. font-weight: bold;
  400. &.code {
  401. margin-left: 8rpx;
  402. }
  403. }
  404. }
  405. .tag {
  406. border: 1px solid #1CE5B0;
  407. background-color: #F6FFFD;
  408. padding: 8rpx;
  409. border-radius: 8rpx;
  410. .label {
  411. color: #1CE5B0;
  412. font-size: 24rpx;
  413. }
  414. &.finished {
  415. border: 1px solid #BBBBBB;
  416. background-color: #F5F5F5;
  417. .label {
  418. color: #BBBBBB;
  419. }
  420. }
  421. &.turnover {
  422. border: 1px solid #FF7901;
  423. background-color: #F6FFFD;
  424. .label {
  425. color: #FF7901;
  426. }
  427. }
  428. }
  429. }
  430. .item-info {
  431. margin-bottom: 8rpx;
  432. .label {
  433. font-size: 28rpx;
  434. width: 220rpx;
  435. color: #808080;
  436. &.right {
  437. flex: 1;
  438. color: #000000;
  439. }
  440. }
  441. }
  442. .status-btn {
  443. justify-content: flex-end;
  444. align-items: center;
  445. .turnover-tag {
  446. padding-right: 12rpx;
  447. padding-left: 12rpx;
  448. border-radius: 8rpx;
  449. border: 1rpx solid #FF7901;
  450. background-color: #FF7901;
  451. font-size: 28rpx;
  452. color: #FFFFFF;
  453. }
  454. .reporting-tag {
  455. padding-right: 12rpx;
  456. padding-left: 12rpx;
  457. border-radius: 8rpx;
  458. margin-left: 16rpx;
  459. border: 1rpx solid #1684fc;
  460. background-color: #1684fc;
  461. font-size: 28rpx;
  462. color: #FFFFFF;
  463. }
  464. }
  465. }
  466. .bottom {
  467. height: 10%;
  468. position: fixed;
  469. right: 0;
  470. bottom: 0;
  471. left: 0;
  472. height: 100rpx;
  473. border-top: 1px solid #999999;
  474. padding: 16rpx 32rpx;
  475. align-items: center;
  476. background-color: #fff;
  477. justify-content: space-evenly;
  478. .start-batch-btn {
  479. flex: 1;
  480. height: 80rpx;
  481. line-height: 80rpx;
  482. border-radius: 8rpx;
  483. color: #FFFFFF;
  484. font-size: 28rpx;
  485. }
  486. }
  487. </style>