index.vue 13 KB

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