index.vue 12 KB

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