index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <view class="uni-column" style="height: 100%; background-color: #f5f5f5;">
  3. <scroll-view class="scroll-container" scroll-y>
  4. <view v-for="(item, index) in listData" :key="index" class="list-item"
  5. @click="handleToreportingForWork(item)">
  6. <view class="title-container uni-row" style="justify-content: flex-start;">
  7. <view class="title uni-row">
  8. <text class="label">批次号:</text>
  9. <text class="label code">{{ item['lotCode'] }}</text>
  10. </view>
  11. <view class=" uni-row" style="margin-left: 16rpx;">
  12. <view v-if="item['status'] == 1" class="tag"><text class="label">进行中</text></view>
  13. <view v-else-if="item['status'] == 3" class="tag turnover "><text class="label">周转中</text>
  14. </view>
  15. <view v-else-if="item['status'] == 2" class="tag turnover "><text class="label">待周转</text>
  16. </view>
  17. <view v-else-if="item['status'] == 0" class="tag finished "><text class="label">未开始</text>
  18. </view>
  19. <view v-else-if="item['status'] == 4" type="default finished" class="tag finished"><text
  20. class="label">已完成</text></view>
  21. </view>
  22. </view>
  23. <view class="item-info uni-row">
  24. <text class="label">产品描述</text>
  25. <text class="label right">{{ curSubPlan['productDescription'] }}</text>
  26. </view>
  27. <view class="item-info uni-row">
  28. <text class="label">箱号</text>
  29. <text class="label right">{{ item['carrierName'] }}</text>
  30. </view>
  31. <view class="item-info uni-row">
  32. <text class="label">总工时</text>
  33. <text class="label right">{{ item['totalWorkingHours']}}</text>
  34. </view>
  35. <view class="item-info uni-row">
  36. <text class="label">合格数/投入数</text>
  37. <text class="label right">{{ item['qualifiedQuantity'] }}/{{item['processQualifiedNum'] == 0 ? item['oneLotQuantity'] : item['processQualifiedNum']}}</text>
  38. </view>
  39. <view class="item-info uni-row">
  40. <text class="label">上道工序</text>
  41. <text
  42. class="label right">{{ item.prevProcess && item.prevProcess.length > 0 ? item.prevProcess[item.prevProcess.length - 1].processAlias : '无'}}</text>
  43. </view>
  44. <view class="item-info uni-row">
  45. <text class="label">当前工序</text>
  46. <text class="label right">{{ item['currentProcess'].processAlias }}</text>
  47. </view>
  48. <view class="item-info uni-row">
  49. <text class="label">下道工序</text>
  50. <text
  51. class="label right">{{item.prevProcess && item.nextProcess.length > 0 ? item.nextProcess[0].processAlias : null }}</text>
  52. </view>
  53. <view class="item-info uni-row">
  54. <text class="label">设备</text>
  55. <text class="label right">{{ curSubPlan['equipmentName'] }}</text>
  56. </view>
  57. <view class="status-btn uni-row">
  58. <view v-if="item['status'] == 2" class=" uni-row">
  59. <button class="turnover-tag" size="mini"
  60. @click.stop="handleShowTurnoverApplication(item)">周转申请</button>
  61. <!-- <button class="reporting-tag" size="mini" @click="handleToreportingForWork">去报工</button> -->
  62. </view>
  63. <view v-else-if="item['status'] == 3" class=" uni-row">
  64. <button class="turnover-tag" size="mini" @click.stop="handleCancelTurnover(item)">取消周转</button>
  65. </view>
  66. </view>
  67. </view>
  68. </scroll-view>
  69. <view v-if="bottomStatus == 0" class="bottom uni-row">
  70. <button class="start-batch-btn" type="primary" @click="handleStartNewBatch">开始新批次</button>
  71. </view>
  72. <view v-else-if="bottomStatus == 1" class="bottom uni-row">
  73. <button class="start-batch-btn" type="primary" @click="handleScanCode">扫一扫开始新批次</button>
  74. </view>
  75. <view v-else="bottomStatus == 2" class="bottom uni-row">
  76. <button class="start-batch-btn" style="width: 40%;margin-right: 10rpx;" type="primary"
  77. @click="handleStartNewBatch">开始新批次</button>
  78. <button class="start-batch-btn" style="width: 40%;margin-left: 10rpx" type="primary"
  79. @click="handleScanCode">扫一扫开始新批次</button>
  80. </view>
  81. <dialog-lot ref="lotDialog" @submit="handleDoIt" />
  82. <dialog-turnoverApplication ref="turnoverApplicationDialog" @confirm="handleDoTurnoverAfter" />
  83. </view>
  84. </template>
  85. <script setup>
  86. import {
  87. reactive,
  88. ref
  89. } from 'vue'
  90. import {
  91. onLoad,
  92. onReady,
  93. onUnload
  94. } from '@dcloudio/uni-app'
  95. import {
  96. getDayWorkList,
  97. showDaywork,
  98. showDayworkSave,
  99. turnoverDelete
  100. } from '@/api/business/dayWork.js'
  101. import {
  102. store
  103. } from '@/store/index.js'
  104. import {
  105. toHHmmss
  106. } from '@/utils/common.js'
  107. const turnoverApplicationDialog = ref(null)
  108. const lotDialog = ref(null)
  109. const listData = ref([])
  110. const bizDayworkObj = ref({})
  111. const curSubPlan = ref({}) // 子计划单信息
  112. const processInfo = ref([]) // 员工工序信息
  113. const bottomStatus = ref(0) // 底部按钮显示
  114. const reqParam = ref(null);
  115. const curDayworkItem = ref({}) // 当前报工记录,回显是否显示取消周转的状态
  116. onLoad(() => {
  117. curSubPlan.value = store.planSubDetails || {
  118. processSequence: []
  119. };
  120. console.log(store.planSubDetails)
  121. processInfo.value = store.userProcessInfo || [];
  122. let sunPlanProcesses = [];
  123. let userProcesses = [];
  124. for (let i = 0; i < curSubPlan.value.processSequence.length; i++) {
  125. sunPlanProcesses.push(curSubPlan.value.processSequence[i].id)
  126. }
  127. for (let i = 0; i < processInfo.value.length; i++) {
  128. userProcesses.push(processInfo.value[i].id)
  129. }
  130. // 判断员工开始批次按钮显示bottomStatus状态
  131. if (userProcesses.includes(sunPlanProcesses[0]) && userProcesses.length == 1) {
  132. bottomStatus.value = 0;
  133. } else if (userProcesses.includes(sunPlanProcesses[0]) && userProcesses.length > 1) {
  134. bottomStatus.value = 2;
  135. } else {
  136. bottomStatus.value = 1;
  137. }
  138. init(curSubPlan.value.id);
  139. uni.$once('batchReporting-addBatch', () => {
  140. init(curSubPlan.value.id);
  141. })
  142. uni.$on('dayworkItemUpdate', reflush)
  143. })
  144. onUnload(() => {
  145. // uni.$off('dayworkItemUpdate', reflush)
  146. })
  147. function reflush() {
  148. init(curSubPlan.value.id);
  149. }
  150. function handleShowTurnoverApplication(data) {
  151. let _data = data ?? {}
  152. // 调用子组件中的方法
  153. turnoverApplicationDialog.value.open(_data)
  154. }
  155. function handleStartNewBatch() {
  156. uni.navigateTo({
  157. url: "/pages/addNewBatch/index"
  158. })
  159. }
  160. function init(id) {
  161. uni.showLoading({
  162. title: '加载中'
  163. });
  164. let reqData = {};
  165. reqData.productionPlanDetailSubDetailId = id;
  166. console.log(reqData)
  167. getDayWorkList(reqData).then(res => {
  168. console.log(reqData)
  169. listData.value = res.rows;
  170. // 设置下道序
  171. for (let i = 0; i < listData.value.length; i++) {
  172. for (let j = 0; j < listData.value[i].processSequence.length; j++) {
  173. if (listData.value[i].currentProcess.processCode === listData.value[i].processSequence[j]
  174. .processCode) {
  175. listData.value[i].nextProcess = (j + 1) < listData.value[i].processSequence.length ?
  176. listData.value[i].processSequence.slice(j + 1) : [];
  177. }
  178. }
  179. }
  180. // 计算总工时
  181. for (let i = 0; i < listData.value.length; i++) {
  182. listData.value[i].totalWorkingHours = 0;
  183. if (listData.value[i].dayworkItemList) {
  184. for (let j = 0; j < listData.value[i].dayworkItemList.length; j++) {
  185. if (listData.value[i].dayworkItemList[j].status == 2 || listData.value[i].dayworkItemList[
  186. j].status == 3) {
  187. listData.value[i].totalWorkingHours += Number(listData.value[i].dayworkItemList[j].workingHours);
  188. }
  189. }
  190. listData.value[i].totalWorkingHours = toHHmmss(listData.value[i].totalWorkingHours);
  191. }
  192. }
  193. console.log(listData.value)
  194. uni.hideLoading();
  195. })
  196. }
  197. function handleToreportingForWork(item) {
  198. store.dayworkInfo = item
  199. uni.navigateTo({
  200. url: "/pages/reportingForWork/index"
  201. })
  202. }
  203. function handleScanCode() {
  204. uni.scanCode({
  205. scanType: ['qrCode'],
  206. onlyFromCamera: true, // 只允许相机扫码
  207. autoZoom: false,
  208. success: function(res) {
  209. console.log(res.result)
  210. let vehicleObj = JSON.parse(res.result);
  211. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  212. uni.showToast({
  213. icon: "error",
  214. title: "请扫载具码",
  215. duration: 1000
  216. })
  217. return;
  218. }
  219. showDaywork({
  220. carrierId: vehicleObj.carrierId,
  221. status: 7
  222. }).then(response => {
  223. if (response.code == 200) {
  224. console.log(response)
  225. lotDialog.value.open(response.data);
  226. }
  227. })
  228. }
  229. });
  230. }
  231. function handleAddDaywork(data) {
  232. console.log(data)
  233. let reqParam = [];
  234. for (var i = 0; i < data.length; i++) {
  235. reqParam.push(data[i].daywork)
  236. }
  237. // for (let i = 0; i < listData.value.length; i++) {
  238. // if (Object.entries(listData.value[i]).toString() === Object.entries(data).toString()) {
  239. // uni.showToast({
  240. // icon: "error",
  241. // title: "该批次已存在"
  242. // })
  243. // console.log("该批次已存在")
  244. // return;
  245. // }
  246. // }
  247. // listData.value.push(data);
  248. // for (let i = 0; i < listData.value.length; i++) {
  249. // listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  250. // }
  251. // console.log(listData.value)
  252. // console.log(data)
  253. showDayworkSave(reqParam).then(res => {
  254. console.log(res)
  255. init(curSubPlan.value.id);
  256. })
  257. }
  258. function handleDoIt(data) {
  259. handleAddDaywork(data);
  260. }
  261. function handleDoTurnoverAfter() {
  262. init();
  263. }
  264. function handleCancelTurnover(data) {
  265. turnoverDelete(data).then(res => {
  266. if (res.code == 200) {
  267. uni.showToast({
  268. icon: "success",
  269. title: "取消成功",
  270. duration: 2000
  271. })
  272. init(curSubPlan.value.id);
  273. } else {
  274. uni.showToast({
  275. icon: "fail",
  276. title: "取消失败",
  277. duration: 2000
  278. })
  279. }
  280. })
  281. }
  282. </script>
  283. <style lang="scss">
  284. .scroll-container {
  285. width: 92%;
  286. margin: 24rpx auto 0 auto;
  287. height: 90%;
  288. }
  289. .list-item {
  290. background-color: #fff;
  291. position: relative;
  292. padding: 16rpx;
  293. padding-bottom: 24rpx;
  294. margin-bottom: 24rpx;
  295. border-radius: 10rpx;
  296. .title-container {
  297. margin-top: 8rpx;
  298. margin-bottom: 16rpx;
  299. .title {
  300. height: 48rpx;
  301. align-items: center;
  302. .label {
  303. font-size: 32rpx;
  304. font-weight: bold;
  305. &.code {
  306. margin-left: 8rpx;
  307. }
  308. }
  309. }
  310. .tag {
  311. border: 1px solid #1CE5B0;
  312. background-color: #F6FFFD;
  313. padding: 8rpx;
  314. border-radius: 8rpx;
  315. .label {
  316. color: #1CE5B0;
  317. font-size: 24rpx;
  318. }
  319. &.finished {
  320. border: 1px solid #BBBBBB;
  321. background-color: #F5F5F5;
  322. .label {
  323. color: #BBBBBB;
  324. }
  325. }
  326. &.turnover {
  327. border: 1px solid #FF7901;
  328. background-color: #F6FFFD;
  329. .label {
  330. color: #FF7901;
  331. }
  332. }
  333. }
  334. }
  335. .item-info {
  336. margin-bottom: 8rpx;
  337. .label {
  338. font-size: 28rpx;
  339. width: 220rpx;
  340. color: #808080;
  341. &.right {
  342. flex: 1;
  343. color: #000000;
  344. }
  345. }
  346. }
  347. .status-btn {
  348. justify-content: flex-end;
  349. align-items: center;
  350. .turnover-tag {
  351. padding-right: 12rpx;
  352. padding-left: 12rpx;
  353. border-radius: 8rpx;
  354. border: 1rpx solid #FF7901;
  355. background-color: #FF7901;
  356. font-size: 28rpx;
  357. color: #FFFFFF;
  358. }
  359. .reporting-tag {
  360. padding-right: 12rpx;
  361. padding-left: 12rpx;
  362. border-radius: 8rpx;
  363. margin-left: 16rpx;
  364. border: 1rpx solid #1684fc;
  365. background-color: #1684fc;
  366. font-size: 28rpx;
  367. color: #FFFFFF;
  368. }
  369. }
  370. }
  371. .bottom {
  372. height: 10%;
  373. position: fixed;
  374. right: 0;
  375. bottom: 0;
  376. left: 0;
  377. height: 100rpx;
  378. border-top: 1px solid #999999;
  379. padding: 16rpx 32rpx;
  380. align-items: center;
  381. background-color: #fff;
  382. .start-batch-btn {
  383. flex: 1;
  384. height: 80rpx;
  385. line-height: 80rpx;
  386. border-radius: 8rpx;
  387. color: #FFFFFF;
  388. font-size: 28rpx;
  389. }
  390. }
  391. </style>