index.vue 14 KB

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