index.vue 11 KB

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