|
@@ -966,6 +966,8 @@ import SelectContract from "@/components/contractCom/selectContract.vue";
|
|
|
import SelectSample from "@/components/contractCom/selectSample.vue";
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
import { nextTick, watch } from "vue";
|
|
|
+import { v4 as uuidv4 } from "uuid";
|
|
|
+
|
|
|
const userInfo = useUserStore();
|
|
|
|
|
|
const route = useRoute();
|
|
@@ -1507,12 +1509,13 @@ const handlePerson = (item) => {
|
|
|
|
|
|
const selectProduct = (goods) => {
|
|
|
if (goods && goods.id) {
|
|
|
- let data = formData.data.contractProductList.filter(
|
|
|
- (item) => item.productId === goods.id
|
|
|
- );
|
|
|
- if (data && data.length > 0) {
|
|
|
- return ElMessage("该产品已添加");
|
|
|
- }
|
|
|
+ // let data = formData.data.contractProductList.filter(
|
|
|
+ // (item) => item.productId === goods.id
|
|
|
+ // );
|
|
|
+ // if (data && data.length > 0) {
|
|
|
+ // return ElMessage("该产品已添加");
|
|
|
+ // }
|
|
|
+ let rowId = uuidv4();
|
|
|
let fileUrl = "";
|
|
|
if (goods.fileList && goods.fileList.length > 0) {
|
|
|
fileUrl = goods.fileList[0].fileUrl;
|
|
@@ -1546,6 +1549,7 @@ const selectProduct = (goods) => {
|
|
|
) {
|
|
|
formData.data.contractProductList.push({
|
|
|
fileUrl: fileUrl,
|
|
|
+ rowId,
|
|
|
productId: goods.id,
|
|
|
productCnName: goods.name,
|
|
|
productName: goods.nameEnglish,
|
|
@@ -1561,6 +1565,7 @@ const selectProduct = (goods) => {
|
|
|
formData.data.contractProductList = [
|
|
|
{
|
|
|
fileUrl: fileUrl,
|
|
|
+ rowId,
|
|
|
productId: goods.id,
|
|
|
productCnName: goods.name,
|
|
|
productName: goods.nameEnglish,
|
|
@@ -1581,18 +1586,12 @@ const selectProduct = (goods) => {
|
|
|
//左侧待出货列表
|
|
|
formData.data.contractWaitShipmentList.push({
|
|
|
productCode: goods.code,
|
|
|
+ rowId,
|
|
|
productId: goods.id,
|
|
|
productName: goods.nameEnglish,
|
|
|
quantity: null,
|
|
|
waitQuantity: "",
|
|
|
});
|
|
|
- // formData.data.contractShipmentList.push({
|
|
|
- // productCode: goods.code,
|
|
|
- // productId: goods.id,
|
|
|
- // productName: goods.nameEnglish,
|
|
|
- // shipmentTime: "",
|
|
|
- // quantity: null,
|
|
|
- // });
|
|
|
ElMessage({
|
|
|
message: "添加成功!",
|
|
|
type: "success",
|
|
@@ -1608,11 +1607,11 @@ const onPicture = (path) => {
|
|
|
const handleRemove = async (index, row) => {
|
|
|
formData.data.contractShipmentList =
|
|
|
formData.data.contractShipmentList.filter(
|
|
|
- (item) => item.productId !== row.productId
|
|
|
+ (item) => item.rowId !== row.rowId
|
|
|
);
|
|
|
formData.data.contractWaitShipmentList =
|
|
|
formData.data.contractWaitShipmentList.filter(
|
|
|
- (item) => item.productId !== row.productId
|
|
|
+ (item) => item.rowId !== row.rowId
|
|
|
);
|
|
|
await formData.data.contractProductList.splice(index, 1);
|
|
|
totalAmount();
|
|
@@ -1747,18 +1746,21 @@ const handleSubmit = async () => {
|
|
|
formData.data.contractShipmentList.length > 0
|
|
|
) {
|
|
|
for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
- let data = formData.data.contractShipmentList.filter(
|
|
|
- (item) =>
|
|
|
- item.productId === formData.data.contractProductList[i].productId
|
|
|
- );
|
|
|
- if (data && data.length > 0) {
|
|
|
- let quantity = 0;
|
|
|
- for (let j = 0; j < data.length; j++) {
|
|
|
- quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
|
|
|
- }
|
|
|
- if (quantity > formData.data.contractProductList[i].quantity) {
|
|
|
- ElMessage("出货数量不能大于商品数量");
|
|
|
- return false;
|
|
|
+ if (formData.data.contractProductList[i].rowId) {
|
|
|
+ let data = formData.data.contractShipmentList.filter(
|
|
|
+ (item) => item.rowId === formData.data.contractProductList[i].rowId
|
|
|
+ );
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ let quantity = 0;
|
|
|
+ for (let j = 0; j < data.length; j++) {
|
|
|
+ quantity = parseFloat(
|
|
|
+ Number(quantity) + Number(data[j].quantity)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (quantity > formData.data.contractProductList[i].quantity) {
|
|
|
+ ElMessage("出货数量不能大于商品数量");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1925,6 +1927,7 @@ onMounted(() => {
|
|
|
) {
|
|
|
for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
const e = formData.data.contractProductList[i];
|
|
|
+ e.rowId = uuidv4();
|
|
|
if (e.ehsdJson) {
|
|
|
let obj = JSON.parse(e.ehsdJson);
|
|
|
e.packMethod = obj.packMethod;
|
|
@@ -1950,6 +1953,19 @@ onMounted(() => {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ if (route.query.processType == 30) {
|
|
|
+ formData.data.contractWaitShipmentList =
|
|
|
+ formData.data.contractProductList.map((x) => ({
|
|
|
+ productCode: x.productCode,
|
|
|
+ rowId: x.rowId,
|
|
|
+ productId: x.productId,
|
|
|
+ productName: x.productName,
|
|
|
+ quantity: 0,
|
|
|
+ waitQuantity: "",
|
|
|
+ }));
|
|
|
+ changeWaitQuantity();
|
|
|
+ formData.data.contractShipmentList = [];
|
|
|
+ }
|
|
|
if (formData.data.countryId) {
|
|
|
getCityData(formData.data.countryId, "20");
|
|
|
}
|
|
@@ -2136,6 +2152,7 @@ const selectContract = (businessId) => {
|
|
|
) {
|
|
|
for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
const e = formData.data.contractProductList[i];
|
|
|
+ e.rowId = uuidv4();
|
|
|
delete e.id;
|
|
|
delete e.contractId;
|
|
|
if (e.ehsdJson) {
|
|
@@ -2147,6 +2164,7 @@ const selectContract = (businessId) => {
|
|
|
formData.data.contractWaitShipmentList =
|
|
|
formData.data.contractProductList.map((x) => ({
|
|
|
productCode: x.productCode,
|
|
|
+ rowId: x.rowId,
|
|
|
productId: x.productId,
|
|
|
productName: x.productName,
|
|
|
quantity: 0,
|
|
@@ -2188,17 +2206,18 @@ const selectContract = (businessId) => {
|
|
|
return x;
|
|
|
});
|
|
|
}
|
|
|
- if (
|
|
|
- formData.data.contractShipmentList &&
|
|
|
- formData.data.contractShipmentList.length > 0
|
|
|
- ) {
|
|
|
- formData.data.contractShipmentList =
|
|
|
- formData.data.contractShipmentList.map((x) => {
|
|
|
- delete x.id;
|
|
|
- delete x.contractId;
|
|
|
- return x;
|
|
|
- });
|
|
|
- }
|
|
|
+ formData.data.contractShipmentList = [];
|
|
|
+ // if (
|
|
|
+ // formData.data.contractShipmentList &&
|
|
|
+ // formData.data.contractShipmentList.length > 0
|
|
|
+ // ) {
|
|
|
+ // formData.data.contractShipmentList =
|
|
|
+ // formData.data.contractShipmentList.map((x) => {
|
|
|
+ // delete x.id;
|
|
|
+ // delete x.contractId;
|
|
|
+ // return x;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
if (formData.data.countryId) {
|
|
|
getCityData(formData.data.countryId, "20");
|
|
|
}
|
|
@@ -2266,6 +2285,7 @@ const selectContract = (businessId) => {
|
|
|
) {
|
|
|
for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
const e = formData.data.contractProductList[i];
|
|
|
+ e.rowId = uuidv4();
|
|
|
if (e.ehsdJson) {
|
|
|
let obj = JSON.parse(e.ehsdJson);
|
|
|
e.packMethod = obj.packMethod;
|
|
@@ -2276,6 +2296,7 @@ const selectContract = (businessId) => {
|
|
|
formData.data.contractWaitShipmentList =
|
|
|
formData.data.contractProductList.map((x) => ({
|
|
|
productCode: x.productCode,
|
|
|
+ rowId: x.rowId,
|
|
|
productId: x.productId,
|
|
|
productName: x.productName,
|
|
|
quantity: 0,
|
|
@@ -2318,17 +2339,18 @@ const selectContract = (businessId) => {
|
|
|
return x;
|
|
|
});
|
|
|
}
|
|
|
- if (
|
|
|
- formData.data.contractShipmentList &&
|
|
|
- formData.data.contractShipmentList.length > 0
|
|
|
- ) {
|
|
|
- formData.data.contractShipmentList =
|
|
|
- formData.data.contractShipmentList.map((x) => {
|
|
|
- delete x.id;
|
|
|
- delete x.sampleId;
|
|
|
- return x;
|
|
|
- });
|
|
|
- }
|
|
|
+ formData.data.contractShipmentList = [];
|
|
|
+ // if (
|
|
|
+ // formData.data.contractShipmentList &&
|
|
|
+ // formData.data.contractShipmentList.length > 0
|
|
|
+ // ) {
|
|
|
+ // formData.data.contractShipmentList =
|
|
|
+ // formData.data.contractShipmentList.map((x) => {
|
|
|
+ // delete x.id;
|
|
|
+ // delete x.sampleId;
|
|
|
+ // return x;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
|
|
|
if (formData.data.countryId) {
|
|
|
getCityData(formData.data.countryId, "20");
|
|
@@ -2368,6 +2390,7 @@ const handleAddShipment = () => {
|
|
|
for (let i = 0; i < selectShipmentData.value.length; i++) {
|
|
|
const e = selectShipmentData.value[i];
|
|
|
formData.data.contractShipmentList.push({
|
|
|
+ rowId: e.rowId,
|
|
|
productId: e.productId,
|
|
|
productCode: e.productCode,
|
|
|
productName: e.productName,
|
|
@@ -2401,7 +2424,7 @@ const changeWaitQuantity = () => {
|
|
|
for (let i = 0; i < formData.data.contractWaitShipmentList.length; i++) {
|
|
|
const e = formData.data.contractWaitShipmentList[i];
|
|
|
let arr = formData.data.contractShipmentList.filter(
|
|
|
- (x) => x.productId === e.productId
|
|
|
+ (x) => x.rowId === e.rowId
|
|
|
);
|
|
|
let quantity = 0;
|
|
|
for (let j = 0; j < arr.length; j++) {
|