index.vue 9.2 KB

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