index.vue 10 KB

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