| | |
| | | import companyInfo from "@/stores/sd/companyInfo"; |
| | | import {multiply} from "@/utils/decimal"; |
| | | import MaterialAddition from "@/views/mm/ingredientStock/MaterialAddition.vue"; |
| | | import {copyTableCellValue} from "@/hook/copyTableCellValue"; |
| | | import SelectOrderList from "@/views/sd/delivery/SelectOrderList.vue"; |
| | | import { ElDialog } from "element-plus"; |
| | | |
| | | //语言获取 |
| | | const { t } = useI18n() |
| | |
| | | let otherMoneyVisible = ref(false) |
| | | let otherMoney = ref(null) |
| | | |
| | | const dialogSelectOrderVisible = ref(false); // 控制弹窗显示 |
| | | const currentOrderIds = ref([]); // 已有的订单ID,用于排除 |
| | | |
| | | |
| | | // 初始化已选订单ID(在onMounted中调用) |
| | | const initCurrentOrderIds = () => { |
| | | if (produceList && produceList.length > 0) { |
| | | const orderIds = produceList.map(item => item.orderId); |
| | | currentOrderIds.value = [...new Set(orderIds)]; |
| | | }else { |
| | | currentOrderIds.value = []; |
| | | } |
| | | }; |
| | | |
| | | const hasDecimal=(value)=>{ |
| | | const regex=/\./ // 定义正则表达式,查找小数点 |
| | |
| | | //禁用按钮 |
| | | gridOptions.toolbarConfig.buttons[2].disabled = true |
| | | gridOptions.toolbarConfig.buttons[3].disabled = true |
| | | //gridOptions.toolbarConfig.buttons[4].disabled = false |
| | | //显示复选框 |
| | | xGrid.value.showColumn("select") |
| | | gridOptions.loading=false |
| | |
| | | pageTotal.value=res.data.total |
| | | titleUploadData.value=deepClone(res.data.delivery) |
| | | titleUploadData.value.deliveryId=str |
| | | |
| | | |
| | | if(userStore.user.permissions.indexOf('createDelivery.add') > -1&&userStore.user.permissions.indexOf('createDelivery.review') > -1){ |
| | | gridOptions.toolbarConfig.buttons[0].visible = false |
| | | }else{ |
| | |
| | | if(titleUploadData.value.deliveryState!==0){ |
| | | gridOptions.toolbarConfig.buttons[2].disabled = true |
| | | gridOptions.toolbarConfig.buttons[1].disabled = true |
| | | //gridOptions.toolbarConfig.buttons[4].disabled = true |
| | | } |
| | | if(titleUploadData.value.deliveryState===0){ |
| | | gridOptions.toolbarConfig.buttons[3].disabled = true |
| | |
| | | resizable: true, |
| | | useKey: true |
| | | }, |
| | | sortConfig: { |
| | | multiple: true, |
| | | }, |
| | | filterConfig: { //筛选配置项 |
| | | //remote: true |
| | | }, |
| | |
| | | {'code': 'addToExamine', 'name': t('reportingWorks.saveAndReview'),status: 'primary',icon: 'vxe-icon-save'}, |
| | | {'code': 'toExamine', 'name': t('basicData.review'),status: 'primary'}, |
| | | {'code': 'CounterExamination', 'name': t('basicData.cancelReview'),status: 'primary'}, |
| | | //{'code': 'addOtherOrders','name': t('delivery.orderAdd'),'status': 'primary'} |
| | | //{'code': 'glassShelf', 'name': t('finishedGlassShelf.finishedGlassShelfEmit'),status: 'primary'} |
| | | ], |
| | | /*import: false, |
| | |
| | | titleUploadData.value.freightQuantity=0 |
| | | } |
| | | |
| | | if($grid.getCheckedFilters().length!==0){ |
| | | ElMessage.error(t('order.msg.pleaseCancelTheFilteringFirst')) |
| | | return |
| | | } |
| | | |
| | | let flowData = ref({ |
| | | delivery: selectRecords, |
| | |
| | | otherMoney:otherMoney.value, |
| | | deliveryIdType:company.deliveryIdType, |
| | | deliveryOutbound:company.deliveryOutbound, |
| | | type:2 |
| | | type:1 |
| | | |
| | | }) |
| | | gridOptions.toolbarConfig.buttons[0].disabled = true |
| | |
| | | titleUploadData.value.freightQuantity=0 |
| | | } |
| | | |
| | | if($grid.getCheckedFilters().length!==0){ |
| | | ElMessage.error(t('order.msg.pleaseCancelTheFilteringFirst')) |
| | | return |
| | | } |
| | | |
| | | |
| | | let flowData = ref({ |
| | | delivery: selectRecords, |
| | |
| | | gridOptions.toolbarConfig.buttons[1].disabled = false |
| | | }) |
| | | break |
| | | } |
| | | case 'addOtherOrders': { |
| | | // 显示弹窗前更新已选订单ID |
| | | initCurrentOrderIds(); |
| | | // 显示弹窗 |
| | | dialogSelectOrderVisible.value = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | } |
| | | }, |
| | | cellDblclick ({row,column}) { |
| | | copyTableCellValue(row,column) |
| | | } |
| | | } |
| | | |
| | | //复选框触发事件 |
| | | const handleCheckboxChange = ({ records, checked, row }) => { |
| | | const $grid = xGrid.value; |
| | | if (!$grid) return; |
| | | |
| | | // 获取当前所有选中的行(返回数组) |
| | | const allCheckedRows = $grid.getCheckboxRecords(); |
| | | // 获取表格所有数据(visibleData 是当前可见数据,fullData 是全部数据,根据需求选择) |
| | | const tableData = $grid.getTableData().visibleData; |
| | | // 按箱号分组 |
| | | const boxNoGroup = groupByBoxNo(tableData); |
| | | // 当前行的箱号 |
| | | const currentBoxNo = row.finishedGoodsInventory?.boxNo || ''; |
| | | |
| | | // 选中逻辑:如果是“选中”操作,同箱号的行全部选中 |
| | | if (checked && currentBoxNo!="" && currentBoxNo!=null) { |
| | | const sameBoxRows = boxNoGroup[currentBoxNo] || []; |
| | | // 批量设置同箱号的行为选中状态(跳过已选中的行,避免重复触发) |
| | | sameBoxRows.forEach(item => { |
| | | const isAlreadyChecked = allCheckedRows.some(checkedRow => { |
| | | return checkedRow._X_ROW_KEY === item._X_ROW_KEY; |
| | | }); |
| | | // 未选中则设置为选中 |
| | | if (!isAlreadyChecked) { |
| | | $grid.setCheckboxRow(item, true); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | |
| | | const groupByBoxNo = (tableData) => { |
| | | return tableData.reduce((group, row) => { |
| | | // 获取当前行的箱号(注意处理 undefined 情况) |
| | | const boxNo = row.finishedGoodsInventory?.boxNo || ''; |
| | | if (!group[boxNo]) { |
| | | group[boxNo] = []; |
| | | } |
| | | group[boxNo].push(row); |
| | | return group; |
| | | }, {}); |
| | | }; |
| | | |
| | | |
| | | //计算金钱 |
| | | const countMoney = (list) => { |
| | |
| | | }; |
| | | |
| | | |
| | | // 处理从SelectOrderList选中的订单 |
| | | const handleSelectedOrders = async (selectedOrders) => { |
| | | if (!selectedOrders || selectedOrders.length === 0) return; |
| | | |
| | | // 关闭弹窗 |
| | | dialogSelectOrderVisible.value = false; |
| | | |
| | | // 验证选中的订单是否符合条件 |
| | | const { customerId, project } = titleUploadData.value; |
| | | const invalidOrders = selectedOrders.filter(order => |
| | | order.customerId !== parseInt(customerId) || order.project !== project |
| | | ); |
| | | |
| | | if (invalidOrders.length > 0) { |
| | | ElMessage.warning(t('delivery.onlySameCustomerProject')); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | // 显示加载状态 |
| | | gridOptions.loading = true; |
| | | |
| | | // 批量查询订单明细(按订单ID) |
| | | const orderIds = selectedOrders.map(order => order.orderId).join('|'); |
| | | filterData.value.orderId=orderIds |
| | | request.post("/delivery/getSelectShippingOrderDetails/1/100",filterData.value).then((res) => { |
| | | if (res.code == 200) { |
| | | // 处理返回的明细数据 |
| | | const orderDetails = res.data.data || []; |
| | | //合并数据 |
| | | mergeData(orderDetails); |
| | | } else { |
| | | ElMessage.warning(res.msg || t('basicData.msg.data获取失败')); |
| | | } |
| | | }) |
| | | } catch (error) { |
| | | ElMessage.error(t('basicData.msg.ServerConnectionError')); |
| | | console.error('查询订单明细失败:', error); |
| | | } finally { |
| | | // 关闭加载状态 |
| | | gridOptions.loading = false; |
| | | } |
| | | }; |
| | | |
| | | // 合并数据:判断orderId、orderNumber、boxNo是否相同,相同则累加数量,不同则新增 |
| | | const mergeData = (newDataList) => { |
| | | // 复制现有数据(避免直接修改响应式源数据) |
| | | const currentList = [...produceList]; |
| | | |
| | | newDataList.forEach(newItem => { |
| | | // 提取新数据的关键比对字段 |
| | | const newOrderId = newItem.orderId; |
| | | const newOrderNumber = newItem.orderNumber; |
| | | const newBoxNo = newItem.finishedGoodsInventory?.boxNo || ''; // 处理可能的undefined |
| | | |
| | | // 在现有数据中查找匹配项(三个字段完全相同) |
| | | const matchedItem = currentList.find(item => |
| | | item.orderId === newOrderId && |
| | | item.orderNumber === newOrderNumber && |
| | | (item.finishedGoodsInventory?.boxNo || '') === newBoxNo |
| | | ); |
| | | |
| | | if (matchedItem) { |
| | | // 找到匹配项:累加数量(确保是数值类型) |
| | | matchedItem.deliveryDetail.quantity = (Number(matchedItem.deliveryDetail.quantity) || 0) + |
| | | (Number(newItem.deliveryDetail.quantity) || 0); |
| | | } else { |
| | | // 未找到匹配项:新增一条数据 |
| | | currentList.push(newItem); |
| | | } |
| | | }); |
| | | |
| | | // 更新响应式数据 |
| | | produceList = currentList; |
| | | // 刷新表格 |
| | | xGrid.value.reloadData(produceList); |
| | | }; |
| | | |
| | | </script> |
| | | |
| | |
| | | v-on="gridEvents" |
| | | :edit-rules="validRules" |
| | | @edit-closed="editClosedEvent" |
| | | @checkbox-change="handleCheckboxChange" |
| | | |
| | | > |
| | | <template #num1_filter="{ column, $panel }"> |
| | |
| | | @handle-result="handleChildResult2" |
| | | /> |
| | | </el-dialog> |
| | | |
| | | <el-dialog |
| | | v-model="dialogSelectOrderVisible" |
| | | :title="t('delivery.orderAdd')" |
| | | style="width: 70%;height:75% " |
| | | destroy-on-close |
| | | :close-on-click-modal="false" |
| | | :close-on-press-escape="false"> |
| | | <SelectOrderList |
| | | style="width: 100%;height: 600px" |
| | | :customer-id="titleUploadData.customerId" |
| | | :project="titleUploadData.project" |
| | | :exclude-order-ids="currentOrderIds" |
| | | @select-orders="handleSelectedOrders" |
| | | /> |
| | | </el-dialog> |
| | | </div> |
| | | |
| | | </template> |