index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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['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" @sendEquipment='getEquipment' />
  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. const listData = ref([]) // 回显
  111. const curPlan = ref({}) // 接收生产计划单信息
  112. const dayWorkInfo = ref({}) // 接收daywork信息
  113. const equipmentList = ref([]) // 设备列表
  114. const endWorkDialog = ref(null) // 组件
  115. const selectEquipment = ref(null) // 组件
  116. const inviteUser = ref(null) // 组件
  117. const dayWorkItem = ref({}) // 添加传输对象
  118. const reqParam = ref([]) // 请求参数
  119. const userInfo = ref(null) // 登录员工信息
  120. const flag = ref(true) // 控制底部开始加工按钮功能
  121. const lotInfo = ref(null) // 详情弹窗
  122. onLoad(() => {
  123. curPlan.value = store.planDetails;
  124. dayWorkInfo.value = store.dayworkInfo;
  125. console.log(dayWorkInfo.value)
  126. init();
  127. })
  128. // onUnload(() => {
  129. // uni.$off('dayworkItemUpdate', reflush)
  130. // })
  131. onShow(() => {
  132. uni.$on('dayworkItemUpdate', reflush)
  133. })
  134. function init() {
  135. console.log(store.dayworkInfo.processSequence)
  136. userInfo.value = store.userInfo;
  137. uni.showLoading({
  138. title: '加载中'
  139. });
  140. getDayWorkItemList({
  141. dayworkId: dayWorkInfo.value.id,
  142. // processId: store.dayworkInfo.currentProcess.id,
  143. type: '非周转中item'
  144. }).then(res => {
  145. if (res.code == 200) {
  146. listData.value = res.rows || [];
  147. console.log(listData.value)
  148. // 时间戳转工时
  149. for (var i = 0; i < listData.value.length; i++) {
  150. let timeStamp = listData.value[i].workingHours;
  151. listData.value[i].taskTime = toHHmmss(timeStamp);
  152. }
  153. flag.value = !listData.value.some(item => item.status == 0);
  154. uni.hideLoading();
  155. } else {
  156. uni.showToast({
  157. icon: "error",
  158. title: res.message,
  159. duration: 1000
  160. })
  161. uni.hideLoading();
  162. }
  163. })
  164. }
  165. function reflush() {
  166. init();
  167. }
  168. function handleOpenLonInfo() {
  169. lotInfo.value.open();
  170. }
  171. function handleShowEndWorkDialog(data) {
  172. checkBizDayworkCarriers({
  173. id: store.dayworkInfo.id
  174. }).then(res => {
  175. if (res.code == 200) {
  176. // 调用子组件中的方法
  177. endWorkDialog.value.open(data, listData)
  178. } else {
  179. uni.showToast({
  180. icon: "none",
  181. title: res.msg + ",请绑定",
  182. duration: 2000
  183. })
  184. uni.navigateTo({
  185. url: "/pages/changeBox/index"
  186. })
  187. }
  188. })
  189. }
  190. function HandleSeleteInviteUser(data) {
  191. // if (data.some(item => item.status == 0)) {
  192. // uni.showToast({
  193. // icon: 'none',
  194. // title: '请报工选择工序后再邀请协作者'
  195. // })
  196. // } else {
  197. inviteUser.value.open(data)
  198. // }
  199. }
  200. function HandleChangevehicle() {
  201. uni.navigateTo({
  202. url: "/pages/changeBox/index"
  203. })
  204. }
  205. function getEquipment(data) {
  206. console.log(data);
  207. equipmentList.value = data;
  208. }
  209. function handleStartProcessing(item) {
  210. // 先判断默认的一条是否开始加工
  211. // if (!item && listData.value.some(item => item.status == 0)) {
  212. // uni.showToast({
  213. // icon: 'none',
  214. // title: '请先开始默认的报工记录再进行报工',
  215. // duration: 2000
  216. // })
  217. // }else{
  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 {
  234. selectEquipment.value.open(item);
  235. }
  236. })
  237. // }
  238. }
  239. /**
  240. * 新批次默认item去报工(执行方法)
  241. * @param {Object} item
  242. */
  243. function handleStartFirstItem(item) {
  244. let reqParam = item;
  245. reqParam.status = 1;
  246. reqParam.startTime = timestampToTime(new Date());
  247. updateDayWorkItem(reqParam).then(res => {
  248. if (res.code === 200) {
  249. uni.showToast({
  250. icon: "success",
  251. title: "报工成功",
  252. duration: 2000
  253. })
  254. init();
  255. } else {
  256. uni.showToast({
  257. icon: "fail",
  258. title: "报工失败,请联系管理员",
  259. duration: 2000
  260. })
  261. }
  262. })
  263. }
  264. function handleAddDayWorkItem(data) {
  265. console.log(data)
  266. if (data.dayworkId) { // data里面任意一对象除了设备相关的字段存在,直接给reqParam赋值
  267. reqParam.value = {
  268. ...data,
  269. productionPlanId: curPlan.value.productionPlanId,
  270. productionPlanDetailId: curPlan.value.id,
  271. technologicalProcessId: curPlan.value.technologicalProcessId,
  272. prodNum: store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store
  273. .dayworkInfo['processQualifiedNum'],
  274. deptId: store.curDeptDetails.deptId,
  275. deptName: store.curDeptDetails.deptName
  276. }
  277. } else {
  278. // equipmentList.value = data;
  279. dayWorkItem.value = {
  280. dayworkId: dayWorkInfo.value.id,
  281. lotId: dayWorkInfo.value.lotId,
  282. productionPlanId: curPlan.value.productionPlanId,
  283. productionPlanDetailId: curPlan.value.id,
  284. technologicalProcessId: curPlan.value.technologicalProcessId,
  285. prodNum: store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store
  286. .dayworkInfo['processQualifiedNum'],
  287. status: 1,
  288. startTime: timestampToTime(new Date()),
  289. deptId: store.curDeptDetails.deptId,
  290. deptName: store.curDeptDetails.deptName,
  291. ...data
  292. }
  293. reqParam.value = dayWorkItem.value;
  294. }
  295. console.log(reqParam.value)
  296. saveDayWorkItemBatch(reqParam.value).then(res => {
  297. if (res.code === 200) {
  298. uni.showToast({
  299. icon: 'success',
  300. title: '操作成功',
  301. duration: 2000
  302. });
  303. reqParam.value = [];
  304. uni.$emit('dayworkItemUpdate');
  305. } else {
  306. uni.showToast({
  307. icon: 'error',
  308. title: '操作失败',
  309. duration: 2000
  310. });
  311. }
  312. })
  313. }
  314. </script>
  315. <style lang="scss">
  316. .container {
  317. height: calc(100% - 232rpx);
  318. background-color: #f5f5f5;
  319. overflow: auto;
  320. }
  321. .scroll-container {
  322. position: relative;
  323. top: 16rpx;
  324. // right: 0;
  325. // bottom: 144rpx;
  326. // left: 0;
  327. }
  328. .selected {
  329. border: 1px solid #1684fc;
  330. }
  331. .list-item {
  332. background-color: #fff;
  333. position: relative;
  334. padding: 16rpx;
  335. padding-bottom: 24rpx;
  336. margin: 0 24rpx;
  337. margin-bottom: 24rpx;
  338. border-radius: 8rpx;
  339. .title-container {
  340. margin: 8rpx 0;
  341. width: 100%;
  342. .title {
  343. height: 48rpx;
  344. justify-content: space-between;
  345. align-items: center;
  346. flex: 7;
  347. .label {
  348. // font-size: 32rpx;
  349. font-weight: bold;
  350. }
  351. .code {
  352. margin-left: 8rpx;
  353. }
  354. }
  355. }
  356. .item-info {
  357. margin-bottom: 8rpx;
  358. .label {
  359. font-size: 28rpx;
  360. width: 152rpx;
  361. color: #808080;
  362. &.right {
  363. flex: 1;
  364. color: #000000;
  365. }
  366. }
  367. }
  368. .right-info {
  369. // justify-content: flex-end;
  370. // width:45%;
  371. // margin-top: 5rpx;
  372. .label {
  373. font-size: 28rpx;
  374. }
  375. .time {
  376. margin-left: 8rpx;
  377. color: #1684fc;
  378. }
  379. .number {
  380. margin-left: 8rpx;
  381. color: #1684fc;
  382. }
  383. }
  384. }
  385. .top {
  386. position: fixed;
  387. bottom: 132rpx;
  388. right: 0;
  389. left: 0;
  390. height: 80rpx;
  391. padding: 0 24rpx;
  392. align-items: center;
  393. justify-content: center;
  394. background-color: #FFFFFF;
  395. .top-btn {
  396. font-size: 28rpx;
  397. color: #FFFFFF;
  398. background-color: #1684fc;
  399. width: 100%;
  400. }
  401. }
  402. .bottom {
  403. position: fixed;
  404. right: 0;
  405. bottom: 0;
  406. left: 0;
  407. height: 100rpx;
  408. padding: 16rpx 24rpx;
  409. align-items: center;
  410. background-color: #FFFFFF;
  411. justify-content: space-between;
  412. .bottom-btn {
  413. flex: 1;
  414. font-size: 28rpx;
  415. color: #FFFFFF;
  416. &.left-btn {
  417. background-color: rgba(0, 226, 166, 1);
  418. }
  419. &.right-btn {
  420. margin-left: 24rpx;
  421. }
  422. }
  423. }
  424. .status-btn {
  425. width: 100%;
  426. justify-content: flex-end;
  427. .finished-turnover-tag {
  428. margin: unset;
  429. border-radius: 8rpx;
  430. background-color: rgb(255, 85, 85);
  431. font-size: 28rpx;
  432. color: #FFFFFF;
  433. }
  434. .start-turnover-tag {
  435. margin: unset;
  436. border-radius: 8rpx;
  437. font-size: 28rpx;
  438. color: #FFFFFF;
  439. }
  440. }
  441. </style>