index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <view class="uni-column container">
  3. <view class="scroll-container">
  4. <view v-for="(item, index) in listData" :key="index" class="list-item">
  5. <view class="title-container">
  6. <view class="title uni-row">
  7. <view class="uni-row">
  8. <text class="label">批次号:</text>
  9. <text class="label code"> {{ item['lotCode'] }}</text>
  10. </view>
  11. <view style="color: #1684fc; margin-right: 0;" @click="handleOpenLonInfo">
  12. <text>批次详情</text>
  13. </view>
  14. </view>
  15. <view class="uni-row">
  16. <view class="right-info uni-row"> <text class="label">工时</text>
  17. <text class="label time">{{ item['taskTime'] }}</text>
  18. <!-- <text class="label time">{{ item['taskTime'] }}h</text> -->
  19. </view>
  20. <view class="right-info uni-row" style="margin-left: 50rpx;"> <text class="label">合格数</text>
  21. <text class="label number ">{{ item['qualifiedNum'] }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="item-info uni-row">
  26. <text class="label">产品描述</text>
  27. <text class="label right">{{ curPlan['productDescription'] }}</text>
  28. </view>
  29. <view class="item-info uni-row">
  30. <text class="label">操作者</text>
  31. <text class="label right">{{ item['nickName'] }}</text>
  32. </view>
  33. <view class="item-info uni-row">
  34. <text class="label">开始时间</text>
  35. <text class="label right">{{ item['startTime'] ? item['startTime'] : '-' }}</text>
  36. </view>
  37. <view class="item-info uni-row">
  38. <text class="label">结束时间</text>
  39. <text class="label right">{{ item['endTime'] ? item['endTime'] : '-' }}</text>
  40. </view>
  41. <view class="item-info uni-row">
  42. <text class="label">废品数</text>
  43. <text class="label right">{{ item['rejectSum'] ? item['rejectSum'] : 0 }}</text>
  44. </view>
  45. <view class="item-info uni-row">
  46. <text class="label">投入数</text>
  47. <text
  48. class="label right">{{store.dayworkInfo.prevProcess == null ? store.dayworkInfo['productionQuantity'] : store.dayworkInfo['processQualifiedNum']}}</text>
  49. </view>
  50. <view class="item-info uni-row">
  51. <text class="label">设备</text>
  52. <text class="label right">{{ item['equipmentDetailCode']}}</text>
  53. </view>
  54. <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 1 : false"
  55. class="status-btn uni-row ">
  56. <button class="finished-turnover-tag" size="mini"
  57. @click.stop="handleShowEndWorkDialog(item)">结束报工</button>
  58. </view>
  59. <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 0 : false"
  60. class="status-btn uni-row ">
  61. <button class="start-turnover-tag" size="mini" type="primary"
  62. @click.stop="handleStartProcessing(item)">开始报工</button>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="bottom uni-row">
  67. <button class="bottom-btn left-btn" @click="handleChangevehicle"><text class="label">更换载具</text></button>
  68. <button v-if="flag" class="bottom-btn right-btn" type="primary" @click="handleStartProcessing(null)"><text
  69. class="label">开始加工</text></button>
  70. </view>
  71. <dialog-end-inner-work ref="endInnerWorkDialog" @resflushItem='resflushItem' />
  72. <dialog-selectEquipment ref='selectEquipment'
  73. @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectEquipment>
  74. <dialog-selectInviteUser ref="inviteUser"
  75. @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectInviteUser>
  76. <dialog-lotInfo ref="lotInfo"></dialog-lotInfo>
  77. </view>
  78. </template>
  79. <script setup>
  80. import {
  81. ref
  82. } from 'vue'
  83. import {
  84. onLoad,
  85. onReady,
  86. onUnload,
  87. onShow
  88. } from '@dcloudio/uni-app'
  89. import {
  90. getDayWorkItemList,
  91. saveDayWorkItemBatch,
  92. updateDayWorkItem
  93. } from "@/api/business/dayWorkItem.js"
  94. import {
  95. store
  96. } from '@/store/index.js'
  97. import {
  98. timestampToTime,
  99. toHHmmss
  100. } from '@/utils/common.js'
  101. import {
  102. checkBizDayworkCarriers
  103. } from '@/api/business/dayWork.js'
  104. import {
  105. isCurProcessFinish
  106. } from '@/api/business/dayWorkItem.js'
  107. import {
  108. getEquipmentByUidAndDid
  109. } from '@/api/resourceGroup/resourceGroupDetail.js'
  110. const listData = ref([]) // 回显
  111. const curPlan = ref({}) // 接收生产计划单信息
  112. const dayWorkInfo = ref({}) // 接收daywork信息
  113. const equipmentList = ref([]) // 设备列表
  114. const endInnerWorkDialog = ref(null) // 组件
  115. const selectEquipment = ref(null) // 组件
  116. const inviteUser = ref(null) // 组件
  117. const dayWorkItem = ref({}) // 添加传输对象
  118. const reqParam = ref([]) // 请求参数
  119. const userInfo = ref(null) // 登录员工信息
  120. const flag = ref(true) // 控制底部开始加工按钮功能
  121. const lotInfo = ref(null) // 详情弹窗
  122. const hasEquipment = ref(true) // 判断资源组是否有设备
  123. onLoad(() => {
  124. curPlan.value = store.planDetails;
  125. dayWorkInfo.value = store.dayworkInfo;
  126. init();
  127. })
  128. // onUnload(() => {
  129. // uni.$off('dayworkItemUpdate', reflush)
  130. // })
  131. onShow(() => {
  132. uni.$on('dayworkItemUpdate', reflush)
  133. })
  134. function init() {
  135. console.log(store.dayworkInfo)
  136. userInfo.value = store.userInfo;
  137. uni.showLoading({
  138. title: '加载中'
  139. });
  140. getDayWorkItemList({
  141. dayworkId: dayWorkInfo.value.id,
  142. lotId: dayWorkInfo.value.lotId,
  143. isWasteRecycling: dayWorkInfo.value.isWasteRecycling,
  144. isAmend: dayWorkInfo.value.isAmend,
  145. processStepNumber: dayWorkInfo.value.currentProcess.processStepNumber,
  146. // processId: store.dayworkInfo.currentProcess.id,
  147. type: '非周转中item'
  148. }).then(res => {
  149. if (res.code == 200) {
  150. listData.value = res.rows || [];
  151. console.log(listData.value)
  152. // 时间戳转工时
  153. for (var i = 0; i < listData.value.length; i++) {
  154. let timeStamp = listData.value[i].workingHours;
  155. listData.value[i].taskTime = toHHmmss(timeStamp);
  156. }
  157. flag.value = !listData.value.some(item => item.status == 0);
  158. uni.hideLoading();
  159. } else {
  160. uni.showToast({
  161. icon: "error",
  162. title: res.message,
  163. duration: 1000
  164. })
  165. uni.hideLoading();
  166. }
  167. })
  168. getEquipmentByUidAndDid(store.planDetails.id, store.curDeptDetails.deptId, store.dayworkInfo.lotId).then(
  169. equipmentRes => {
  170. if (equipmentRes.code == 200) {
  171. hasEquipment.value = equipmentRes.rows.length > 0 ? true : false;
  172. }
  173. })
  174. }
  175. function reflush() {
  176. init();
  177. }
  178. function resflushItem() {
  179. reflush();
  180. }
  181. function handleOpenLonInfo() {
  182. lotInfo.value.open();
  183. }
  184. function handleShowEndWorkDialog(data) {
  185. checkBizDayworkCarriers({
  186. id: store.dayworkInfo.id
  187. }).then(res => {
  188. if (res.code == 200) {
  189. // 调用子组件中的方法
  190. endInnerWorkDialog.value.open(data, listData)
  191. } else {
  192. uni.showToast({
  193. icon: "none",
  194. title: res.msg + ",请绑定",
  195. duration: 2000
  196. })
  197. uni.navigateTo({
  198. url: "/pages/changeBox/index"
  199. })
  200. }
  201. })
  202. }
  203. function HandleSeleteInviteUser(data) {
  204. isCurProcessFinish({
  205. dayworkId: store.dayworkInfo.id,
  206. processId: listData.value[0].processId
  207. }).then(res => {
  208. if (store.dayworkInfo.status == 4) {
  209. uni.showToast({
  210. icon: 'none',
  211. title: '当前批次已完成'
  212. })
  213. } else if (res.data) {
  214. uni.showToast({
  215. icon: 'none',
  216. title: '该工序已完成,不能邀请报工'
  217. })
  218. } else if (!hasEquipment.value) {
  219. uni.showToast({
  220. icon: 'none',
  221. title: '当前无可用设备',
  222. })
  223. } else {
  224. inviteUser.value.open(data);
  225. }
  226. })
  227. }
  228. function handleChangevehicle() {
  229. if (store.dayworkInfo.status == 4) {
  230. uni.showToast({
  231. icon: 'none',
  232. title: '该工序已完成'
  233. })
  234. } else {
  235. uni.navigateTo({
  236. url: "/pages/changeBox/index"
  237. })
  238. }
  239. }
  240. //送检跳转
  241. function HandleSendInspection() {
  242. uni.navigateTo({
  243. url: "/pages/firstInspection/scan"
  244. })
  245. }
  246. function getEquipment(data) {
  247. console.log(data);
  248. equipmentList.value = data;
  249. }
  250. function handleStartProcessing(item) {
  251. // 先判断默认的一条是否开始加工
  252. // if (!item && listData.value.some(item => item.status == 0)) {
  253. // uni.showToast({
  254. // icon: 'none',
  255. // title: '请先开始默认的报工记录再进行报工',
  256. // duration: 2000
  257. // })
  258. // }else{
  259. // 查询当前工序是否完成再判断是否进行报工
  260. isCurProcessFinish({
  261. dayworkId: store.dayworkInfo.id,
  262. processId: listData.value[0].processId
  263. }).then(res => {
  264. if (store.dayworkInfo.status == 4) {
  265. uni.showToast({
  266. icon: 'none',
  267. title: '当前批次已完成'
  268. })
  269. } else if (res.data) {
  270. uni.showToast({
  271. icon: 'none',
  272. title: '该工序已完成,不能继续报工'
  273. })
  274. } else if (!hasEquipment.value) {
  275. uni.showToast({
  276. icon: 'none',
  277. title: '当前无可用设备',
  278. })
  279. } else {
  280. selectEquipment.value.open(item);
  281. }
  282. })
  283. // }
  284. }
  285. /**
  286. * 新批次默认item去报工(执行方法)
  287. * @param {Object} item
  288. */
  289. function handleStartFirstItem(item) {
  290. let reqParam = item;
  291. reqParam.status = 1;
  292. reqParam.startTime = timestampToTime(new Date());
  293. updateDayWorkItem(reqParam).then(res => {
  294. if (res.code === 200) {
  295. uni.showToast({
  296. icon: "success",
  297. title: "报工成功",
  298. duration: 2000
  299. })
  300. init();
  301. } else {
  302. uni.showToast({
  303. icon: "none",
  304. title: "报工失败,请联系管理员",
  305. duration: 2000
  306. })
  307. }
  308. })
  309. }
  310. function handleAddDayWorkItem(data) {
  311. console.log(data)
  312. console.log(dayWorkInfo.value)
  313. if (data.dayworkId) { // data里面任意一对象除了设备相关的字段存在,直接给reqParam赋值
  314. reqParam.value = {
  315. ...data,
  316. productionPlanId: curPlan.value.productionPlanId,
  317. productionPlanDetailId: curPlan.value.id,
  318. technologicalProcessId: dayWorkInfo.value.technologicalProcessId,
  319. prodNum: store.dayworkInfo.prevProcess == null ?
  320. store.dayworkInfo['isLast'] == 1 ? store.dayworkInfo['lastLotQuantity'] : store.dayworkInfo[
  321. 'oneLotQuantity'] : store.dayworkInfo['processQualifiedNum'],
  322. deptId: store.curDeptDetails.deptId,
  323. deptName: store.curDeptDetails.deptName,
  324. outsourceDetailId: dayWorkInfo.value.dayworkItemList[0].outsourceDetailId,
  325. tenantId: !store.tenantId ? store.userInfo.tenantId : store.tenantId,
  326. isWx: 1
  327. }
  328. } else {
  329. // equipmentList.value = data;
  330. dayWorkItem.value = {
  331. dayworkId: dayWorkInfo.value.id,
  332. lotId: dayWorkInfo.value.lotId,
  333. productionPlanId: curPlan.value.productionPlanId,
  334. productionPlanDetailId: curPlan.value.id,
  335. technologicalProcessId: dayWorkInfo.value.technologicalProcessId,
  336. prodNum: store.dayworkInfo.prevProcess == null ?
  337. store.dayworkInfo['isLast'] == 1 ? store.dayworkInfo['lastLotQuantity'] : store.dayworkInfo[
  338. 'oneLotQuantity'] : store.dayworkInfo['processQualifiedNum'],
  339. status: 1,
  340. startTime: timestampToTime(new Date()),
  341. deptId: store.curDeptDetails.deptId,
  342. deptName: store.curDeptDetails.deptName,
  343. outsourceDetailId: dayWorkInfo.value.dayworkItemList[0].outsourceDetailId,
  344. tenantId: !store.tenantId ? store.userInfo.tenantId : store.tenantId,
  345. isWx: 1,
  346. ...data
  347. }
  348. reqParam.value = dayWorkItem.value;
  349. }
  350. console.log(reqParam.value)
  351. saveDayWorkItemBatch(reqParam.value).then(res => {
  352. if (res.code === 200) {
  353. uni.showToast({
  354. icon: 'success',
  355. title: '操作成功',
  356. duration: 2000
  357. });
  358. reqParam.value = [];
  359. reflush();
  360. } else {
  361. uni.showToast({
  362. icon: 'none',
  363. title: '操作失败',
  364. duration: 2000
  365. });
  366. }
  367. })
  368. }
  369. </script>
  370. <style lang="scss">
  371. .container {
  372. // height: calc(100% - 232rpx);
  373. background-color: #f5f5f5;
  374. overflow: auto;
  375. position: absolute;
  376. height: 90%;
  377. right: 0;
  378. left: 0;
  379. }
  380. .scroll-container {
  381. position: relative;
  382. top: 16rpx;
  383. // right: 0;
  384. // bottom: 144rpx;
  385. // left: 0;
  386. }
  387. .selected {
  388. border: 1px solid #1684fc;
  389. }
  390. .list-item {
  391. background-color: #fff;
  392. position: relative;
  393. padding: 16rpx;
  394. padding-bottom: 24rpx;
  395. margin: 0 24rpx;
  396. margin-bottom: 24rpx;
  397. border-radius: 8rpx;
  398. .title-container {
  399. margin: 8rpx 0;
  400. width: 100%;
  401. .title {
  402. height: 48rpx;
  403. justify-content: space-between;
  404. align-items: center;
  405. flex: 7;
  406. .label {
  407. // font-size: 32rpx;
  408. font-weight: bold;
  409. }
  410. .code {
  411. margin-left: 8rpx;
  412. }
  413. }
  414. }
  415. .item-info {
  416. margin-bottom: 8rpx;
  417. .label {
  418. font-size: 28rpx;
  419. width: 152rpx;
  420. color: #808080;
  421. &.right {
  422. flex: 1;
  423. color: #000000;
  424. }
  425. }
  426. }
  427. .right-info {
  428. // justify-content: flex-end;
  429. // width:45%;
  430. // margin-top: 5rpx;
  431. .label {
  432. font-size: 28rpx;
  433. }
  434. .time {
  435. margin-left: 8rpx;
  436. color: #1684fc;
  437. }
  438. .number {
  439. margin-left: 8rpx;
  440. color: #1684fc;
  441. }
  442. }
  443. }
  444. .bottom {
  445. height: 10%;
  446. position: fixed;
  447. right: 0;
  448. bottom: 0;
  449. left: 0;
  450. height: 100rpx;
  451. border-top: 1px solid #999999;
  452. padding: 16rpx 32rpx;
  453. align-items: center;
  454. background-color: #fff;
  455. justify-content: space-evenly;
  456. .left-btn {
  457. flex: 1;
  458. height: 80rpx;
  459. line-height: 80rpx;
  460. border-radius: 8rpx;
  461. color: #FFFFFF;
  462. font-size: 28rpx;
  463. background-color: rgba(0, 226, 166, 1);
  464. }
  465. .right-btn {
  466. flex: 1;
  467. height: 80rpx;
  468. line-height: 80rpx;
  469. border-radius: 8rpx;
  470. color: #FFFFFF;
  471. font-size: 28rpx;
  472. margin-left: 24rpx;
  473. }
  474. }
  475. // .bottom {
  476. // position: fixed;
  477. // right: 0;
  478. // bottom: 0;
  479. // left: 0;
  480. // height: 100rpx;
  481. // padding: 16rpx 24rpx;
  482. // align-items: center;
  483. // background-color: #FFFFFF;
  484. // justify-content: space-between;
  485. // .bottom-btn {
  486. // flex: 1;
  487. // font-size: 28rpx;
  488. // color: #FFFFFF;
  489. // &.left-btn {
  490. // background-color: rgba(0, 226, 166, 1);
  491. // }
  492. // &.right-btn {
  493. // margin-left: 24rpx;
  494. // }
  495. // }
  496. // }
  497. .status-btn {
  498. width: 100%;
  499. justify-content: flex-end;
  500. .finished-turnover-tag {
  501. margin: unset;
  502. border-radius: 8rpx;
  503. background-color: rgb(255, 85, 85);
  504. font-size: 28rpx;
  505. color: #FFFFFF;
  506. }
  507. .start-turnover-tag {
  508. margin: unset;
  509. border-radius: 8rpx;
  510. font-size: 28rpx;
  511. color: #FFFFFF;
  512. }
  513. }
  514. </style>