index.vue 18 KB

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