index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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.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.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">取消周转</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" />
  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. } from '@/api/business/dayWork.js'
  89. // import {
  90. // getDayWorkItemList
  91. // } from '@/api/business/dayWorkItem.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.$on('batchReporting-addBatch', () => {
  128. init(curSubPlan.value.id);
  129. })
  130. })
  131. function handleShowTurnoverApplication(data) {
  132. let _data = data ?? {}
  133. // 调用子组件中的方法
  134. turnoverApplicationDialog.value.open(_data)
  135. }
  136. function handleStartNewBatch() {
  137. uni.navigateTo({
  138. url: "/pages/addNewBatch/index"
  139. })
  140. }
  141. function init(id) {
  142. uni.showLoading({
  143. title: '加载中'
  144. });
  145. let reqData = {};
  146. reqData.productionPlanDetailSubDetailId = id;
  147. // console.log(reqData)
  148. getDayWorkList(reqData).then(res => {
  149. console.log(reqData)
  150. listData.value = res.rows;
  151. // 设置下道序
  152. for (let i = 0; i < listData.value.length; i++) {
  153. for (let j = 0; j < listData.value[i].processSequence.length; j++) {
  154. if (listData.value[i].currentProcess.processCode === listData.value[i].processSequence[j]
  155. .processCode) {
  156. listData.value[i].nextProcess = (j + 1) < listData.value[i].processSequence.length ?
  157. listData.value[i].processSequence.slice(j + 1) : [];
  158. }
  159. }
  160. }
  161. console.log(listData.value)
  162. // if (res.rows.length > 0) {
  163. // for (let i = 0; i < listData.value.length; i++) {
  164. // getDayWorkItemList({
  165. // dayworkId: listData.value[i].id,
  166. // userId: store.userInfo.userId
  167. // }).then(response => {
  168. // if (response.code == 200) {
  169. // curDayworkItem.value = response.rows[0]
  170. // console.log(res)
  171. // }
  172. // })
  173. // }
  174. // }
  175. uni.hideLoading();
  176. })
  177. }
  178. function handleToreportingForWork(item) {
  179. store.dayworkInfo = item
  180. uni.navigateTo({
  181. url: "/pages/reportingForWork/index"
  182. })
  183. }
  184. function handleScanCode() {
  185. uni.scanCode({
  186. scanType: ['qrCode'],
  187. onlyFromCamera: true, // 只允许相机扫码
  188. success: function(res) {
  189. console.log(res.result)
  190. let vehicleObj = JSON.parse(res.result);
  191. showDaywork({
  192. carrierId: vehicleObj.carrierId,
  193. status: 7
  194. }).then(response => {
  195. lotDialog.value.open(response.data);
  196. reqParam.value = response.data
  197. })
  198. }
  199. });
  200. }
  201. function handleAddDaywork(data) {
  202. for (let i = 0; i < listData.value.length; i++) {
  203. if (Object.entries(listData.value[i]).toString() === Object.entries(data).toString()) {
  204. uni.showToast({
  205. icon: "error",
  206. title: "该批次已存在"
  207. })
  208. console.log("该批次已存在")
  209. return;
  210. }
  211. }
  212. listData.value.push(data);
  213. for (let i = 0; i < listData.value.length; i++) {
  214. listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  215. }
  216. console.log(listData.value)
  217. showDayworkSave(data).then(res => {
  218. init(curSubPlan.value.id);
  219. })
  220. }
  221. function handleDoIt() {
  222. handleAddDaywork(reqParam.value);
  223. }
  224. </script>
  225. <style lang="scss">
  226. .scroll-container {
  227. width: 92%;
  228. margin: 24rpx auto 0 auto;
  229. height: 90%;
  230. }
  231. .list-item {
  232. background-color: #fff;
  233. position: relative;
  234. padding: 16rpx;
  235. padding-bottom: 24rpx;
  236. margin-bottom: 24rpx;
  237. border-radius: 10rpx;
  238. .title-container {
  239. margin-top: 8rpx;
  240. margin-bottom: 16rpx;
  241. .title {
  242. height: 48rpx;
  243. align-items: center;
  244. .label {
  245. font-size: 32rpx;
  246. font-weight: bold;
  247. &.code {
  248. margin-left: 8rpx;
  249. }
  250. }
  251. }
  252. .tag {
  253. border: 1px solid #1CE5B0;
  254. background-color: #F6FFFD;
  255. padding: 8rpx;
  256. border-radius: 8rpx;
  257. .label {
  258. color: #1CE5B0;
  259. font-size: 24rpx;
  260. }
  261. &.finished {
  262. border: 1px solid #BBBBBB;
  263. background-color: #F5F5F5;
  264. .label {
  265. color: #BBBBBB;
  266. }
  267. }
  268. &.turnover {
  269. border: 1px solid #FF7901;
  270. background-color: #F6FFFD;
  271. .label {
  272. color: #FF7901;
  273. }
  274. }
  275. }
  276. }
  277. .item-info {
  278. margin-bottom: 8rpx;
  279. .label {
  280. font-size: 28rpx;
  281. width: 220rpx;
  282. color: #808080;
  283. &.right {
  284. flex: 1;
  285. color: #000000;
  286. }
  287. }
  288. }
  289. .status-btn {
  290. justify-content: flex-end;
  291. align-items: center;
  292. .turnover-tag {
  293. padding-right: 12rpx;
  294. padding-left: 12rpx;
  295. border-radius: 8rpx;
  296. border: 1rpx solid #FF7901;
  297. background-color: #FF7901;
  298. font-size: 28rpx;
  299. color: #FFFFFF;
  300. }
  301. .reporting-tag {
  302. padding-right: 12rpx;
  303. padding-left: 12rpx;
  304. border-radius: 8rpx;
  305. margin-left: 16rpx;
  306. border: 1rpx solid #1684fc;
  307. background-color: #1684fc;
  308. font-size: 28rpx;
  309. color: #FFFFFF;
  310. }
  311. }
  312. }
  313. .bottom {
  314. height: 10%;
  315. position: fixed;
  316. right: 0;
  317. bottom: 0;
  318. left: 0;
  319. height: 100rpx;
  320. border-top: 1px solid #999999;
  321. padding: 16rpx 32rpx;
  322. align-items: center;
  323. background-color: #fff;
  324. .start-batch-btn {
  325. flex: 1;
  326. height: 80rpx;
  327. // padding-top: 20 rpx;
  328. border-radius: 8rpx;
  329. color: #FFFFFF;
  330. font-size: 28rpx;
  331. }
  332. }
  333. </style>