|
@@ -15,12 +15,21 @@
|
|
|
|
|
|
<el-button
|
|
|
v-if="editStatus"
|
|
|
- type="primary"
|
|
|
+ type="success"
|
|
|
icon="check"
|
|
|
@click="saveFrom"
|
|
|
>
|
|
|
- 保存
|
|
|
+ 暂存
|
|
|
</el-button>
|
|
|
+
|
|
|
+ <el-button
|
|
|
+ v-if="!editStatus"
|
|
|
+ type="primary"
|
|
|
+ icon="Download"
|
|
|
+ @click="handleExport"
|
|
|
+ v-hasPermi="['business:outsource:export']"
|
|
|
+ >导出</el-button
|
|
|
+ >
|
|
|
<el-button
|
|
|
v-if="editStatus"
|
|
|
type="primary"
|
|
@@ -28,15 +37,6 @@
|
|
|
@click="submitFrom"
|
|
|
>保存并提交</el-button
|
|
|
>
|
|
|
- <!-- <el-button
|
|
|
- v-if="form.id && editStatus"
|
|
|
- type="info"
|
|
|
- icon="Close"
|
|
|
- @click="editStatus = false"
|
|
|
- >
|
|
|
- 取消编辑
|
|
|
- </el-button> -->
|
|
|
-
|
|
|
<div class="close-btn" @click="cancel">
|
|
|
<i class="fa fa-times" aria-hidden="true" />
|
|
|
<!-- <span>关闭</span> -->
|
|
@@ -224,6 +224,18 @@
|
|
|
prop="productDescription"
|
|
|
width="320"
|
|
|
/>
|
|
|
+ <el-table-column label="产品数" align="center" prop="productNum">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input-number
|
|
|
+ v-if="editStatus"
|
|
|
+ :min="0"
|
|
|
+ v-model="scope.row.productNum"
|
|
|
+ placeholder="产品数"
|
|
|
+ />
|
|
|
+ <span v-else>{{ scope.row.productNum }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
<el-table-column
|
|
|
:label="form.packagingMethod === '0' ? '箱号' : '原箱号'"
|
|
|
align="center"
|
|
@@ -231,14 +243,37 @@
|
|
|
width="320"
|
|
|
/>
|
|
|
<el-table-column
|
|
|
- v-if="form.packagingMethod === '1'"
|
|
|
label="新箱号"
|
|
|
align="center"
|
|
|
prop="newCarrier"
|
|
|
width="320"
|
|
|
>
|
|
|
<template #default="scope">
|
|
|
- <el-input
|
|
|
+ <el-select
|
|
|
+ v-if="editStatus"
|
|
|
+ v-model="scope.row.carrierIds"
|
|
|
+ multiple
|
|
|
+ filterable
|
|
|
+ remote
|
|
|
+ reserve-keyword
|
|
|
+ placeholder="请选择箱号"
|
|
|
+ collapse-tags-tooltip
|
|
|
+ collapse-tags
|
|
|
+ :remote-method="
|
|
|
+ (arg) => remoteCarriers(arg, scope.row.newCarriers)
|
|
|
+ "
|
|
|
+ :loading="loadingCarrier"
|
|
|
+ @change="(arg) => handleCarrierChange(arg, scope.row)"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in carriers"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <span v-else>{{ scope.row.newCarrier }}</span>
|
|
|
+ <!-- <el-input
|
|
|
v-if="editStatus"
|
|
|
v-model="scope.row.newCarrier"
|
|
|
readonly
|
|
@@ -251,7 +286,7 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-input>
|
|
|
- <span v-else>{{ scope.row.newCarrier }}</span>
|
|
|
+ <span v-else>{{ scope.row.newCarrier }}</span>-->
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
@@ -335,7 +370,9 @@
|
|
|
import {
|
|
|
getOrder,
|
|
|
saveOrder,
|
|
|
+ carrierForOutsource,
|
|
|
submitOrder,
|
|
|
+ exportOutsource,
|
|
|
} from "@/api/business/outsourcedOrder";
|
|
|
import dialogCarrier from "./DialogCarrier";
|
|
|
import dialogSuppliers from "./DialogSuppliers";
|
|
@@ -371,6 +408,8 @@ const multiple = ref(true);
|
|
|
const visible = ref(false);
|
|
|
const editStatus = ref(true);
|
|
|
const isFullscreen = ref(false);
|
|
|
+const loadingCarrier = ref(false);
|
|
|
+const carriers = ref([]);
|
|
|
const webHost = import.meta.env.VITE_APP_BASE_API;
|
|
|
const form = ref({});
|
|
|
// const formatDetails = ref([])
|
|
@@ -382,6 +421,11 @@ const rules = {
|
|
|
};
|
|
|
|
|
|
/*********************** 方法区 ****************************/
|
|
|
+/** 导出按钮操作 */
|
|
|
+function handleExport() {
|
|
|
+ exportOutsource({ id: form.value.id });
|
|
|
+}
|
|
|
+
|
|
|
/** 打开抽屉 */
|
|
|
function open(id) {
|
|
|
reset();
|
|
@@ -404,12 +448,6 @@ function getForm() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-/** 查询表单信息 */
|
|
|
-// function selectProceseName(row) {
|
|
|
-// row.processNames = row.processes.map((item) => item.processAlias).join(",");
|
|
|
-// return row.processNames;
|
|
|
-// }
|
|
|
-
|
|
|
function selectText(value, data) {
|
|
|
if (value) {
|
|
|
return data.filter((item) => item.value == value)[0].label;
|
|
@@ -450,6 +488,7 @@ function saveFrom() {
|
|
|
proxy.$modal.msgError("请添加产品明细");
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
proxy.$refs["formRef"].validate((valid) => {
|
|
|
for (const item of form.value.details) {
|
|
|
if (!item.processNames) {
|
|
@@ -457,6 +496,16 @@ function saveFrom() {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (form.value.packagingMethod == 1) {
|
|
|
+ console.log("form.value.details", form.value.details);
|
|
|
+ for (const item of form.value.details) {
|
|
|
+ if (item.newCarriers.length == 0) {
|
|
|
+ proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (valid) {
|
|
|
saveOrder(form.value).then((response) => {
|
|
|
if (response.code == 200) {
|
|
@@ -469,34 +518,46 @@ function saveFrom() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function save() {}
|
|
|
-
|
|
|
/** 保存并提交 */
|
|
|
function submitFrom() {
|
|
|
- proxy.$modal.confirm("是否确定提交吗,提交后不可修改").then(function () {
|
|
|
- return;
|
|
|
- });
|
|
|
-
|
|
|
- if (!form.value.details || form.value.details.length == 0) {
|
|
|
- proxy.$modal.msgError("请添加产品明细");
|
|
|
- return;
|
|
|
- }
|
|
|
+ console.log("from", form.value);
|
|
|
+ proxy.$modal
|
|
|
+ .confirm("是否确定提交,提交后不可修改,删除")
|
|
|
+ .then(function () {
|
|
|
+ return;
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ if (!form.value.details || form.value.details.length == 0) {
|
|
|
+ proxy.$modal.msgError("请添加产品明细");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- proxy.$refs["formRef"].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- for (const item of form.value.details) {
|
|
|
- if (!item.processNames) {
|
|
|
- proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
|
|
|
- return;
|
|
|
+ proxy.$refs["formRef"].validate((valid) => {
|
|
|
+ for (const item of form.value.details) {
|
|
|
+ if (!item.processNames) {
|
|
|
+ proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (form.value.packagingMethod == 1) {
|
|
|
+ console.log("form.value.details", form.value.details);
|
|
|
+ for (const item of form.value.details) {
|
|
|
+ if (item.newCarriers.length == 0) {
|
|
|
+ proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (valid) {
|
|
|
+ submitOrder(form.value).then((response) => {
|
|
|
+ proxy.$modal.msgSuccess("提交成功");
|
|
|
+ visible.value = false;
|
|
|
+ getList.value();
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
- submitOrder(form.value).then((response) => {
|
|
|
- proxy.$modal.msgSuccess("提交成功");
|
|
|
- visible.value = false;
|
|
|
- getList.value();
|
|
|
});
|
|
|
- }
|
|
|
- });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
}
|
|
|
|
|
|
/***************************** 外协商对话框相关 *****************************/
|
|
@@ -538,6 +599,7 @@ const handleMultipleSelectedProducts = (selection) => {
|
|
|
productCode: item.productCode,
|
|
|
newCarrier: "",
|
|
|
newCarrierCount: 0,
|
|
|
+ newCarriers: [],
|
|
|
processNames: "",
|
|
|
remark: item.remark,
|
|
|
processes: [],
|
|
@@ -549,10 +611,69 @@ const handleMultipleSelectedProducts = (selection) => {
|
|
|
|
|
|
/***************************** 外协箱子对话框相关 *****************************/
|
|
|
// 打开外协箱子选择对话框
|
|
|
-const handleShowDialogOutsourceCarriers = (row) => {
|
|
|
+const handleShowDialogOutsourceCarriers = (row) => {};
|
|
|
+
|
|
|
+function remoteCarriers(code, row) {
|
|
|
+ loadingCarrier.value = true;
|
|
|
console.log("row", row);
|
|
|
- proxy.$refs.dialogCarrierRef.open(row.lotId);
|
|
|
-};
|
|
|
+ let categoryId;
|
|
|
+ if (form.value.packagingMethod == 1) {
|
|
|
+ categoryId = "1783783697558847489";
|
|
|
+ } else {
|
|
|
+ categoryId = "2";
|
|
|
+ }
|
|
|
+ if (code == "") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ carrierForOutsource({
|
|
|
+ categoryId: categoryId,
|
|
|
+ code: code,
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ carriers.value = res.rows.map((v) => ({ value: v.id, label: v.code }));
|
|
|
+ if (Array.isArray(row)) {
|
|
|
+ // 安全地更新 carriers
|
|
|
+ carriers.value.push(
|
|
|
+ ...row
|
|
|
+ .filter((v) => !carriers.value.map((e) => e.value).includes(v.id))
|
|
|
+ .map((v) => ({ value: v.id, label: v.code }))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ carriers.value = [];
|
|
|
+ carriers.value.push(...row);
|
|
|
+ }
|
|
|
+ loadingCarrier.value = false;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function handleCarrierChange(arg, item) {
|
|
|
+ item.newCarriers = carriers.value
|
|
|
+ .filter((v) => arg.includes(v.value))
|
|
|
+ .map((v) => ({ id: v.value, code: v.label }));
|
|
|
+ console.log("item", item);
|
|
|
+ console.log("form", form.value);
|
|
|
+}
|
|
|
+
|
|
|
+/** 使用新方式 */
|
|
|
+// const handleShowDialogOutsourceCarriers = (row) => {
|
|
|
+// // 确保 form.details 存在且不是 undefined
|
|
|
+// let allNewCarriers;
|
|
|
+// if (form.value && form.value.details && Array.isArray(form.value.details)) {
|
|
|
+// allNewCarriers = form.value.details
|
|
|
+// .flatMap((detail) =>
|
|
|
+// detail.newCarriers ? detail.newCarriers.filter((item) => item) : []
|
|
|
+// )
|
|
|
+// .filter(Boolean);
|
|
|
+
|
|
|
+// // 现在 allNewCarriers 包含了所有非空的 newCarriers 数组的元素
|
|
|
+// }
|
|
|
+// // form.value.details.newCarriers
|
|
|
+// // const allNewCarriers = form.details.flatMap((detail) => detail.newCarriers);
|
|
|
+// console.log("allNewCarriers", allNewCarriers);
|
|
|
+// proxy.$refs.dialogCarrierRef.open(row.lotId, from.value.deliveryMethod);
|
|
|
+// };
|
|
|
+
|
|
|
// 箱子选择带回
|
|
|
const handleMultipleSelectedOutsourceCarriers = (selection, lotId) => {
|
|
|
const carrierNames = selection.map((item) => item.code);
|