index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <view class="uni-column" style="height: 100%; background-color: #f5f5f5;">
  3. <view class="box-bg uni-row">
  4. <view class="input-view uni-row">
  5. <uni-icons class="input-uni-icon" type="search" size="18" color="#999" />
  6. <input class="nav-bar-input" type="text" v-model="keywords" placeholder="输入搜索关键词" />
  7. </view>
  8. <view class="search" @click="handleSearch">
  9. 搜索
  10. </view>
  11. </view>
  12. <view class="scroll-container" >
  13. <view v-for="(item, index) in listData" :key="index" class="list-item"
  14. @click="handleToreportingForWork(item)">
  15. <view class="title-container uni-row" style="justify-content: flex-start;">
  16. <view class="title uni-row">
  17. <text class="label">批次号:</text>
  18. <text class="label code">{{ item['lotCode'] }}</text>
  19. </view>
  20. <view class=" uni-row" style="margin-left: 16rpx;">
  21. <view v-if="item['status'] == 1" class="tag"><text class="label">进行中</text></view>
  22. <view v-else-if="item['status'] == 3" class="tag turnover "><text class="label">周转中</text>
  23. </view>
  24. <view v-else-if="item['status'] == 2" class="tag turnover "><text class="label">待周转</text>
  25. </view>
  26. <view v-else-if="item['status'] == 0" class="tag finished "><text class="label">未开始</text>
  27. </view>
  28. <view v-else-if="item['status'] == 4" type="default finished" class="tag finished"><text
  29. class="label">已完成</text></view>
  30. </view>
  31. </view>
  32. <view class="item-info uni-row">
  33. <text class="label">产品描述</text>
  34. <text class="label right">{{ curSubPlan['productDescription'] }}</text>
  35. </view>
  36. <view class="item-info uni-row">
  37. <text class="label">箱号</text>
  38. <text class="label right">{{ item['carrierName'] }}</text>
  39. </view>
  40. <view class="item-info uni-row">
  41. <text class="label">总工时</text>
  42. <text class="label right">{{ item['totalWorkingHours']}}</text>
  43. </view>
  44. <view class="item-info uni-row">
  45. <text class="label">合格数/投入数</text>
  46. <text class="label right">{{ item['qualifiedQuantity'] }}/{{item['processQualifiedNum'] == 0 ? item['oneLotQuantity'] : item['processQualifiedNum']}}</text>
  47. </view>
  48. <view class="item-info uni-row">
  49. <text class="label">上道工序</text>
  50. <text
  51. class="label right">{{ item.prevProcess && item.prevProcess.length > 0 ? item.prevProcess[item.prevProcess.length - 1].processAlias : '无'}}</text>
  52. </view>
  53. <view class="item-info uni-row">
  54. <text class="label">当前工序</text>
  55. <text class="label right">{{ item['currentProcess'].processAlias }}</text>
  56. </view>
  57. <view class="item-info uni-row">
  58. <text class="label">下道工序</text>
  59. <text
  60. class="label right">{{item.prevProcess && item.nextProcess.length > 0 ? item.nextProcess[0].processAlias : null }}</text>
  61. </view>
  62. <view class="item-info uni-row">
  63. <text class="label">设备</text>
  64. <text class="label right">{{ curSubPlan['equipmentName'] }}</text>
  65. </view>
  66. <view v-if="notPreProcess" class="item-info uni-row">
  67. <text class="label">所在区域</text>
  68. <text class="label right">{{ curSubPlan['area'] }}</text>
  69. </view>
  70. <view class="status-btn uni-row">
  71. <view v-if="item['status'] == 2" class=" uni-row">
  72. <button class="turnover-tag" size="mini"
  73. @click.stop="handleShowTurnoverApplication(item)">周转申请</button>
  74. <!-- <button class="reporting-tag" size="mini" @click="handleToreportingForWork">去报工</button> -->
  75. </view>
  76. <view v-else-if="item['status'] == 3" class=" uni-row">
  77. <button class="turnover-tag" size="mini" @click.stop="handleCancelTurnover(item)">取消周转</button>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view v-if="bottomStatus == 0" class="bottom uni-row">
  83. <button class="start-batch-btn" type="primary" @click="handleStartNewBatch">开始新批次</button>
  84. </view>
  85. <view v-else-if="bottomStatus == 1" class="bottom uni-row">
  86. <button class="start-batch-btn" type="primary" @click="handleScanCode">扫一扫开始新批次</button>
  87. </view>
  88. <view v-else="bottomStatus == 2" class="bottom uni-row">
  89. <button class="start-batch-btn" style="width: 40%;margin-right: 10rpx;" type="primary"
  90. @click="handleStartNewBatch">开始新批次</button>
  91. <button class="start-batch-btn" style="width: 40%;margin-left: 10rpx" type="primary"
  92. @click="handleScanCode">扫一扫开始新批次</button>
  93. </view>
  94. <dialog-lot ref="lotDialog" @submit="handleDoIt" />
  95. <dialog-turnoverApplication ref="turnoverApplicationDialog" @confirm="handleDoTurnoverAfter" />
  96. </view>
  97. </template>
  98. <script setup>
  99. import {
  100. reactive,
  101. ref
  102. } from 'vue'
  103. import {
  104. onLoad,
  105. onReady,
  106. onUnload
  107. } from '@dcloudio/uni-app'
  108. import {
  109. getDayWorkList,
  110. showDaywork,
  111. showDayworkSave,
  112. turnoverDelete
  113. } from '@/api/business/dayWork.js'
  114. import {
  115. store
  116. } from '@/store/index.js'
  117. import {
  118. toHHmmss
  119. } from '@/utils/common.js'
  120. const turnoverApplicationDialog = ref(null)
  121. const lotDialog = ref(null)
  122. const listData = ref([])
  123. const bizDayworkObj = ref({})
  124. const curSubPlan = ref({}) // 子计划单信息
  125. const processInfo = ref([]) // 员工工序信息
  126. const bottomStatus = ref(0) // 底部按钮显示
  127. const reqParam = ref(null);
  128. const curDayworkItem = ref({}) // 当前报工记录,回显是否显示取消周转的状态
  129. const keywords = ref(null)
  130. const notPreProcess = ref(true)
  131. onLoad(() => {
  132. curSubPlan.value = store.planSubDetails || {
  133. processSequence: []
  134. };
  135. console.log(store.planSubDetails)
  136. processInfo.value = store.userProcessInfo || [];
  137. let sunPlanProcesses = [];
  138. let userProcesses = [];
  139. for (let i = 0; i < curSubPlan.value.processSequence.length; i++) {
  140. sunPlanProcesses.push(curSubPlan.value.processSequence[i].id)
  141. }
  142. for (let i = 0; i < processInfo.value.length; i++) {
  143. userProcesses.push(processInfo.value[i].id)
  144. }
  145. // 判断员工开始批次按钮显示bottomStatus状态
  146. if (userProcesses.includes(sunPlanProcesses[0]) && userProcesses.length == 1) {
  147. bottomStatus.value = 0;
  148. } else if (userProcesses.includes(sunPlanProcesses[0]) && userProcesses.length > 1) {
  149. bottomStatus.value = 2;
  150. } else {
  151. bottomStatus.value = 1;
  152. }
  153. init(curSubPlan.value.id);
  154. uni.$once('batchReporting-addBatch', () => {
  155. init(curSubPlan.value.id);
  156. })
  157. uni.$on('dayworkItemUpdate', reflush)
  158. })
  159. onUnload(() => {
  160. // uni.$off('dayworkItemUpdate', reflush)
  161. })
  162. function reflush() {
  163. init(curSubPlan.value.id);
  164. }
  165. function handleShowTurnoverApplication(data) {
  166. let _data = data ?? {}
  167. // 调用子组件中的方法
  168. turnoverApplicationDialog.value.open(_data)
  169. }
  170. function handleStartNewBatch() {
  171. uni.navigateTo({
  172. url: "/pages/addNewBatch/index"
  173. })
  174. }
  175. function init(id) {
  176. uni.showLoading({
  177. title: '加载中'
  178. });
  179. let reqData = {};
  180. reqData.productionPlanDetailSubDetailId = id;
  181. console.log(reqData)
  182. getDayWorkList(reqData).then(res => {
  183. console.log(reqData)
  184. listData.value = res.rows;
  185. // 设置下道序
  186. for (let i = 0; i < listData.value.length; i++) {
  187. for (let j = 0; j < listData.value[i].processSequence.length; j++) {
  188. if (listData.value[i].currentProcess.processCode === listData.value[i].processSequence[j]
  189. .processCode) {
  190. listData.value[i].nextProcess = (j + 1) < listData.value[i].processSequence.length ?
  191. listData.value[i].processSequence.slice(j + 1) : [];
  192. }
  193. }
  194. }
  195. // 计算总工时
  196. for (let i = 0; i < listData.value.length; i++) {
  197. listData.value[i].totalWorkingHours = 0;
  198. if (listData.value[i].dayworkItemList) {
  199. for (let j = 0; j < listData.value[i].dayworkItemList.length; j++) {
  200. if (listData.value[i].dayworkItemList[j].status == 2 || listData.value[i].dayworkItemList[
  201. j].status == 3) {
  202. listData.value[i].totalWorkingHours += Number(listData.value[i].dayworkItemList[j].workingHours);
  203. }
  204. }
  205. listData.value[i].totalWorkingHours = toHHmmss(listData.value[i].totalWorkingHours);
  206. }
  207. }
  208. console.log(listData.value)
  209. uni.hideLoading();
  210. })
  211. }
  212. function handleSearch(){
  213. }
  214. function handleToreportingForWork(item) {
  215. store.dayworkInfo = item
  216. uni.navigateTo({
  217. url: "/pages/reportingForWork/index"
  218. })
  219. }
  220. function handleScanCode() {
  221. uni.scanCode({
  222. scanType: ['qrCode'],
  223. onlyFromCamera: true, // 只允许相机扫码
  224. autoZoom: false,
  225. success: function(res) {
  226. console.log(res.result)
  227. let vehicleObj = JSON.parse(res.result);
  228. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  229. uni.showToast({
  230. icon: "error",
  231. title: "请扫载具码",
  232. duration: 1000
  233. })
  234. return;
  235. }
  236. showDaywork({
  237. carrierId: vehicleObj.carrierId,
  238. status: 7
  239. }).then(response => {
  240. if (response.code == 200) {
  241. console.log(response)
  242. lotDialog.value.open(response.data);
  243. }
  244. })
  245. }
  246. });
  247. }
  248. function handleAddDaywork(data) {
  249. console.log(data)
  250. let reqParam = [];
  251. for (var i = 0; i < data.length; i++) {
  252. reqParam.push(data[i].daywork)
  253. }
  254. // for (let i = 0; i < listData.value.length; i++) {
  255. // if (Object.entries(listData.value[i]).toString() === Object.entries(data).toString()) {
  256. // uni.showToast({
  257. // icon: "error",
  258. // title: "该批次已存在"
  259. // })
  260. // console.log("该批次已存在")
  261. // return;
  262. // }
  263. // }
  264. // listData.value.push(data);
  265. // for (let i = 0; i < listData.value.length; i++) {
  266. // listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  267. // }
  268. // console.log(listData.value)
  269. // console.log(data)
  270. showDayworkSave(reqParam).then(res => {
  271. console.log(res)
  272. init(curSubPlan.value.id);
  273. })
  274. }
  275. function handleDoIt(data) {
  276. handleAddDaywork(data);
  277. }
  278. function handleDoTurnoverAfter() {
  279. init();
  280. }
  281. function handleCancelTurnover(data) {
  282. turnoverDelete(data).then(res => {
  283. if (res.code == 200) {
  284. uni.showToast({
  285. icon: "success",
  286. title: "取消成功",
  287. duration: 2000
  288. })
  289. init(curSubPlan.value.id);
  290. } else {
  291. uni.showToast({
  292. icon: "fail",
  293. title: "取消失败",
  294. duration: 2000
  295. })
  296. }
  297. })
  298. }
  299. </script>
  300. <style lang="scss">
  301. $nav-height: 60rpx;
  302. .box-bg {
  303. width: 100%;
  304. background-color: #F5F5F5;
  305. padding: 5rpx 16rpx;
  306. justify-content: space-around;
  307. align-items: center;
  308. margin-top: 20rpx;
  309. .input-view {
  310. width: 100%;
  311. flex: 4;
  312. background-color: #f8f8f8;
  313. height: $nav-height;
  314. border: 1rpx solid #999;
  315. border-radius: 15rpx;
  316. padding: 0 15rpx;
  317. flex-wrap: nowrap;
  318. margin: 0 10rpx 0;
  319. line-height: $nav-height;
  320. .input-uni-icon {
  321. line-height: $nav-height;
  322. }
  323. .nav-bar-input {
  324. width: 80%;
  325. height: $nav-height;
  326. line-height: $nav-height;
  327. padding: 0 5rpx;
  328. background-color: #f8f8f8;
  329. }
  330. }
  331. .search {
  332. width: 20%;
  333. text-align: center;
  334. color: #808080;
  335. }
  336. }
  337. .scroll-container {
  338. width: 92%;
  339. margin: 24rpx auto 0 auto;
  340. height: calc(90% - 100rpx);
  341. overflow: auto;
  342. }
  343. .list-item {
  344. background-color: #fff;
  345. position: relative;
  346. padding: 16rpx;
  347. padding-bottom: 24rpx;
  348. margin-bottom: 24rpx;
  349. border-radius: 10rpx;
  350. .title-container {
  351. margin-top: 8rpx;
  352. margin-bottom: 16rpx;
  353. .title {
  354. height: 48rpx;
  355. align-items: center;
  356. .label {
  357. font-size: 32rpx;
  358. font-weight: bold;
  359. &.code {
  360. margin-left: 8rpx;
  361. }
  362. }
  363. }
  364. .tag {
  365. border: 1px solid #1CE5B0;
  366. background-color: #F6FFFD;
  367. padding: 8rpx;
  368. border-radius: 8rpx;
  369. .label {
  370. color: #1CE5B0;
  371. font-size: 24rpx;
  372. }
  373. &.finished {
  374. border: 1px solid #BBBBBB;
  375. background-color: #F5F5F5;
  376. .label {
  377. color: #BBBBBB;
  378. }
  379. }
  380. &.turnover {
  381. border: 1px solid #FF7901;
  382. background-color: #F6FFFD;
  383. .label {
  384. color: #FF7901;
  385. }
  386. }
  387. }
  388. }
  389. .item-info {
  390. margin-bottom: 8rpx;
  391. .label {
  392. font-size: 28rpx;
  393. width: 220rpx;
  394. color: #808080;
  395. &.right {
  396. flex: 1;
  397. color: #000000;
  398. }
  399. }
  400. }
  401. .status-btn {
  402. justify-content: flex-end;
  403. align-items: center;
  404. .turnover-tag {
  405. padding-right: 12rpx;
  406. padding-left: 12rpx;
  407. border-radius: 8rpx;
  408. border: 1rpx solid #FF7901;
  409. background-color: #FF7901;
  410. font-size: 28rpx;
  411. color: #FFFFFF;
  412. }
  413. .reporting-tag {
  414. padding-right: 12rpx;
  415. padding-left: 12rpx;
  416. border-radius: 8rpx;
  417. margin-left: 16rpx;
  418. border: 1rpx solid #1684fc;
  419. background-color: #1684fc;
  420. font-size: 28rpx;
  421. color: #FFFFFF;
  422. }
  423. }
  424. }
  425. .bottom {
  426. height: 10%;
  427. position: fixed;
  428. right: 0;
  429. bottom: 0;
  430. left: 0;
  431. height: 100rpx;
  432. border-top: 1px solid #999999;
  433. padding: 16rpx 32rpx;
  434. align-items: center;
  435. background-color: #fff;
  436. .start-batch-btn {
  437. flex: 1;
  438. height: 80rpx;
  439. line-height: 80rpx;
  440. border-radius: 8rpx;
  441. color: #FFFFFF;
  442. font-size: 28rpx;
  443. }
  444. }
  445. </style>