index.vue 13 KB

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