index.vue 13 KB

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