index.vue 11 KB

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