index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <template>
  2. <view class='container uni-column'>
  3. <view class='nav uni-row'>
  4. <view v-for="(item,index) in statusList" :key="index" :class="{'selecter':singleSelectd(item)}">
  5. <text @click='selectedStatus(item)'> {{item['name']}}</text>
  6. </view>
  7. </view>
  8. <!-- 待周转页面 -->
  9. <view class="padding-container" v-if='selectedInfo.id == 4'>
  10. <view class="scroll-container">
  11. <view v-if="listData.length == 0" style="color: #999;margin: 50% auto;">
  12. <text>暂无待周转批次</text>
  13. </view>
  14. <view v-else v-for="(item, index) in listData" :key="index"
  15. :class="{'list-item':true,'selected':isSelected(item)}">
  16. <!-- @click="handleSelection(item)" -->
  17. <view class="title-container uni-row">
  18. <view class="title uni-row">
  19. <text class="label">{{ item['turnoverArea'] }}</text>
  20. <text class="label code">{{ item['preDeptName'] }}</text>
  21. <text class="label code" style="margin-left: 16rpx;">→</text>
  22. <text class="label code" style="margin-left: 16rpx;">{{ item['deptName'] }}</text>
  23. </view>
  24. <view class="right-info uni-row">
  25. <view class="uni-row"><text class="label right">待周转</text></view>
  26. </view>
  27. </view>
  28. <view class="item-info uni-row"> <text class="label ">批次</text>
  29. <text class="label right">{{ item['lotCode'] }}</text>
  30. </view>
  31. <view class="item-info uni-row"> <text class="label">箱数</text>
  32. <text class="label right ">{{ item['carriers'] }}</text>
  33. </view>
  34. <view class="item-info uni-row">
  35. <text class="label">数量</text>
  36. <text class="label right">{{ item['daywork'].temporaryProcessQualifiedNum }}</text>
  37. </view>
  38. <view class="item-info uni-row">
  39. <text class="label">箱号</text>
  40. <text class="label right">{{ item['carrierName']}}</text>
  41. </view>
  42. <view class="item-info uni-row">
  43. <text class="label">申请时间</text>
  44. <text class="label right">{{ item['startTime']}}</text>
  45. </view>
  46. <view class="item-info uni-row">
  47. <text class="label">申请人</text>
  48. <text class="label right">{{ item['nickName']}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="bottom-btn-container uni-row">
  53. <button class="bottom-btn" @click="handleStartTurn">开始周转</button>
  54. </view>
  55. </view>
  56. <!-- 周转中页面 -->
  57. <view class='turnover-container' v-if='selectedInfo.id == 5'>
  58. <view class="scroll-container">
  59. <view v-if="lotList.length == 0" style="color: #999;margin: 50% auto;">
  60. <text>暂无周转中批次</text>
  61. </view>
  62. <!-- 循环周转中的数据 -->
  63. <view v-else class='item-container'>
  64. <!-- <view v-if="products.length > 0" class="turnover-title uni-row">
  65. <view class="uni-row" style="align-items: center;">
  66. <view><text class='title-color'>{{turnoverContentTitle}}箱</text></view>
  67. <view><text class="second-info">{{turnoverSecondTitle}}</text></view>
  68. </view>
  69. <view><text class="label">周转中</text></view>
  70. </view> -->
  71. <view :class="{'list-container':true,'selected':isSelected(item)}" v-for="(item,index) in lotList"
  72. @click="handleSelection(item)" :key='index'>
  73. <view class="turnover-title uni-row">
  74. <view class="uni-row" style="align-items: center;">
  75. <view><text class='title-color'>{{ item[0]['totalCarrier'] }}箱</text></view>
  76. <view><text class="second-info">目标工段: {{ item[0].deptName }}</text>
  77. </view>
  78. </view>
  79. </view>
  80. <view v-for="(lot,index) in item" :key="index" style="margin-bottom: 10rpx;">
  81. <view class="list-container-item product-description uni-row">
  82. <text class="label left-value">产品描述</text>
  83. <text class="label right-value">{{lot['productDescription']}}</text>
  84. </view>
  85. <view class="list-container-item uni-row">
  86. <text class="label left-value">目标</text>
  87. <text class="label right-value">{{item[0].preDeptName + '→' + item[0].deptName }}</text>
  88. </view>
  89. <view class="list-container-item uni-row">
  90. <text class="label left-value">批次</text>
  91. <text class="label right-value">{{lot['lotCode']}}</text>
  92. </view>
  93. <view class="list-container-item uni-row">
  94. <text class="label left-value">箱数</text>
  95. <text class="label right-value">{{lot['carrierName'].split('、').length}}</text>
  96. </view>
  97. <view class="list-container-item uni-row">
  98. <text class="label left-value">箱号</text>
  99. <text class="label right-value">{{lot['carrierName']}}</text>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <view class='bottom-btn-container uni-row'>
  106. <button type='primary' class='bottom-btn'
  107. @click="handleConfirm('确认送达',store.itemStatus.received)">确认送达</button>
  108. <button class='bottom-btn' @click="handleConfirm('取消周转',store.itemStatus.pendingTurnover,true)"
  109. style="margin-left: 24rpx;background-color: coral;">取消周转</button>
  110. </view>
  111. </view>
  112. <!-- 已送达页面 -->
  113. <view class='turnover-container' v-if='selectedInfo.id == 7'>
  114. <view class="scroll-container">
  115. <view v-if="deliveredList.length == 0" style="color: #999;margin: 50% auto;">
  116. <text>暂无已送达批次</text>
  117. </view>
  118. <!-- 循环已送达的数据 -->
  119. <view v-else class='item-container'>
  120. <view :class="{'list-container':true,'selected':isSelectedDelivered(item)}"
  121. v-for="(item,index) in deliveredList" @click="handleSelectionDelivered(item)" :key='index'>
  122. <view class="list-container-item product-description uni-row">
  123. <text class="label left-value">周转路径</text>
  124. <text class="">{{item.preDeptName + '→' + item.deptName }}</text>
  125. </view>
  126. <view class="list-container-item product-description uni-row">
  127. <text class="label left-value">产品描述</text>
  128. <text class="label right-value">{{item['productDescription']}}</text>
  129. </view>
  130. <view class="list-container-item uni-row">
  131. <text class="label left-value">批次</text>
  132. <text class="label right-value">{{item['lotCode']}}</text>
  133. </view>
  134. <view class="list-container-item uni-row">
  135. <text class="label left-value">箱数</text>
  136. <text class="label right-value">{{item['carrierName'].split('、').length}}</text>
  137. </view>
  138. <view class="list-container-item uni-row">
  139. <text class="label left-value">箱号</text>
  140. <text class="label right-value">{{item['carrierName']}}</text>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. <view class='bottom-btn-container uni-row'>
  146. <button type='primary' class='bottom-btn'
  147. @click="handleConfirm('取消送达',store.itemStatus.turnoveing)">取消送达</button>
  148. </view>
  149. </view>
  150. </view>
  151. <dialog-turnoverTask ref="turnoverTask"></dialog-turnoverTask>
  152. </template>
  153. <script setup>
  154. import {
  155. ref
  156. } from 'vue'
  157. import {
  158. onLoad,
  159. onShow
  160. } from '@dcloudio/uni-app'
  161. // import pending from './pending';
  162. // import turnover from './turnover';
  163. import {
  164. getDayWorkItemList,
  165. getItemList
  166. } from '@/api/business/dayWorkItem.js'
  167. import {
  168. updateDayWorkItem,
  169. updateDayWorkItemBatch,
  170. updateBatchBack
  171. } from '@/api/business/dayWorkItem.js'
  172. import {
  173. getDictInfoByType
  174. } from '@/api/dict/dict.js'
  175. import {
  176. store
  177. } from '../../store'
  178. const sum = ref(0)
  179. const pendingClass = ref({
  180. selecter: true
  181. })
  182. const turnoverClass = ref({
  183. selecter: false
  184. })
  185. const selection = ref([])
  186. const selectedInfo = ref({})
  187. const pendingShow = ref(true)
  188. const turnoverShow = ref(false)
  189. const listData = ref([])
  190. const products = ref([])
  191. const confirm = ref(null) // 弹窗组件
  192. const turnoverTask = ref(null) // 弹窗组件
  193. const lotList = ref([])
  194. const deliveredList = ref([])
  195. const statusList = ref([{
  196. "id": 4,
  197. "name": "待周转"
  198. },
  199. {
  200. "id": 5,
  201. "name": "周转中"
  202. },
  203. {
  204. "id": 7,
  205. "name": "已送达"
  206. }
  207. ])
  208. onLoad(() => {
  209. selectedInfo.value = statusList.value[0]
  210. })
  211. onShow(() => {
  212. init();
  213. })
  214. function init() {
  215. uni.showLoading({
  216. title: '加载中'
  217. })
  218. Promise.all([getItemList({
  219. status: 4
  220. }), getItemList({
  221. status: 5,
  222. updaterId: store.userInfo.userId
  223. }), getItemList({
  224. status: 7,
  225. updaterId: store.userInfo.userId
  226. })])
  227. .then(([res1, res2, res3]) => {
  228. //待周转
  229. if (res1.code == 200) {
  230. listData.value = res1.rows;
  231. // 设置箱数
  232. for (var i = 0; i < listData.value.length; i++) {
  233. listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  234. }
  235. console.log(res1)
  236. }
  237. //周转
  238. if (res2.code == 200) {
  239. // 通过dayworkId再分组
  240. const groupedRows = res2.rows.reduce((acc, item) => {
  241. const dept = item.deptId;
  242. if (acc.hasOwnProperty(dept)) {
  243. acc[dept].push(item);
  244. } else {
  245. acc[dept] = [item];
  246. }
  247. return acc;
  248. }, {});
  249. // groupedRows 是一个对象,其键是dayworkId,值是具有相同dayworkId的对象数组
  250. // 如果需要将它转换为二维数组,您可以使用 Object.values 方法
  251. lotList.value = Object.values(groupedRows);
  252. // 设置箱数
  253. for (let i = 0; i < lotList.value.length; i++) {
  254. lotList.value[i][0].totalCarrier = 0;
  255. for (let j = 0; j < lotList.value[i].length; j++) {
  256. lotList.value[i][0].totalCarrier += lotList.value[i][j].carrierName.split('、').length;
  257. }
  258. }
  259. console.log(lotList.value)
  260. console.log(res2.rows)
  261. }
  262. if (res3.code == 200) {
  263. deliveredList.value = res3.rows;
  264. }
  265. uni.hideLoading();
  266. })
  267. }
  268. function reflush() {
  269. // turnoverContentTitle.value = 0;
  270. lotList.value = [];
  271. init();
  272. }
  273. function handleStartTurn() {
  274. // if(selection.value.length > 0){
  275. // let msg = '是否确认周转?';
  276. // confirm.value.open(msg);
  277. // }
  278. // turnoverTask.value.open(selection.value);
  279. uni.navigateTo({
  280. url: "/pages/startTurnover/index"
  281. })
  282. }
  283. /**
  284. * 确认后修改item方法
  285. * @param str 弹窗显示的内容
  286. * @param status 修改的状态
  287. * @param isBack 是否为回退修改
  288. */
  289. function handleConfirm(str, status, isBack = false) {
  290. if (selection.value.length > 0) {
  291. uni.showModal({
  292. title: '提示',
  293. content: `是否${str}?`,
  294. success: function(res) {
  295. if (res.confirm) {
  296. handleUpadteStatus(status,isBack);
  297. } else if (res.cancel) {
  298. }
  299. }
  300. })
  301. } else {
  302. uni.showToast({
  303. icon: 'none',
  304. title: `请选择后再点击${str}按钮`,
  305. duration: 2000
  306. })
  307. }
  308. }
  309. function handleUpadteStatus(status,isBack) {
  310. // 设置周转状态
  311. for (let i = 0; i < selection.value.length; i++) {
  312. selection.value[i].status = status;
  313. }
  314. if(isBack){
  315. updateBatchBack(selection.value).then(res => {
  316. if (res.code === 200) {
  317. uni.showToast({
  318. icon: 'success',
  319. title: '操作成功',
  320. duration: 2000
  321. });
  322. reflush();
  323. } else {
  324. uni.showToast({
  325. icon: 'none',
  326. title: '操作失败',
  327. duration: 2000
  328. });
  329. }
  330. })
  331. }else{
  332. updateDayWorkItemBatch(selection.value).then(res => {
  333. if (res.code === 200) {
  334. uni.showToast({
  335. icon: 'success',
  336. title: '操作成功',
  337. duration: 2000
  338. });
  339. reflush();
  340. } else {
  341. uni.showToast({
  342. icon: 'none',
  343. title: '操作失败',
  344. duration: 2000
  345. });
  346. }
  347. })
  348. }
  349. // 清空选中数组
  350. selection.value = [];
  351. }
  352. function isSelected(item) {
  353. //单选
  354. return selection.value == item;
  355. //多选
  356. // return selection.value.includes(item);
  357. }
  358. function handleSelection(item) {
  359. // 单选
  360. if (selection.value == item) {
  361. selection.value = []
  362. } else {
  363. selection.value = item;
  364. }
  365. console.log(selection.value, "selection");
  366. }
  367. function isSelectedDelivered(item) {
  368. //多选
  369. return selection.value.includes(item);
  370. }
  371. function handleSelectionDelivered(item) {
  372. //多选
  373. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  374. if (buttonIndex > -1) {
  375. selection.value.splice(buttonIndex, 1); // 取消选中
  376. } else {
  377. selection.value.push(item); // 选中
  378. }
  379. }
  380. function selectPending() {
  381. pendingClass.value['selecter'] = true;
  382. turnoverClass.value['selecter'] = false;
  383. pendingShow.value = true;
  384. turnoverShow.value = false;
  385. }
  386. function selectTurnover() {
  387. pendingClass.value['selecter'] = false;
  388. turnoverClass.value['selecter'] = true;
  389. pendingShow.value = false;
  390. turnoverShow.value = true;
  391. }
  392. function selectedStatus(item) {
  393. console.log(item)
  394. selectedInfo.value = item
  395. }
  396. function singleSelectd(item) {
  397. return selectedInfo.value == item
  398. }
  399. </script>
  400. <style lang="scss">
  401. $navHeight: 48rpx;
  402. /* 导航栏样式 */
  403. .container {
  404. // height: calc(100% - $navHeight);
  405. height: 1500rpx;
  406. position: relative;
  407. top: $navHeight;
  408. background-color: #f5f5f5;
  409. }
  410. .selected {
  411. border: 1px solid #1684fc;
  412. border-radius: 8rpx;
  413. padding: 8rpx;
  414. }
  415. .nav {
  416. justify-content: space-around;
  417. // position: fixed;
  418. // top:0;
  419. width: 100%;
  420. height: $navHeight;
  421. border-bottom: 3rpx solid rgba(228, 231, 237, 1);
  422. background-color: rgba(255, 255, 255, 1);
  423. .img {
  424. width: 24rpx;
  425. height: 24rpx;
  426. position: fixed;
  427. right: 10rpx;
  428. top: 0;
  429. }
  430. }
  431. .selecter {
  432. height: 48rpx;
  433. color: rgba(25, 137, 250, 1);
  434. border-bottom: 3rpx solid rgba(25, 137, 250, 1);
  435. }
  436. /* 待周转样式 */
  437. .padding-container,
  438. .turnover-container {
  439. position: absolute;
  440. top: 56rpx;
  441. right: 0;
  442. bottom: 0rpx;
  443. left: 0;
  444. background-color: #f5f5f5;
  445. .scroll-container {
  446. position: absolute;
  447. top: 24rpx;
  448. right: 0;
  449. bottom: 136rpx;
  450. left: 0;
  451. }
  452. .bottom-btn-container {
  453. height: 10%;
  454. position: fixed;
  455. right: 0;
  456. bottom: 0;
  457. left: 0;
  458. height: 80rpx;
  459. border-top: 1px solid #999999;
  460. padding: 16rpx 32rpx;
  461. align-items: center;
  462. background-color: #fff;
  463. .bottom-btn {
  464. // padding-left: 0;
  465. // padding-top: 4rpx;
  466. flex: 1;
  467. font-size: 28rpx;
  468. color: #FFFFFF;
  469. background-color: #1684fc;
  470. }
  471. }
  472. }
  473. .padding-container {
  474. .scroll-container {
  475. max-height: 90%;
  476. overflow: auto;
  477. .list-item {
  478. background-color: #fff;
  479. padding: 0 24rpx;
  480. padding-bottom: 24rpx;
  481. margin: 0 24rpx;
  482. margin-bottom: 24rpx;
  483. border-radius: 8rpx;
  484. .title-container {
  485. justify-content: space-between;
  486. margin-top: 8rpx;
  487. margin-bottom: 16rpx;
  488. .title {
  489. height: 48rpx;
  490. align-items: center;
  491. .label {
  492. color: #1684fc;
  493. font-size: 32rpx;
  494. font-weight: bold;
  495. &.code {
  496. color: #000000;
  497. margin-left: 32rpx;
  498. }
  499. }
  500. }
  501. }
  502. .item-info {
  503. margin-bottom: 16rpx;
  504. .label {
  505. font-size: 28rpx;
  506. width: 160rpx;
  507. color: #808080;
  508. &.right {
  509. flex: 1;
  510. color: #000000;
  511. }
  512. }
  513. }
  514. .right-info {
  515. justify-content: flex-end;
  516. margin-top: 2rpx;
  517. .label {
  518. font-size: 28rpx;
  519. color: #808080;
  520. }
  521. }
  522. }
  523. }
  524. }
  525. /* 周转中样式 */
  526. .turnover-container {
  527. .scroll-container {
  528. height: 90%;
  529. overflow: scroll;
  530. .item-container {
  531. // height: 90%;
  532. // padding: 8rpx 0 32rpx 0;
  533. margin: 0 24rpx;
  534. margin-bottom: 24rpx;
  535. background-color: rgba(255, 255, 255, 1);
  536. border-radius: 8rpx;
  537. .turnover-title {
  538. width: auto;
  539. justify-content: space-between;
  540. margin: 16rpx;
  541. font-weight: bold;
  542. .label {
  543. font-size: 28rpx;
  544. color: #808080;
  545. }
  546. }
  547. .list-container {
  548. // margin: 16rpx 24rpx 16rpx 24rpx;
  549. width: calc(100% - 48rpx);
  550. margin: 16rpx auto;
  551. .list-container-item {
  552. border-bottom: 1px solid #999999;
  553. padding: 12rpx 8rpx;
  554. background-color: #EEF0F5;
  555. &.product-description {
  556. background-color: #ECF5FF;
  557. }
  558. .label {
  559. font-size: 28rpx;
  560. color: #999999;
  561. &.left-value {
  562. width: 152rpx;
  563. }
  564. &.right-value {
  565. flex: 1;
  566. color: #000000;
  567. }
  568. }
  569. }
  570. }
  571. .title-color {
  572. color: rgba(22, 132, 252, 1);
  573. font-size: 36rpx;
  574. font-weight: bold;
  575. }
  576. .second-info {
  577. font-size: 36rpx;
  578. font-weight: bold;
  579. margin-left: 32rpx;
  580. }
  581. .turnover-info {
  582. color: rgba(128, 128, 128, 1);
  583. position: absolute;
  584. top: 10rpx;
  585. right: 40rpx;
  586. font-size: 30rpx;
  587. }
  588. }
  589. }
  590. }
  591. </style>