index.vue 12 KB

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