index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="uni-column container">
  3. <scroll-view class="scroll-container" scroll-y>
  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. <text class="label">批次号:</text>
  8. <text class="label code"> {{ item['lotCode'] }}</text>
  9. </view>
  10. <view class="uni-row">
  11. <view class="right-info uni-row"> <text class="label">工时</text>
  12. <text class="label time">{{ item['taskTime'] }}</text>
  13. <!-- <text class="label time">{{ item['taskTime'] }}h</text> -->
  14. </view>
  15. <view class="right-info uni-row" style="margin-left: 50rpx;"> <text class="label">合格数</text>
  16. <text class="label number ">{{ item['qualifiedNum'] }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="item-info uni-row">
  21. <text class="label">产品描述</text>
  22. <text class="label right">{{ curPlan['productDescription'] }}</text>
  23. </view>
  24. <view class="item-info uni-row">
  25. <text class="label">操作者</text>
  26. <text class="label right">{{ item['nickName'] }}</text>
  27. </view>
  28. <view class="item-info uni-row">
  29. <text class="label">开始时间</text>
  30. <text class="label right">{{ item['startTime']}}</text>
  31. </view>
  32. <view class="item-info uni-row">
  33. <text class="label">结束时间</text>
  34. <text class="label right">{{ item['endTime'] ? item['endTime'] : '-'}}</text>
  35. </view>
  36. <view class="item-info uni-row">
  37. <text class="label">废品数</text>
  38. <text class="label right">{{ item['rejectSum'] ? item['rejectSum'] : 0 }}</text>
  39. </view>
  40. <view class="item-info uni-row">
  41. <text class="label">投入数</text>
  42. <text
  43. class="label right">{{store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store.dayworkInfo['processQualifiedNum']}}</text>
  44. </view>
  45. <view class="item-info uni-row">
  46. <text class="label">设备</text>
  47. <text class="label right">{{ item['equipmentDetailCode']}}</text>
  48. </view>
  49. <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 1 : false"
  50. class="status-btn uni-row ">
  51. <button class="finished-turnover-tag" size="mini"
  52. @click.stop="handleShowEndWorkDialog(item)">结束报工</button>
  53. </view>
  54. <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 0 : false"
  55. class="status-btn uni-row ">
  56. <button class="start-turnover-tag" size="mini" type="primary"
  57. @click.stop="handleStartProcessing(item)">开始报工</button>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. <view class="top">
  62. <button class="top-btn" @click="HandleSeleteInviteUser(null)"><text class="label">邀请报工</text></button>
  63. </view>
  64. <view class="bottom uni-row">
  65. <button class="bottom-btn left-btn" @click="HandleChangevehicle"><text class="label">更换载具</text></button>
  66. <button class="bottom-btn right-btn" type="primary" @click="handleStartProcessing(null)"><text
  67. class="label">开始加工</text></button>
  68. </view>
  69. <dialog-end-work ref="endWorkDialog" @sendEquipment='getEquipment' />
  70. <dialog-selectEquipment ref='selectEquipment'
  71. @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectEquipment>
  72. <dialog-selectInviteUser ref="inviteUser"
  73. @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectInviteUser>
  74. </view>
  75. </template>
  76. <script setup>
  77. import {
  78. ref
  79. } from 'vue'
  80. import {
  81. onLoad,
  82. onReady,
  83. onUnload
  84. } from '@dcloudio/uni-app'
  85. import {
  86. getDayWorkItemList,
  87. saveDayWorkItemBatch,
  88. updateDayWorkItem
  89. } from "@/api/business/dayWorkItem.js"
  90. import {
  91. store
  92. } from '@/store/index.js'
  93. import {
  94. timestampToTime,
  95. toHHmmss
  96. } from '@/utils/common.js'
  97. import {
  98. checkBizDayworkCarriers
  99. } from '@/api/business/dayWork.js'
  100. const listData = ref([]) // 回显
  101. const curPlan = ref({}) // 接收生产计划单信息
  102. const dayWorkInfo = ref({}) // 接收daywork信息
  103. const equipmentList = ref([]) // 设备列表
  104. const endWorkDialog = ref(null) // 组件
  105. const selectEquipment = ref(null) // 组件
  106. const inviteUser = ref(null) // 组件
  107. const dayWorkItem = ref({}) // 添加传输对象
  108. const reqParam = ref([]) // 请求参数
  109. const userInfo = ref(null) // 登录员工信息
  110. const flag = ref(true) // 控制底部开始加工按钮功能
  111. onLoad(() => {
  112. curPlan.value = store.planDetails;
  113. dayWorkInfo.value = store.dayworkInfo;
  114. console.log(dayWorkInfo.value)
  115. init();
  116. uni.$on('dayworkItemUpdate', reflush)
  117. })
  118. onUnload(() => {
  119. uni.$off('dayworkItemUpdate', reflush)
  120. })
  121. function init() {
  122. console.log(store.dayworkInfo.processSequence)
  123. userInfo.value = store.userInfo;
  124. uni.showLoading({
  125. title: '加载中'
  126. });
  127. getDayWorkItemList({
  128. dayworkId: dayWorkInfo.value.id,
  129. // processId: store.dayworkInfo.currentProcess.id,
  130. type: '非周转中item'
  131. }).then(res => {
  132. if (res.code == 200) {
  133. listData.value = res.rows || [];
  134. console.log(listData.value)
  135. // 时间戳转工时
  136. for (var i = 0; i < listData.value.length; i++) {
  137. let timeStamp = listData.value[i].workingHours;
  138. listData.value[i].taskTime = toHHmmss(timeStamp);
  139. }
  140. // flag.value = listData.value[0].status == 2 ? false : true;
  141. uni.hideLoading();
  142. } else {
  143. uni.showToast({
  144. icon: "error",
  145. title: res.message,
  146. duration: 1000
  147. })
  148. uni.hideLoading();
  149. }
  150. })
  151. }
  152. function reflush() {
  153. init();
  154. }
  155. function handleShowEndWorkDialog(data) {
  156. checkBizDayworkCarriers({
  157. id: store.dayworkInfo.id
  158. }).then(res => {
  159. if (res.code == 200) {
  160. // 调用子组件中的方法
  161. endWorkDialog.value.open(data, listData)
  162. } else {
  163. uni.showToast({
  164. icon: "none",
  165. title: res.msg + ",请绑定",
  166. duration: 2000
  167. })
  168. uni.navigateTo({
  169. url: "/pages/changeBox/index"
  170. })
  171. }
  172. })
  173. }
  174. function HandleSeleteInviteUser(data) {
  175. inviteUser.value.open(data)
  176. }
  177. function HandleChangevehicle() {
  178. uni.navigateTo({
  179. url: "/pages/changeBox/index"
  180. })
  181. }
  182. function getEquipment(data) {
  183. console.log(data);
  184. equipmentList.value = data;
  185. }
  186. function handleStartProcessing(item) {
  187. let flag = false;
  188. for (let i = 0; i < listData.value.length; i++) {
  189. if(listData.value[i].status == 3){
  190. flag = true;
  191. break;
  192. }
  193. }
  194. if (store.dayworkInfo.status == 4) {
  195. uni.showToast({
  196. icon: 'none',
  197. title: '当前批次已完成'
  198. })
  199. } else if (flag) {
  200. uni.showToast({
  201. icon: 'none',
  202. title: '该工序已完成,请转到下一工序再报工'
  203. })
  204. } else {
  205. selectEquipment.value.open(item);
  206. }
  207. }
  208. /**
  209. * 新批次默认item去报工(执行方法)
  210. * @param {Object} item
  211. */
  212. function handleStartFirstItem(item) {
  213. let reqParam = item;
  214. reqParam.status = 1;
  215. reqParam.startTime = timestampToTime(new Date());
  216. updateDayWorkItem(reqParam).then(res => {
  217. if (res.code === 200) {
  218. uni.showToast({
  219. icon: "success",
  220. title: "报工成功",
  221. duration: 2000
  222. })
  223. init();
  224. } else {
  225. uni.showToast({
  226. icon: "fail",
  227. title: "报工失败,请联系管理员",
  228. duration: 2000
  229. })
  230. }
  231. })
  232. }
  233. function handleAddDayWorkItem(data) {
  234. console.log(data)
  235. if (data.dayworkId) { // data里面任意一对象除了设备相关的字段存在,直接给reqParam赋值
  236. reqParam.value = {
  237. ...data,
  238. productionPlanId: curPlan.value.productionPlanId,
  239. productionPlanDetailId: curPlan.value.id,
  240. technologicalProcessId: curPlan.value.technologicalProcessId,
  241. prodNum: store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store
  242. .dayworkInfo['processQualifiedNum'],
  243. deptId: store.curDeptDetails.deptId,
  244. deptName: store.curDeptDetails.deptName
  245. }
  246. } else {
  247. // equipmentList.value = data;
  248. dayWorkItem.value = {
  249. dayworkId: dayWorkInfo.value.id,
  250. lotId: dayWorkInfo.value.lotId,
  251. productionPlanId: curPlan.value.productionPlanId,
  252. productionPlanDetailId: curPlan.value.id,
  253. technologicalProcessId: curPlan.value.technologicalProcessId,
  254. prodNum: store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store
  255. .dayworkInfo['processQualifiedNum'],
  256. status: 1,
  257. startTime: timestampToTime(new Date()),
  258. deptId: store.curDeptDetails.deptId,
  259. deptName: store.curDeptDetails.deptName,
  260. ...data
  261. }
  262. reqParam.value = dayWorkItem.value;
  263. }
  264. console.log(reqParam.value)
  265. saveDayWorkItemBatch(reqParam.value).then(res => {
  266. if (res.code === 200) {
  267. uni.showToast({
  268. icon: 'success',
  269. title: '操作成功',
  270. duration: 2000
  271. });
  272. reqParam.value = [];
  273. uni.$emit('dayworkItemUpdate');
  274. } else {
  275. uni.showToast({
  276. icon: 'error',
  277. title: '操作失败',
  278. duration: 2000
  279. });
  280. }
  281. })
  282. }
  283. </script>
  284. <style lang="scss">
  285. .container {
  286. height: calc(100% - 232rpx);
  287. background-color: #f5f5f5;
  288. overflow: auto;
  289. }
  290. .scroll-container {
  291. position: relative;
  292. top: 16rpx;
  293. // right: 0;
  294. // bottom: 144rpx;
  295. // left: 0;
  296. }
  297. .selected {
  298. border: 1px solid #1684fc;
  299. }
  300. .list-item {
  301. background-color: #fff;
  302. position: relative;
  303. padding: 16rpx;
  304. padding-bottom: 24rpx;
  305. margin: 0 24rpx;
  306. margin-bottom: 24rpx;
  307. border-radius: 8rpx;
  308. .title-container {
  309. margin: 8rpx 0;
  310. width: 100%;
  311. .title {
  312. height: 48rpx;
  313. align-items: center;
  314. flex: 7;
  315. .label {
  316. // font-size: 32rpx;
  317. font-weight: bold;
  318. }
  319. .code {
  320. margin-left: 8rpx;
  321. }
  322. }
  323. }
  324. .item-info {
  325. margin-bottom: 8rpx;
  326. .label {
  327. font-size: 28rpx;
  328. width: 152rpx;
  329. color: #808080;
  330. &.right {
  331. flex: 1;
  332. color: #000000;
  333. }
  334. }
  335. }
  336. .right-info {
  337. // justify-content: flex-end;
  338. // width:45%;
  339. // margin-top: 5rpx;
  340. .label {
  341. font-size: 28rpx;
  342. }
  343. .time {
  344. margin-left: 8rpx;
  345. color: #1684fc;
  346. }
  347. .number {
  348. margin-left: 8rpx;
  349. color: #1684fc;
  350. }
  351. }
  352. }
  353. .top {
  354. position: fixed;
  355. bottom: 132rpx;
  356. right: 0;
  357. left: 0;
  358. height: 80rpx;
  359. padding: 0 24rpx;
  360. align-items: center;
  361. justify-content: center;
  362. background-color: #FFFFFF;
  363. .top-btn {
  364. font-size: 28rpx;
  365. color: #FFFFFF;
  366. background-color: #1684fc;
  367. width: 100%;
  368. }
  369. }
  370. .bottom {
  371. position: fixed;
  372. right: 0;
  373. bottom: 0;
  374. left: 0;
  375. height: 100rpx;
  376. padding: 16rpx 24rpx;
  377. align-items: center;
  378. background-color: #FFFFFF;
  379. justify-content: space-between;
  380. .bottom-btn {
  381. flex: 1;
  382. font-size: 28rpx;
  383. color: #FFFFFF;
  384. &.left-btn {
  385. background-color: rgba(0, 226, 166, 1);
  386. }
  387. &.right-btn {
  388. margin-left: 24rpx;
  389. }
  390. }
  391. }
  392. .status-btn {
  393. width: 100%;
  394. justify-content: flex-end;
  395. .finished-turnover-tag {
  396. margin: unset;
  397. border-radius: 8rpx;
  398. background-color: rgb(255, 85, 85);
  399. font-size: 28rpx;
  400. color: #FFFFFF;
  401. }
  402. .start-turnover-tag {
  403. margin: unset;
  404. border-radius: 8rpx;
  405. font-size: 28rpx;
  406. color: #FFFFFF;
  407. }
  408. }
  409. </style>