index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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'] == 3" 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.$on('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. setTimeout(function(){
  149. uni.hideLoading();
  150. },2000)
  151. let reqData = {};
  152. reqData.productionPlanDetailSubDetailId = id;
  153. console.log(reqData)
  154. getDayWorkList(reqData).then(res => {
  155. console.log(reqData)
  156. listData.value = res.rows;
  157. // 设置下道序
  158. for (let i = 0; i < listData.value.length; i++) {
  159. for (let j = 0; j < listData.value[i].processSequence.length; j++) {
  160. if (listData.value[i].currentProcess.processCode === listData.value[i].processSequence[j]
  161. .processCode) {
  162. listData.value[i].nextProcess = (j + 1) < listData.value[i].processSequence.length ?
  163. listData.value[i].processSequence.slice(j + 1) : [];
  164. }
  165. }
  166. }
  167. console.log(listData.value)
  168. })
  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. console.log(response)
  189. lotDialog.value.open(response.data);
  190. // reqParam.value = response.data
  191. }
  192. })
  193. }
  194. });
  195. }
  196. function handleAddDaywork(data) {
  197. console.log(data)
  198. let reqParam = [];
  199. for (var i = 0; i < data.length; i++) {
  200. reqParam.push(data[i].daywork)
  201. }
  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. // console.log(data)
  218. showDayworkSave(reqParam).then(res => {
  219. console.log(res)
  220. init(curSubPlan.value.id);
  221. })
  222. }
  223. function handleDoIt(data) {
  224. handleAddDaywork(data);
  225. }
  226. function handleDoTurnoverAfter(){
  227. init();
  228. }
  229. function handleCancelTurnover(data){
  230. turnoverDelete(data).then(res => {
  231. if(res.code == 200){
  232. uni.showToast({
  233. icon: "success",
  234. title: "取消成功",
  235. duration: 2000
  236. })
  237. init(curSubPlan.value.id);
  238. }else{
  239. uni.showToast({
  240. icon: "fail",
  241. title: "取消失败",
  242. duration: 2000
  243. })
  244. }
  245. })
  246. }
  247. </script>
  248. <style lang="scss">
  249. .scroll-container {
  250. width: 92%;
  251. margin: 24rpx auto 0 auto;
  252. height: 90%;
  253. }
  254. .list-item {
  255. background-color: #fff;
  256. position: relative;
  257. padding: 16rpx;
  258. padding-bottom: 24rpx;
  259. margin-bottom: 24rpx;
  260. border-radius: 10rpx;
  261. .title-container {
  262. margin-top: 8rpx;
  263. margin-bottom: 16rpx;
  264. .title {
  265. height: 48rpx;
  266. align-items: center;
  267. .label {
  268. font-size: 32rpx;
  269. font-weight: bold;
  270. &.code {
  271. margin-left: 8rpx;
  272. }
  273. }
  274. }
  275. .tag {
  276. border: 1px solid #1CE5B0;
  277. background-color: #F6FFFD;
  278. padding: 8rpx;
  279. border-radius: 8rpx;
  280. .label {
  281. color: #1CE5B0;
  282. font-size: 24rpx;
  283. }
  284. &.finished {
  285. border: 1px solid #BBBBBB;
  286. background-color: #F5F5F5;
  287. .label {
  288. color: #BBBBBB;
  289. }
  290. }
  291. &.turnover {
  292. border: 1px solid #FF7901;
  293. background-color: #F6FFFD;
  294. .label {
  295. color: #FF7901;
  296. }
  297. }
  298. }
  299. }
  300. .item-info {
  301. margin-bottom: 8rpx;
  302. .label {
  303. font-size: 28rpx;
  304. width: 220rpx;
  305. color: #808080;
  306. &.right {
  307. flex: 1;
  308. color: #000000;
  309. }
  310. }
  311. }
  312. .status-btn {
  313. justify-content: flex-end;
  314. align-items: center;
  315. .turnover-tag {
  316. padding-right: 12rpx;
  317. padding-left: 12rpx;
  318. border-radius: 8rpx;
  319. border: 1rpx solid #FF7901;
  320. background-color: #FF7901;
  321. font-size: 28rpx;
  322. color: #FFFFFF;
  323. }
  324. .reporting-tag {
  325. padding-right: 12rpx;
  326. padding-left: 12rpx;
  327. border-radius: 8rpx;
  328. margin-left: 16rpx;
  329. border: 1rpx solid #1684fc;
  330. background-color: #1684fc;
  331. font-size: 28rpx;
  332. color: #FFFFFF;
  333. }
  334. }
  335. }
  336. .bottom {
  337. height: 10%;
  338. position: fixed;
  339. right: 0;
  340. bottom: 0;
  341. left: 0;
  342. height: 100rpx;
  343. border-top: 1px solid #999999;
  344. padding: 16rpx 32rpx;
  345. align-items: center;
  346. background-color: #fff;
  347. .start-batch-btn {
  348. flex: 1;
  349. height: 80rpx;
  350. line-height: 80rpx;
  351. border-radius: 8rpx;
  352. color: #FFFFFF;
  353. font-size: 28rpx;
  354. }
  355. }
  356. </style>