index.vue 10 KB

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