index.vue 9.4 KB

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