index.vue 12 KB

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