index.vue 7.0 KB

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