123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648 |
- <template>
- <view class='container uni-column'>
- <view class='nav uni-row'>
- <view v-for="(item,index) in statusList" :key="index" :class="{'selecter':singleSelectd(item)}">
- <text @click='selectedStatus(item)'> {{item['name']}}</text>
- </view>
- </view>
- <!-- 待周转页面 -->
- <view class="padding-container" v-if='selectedInfo.id == 4'>
- <view class="scroll-container">
- <view v-if="listData.length == 0" style="color: #999;margin: 50% auto;">
- <text>暂无待周转批次</text>
- </view>
- <view v-else v-for="(item, index) in listData" :key="index"
- :class="{'list-item':true,'selected':isSelected(item)}">
- <!-- @click="handleSelection(item)" -->
- <view class="title-container uni-row">
- <view class="title uni-row">
- <text class="label">{{ item['turnoverArea'] }}</text>
- <text class="label code">{{ item['preDeptName'] }}</text>
- <text class="label code" style="margin-left: 16rpx;">→</text>
- <text class="label code" style="margin-left: 16rpx;">{{ item['deptName'] }}</text>
- </view>
- <view class="right-info uni-row">
- <view class="uni-row"><text class="label right">待周转</text></view>
- </view>
- </view>
- <view class="item-info uni-row"> <text class="label ">批次</text>
- <text class="label right">{{ item['lotCode'] }}</text>
- </view>
- <view class="item-info uni-row"> <text class="label">箱数</text>
- <text class="label right ">{{ item['carriers'] }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">数量</text>
- <text class="label right">{{ item['daywork'].temporaryProcessQualifiedNum }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">箱号</text>
- <text class="label right">{{ item['carrierName']}}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">申请时间</text>
- <text class="label right">{{ item['startTime']}}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">申请人</text>
- <text class="label right">{{ item['nickName']}}</text>
- </view>
- </view>
- </view>
- <view class="bottom-btn-container uni-row">
- <button class="bottom-btn" @click="handleStartTurn">开始周转</button>
- </view>
- </view>
- <!-- 周转中页面 -->
- <view class='turnover-container' v-if='selectedInfo.id == 5'>
- <view class="scroll-container">
- <view v-if="lotList.length == 0" style="color: #999;margin: 50% auto;">
- <text>暂无周转中批次</text>
- </view>
- <!-- 循环周转中的数据 -->
- <view v-else class='item-container'>
- <!-- <view v-if="products.length > 0" class="turnover-title uni-row">
- <view class="uni-row" style="align-items: center;">
- <view><text class='title-color'>{{turnoverContentTitle}}箱</text></view>
- <view><text class="second-info">{{turnoverSecondTitle}}</text></view>
- </view>
- <view><text class="label">周转中</text></view>
- </view> -->
- <view :class="{'list-container':true,'selected':isSelected(item)}" v-for="(item,index) in lotList"
- @click="handleSelection(item)" :key='index'>
- <view class="turnover-title uni-row">
- <view class="uni-row" style="align-items: center;">
- <view><text class='title-color'>{{ item[0]['totalCarrier'] }}箱</text></view>
- <view><text class="second-info">目标工段: {{ item[0].deptName }}</text>
- </view>
- </view>
- </view>
- <view v-for="(lot,index) in item" :key="index" style="margin-bottom: 10rpx;">
- <view class="list-container-item product-description uni-row">
- <text class="label left-value">产品描述</text>
- <text class="label right-value">{{lot['productDescription']}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label left-value">目标</text>
- <text class="label right-value">{{item[0].preDeptName + '→' + item[0].deptName }}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label left-value">批次</text>
- <text class="label right-value">{{lot['lotCode']}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label left-value">箱数</text>
- <text class="label right-value">{{lot['carrierName'].split('、').length}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label left-value">箱号</text>
- <text class="label right-value">{{lot['carrierName']}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class='bottom-btn-container uni-row'>
- <button type='primary' class='bottom-btn'
- @click="handleConfirm('确认送达',store.itemStatus.received)">确认送达</button>
- <button class='bottom-btn' @click="handleConfirm('取消周转',store.itemStatus.pendingTurnover,true)"
- style="margin-left: 24rpx;background-color: coral;">取消周转</button>
- </view>
- </view>
- <!-- 已送达页面 -->
- <view class='turnover-container' v-if='selectedInfo.id == 7'>
- <view class="scroll-container">
- <view v-if="deliveredList.length == 0" style="color: #999;margin: 50% auto;">
- <text>暂无已送达批次</text>
- </view>
- <!-- 循环已送达的数据 -->
- <view v-else class='item-container'>
- <view :class="{'list-container':true,'selected':isSelectedDelivered(item)}"
- v-for="(item,index) in deliveredList" @click="handleSelectionDelivered(item)" :key='index'>
- <view class="list-container-item product-description uni-row">
- <text class="label left-value">周转路径</text>
- <text class="">{{item.preDeptName + '→' + item.deptName }}</text>
- </view>
- <view class="list-container-item product-description uni-row">
- <text class="label left-value">产品描述</text>
- <text class="label right-value">{{item['productDescription']}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label left-value">批次</text>
- <text class="label right-value">{{item['lotCode']}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label left-value">箱数</text>
- <text class="label right-value">{{item['carrierName'].split('、').length}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label left-value">箱号</text>
- <text class="label right-value">{{item['carrierName']}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class='bottom-btn-container uni-row'>
- <button type='primary' class='bottom-btn'
- @click="handleConfirm('取消送达',store.itemStatus.turnoveing)">取消送达</button>
- </view>
- </view>
- </view>
- <dialog-turnoverTask ref="turnoverTask"></dialog-turnoverTask>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad,
- onShow
- } from '@dcloudio/uni-app'
- // import pending from './pending';
- // import turnover from './turnover';
- import {
- getDayWorkItemList,
- getItemList
- } from '@/api/business/dayWorkItem.js'
- import {
- updateDayWorkItem,
- updateDayWorkItemBatch,
- updateBatchBack
- } from '@/api/business/dayWorkItem.js'
- import {
- getDictInfoByType
- } from '@/api/dict/dict.js'
- import {
- store
- } from '../../store'
- const sum = ref(0)
- const pendingClass = ref({
- selecter: true
- })
- const turnoverClass = ref({
- selecter: false
- })
- const selection = ref([])
- const selectedInfo = ref({})
- const pendingShow = ref(true)
- const turnoverShow = ref(false)
- const listData = ref([])
- const products = ref([])
- const confirm = ref(null) // 弹窗组件
- const turnoverTask = ref(null) // 弹窗组件
- const lotList = ref([])
- const deliveredList = ref([])
- const statusList = ref([{
- "id": 4,
- "name": "待周转"
- },
- {
- "id": 5,
- "name": "周转中"
- },
- {
- "id": 7,
- "name": "已送达"
- }
- ])
- onLoad(() => {
- selectedInfo.value = statusList.value[0]
- })
- onShow(() => {
- init();
- })
- function init() {
- uni.showLoading({
- title: '加载中'
- })
- Promise.all([getItemList({
- status: 4
- }), getItemList({
- status: 5,
- updaterId: store.userInfo.userId
- }), getItemList({
- status: 7,
- updaterId: store.userInfo.userId
- })])
- .then(([res1, res2, res3]) => {
- //待周转
- if (res1.code == 200) {
- listData.value = res1.rows;
- // 设置箱数
- for (var i = 0; i < listData.value.length; i++) {
- listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
- }
- console.log(res1)
- }
- //周转
- if (res2.code == 200) {
- // 通过dayworkId再分组
- const groupedRows = res2.rows.reduce((acc, item) => {
- const dept = item.deptId;
- if (acc.hasOwnProperty(dept)) {
- acc[dept].push(item);
- } else {
- acc[dept] = [item];
- }
- return acc;
- }, {});
- // groupedRows 是一个对象,其键是dayworkId,值是具有相同dayworkId的对象数组
- // 如果需要将它转换为二维数组,您可以使用 Object.values 方法
- lotList.value = Object.values(groupedRows);
- // 设置箱数
- for (let i = 0; i < lotList.value.length; i++) {
- lotList.value[i][0].totalCarrier = 0;
- for (let j = 0; j < lotList.value[i].length; j++) {
- lotList.value[i][0].totalCarrier += lotList.value[i][j].carrierName.split('、').length;
- }
- }
- console.log(lotList.value)
- console.log(res2.rows)
- }
- if (res3.code == 200) {
- deliveredList.value = res3.rows;
- }
- uni.hideLoading();
- })
- }
- function reflush() {
- // turnoverContentTitle.value = 0;
- lotList.value = [];
- init();
- }
- function handleStartTurn() {
- // if(selection.value.length > 0){
- // let msg = '是否确认周转?';
- // confirm.value.open(msg);
- // }
- // turnoverTask.value.open(selection.value);
- uni.navigateTo({
- url: "/pages/startTurnover/index"
- })
- }
- /**
- * 确认后修改item方法
- * @param str 弹窗显示的内容
- * @param status 修改的状态
- * @param isBack 是否为回退修改
- */
- function handleConfirm(str, status, isBack = false) {
- if (selection.value.length > 0) {
- uni.showModal({
- title: '提示',
- content: `是否${str}?`,
- success: function(res) {
- if (res.confirm) {
- handleUpadteStatus(status,isBack);
- } else if (res.cancel) {
- }
- }
- })
- } else {
- uni.showToast({
- icon: 'none',
- title: `请选择后再点击${str}按钮`,
- duration: 2000
- })
- }
- }
- function handleUpadteStatus(status,isBack) {
- // 设置周转状态
- for (let i = 0; i < selection.value.length; i++) {
- selection.value[i].status = status;
- }
- if(isBack){
- updateBatchBack(selection.value).then(res => {
- if (res.code === 200) {
- uni.showToast({
- icon: 'success',
- title: '操作成功',
- duration: 2000
- });
- reflush();
- } else {
- uni.showToast({
- icon: 'none',
- title: '操作失败',
- duration: 2000
- });
- }
- })
- }else{
- updateDayWorkItemBatch(selection.value).then(res => {
- if (res.code === 200) {
- uni.showToast({
- icon: 'success',
- title: '操作成功',
- duration: 2000
- });
- reflush();
- } else {
- uni.showToast({
- icon: 'none',
- title: '操作失败',
- duration: 2000
- });
- }
- })
- }
- // 清空选中数组
- selection.value = [];
- }
- function isSelected(item) {
- //单选
- return selection.value == item;
- //多选
- // return selection.value.includes(item);
- }
- function handleSelection(item) {
- // 单选
- if (selection.value == item) {
- selection.value = []
- } else {
- selection.value = item;
- }
- console.log(selection.value, "selection");
- }
- function isSelectedDelivered(item) {
- //多选
- return selection.value.includes(item);
- }
- function handleSelectionDelivered(item) {
- //多选
- const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
- if (buttonIndex > -1) {
- selection.value.splice(buttonIndex, 1); // 取消选中
- } else {
- selection.value.push(item); // 选中
- }
- }
- function selectPending() {
- pendingClass.value['selecter'] = true;
- turnoverClass.value['selecter'] = false;
- pendingShow.value = true;
- turnoverShow.value = false;
- }
- function selectTurnover() {
- pendingClass.value['selecter'] = false;
- turnoverClass.value['selecter'] = true;
- pendingShow.value = false;
- turnoverShow.value = true;
- }
- function selectedStatus(item) {
- console.log(item)
- selectedInfo.value = item
- }
- function singleSelectd(item) {
- return selectedInfo.value == item
- }
- </script>
- <style lang="scss">
- $navHeight: 48rpx;
- /* 导航栏样式 */
- .container {
- // height: calc(100% - $navHeight);
- height: 1500rpx;
- position: relative;
- top: $navHeight;
- background-color: #f5f5f5;
- }
- .selected {
- border: 1px solid #1684fc;
- border-radius: 8rpx;
- padding: 8rpx;
- }
- .nav {
- justify-content: space-around;
- // position: fixed;
- // top:0;
- width: 100%;
- height: $navHeight;
- border-bottom: 3rpx solid rgba(228, 231, 237, 1);
- background-color: rgba(255, 255, 255, 1);
- .img {
- width: 24rpx;
- height: 24rpx;
- position: fixed;
- right: 10rpx;
- top: 0;
- }
- }
- .selecter {
- height: 48rpx;
- color: rgba(25, 137, 250, 1);
- border-bottom: 3rpx solid rgba(25, 137, 250, 1);
- }
- /* 待周转样式 */
- .padding-container,
- .turnover-container {
- position: absolute;
- top: 56rpx;
- right: 0;
- bottom: 0rpx;
- left: 0;
- background-color: #f5f5f5;
- .scroll-container {
- position: absolute;
- top: 24rpx;
- right: 0;
- bottom: 136rpx;
- left: 0;
- }
- .bottom-btn-container {
- height: 10%;
- position: fixed;
- right: 0;
- bottom: 0;
- left: 0;
- height: 80rpx;
- border-top: 1px solid #999999;
- padding: 16rpx 32rpx;
- align-items: center;
- background-color: #fff;
- .bottom-btn {
- // padding-left: 0;
- // padding-top: 4rpx;
- flex: 1;
- font-size: 28rpx;
- color: #FFFFFF;
- background-color: #1684fc;
- }
- }
- }
- .padding-container {
- .scroll-container {
- max-height: 90%;
- overflow: auto;
- .list-item {
- background-color: #fff;
- padding: 0 24rpx;
- padding-bottom: 24rpx;
- margin: 0 24rpx;
- margin-bottom: 24rpx;
- border-radius: 8rpx;
- .title-container {
- justify-content: space-between;
- margin-top: 8rpx;
- margin-bottom: 16rpx;
- .title {
- height: 48rpx;
- align-items: center;
- .label {
- color: #1684fc;
- font-size: 32rpx;
- font-weight: bold;
- &.code {
- color: #000000;
- margin-left: 32rpx;
- }
- }
- }
- }
- .item-info {
- margin-bottom: 16rpx;
- .label {
- font-size: 28rpx;
- width: 160rpx;
- color: #808080;
- &.right {
- flex: 1;
- color: #000000;
- }
- }
- }
- .right-info {
- justify-content: flex-end;
- margin-top: 2rpx;
- .label {
- font-size: 28rpx;
- color: #808080;
- }
- }
- }
- }
- }
- /* 周转中样式 */
- .turnover-container {
- .scroll-container {
- height: 90%;
- overflow: scroll;
- .item-container {
- // height: 90%;
- // padding: 8rpx 0 32rpx 0;
- margin: 0 24rpx;
- margin-bottom: 24rpx;
- background-color: rgba(255, 255, 255, 1);
- border-radius: 8rpx;
- .turnover-title {
- width: auto;
- justify-content: space-between;
- margin: 16rpx;
- font-weight: bold;
- .label {
- font-size: 28rpx;
- color: #808080;
- }
- }
- .list-container {
- // margin: 16rpx 24rpx 16rpx 24rpx;
- width: calc(100% - 48rpx);
- margin: 16rpx auto;
- .list-container-item {
- border-bottom: 1px solid #999999;
- padding: 12rpx 8rpx;
- background-color: #EEF0F5;
- &.product-description {
- background-color: #ECF5FF;
- }
- .label {
- font-size: 28rpx;
- color: #999999;
- &.left-value {
- width: 152rpx;
- }
- &.right-value {
- flex: 1;
- color: #000000;
- }
- }
- }
- }
- .title-color {
- color: rgba(22, 132, 252, 1);
- font-size: 36rpx;
- font-weight: bold;
- }
- .second-info {
- font-size: 36rpx;
- font-weight: bold;
- margin-left: 32rpx;
- }
- .turnover-info {
- color: rgba(128, 128, 128, 1);
- position: absolute;
- top: 10rpx;
- right: 40rpx;
- font-size: 30rpx;
- }
- }
- }
- }
- </style>
|