index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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">
  6. <view class="title uni-row">
  7. <text class="label">批次号:</text>
  8. <text class="label code"> {{ item['lotCode'] }}</text>
  9. </view>
  10. <view class="uni-row">
  11. <view class="right-info uni-row"> <text class="label">工时</text>
  12. <text class="label time">{{ item['taskTime'] }}</text>
  13. <!-- <text class="label time">{{ item['taskTime'] }}h</text> -->
  14. </view>
  15. <view class="right-info uni-row" style="margin-left: 50rpx;"> <text class="label">合格数</text>
  16. <text class="label number ">{{ item['qualifiedNum'] }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="item-info uni-row">
  21. <text class="label">产品描述</text>
  22. <text class="label right">{{ curSubDetails['productDescription'] }}</text>
  23. </view>
  24. <view class="item-info uni-row">
  25. <text class="label">操作者</text>
  26. <text class="label right">{{ item['nickName'] }}</text>
  27. </view>
  28. <view class="item-info uni-row">
  29. <text class="label">开始时间</text>
  30. <text class="label right">{{ item['startTime']}}</text>
  31. </view>
  32. <view class="item-info uni-row">
  33. <text class="label">结束时间</text>
  34. <text class="label right">{{ (item['endTime'] !="")?item['endTime']:'-'}}</text>
  35. </view>
  36. <view class="item-info uni-row">
  37. <text class="label">废品数</text>
  38. <text class="label right">{{ item['rejectSum'] ? item['rejectSum'] : 0 }}</text>
  39. </view>
  40. <view class="item-info uni-row">
  41. <text class="label">设备</text>
  42. <text class="label right">{{ item['equipmentDetailCode']}}</text>
  43. </view>
  44. <!-- <view class="item-info uni-row">
  45. <text class="label">废品原因</text>
  46. <text class="label right">{{ (item['reason'] != "")?item['reason']:'-'}}</text>
  47. </view> -->
  48. <!-- <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 0 : false" class="status-btn uni-row ">
  49. <button class="finished-turnover-tag" size="mini">开始加工</button>
  50. </view> -->
  51. <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 1 : false"
  52. class="status-btn uni-row ">
  53. <button class="finished-turnover-tag" size="mini"
  54. @click.stop="handleShowEndWorkDialog(item)">结束报工</button>
  55. </view>
  56. <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 0 : false"
  57. class="status-btn uni-row ">
  58. <button class="start-turnover-tag" size="mini" type="primary"
  59. @click.stop="handleStartProcessing(item)">开始报工</button>
  60. </view>
  61. </view>
  62. </scroll-view>
  63. <view class="bottom uni-row">
  64. <button class="bottom-btn left-btn" @click="HandleChangevehicle"><text class="label">更换载具</text></button>
  65. <button class="bottom-btn right-btn" type="primary" @click="handleStartProcessing(null)"><text
  66. class="label">开始加工</text></button>
  67. </view>
  68. <dialog-end-work ref="endWorkDialog" @sendEquipment='getEquipment' />
  69. <dialog-selectEquipment ref='selectEquipment'
  70. @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectEquipment>
  71. </view>
  72. </template>
  73. <script setup>
  74. import {
  75. ref
  76. } from 'vue'
  77. import {
  78. onLoad,
  79. onReady,
  80. onUnload
  81. } from '@dcloudio/uni-app'
  82. import {
  83. getDayWorkItemList,
  84. saveDayWorkItemBatch,
  85. updateDayWorkItem
  86. } from "@/api/business/dayWorkItem.js"
  87. import {
  88. store
  89. } from '@/store/index.js'
  90. import {
  91. timestampToTime,
  92. toHHmmss
  93. } from '@/utils/common.js'
  94. const listData = ref([]) // 回显
  95. const curSubDetails = ref({}) // 接收生产计划单信息
  96. const dayWorkInfo = ref({}) // 接收daywork信息
  97. const equipmentList = ref([]) // 设备列表
  98. const endWorkDialog = ref(null) // 组件
  99. const selectEquipment = ref(null) // 组件
  100. const dayWorkItem = ref({}) // 添加传输对象
  101. const reqParam = ref([]) // 请求参数
  102. const userInfo = ref(null) // 登录员工信息
  103. const flag = ref(true) // 控制底部开始加工按钮功能
  104. onLoad(() => {
  105. curSubDetails.value = store.planSubDetails;
  106. dayWorkInfo.value = store.dayworkInfo;
  107. console.log(dayWorkInfo.value)
  108. init();
  109. uni.$on('dayworkItemUpdate', reflush)
  110. })
  111. onUnload(() => {
  112. // uni.$off('dayworkItemUpdate', reflush)
  113. })
  114. function init() {
  115. userInfo.value = store.userInfo;
  116. uni.showLoading({
  117. title: '加载中'
  118. });
  119. getDayWorkItemList({
  120. dayworkId: dayWorkInfo.value.id,
  121. processId: store.dayworkInfo.currentProcess.id,
  122. type: '非周转中item'
  123. }).then(res => {
  124. if (res.code == 200) {
  125. listData.value = res.rows || [];
  126. console.log(listData)
  127. // 时间戳转工时
  128. for (var i = 0; i < listData.value.length; i++) {
  129. let timeStamp = listData.value[i].workingHours;
  130. listData.value[i].taskTime = toHHmmss(timeStamp);
  131. }
  132. flag.value = listData.value[0].status == 2 ? false : true;
  133. console.log(flag.value)
  134. uni.hideLoading();
  135. } else {
  136. uni.showToast({
  137. icon: "error",
  138. title: res.message,
  139. duration: 1000
  140. })
  141. uni.hideLoading();
  142. }
  143. })
  144. }
  145. function reflush() {
  146. init();
  147. }
  148. function handleShowEndWorkDialog(data) {
  149. // 调用子组件中的方法
  150. endWorkDialog.value.open(data)
  151. }
  152. function HandleChangevehicle() {
  153. uni.navigateTo({
  154. url: "/pages/changeBox/index"
  155. })
  156. }
  157. function getEquipment(data) {
  158. console.log(data);
  159. equipmentList.value = data;
  160. }
  161. function handleStartProcessing(item) {
  162. if(item){
  163. selectEquipment.value.open(item);
  164. }else{
  165. if (flag.value) {
  166. uni.showToast({
  167. icon: "none",
  168. title: "报工未结束或工序已完成"
  169. })
  170. } else {
  171. selectEquipment.value.open(item);
  172. }
  173. }
  174. }
  175. /**
  176. * 新批次默认item去报工(执行方法)
  177. * @param {Object} item
  178. */
  179. function handleStartFirstItem(item) {
  180. let reqParam = item;
  181. reqParam.status = 1;
  182. reqParam.startTime = timestampToTime(new Date());
  183. updateDayWorkItem(reqParam).then(res => {
  184. if (res.code === 200) {
  185. uni.showToast({
  186. icon: "success",
  187. title: "报工成功",
  188. duration: 2000
  189. })
  190. init();
  191. } else {
  192. uni.showToast({
  193. icon: "fail",
  194. title: "报工失败,请联系管理员",
  195. duration: 2000
  196. })
  197. }
  198. })
  199. }
  200. function handleAddDayWorkItem(data) {
  201. console.log(data)
  202. if (data[0].dayworkId) { // data里面任意一对象除了设备相关的字段存在,直接给reqParam赋值
  203. reqParam.value = data;
  204. } else {
  205. // equipmentList.value = data;
  206. dayWorkItem.value = {
  207. dayworkId: dayWorkInfo.value.id,
  208. lotId: dayWorkInfo.value.lotId,
  209. productionPlanId: curSubDetails.value.productionPlanId,
  210. productionPlanDetailId: curSubDetails.value.productionPlanDetailId,
  211. productionPlanDetailSubDetailId: curSubDetails.value.id,
  212. processId: store.dayworkInfo.currentProcess.id,
  213. technologicalProcessId: store.dayworkInfo.technologicalProcessId,
  214. status: 1,
  215. startTime: timestampToTime(new Date())
  216. }
  217. for (var i = 0; i < data.length; i++) {
  218. reqParam.value.push(dayWorkItem.value);
  219. reqParam.value[i].equipmentDetailId = data[i].equipmentDetailId;
  220. reqParam.value[i].equipmentDetailCode = data[i].equipmentDetailCode;
  221. }
  222. }
  223. console.log(reqParam.value)
  224. saveDayWorkItemBatch(reqParam.value).then(res => {
  225. if (res.code === 200) {
  226. uni.showToast({
  227. icon: 'success',
  228. title: '操作成功',
  229. duration: 2000
  230. });
  231. reqParam.value = [];
  232. init();
  233. uni.$emit('dayworkItemUpdate');
  234. } else {
  235. uni.showToast({
  236. icon: 'error',
  237. title: '操作失败',
  238. duration: 2000
  239. });
  240. }
  241. })
  242. }
  243. </script>
  244. <style lang="scss">
  245. .container {
  246. height: calc(100% - 144rpx);
  247. background-color: #f5f5f5;
  248. overflow: auto;
  249. }
  250. .scroll-container {
  251. position: relative;
  252. top: 24rpx;
  253. // right: 0;
  254. // bottom: 144rpx;
  255. // left: 0;
  256. }
  257. .selected {
  258. border: 1px solid #1684fc;
  259. }
  260. .list-item {
  261. background-color: #fff;
  262. position: relative;
  263. padding: 16rpx;
  264. padding-bottom: 24rpx;
  265. margin: 0 24rpx;
  266. margin-bottom: 24rpx;
  267. border-radius: 8rpx;
  268. .title-container {
  269. margin: 8rpx 0;
  270. width: 100%;
  271. .title {
  272. height: 48rpx;
  273. align-items: center;
  274. flex: 7;
  275. .label {
  276. // font-size: 32rpx;
  277. font-weight: bold;
  278. }
  279. .code {
  280. margin-left: 8rpx;
  281. }
  282. }
  283. }
  284. .item-info {
  285. margin-bottom: 8rpx;
  286. .label {
  287. font-size: 28rpx;
  288. width: 152rpx;
  289. color: #808080;
  290. &.right {
  291. flex: 1;
  292. color: #000000;
  293. }
  294. }
  295. }
  296. .right-info {
  297. // justify-content: flex-end;
  298. // width:45%;
  299. // margin-top: 5rpx;
  300. .label {
  301. font-size: 28rpx;
  302. }
  303. .time {
  304. margin-left: 8rpx;
  305. color: #1684fc;
  306. }
  307. .number {
  308. margin-left: 8rpx;
  309. color: #1684fc;
  310. }
  311. }
  312. }
  313. .bottom {
  314. position: fixed;
  315. right: 0;
  316. bottom: 0;
  317. left: 0;
  318. height: 100rpx;
  319. padding: 16rpx 24rpx;
  320. align-items: center;
  321. background-color: #FFFFFF;
  322. justify-content: space-between;
  323. .bottom-btn {
  324. flex: 1;
  325. font-size: 28rpx;
  326. color: #FFFFFF;
  327. &.left-btn {
  328. background-color: rgba(0, 226, 166, 1);
  329. }
  330. &.right-btn {
  331. margin-left: 24rpx;
  332. }
  333. }
  334. }
  335. .status-btn {
  336. width: 100%;
  337. justify-content: flex-end;
  338. .finished-turnover-tag {
  339. margin: unset;
  340. border-radius: 8rpx;
  341. background-color: rgb(255, 85, 85);
  342. font-size: 28rpx;
  343. color: #FFFFFF;
  344. }
  345. .start-turnover-tag {
  346. margin: unset;
  347. border-radius: 8rpx;
  348. font-size: 28rpx;
  349. color: #FFFFFF;
  350. }
  351. }
  352. </style>