index.vue 16 KB

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