index.vue 14 KB

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