index.vue 9.0 KB

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