index.vue 9.2 KB

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