index.vue 11 KB

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