index.vue 7.6 KB

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