index.vue 10 KB

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