index.vue 8.2 KB

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