index.vue 9.9 KB

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