index.vue 13 KB

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