index.vue 13 KB

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