index.vue 12 KB

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