index.vue 7.8 KB

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