index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 uni-row">
  6. <view class="title uni-row" >
  7. <text class="label">批次号:</text>
  8. <text class="label code"> {{ item['lotCode'] }}</text>
  9. </view>
  10. <view class="right-info " style="flex: 3;margin-right: -30rpx;">
  11. <view class="right-info uni-row" > <text class="label">工时</text>
  12. <text class="label time" >{{ item['taskTime'] }}h</text>
  13. </view>
  14. <view class="right-info uni-row"> <text class="label">合格数</text>
  15. <text class="label number ">{{ item['qualifiedNum'] }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="item-info uni-row">
  20. <text class="label">操作者</text>
  21. <text class="label right">{{ item['nickName'] }}</text>
  22. </view>
  23. <view class="item-info uni-row">
  24. <text class="label">开始时间</text>
  25. <text class="label right">{{ item['startTime']}}</text>
  26. </view>
  27. <view class="item-info uni-row">
  28. <text class="label">结束时间</text>
  29. <text class="label right">{{ (item['endTime'] !="")?item['endTime']:'-'}}</text>
  30. </view>
  31. <view class="item-info uni-row">
  32. <text class="label">废品数</text>
  33. <text class="label right">{{ item['rejectNum']}}</text>
  34. </view>
  35. <view class="item-info uni-row">
  36. <text class="label">废品原因</text>
  37. <text class="label right">{{ (item['reason'] != "")?item['reason']:'-'}}</text>
  38. </view>
  39. <!-- <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 0 : false" class="status-btn uni-row ">
  40. <button class="finished-turnover-tag" size="mini">开始加工</button>
  41. </view> -->
  42. <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 0 : false" class="status-btn uni-row ">
  43. <button class="finished-turnover-tag" size="mini"
  44. @click.stop="handleShowEndWorkDialog(item)">结束报工</button>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. <view class="bottom uni-row">
  49. <button class="bottom-btn left-btn" @click="HandleChangevehicle"><text class="label">更换载具</text></button>
  50. <button class="bottom-btn right-btn" type="primary" @click="handleStartProcessing"><text
  51. class="label">开始加工</text></button>
  52. </view>
  53. <dialog-end-work ref="endWorkDialog" @sendEquipment='getEquipment' @reset="reset" />
  54. <dialog-selectEquipment ref='selectEquipment'
  55. @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectEquipment>
  56. </view>
  57. </template>
  58. <script setup>
  59. import {
  60. ref
  61. } from 'vue'
  62. import {
  63. onLoad,
  64. onReady
  65. } from '@dcloudio/uni-app'
  66. import {
  67. getDayWorkItemList,
  68. saveDayWorkItemBatch
  69. } from "@/api/business/dayWorkItem.js"
  70. import {
  71. store
  72. } from '@/store/index.js'
  73. import {
  74. timestampToTime
  75. } from '@/utils/common.js'
  76. const listData = ref([]) // 回显
  77. const curSubDetails = ref({}) // 接收生产计划单信息
  78. const dayWorkInfo = ref({}) // 接收daywork信息
  79. const equipmentList = ref([]) // 设备列表
  80. const endWorkDialog = ref(null) // 组件
  81. const selectEquipment = ref(null)// 组件
  82. const dayWorkItem = ref({}) // 添加传输对象
  83. const reqParam = ref([]) // 请求参数
  84. const userInfo = ref(null) // 登录员工信息
  85. onLoad(() => {
  86. curSubDetails.value = store.planSubDetails;
  87. dayWorkInfo.value = store.dayworkInfo;
  88. console.log(dayWorkInfo.value)
  89. init();
  90. })
  91. function init() {
  92. userInfo.value = store.userInfo;
  93. uni.showLoading({
  94. title: '加载中'
  95. });
  96. getDayWorkItemList({
  97. dayworkId: dayWorkInfo.value.id
  98. }).then(res => {
  99. listData.value = res.rows || [];
  100. console.log(listData)
  101. // 时间戳转工时
  102. for (var i = 0; i < listData.value.length; i++) {
  103. let timeStamp = Date.parse(listData.value[i].endTime) - Date.parse(listData.value[i].startTime);
  104. listData.value[i].taskTime = (timeStamp / 3600000).toFixed(2) === 'NaN' ? 0 : (timeStamp / 3600000).toFixed(2);
  105. console.log(typeof(listData.value[i].taskTime),listData.value[i].taskTime)
  106. }
  107. uni.hideLoading()
  108. })
  109. }
  110. function reset() {
  111. init();
  112. }
  113. function handleShowEndWorkDialog(data) {
  114. // 调用子组件中的方法
  115. endWorkDialog.value.open(data)
  116. }
  117. function HandleChangevehicle() {
  118. uni.navigateTo({
  119. url: "/pages/changeBox/index"
  120. })
  121. }
  122. function getEquipment(data) {
  123. console.log(data);
  124. equipmentList.value = data;
  125. }
  126. function handleStartProcessing() {
  127. selectEquipment.value.open();
  128. }
  129. function handleAddDayWorkItem(data) {
  130. equipmentList.value = data;
  131. dayWorkItem.value = {
  132. dayworkId: dayWorkInfo.value.id,
  133. lotId: dayWorkInfo.value.lotId,
  134. productionPlanId: curSubDetails.value.productionPlanId,
  135. productionPlanDetailId: curSubDetails.value.productionPlanDetailId,
  136. productionPlanDetailSubDetailId: curSubDetails.value.id,
  137. processId: store.dayworkInfo.currentProcess.id,
  138. technologicalProcessId: dayworkInfo.technologicalProcessId,
  139. startTime: timestampToTime(new Date())
  140. }
  141. for (var i = 0; i < equipmentList.value.length; i++) {
  142. reqParam.value.push(dayWorkItem.value);
  143. reqParam.value[i].equipmentDetailId = equipmentList.value[i].equipmentId;
  144. reqParam.value[i].equipmentDetailCode = equipmentList.value[i].equipmentCode;
  145. console.log(reqParam.value[i])
  146. }
  147. console.log(reqParam.value)
  148. saveDayWorkItemBatch(reqParam.value).then(res => {
  149. if (res.code === 200) {
  150. uni.showToast({
  151. icon: 'success',
  152. title: '操作成功',
  153. duration: 2000
  154. });
  155. init();
  156. } else {
  157. uni.showToast({
  158. icon: 'error',
  159. title: '操作失败',
  160. duration: 2000
  161. });
  162. }
  163. })
  164. }
  165. </script>
  166. <style lang="scss">
  167. .container {
  168. height: 2000rpx;
  169. background-color: #f5f5f5;
  170. overflow: auto;
  171. }
  172. .scroll-container {
  173. position: absolute;
  174. top: 24rpx;
  175. right: 0;
  176. bottom: 144rpx;
  177. left: 0;
  178. }
  179. .selected {
  180. border: 1px solid #1684fc;
  181. }
  182. .list-item {
  183. background-color: #fff;
  184. position: relative;
  185. padding: 16rpx;
  186. padding-bottom: 24rpx;
  187. margin: 0 24rpx;
  188. margin-bottom: 24rpx;
  189. border-radius: 8rpx;
  190. .title-container {
  191. justify-content: space-between;
  192. align-items: center;
  193. margin-top: 8rpx;
  194. width: 100%;
  195. .title {
  196. height: 48rpx;
  197. align-items: center;
  198. flex: 7;
  199. .label {
  200. font-size: 32rpx;
  201. font-weight: bold;
  202. }
  203. .code {
  204. margin-left: 8rpx;
  205. }
  206. }
  207. }
  208. .item-info {
  209. margin-bottom: 8rpx;
  210. .label {
  211. font-size: 28rpx;
  212. width: 152rpx;
  213. color: #808080;
  214. &.right {
  215. flex: 1;
  216. color: #000000;
  217. }
  218. }
  219. }
  220. .right-info {
  221. // justify-content: flex-end;
  222. // width:45%;
  223. // margin-top: 5rpx;
  224. .label {
  225. font-size: 28rpx;
  226. }
  227. .time {
  228. margin-left: 8rpx;
  229. color: #1684fc;
  230. }
  231. .number {
  232. margin-left: 8rpx;
  233. color: #1684fc;
  234. }
  235. }
  236. }
  237. .bottom {
  238. position: fixed;
  239. right: 0;
  240. bottom: 0;
  241. left: 0;
  242. height: 100rpx;
  243. padding: 16rpx 24rpx;
  244. align-items: center;
  245. background-color: #FFFFFF;
  246. justify-content: space-between;
  247. .bottom-btn {
  248. flex: 1;
  249. font-size: 28rpx;
  250. color: #FFFFFF;
  251. &.left-btn {
  252. background-color: rgba(0, 226, 166, 1);
  253. }
  254. &.right-btn {
  255. margin-left: 24rpx;
  256. }
  257. }
  258. }
  259. .status-btn {
  260. width: 100%;
  261. justify-content: flex-end;
  262. .finished-turnover-tag {
  263. margin: unset;
  264. border-radius: 8rpx;
  265. background-color: rgb(255, 85, 85);
  266. font-size: 28rpx;
  267. color: #FFFFFF;
  268. }
  269. }
  270. </style>