index.vue 14 KB

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