index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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"
  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. technologicalProcessId: dayworkInfo.technologicalProcessId,
  136. startTime: timestampToTime(new Date())
  137. }
  138. for (var i = 0; i < equipmentList.value.length; i++) {
  139. reqParam.value.push(dayWorkItem.value);
  140. reqParam.value[i].equipmentDetailId = equipmentList.value[i].equipmentId;
  141. reqParam.value[i].equipmentDetailCode = equipmentList.value[i].equipmentCode;
  142. console.log(reqParam.value[i])
  143. }
  144. console.log(reqParam.value)
  145. saveDayWorkItemBatch(reqParam.value).then(res => {
  146. if (res.code === 200) {
  147. uni.showToast({
  148. icon: 'success',
  149. title: '操作成功',
  150. duration: 2000
  151. });
  152. init();
  153. } else {
  154. uni.showToast({
  155. icon: 'error',
  156. title: '操作失败',
  157. duration: 2000
  158. });
  159. }
  160. })
  161. }
  162. </script>
  163. <style lang="scss">
  164. .container {
  165. height: 2000rpx;
  166. background-color: #f5f5f5;
  167. overflow: auto;
  168. }
  169. .scroll-container {
  170. position: absolute;
  171. top: 24rpx;
  172. right: 0;
  173. bottom: 144rpx;
  174. left: 0;
  175. }
  176. .selected {
  177. border: 1px solid #1684fc;
  178. }
  179. .list-item {
  180. background-color: #fff;
  181. position: relative;
  182. padding: 16rpx;
  183. padding-bottom: 24rpx;
  184. margin: 0 24rpx;
  185. margin-bottom: 24rpx;
  186. border-radius: 8rpx;
  187. .title-container {
  188. justify-content: space-between;
  189. align-items: center;
  190. margin-top: 8rpx;
  191. width: 100%;
  192. .title {
  193. height: 48rpx;
  194. align-items: center;
  195. flex: 7;
  196. .label {
  197. font-size: 32rpx;
  198. font-weight: bold;
  199. }
  200. .code {
  201. margin-left: 8rpx;
  202. }
  203. }
  204. }
  205. .item-info {
  206. margin-bottom: 8rpx;
  207. .label {
  208. font-size: 28rpx;
  209. width: 152rpx;
  210. color: #808080;
  211. &.right {
  212. flex: 1;
  213. color: #000000;
  214. }
  215. }
  216. }
  217. .right-info {
  218. // justify-content: flex-end;
  219. // width:45%;
  220. // margin-top: 5rpx;
  221. .label {
  222. font-size: 28rpx;
  223. }
  224. .time {
  225. margin-left: 8rpx;
  226. color: #1684fc;
  227. }
  228. .number {
  229. margin-left: 8rpx;
  230. color: #1684fc;
  231. }
  232. }
  233. }
  234. .bottom {
  235. position: fixed;
  236. right: 0;
  237. bottom: 0;
  238. left: 0;
  239. height: 100rpx;
  240. padding: 16rpx 24rpx;
  241. align-items: center;
  242. background-color: #FFFFFF;
  243. justify-content: space-between;
  244. .bottom-btn {
  245. flex: 1;
  246. font-size: 28rpx;
  247. color: #FFFFFF;
  248. &.left-btn {
  249. background-color: rgba(0, 226, 166, 1);
  250. }
  251. &.right-btn {
  252. margin-left: 24rpx;
  253. }
  254. }
  255. }
  256. .status-btn {
  257. width: 100%;
  258. justify-content: flex-end;
  259. .finished-turnover-tag {
  260. margin: unset;
  261. border-radius: 8rpx;
  262. background-color: rgb(255, 85, 85);
  263. font-size: 28rpx;
  264. color: #FFFFFF;
  265. }
  266. }
  267. </style>