index.vue 13 KB

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