Merge branch 'main' of http://47.100.212.83:3000/yangzifeng/shzg_projectManage
This commit is contained in:
@@ -307,10 +307,24 @@
|
||||
<el-button type="primary" @click="addLineFun" :disabled="idEdit != 0">添加</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table :data="planList" height="400" style="width: 100%" show-overflow-tooltip
|
||||
<div class="addBox">
|
||||
<div style="display: flex;align-items: center;">
|
||||
<div class="addData" @click="addData">
|
||||
<el-icon style="margin-right: 10px;" size="20"><FolderAdd /></el-icon>
|
||||
添加至入库
|
||||
</div>
|
||||
<div @click="viewData" style="color: #000;text-decoration: underline;margin-left: 5px;">[已添加{{ outTempData.length }}条库存]</div>
|
||||
<!-- <div @click="viewData" style="color: red;text-decoration: underline;font-weight: bold;">[凭证重复入库或项目已关闭,请点击查看!]</div> -->
|
||||
</div>
|
||||
<div v-show="outTempData.length > 0 && planList.length === outTempData.length" @click="deleteData" style="display: flex;align-items: center;color: var(--el-color-primary);">
|
||||
<el-icon><delete /></el-icon>
|
||||
<span>删除</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="planList" height="400" style="width: 100%" show-overflow-tooltip border
|
||||
:row-class-name="tableRowClassName" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="30" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" width="50" />
|
||||
<el-table-column label="序号" align="center" type="index" width="70" />
|
||||
<el-table-column label="状态" align="center" prop="status" width="100" v-if="idEdit == 0">
|
||||
<template #default="scoped">
|
||||
<el-tag :type="scoped.row.status == 1
|
||||
@@ -666,7 +680,7 @@ const printNumList = ref([
|
||||
{ id: 3, statusName: "3" },
|
||||
{ id: 4, statusName: "4" },
|
||||
]);
|
||||
const printNum = ref(0); //打印机编号
|
||||
const printNum = ref(1); //打印机编号
|
||||
const moveReason = ref(""); //移库原因
|
||||
const operationTime = ref([]);
|
||||
const actionUrl =
|
||||
@@ -860,6 +874,7 @@ function handleAdd(single) {
|
||||
isSingle.value = single;
|
||||
reset();
|
||||
open.value = true;
|
||||
outTempData.value = []
|
||||
title.value = "添加库存单据";
|
||||
}
|
||||
|
||||
@@ -880,6 +895,88 @@ const statusList = ref([
|
||||
{ value: 2, label: "部分入库" },
|
||||
]);
|
||||
const checkPlanList = ref([]); //已选中的要入库的数据
|
||||
|
||||
// 点击添加至入库
|
||||
const outTempData = ref([]);
|
||||
function addData() {
|
||||
if (checkPlanList.value.length == 0) {
|
||||
proxy.$modal.msgError("请勾选数据");
|
||||
return;
|
||||
}
|
||||
let data = outTempData.value.concat(checkPlanList.value);
|
||||
let arr = []; // 去重后的最终数组
|
||||
let duplicateSapNos = ''; // 存储重复数据的sapNo
|
||||
let invalidQtySapNos = ''; // 存储入库数量有误的sapNo
|
||||
const uniqueKeys = new Set(); // 用于存储唯一的组合键 (id+pcode+realQty)
|
||||
|
||||
// 遍历数组,先校验数量合法性,再判断唯一性
|
||||
data.forEach(item => {
|
||||
// 1. 校验realQty是否大于0(处理空值/非数字情况)
|
||||
const realQty = Number(item.realQty);
|
||||
if (isNaN(realQty) || realQty <= 0) {
|
||||
// 避免同一个sapNo重复添加到提示中
|
||||
if (!invalidQtySapNos.includes(item.sapNo)) {
|
||||
invalidQtySapNos += item.sapNo + ',';
|
||||
}
|
||||
return; // 数量不合法,直接跳过后续唯一性判断
|
||||
}
|
||||
|
||||
// 2. 生成唯一标识组合键
|
||||
const uniqueKey = `${item.id}_${item.pcode}_${realQty}`;
|
||||
|
||||
// 3. 检查组合键是否已存在
|
||||
if (uniqueKeys.has(uniqueKey)) {
|
||||
// 存在重复,拼接sapNo(去重避免重复拼接)
|
||||
if (!duplicateSapNos.includes(item.sapNo)) {
|
||||
duplicateSapNos += item.sapNo + ',';
|
||||
}
|
||||
} else {
|
||||
// 不存在重复,加入结果数组并记录组合键
|
||||
arr.push(item);
|
||||
uniqueKeys.add(uniqueKey);
|
||||
}
|
||||
console.log(uniqueKeys)
|
||||
});
|
||||
|
||||
// 处理入库数量有误的提示
|
||||
if (invalidQtySapNos) {
|
||||
invalidQtySapNos = invalidQtySapNos.slice(0, -1); // 去掉最后一个逗号
|
||||
proxy.$modal.msgError(`入库数量有误:${invalidQtySapNos}(入库数量需大于0)`);
|
||||
return
|
||||
}
|
||||
|
||||
// 处理重复数据的提示
|
||||
if (duplicateSapNos) {
|
||||
duplicateSapNos = duplicateSapNos.slice(0, -1); // 去掉最后一个逗号
|
||||
proxy.$modal.msgError(`存在重复数据:${duplicateSapNos}`);
|
||||
}
|
||||
|
||||
outTempData.value = arr
|
||||
}
|
||||
|
||||
// 查看所有的出库数据
|
||||
const viewData = () => {
|
||||
planList.value = JSON.parse(JSON.stringify(outTempData.value));
|
||||
}
|
||||
|
||||
// 删除选中的出库数据
|
||||
const deleteData = () => {
|
||||
if (checkPlanList.value.length == 0) {
|
||||
proxy.$modal.msgError("请勾选数据");
|
||||
return;
|
||||
}
|
||||
proxy.$modal.confirm("确认删除选中的出库数据吗?").then(() => {
|
||||
const ids = checkPlanList.value.map(item => item.id);
|
||||
console.log(ids)
|
||||
planList.value = planList.value.filter(item => {
|
||||
// 无id的元素默认保留(如果想删除无id的,可改为 item?.id && !arr2Ids.has(item.id))
|
||||
return !ids.includes(item?.id);
|
||||
});
|
||||
outTempData.value = planList.value
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//新增入库 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
checkPlanList.value = selection;
|
||||
@@ -898,6 +995,7 @@ function searchPlan() {
|
||||
for (let i = 0; i < planData.length; i++) {
|
||||
planData[i].realQty = planData[i].waitQty;
|
||||
planData[i].gysJhId = planData[i].id;
|
||||
planData[i].pcode = "";
|
||||
if (autoFill.value && kzms.value != "") {
|
||||
planData[i].remark = kzms.value;
|
||||
}
|
||||
@@ -972,6 +1070,10 @@ function addNum(row) {
|
||||
|
||||
/** 确定入库按钮 */
|
||||
function submitForm() {
|
||||
if (outTempData.value.length !== planList.value.length) {
|
||||
proxy.$modal.msgError("请查看勾选数据");
|
||||
return;
|
||||
}
|
||||
proxy.$refs["stockRef"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (checkPlanList.value.length == 0) {
|
||||
@@ -1801,4 +1903,20 @@ isAudit();
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
|
||||
.addBox{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
cursor: pointer;
|
||||
.addData {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: var(--el-text-color-regular);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user