Przeglądaj źródła

任务获取-批量获取混拣活动单(限制20格口内)

zhaohuanhuan 11 miesięcy temu
rodzic
commit
a5d2e262ae

+ 11 - 1
src/api/picking/index.ts

@@ -164,7 +164,17 @@ export function printerByPick(params:any) {
     params,
   })
 }
-
+/**
+ * 活动单混波次获取
+ */
+export function getMixPickActivityOrders(params:any,data:any) {
+  return request({
+    url: 'api/wms/picking/getMixPickActivityOrders',
+    method: 'post',
+    params,
+    data,
+  })
+}
 
 
 /**

+ 15 - 0
src/types/picking.ts

@@ -24,6 +24,9 @@ export interface getPickingTaskDetailType {
   page:number,
 }
 
+/**
+ * 获取拣货任务详情(大件)
+ */
 export interface getBigPickingTaskDetailType {
   warehouse: string;
   type:string;
@@ -123,6 +126,9 @@ export interface setPickingDetailType {
   product: string
 }
 
+/**
+ * 大件拣货任务列表
+ */
 export interface getBigPickingListType {
   warehouse: string;
   orderNo: string;
@@ -132,13 +138,22 @@ export interface getBigPickingListType {
   size?: number;
   page?: number;
 }
+
+/**
+ * 巷道模式,获取站点任务
+ */
 export interface getPickingDetailsByAisleType {
   warehouse: string;
   pickingCode: string;
 }
+
+/**
+ * 巷道模式,修改拣货单明细操作人
+ */
 export interface updatePickingDetailOperatorType {
   warehouse: string;
   pickingCode: string;
   aisle: string;
 }
 
+

+ 26 - 6
src/views/outbound/picking/list/index.vue

@@ -206,7 +206,11 @@ const loadData =  async (pickingCode,type) => {
   taskItem.value=taskList.value
   // 对数组进行分组
   taskMap.value = {}
-  waveNoJson.value = getWave()
+  const uniqueBinds = new Map()
+  taskItem.value.forEach(item => {
+    item.binds.forEach(bind => uniqueBinds.set(bind.waveNo, bind));
+  });
+  waveNoJson.value = uniqueBinds.size === 1 ? getWaveOne() : getWave()
   taskItem.value.forEach(item => {
     if(item.operationTime){
       item.count=item.quantity
@@ -220,9 +224,9 @@ const loadData =  async (pickingCode,type) => {
     }
     //将有操作时间的放到后边
     if (item.operationTime) {
-      taskMap.value[location].list.push(item);
+      taskMap.value[location].list.push(item)
     } else {
-      taskMap.value[location].list.unshift(item);
+      taskMap.value[location].list.unshift(item)
     }
   })
   locationList.value = Object.values(taskMap.value)
@@ -238,8 +242,8 @@ const loadData =  async (pickingCode,type) => {
         operationTime: item.operationTime,
         container: item.container,
         quantity:item.quantity
-      };
-    });
+      }
+    })
   if(selectTask.value.length>0){
     getDefContainer(selectTask.value)
   }else {
@@ -314,7 +318,7 @@ const itemRefs = ref([]);
 // 监听 activeIndex 变化,滚动到指定位置
 watch(activeIndex, (newIndex) => {
   nextTick(() => {
-    const item = itemRefs.value[newIndex];
+    const item = itemRefs.value[newIndex]
     if (item) {
       item.scrollIntoView({
         behavior: 'smooth',  // 平滑滚动
@@ -720,6 +724,22 @@ const allPicking = (location) => {
   }
 }
 //获取拣货任务里的波次号
+const getWaveOne = () => {
+  const uniqueBinds = new Map();
+  // 去重
+  taskItem.value.forEach(item => {
+    item.binds.forEach(bind => {
+      if (!uniqueBinds.has(bind.waveNo)) {
+        uniqueBinds.set(bind.waveNo, bind);
+      }
+    });
+  });
+  //排序
+  const sortedBinds = Array.from(uniqueBinds.values())
+    .sort((a, b) => a.waveNo.localeCompare(b.waveNo))
+    .map((item, index) => ({ ...item, index: index + 1 }))
+  return toMap(sortedBinds, 'waveNo', 'index');
+};
 const getWave = () => {
   const barcodeGroups = new Map()
   // 根据条码进行分组

+ 23 - 107
src/views/outbound/picking/task/index.vue

@@ -21,29 +21,20 @@
       <table border="1" style="width: 100%;border-collapse: collapse;text-align: center;table-layout: fixed;" >
         <thead>
         <tr>
-          <th style="width: 40px" v-if="modeType==='task'">
-            <van-checkbox style="justify-content: center" v-model="ownerCheckAll" :indeterminate="ownerIsIndeterminate"  @change="ownerCheckAllChange"></van-checkbox>
-          </th>
           <th style="width: 80px">货主</th>
           <th>标记</th>
           <th>承运商</th>
           <th>类型</th>
           <th>数量</th>
-          <th>
-            <van-button  v-if="modeType==='task'" type="warning"  @click="queryOwnerTask('all')">批量</van-button>
-            <span v-else>操作</span>
-          </th>
+          <th>操作</th>
         </tr>
         </thead>
         <tbody>
         <tr v-for="(row, rowIndex) in taskList" :key="rowIndex">
-          <td v-if="modeType==='task'">
-            <van-checkbox style="justify-content: center" v-model="row.checked" :disabled="row.disabled" @change="ownerTypeSelect" />
-          </td>
           <td style="word-wrap: break-word" v-if="isFirstInGroup(row, rowIndex)" :rowspan="getRowspan(row, rowIndex)">
             {{ ownerMap[row.owner] || row.owner }}
           </td>
-          <td style="word-wrap: break-word;" >
+          <td style="word-wrap: break-word" >
             <div>{{ row.ruleName }}</div>
           </td>
           <td style="word-wrap: break-word;">
@@ -63,7 +54,7 @@
           <td>
             <van-button type="primary" v-if="row.type=='Y'|| row.type=='N'" @click="onCreateTask(row)">获取</van-button>
             <van-button type="success" v-else-if="row.type=='M'" @click="onTaskList(row,'M')">查看</van-button>
-            <van-button type="success" v-else @click="modeType==='task'?queryOwnerTask(row):onTaskList(row,'*')">查看</van-button>
+            <van-button type="success" v-else @click="onTaskList(row,'*')">查看</van-button>
           </td>
         </tr>
         <tr v-if="taskList.length==0">
@@ -173,7 +164,6 @@
     <picking-no-input  ref="pickingNoInputRef" @loadData="loadTask" />
     <big-picking ref="bigPickingRef" :model="model" :owner-map="ownerMap" :task-detail-list="taskDetailList" :warehouse="warehouse" />
     <select-owner ref="selectOwnerRef" :taskList="allTaskList" :ownerMap="ownerMap" @queryOwner="queryOwner" />
-<!--    <owner-batch-task ref="ownerBatchTaskRef" :ownerMap="ownerMap"  />-->
   </div>
 </template>
 
@@ -184,7 +174,12 @@ import { getTaskList } from '@/views/outbound/picking/task/hooks/task'
 import { computed, defineAsyncComponent, nextTick, ref } from 'vue'
 import { showConfirmDialog, showDialog, showFailToast, showToast } from 'vant'
 import { basicStore } from '@/store/modules/basic'
-import { createPickingTask, getBigPickingTaskDetail, getPickingTaskDetail } from '@/api/picking'
+import {
+  createPickingTask,
+  getBigPickingTaskDetail,
+  getMixPickActivityOrders,
+  getPickingTaskDetail,
+} from '@/api/picking'
 import { useStore } from '@/store/modules/user'
 import { goBack } from '@/utils/android'
 const PickingNoInput = defineAsyncComponent(() => import('@/views/outbound/picking/components/PickingNoInput.vue'))
@@ -193,8 +188,6 @@ const SelectOwner = defineAsyncComponent(() => import('@/views/outbound/picking/
 import { closeLoading, showLoading } from '@/utils/loading'
 import { getTimeHours } from '@/utils/date'
 import { fetchPickingData } from '@/views/outbound/picking/list/hooks/list'
-import { getPickingTaskDetailType } from '@/types/picking'
-import OwnerBatchTask from '@/views/outbound/picking/components/OwnerBatchTask.vue'
 import { toMap } from '@/utils/dataType'
 const router = useRouter()
 const store = basicStore()
@@ -236,7 +229,6 @@ const ownerTaskTitle = computed(() => {
     'Y': '单品',
   };
   const typeTitle = typeMap[type] || '订单列表';
-
   return owner ? `${owner}-${typeTitle}` : typeTitle;
 });
 
@@ -322,93 +314,33 @@ const onTaskList=async (row:Object,type)=>{
     },100)
   }
 }
-/**
- * 选择活动单
- */
-const ownerCheckAll=ref(false)
-//不确定状态
-const ownerIsIndeterminate=ref(false)
-//货主订单选择列表
-const ownerCheckedResult=ref([])
-//全选/反选
-const ownerCheckAllChange=(val)=>{
-  taskList.value.forEach(item => {
-    if (!item.disabled) {
-      item.checked = val;
-    }
-  });
-  updateOwnerCheckAllStatus()
-}
-//单选
-const ownerTypeSelect=(val)=>{
-  updateOwnerCheckAllStatus()
-}
-// 更新全选框和部分选中状态
-const updateOwnerCheckAllStatus=()=>{
-  const totalItems = taskList.value.length
-  ownerCheckedResult.value = taskList.value.filter(item => item.checked)
-  // 如果所有项都被选中
-  ownerCheckAll.value = ownerCheckedResult.value.length === totalItems;
-  // 如果有部分项被选中
-  ownerIsIndeterminate.value = ownerCheckedResult.value.length > 0 && ownerCheckedResult.value.length < totalItems;
-}
 // 查看活动单列表
-const ownerBatchTaskRef=ref(null)
-const queryOwnerTask= (row)=>{
-  let orderNoList =row.matchedOrderNoList
-  if(row=='all'){
-    orderNoList=typeTaskList().flatMap(item => item.matchedOrderNoList);
-  }
-  const params = {
-    warehouse,
-    type: '*',
-    orderNoList,
-    size:1000,
-    page:1
-  };
+const queryOwnerTask= ()=>{
+  let customerList = [...new Set(taskList.value.map(item => item.owner))];
   showLoading()
-  getPickingTaskDetail(<getPickingTaskDetailType>params).then(res=> {
+  getMixPickActivityOrders({warehouse}, customerList).then(res=>{
     closeLoading()
-    if (res.data.length === 0) {
-      showToast({ duration: 5000, message: '任务已被获取,请刷新后重新查看!' })
+    if(res.data.orderCount==0){
+      showToast({ duration: 5000, message: '暂无可批量生成的活动单,请稍后再试!' })
       return
     }
-    const dataList = res.data.filter(item => item.residualOrderQty <= 30)
-    if (dataList.length == 0) {
-      showToast({ duration: 5000, message: '当前活动单,没有30单内的数据!' })
-      return
-    }
-    taskList.value.sort((a, b) => {
-      if (a.customerId !== b.customerId) {
-        return a.customerId.localeCompare(b.customerId);
-      }
-      if (a.carrier !== b.carrier) {
-        return a.carrier.localeCompare(b.carrier)
-      }
-      return b.residualOrderQty - a.residualOrderQty
-    });
-    const dataListsSlice=dataList.slice(0, 10)
-    const sumQty = dataListsSlice.reduce((sum, item) => sum + Number(item.residualOrderQty), 0)
     showConfirmDialog({
       title: '温馨提示',
-      message:`您正在生成${dataListsSlice.length}个活动波次,共:${sumQty}单是否继续`,
+      message:`您正在生成${res.data.waveCount}个活动波次,共:${res.data.orderCount}单是否继续`,
       allowHtml:true,
       keyboardEnabled:false
     }).then(() => {
-      _createPickingTask(dataListsSlice)
-    })
-      .catch(() => {})
-  }).catch(()=>{
+      _createPickingTask(res.data.activityFlagAndCountMap)
+    }).catch(() => {})
+  }).catch(err=>{
     closeLoading()
   })
 }
-const _createPickingTask=(dataList)=>{
+const _createPickingTask=(uidMap)=>{
   const params = {
     warehouse,
-    owners: [...new Set(dataList.map(item => item.customerId))],
-    carriers: [...new Set(dataList.map(item => item.carrier))],
     type:'*',
-    uidMap:toMap(dataList,'uid','residualOrderQty'),
+    uidMap,
     enableFlag:false
   }
   showLoading()
@@ -608,19 +540,12 @@ const onMore= async (row)=>{
   });
 }
 //切换模式
-const taskActions = [
-  { name: '查看全部任务', key: 'all' },
-  { name: '货主筛选', key: 'selectOwner' }
-];
-const defaultActions = [
+const actions = [
   { name: '批量获取活动单', key: 'task' },
   { name: '货主筛选', key: 'selectOwner' }
-];
-const actions = ref(defaultActions)
+]
 const modeTrueFalseBy = ref(false)
-
 const onClickRightIcon = () => {
-  actions.value = (modeType.value === 'task') ? taskActions : defaultActions
   modeTrueFalseBy.value = true
 }
 const typeTaskList = () => {
@@ -631,16 +556,7 @@ const onSelectMode= async (value) => {
   if (value.key == 'selectOwner') {
     selectOwnerRef.value?.show()
   }else if(value.key == 'task') {
-    if(typeTaskList().length==0){
-      showToast({duration:3000,message:'当前没有活动单'})
-      return
-    }
-    queryOwnerTask('all')
-    // modeType.value=value.key
-    // taskList.value=typeTaskList()
-    // if(typeTaskList().length<=10){
-    //   ownerCheckAllChange(true)
-    // }
+    queryOwnerTask()
   }else if(value.key == 'all'){
     queryOwner(value.key)
   }