|
|
@@ -305,11 +305,11 @@
|
|
|
</el-form-item>
|
|
|
</el-col> -->
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="存储地点" prop="warehouseId">
|
|
|
+ <el-form-item :label="getWarehouseLabel" prop="warehouseId">
|
|
|
<el-select
|
|
|
v-model="formData.warehouseId"
|
|
|
:disabled="isFormDisabled || !formData.businessType"
|
|
|
- placeholder="请选择存储地点"
|
|
|
+ placeholder="请选择仓库"
|
|
|
clearable
|
|
|
filterable
|
|
|
>
|
|
|
@@ -322,6 +322,42 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col v-if="formData.businessType === '13'" :span="12">
|
|
|
+ <el-form-item label="调入区域" prop="areaCode">
|
|
|
+ <el-select
|
|
|
+ v-model="formData.areaCode"
|
|
|
+ :disabled="isFormDisabled || !formData.businessType"
|
|
|
+ filterable
|
|
|
+ placeholder="请输入调入区域"
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in areaList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.areaCode"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-if="formData.businessType === '13'" :span="12">
|
|
|
+ <el-form-item label="调入货位" prop="locationCode">
|
|
|
+ <el-select
|
|
|
+ v-model="formData.locationCode"
|
|
|
+ :disabled="isFormDisabled || !formData.businessType"
|
|
|
+ filterable
|
|
|
+ placeholder="请输入调入货位"
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in locationList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.locationCode"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="状态" prop="status" aria-disabled="true">
|
|
|
<el-select
|
|
|
@@ -552,6 +588,10 @@ export default {
|
|
|
loadingMaterial: false,
|
|
|
loadingSourceOrder: false,
|
|
|
loadingWarehouse: false,
|
|
|
+ loadingArea: false,
|
|
|
+ loadingLocation: false,
|
|
|
+ areaList: [],
|
|
|
+ locationList: [],
|
|
|
uploadFiles: [], // 上传的文件
|
|
|
// 页面标题
|
|
|
dialogTitle: "",
|
|
|
@@ -592,6 +632,8 @@ export default {
|
|
|
erpBackId: undefined,
|
|
|
list: [],
|
|
|
bpmInstanceId: undefined,
|
|
|
+ areaCode: undefined,
|
|
|
+ locationCode: undefined,
|
|
|
},
|
|
|
// 表单校验
|
|
|
formRules: {
|
|
|
@@ -649,6 +691,14 @@ export default {
|
|
|
this.formData.id === ""
|
|
|
);
|
|
|
},
|
|
|
+ // 动态获取地点标签
|
|
|
+ getWarehouseLabel() {
|
|
|
+ const businessType = this.formData.businessType;
|
|
|
+ if (businessType === "13") {
|
|
|
+ return "调入仓库";
|
|
|
+ }
|
|
|
+ return "存储地点";
|
|
|
+ },
|
|
|
// 动态获取部门标签
|
|
|
getDeptLabel() {
|
|
|
const businessType = this.formData.businessType;
|
|
|
@@ -734,6 +784,16 @@ export default {
|
|
|
rules.warehouseId = [
|
|
|
{ required: true, message: "存储地点不能为空", trigger: "blur" },
|
|
|
];
|
|
|
+ } else if (businessType === "13") {
|
|
|
+ rules.warehouseId = [
|
|
|
+ { required: true, message: "调入仓库不能为空", trigger: "blur" },
|
|
|
+ ];
|
|
|
+ rules.areaCode = [
|
|
|
+ { required: true, message: "调入区域不能为空", trigger: "blur" },
|
|
|
+ ];
|
|
|
+ rules.locationCode = [
|
|
|
+ { required: true, message: "调入货位不能为空", trigger: "blur" },
|
|
|
+ ];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -761,12 +821,41 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
+ // 监听仓库选择变化,获取对应区域列表
|
|
|
+ "formData.warehouseId": {
|
|
|
+ handler(newVal) {
|
|
|
+ if (this.formData.businessType === "13" && newVal) {
|
|
|
+ this.loadAreaList(newVal);
|
|
|
+ // 清空已选择的区域和货位
|
|
|
+ this.formData.areaCode = undefined;
|
|
|
+ this.formData.locationCode = undefined;
|
|
|
+ this.locationList = [];
|
|
|
+ } else {
|
|
|
+ this.areaList = [];
|
|
|
+ this.locationList = [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ // 监听区域选择变化,获取对应货位列表
|
|
|
+ "formData.areaCode": {
|
|
|
+ handler(newVal) {
|
|
|
+ if (
|
|
|
+ this.formData.businessType === "13" &&
|
|
|
+ newVal &&
|
|
|
+ this.formData.warehouseId
|
|
|
+ ) {
|
|
|
+ this.loadLocationList(this.formData.warehouseId, newVal);
|
|
|
+ // 清空已选择的货位
|
|
|
+ this.formData.locationCode = undefined;
|
|
|
+ } else {
|
|
|
+ this.locationList = [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
// 一次性获取全部仓库
|
|
|
- InRequestApi.getStockPage({ pageSize: 9999 }).then(({ data }) => {
|
|
|
- this.warehouseList = data.list || [];
|
|
|
- });
|
|
|
+ this.loadWarehouseList();
|
|
|
// 一次性获取全部供应商
|
|
|
InRequestApi.getSupplierPage({ pageSize: 9999 }).then(({ data }) => {
|
|
|
this.supplierList = data.list || [];
|
|
|
@@ -778,6 +867,12 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
methods: {
|
|
|
+ /* 1. 保证仓库列表就位 */
|
|
|
+ async loadWarehouseList() {
|
|
|
+ if (this.warehouseList.length) return; // 已经拿过
|
|
|
+ const { data } = await InRequestApi.getStockPage({ pageSize: 9999 });
|
|
|
+ this.warehouseList = data.list || [];
|
|
|
+ },
|
|
|
// 通用的判断函数判断按钮是否可点击
|
|
|
isButtonDisabled(buttonType) {
|
|
|
const status = Number(this.formData.status);
|
|
|
@@ -899,6 +994,78 @@ export default {
|
|
|
this.sourceOrderNoList = this.allSourceOrderNoList;
|
|
|
}
|
|
|
},
|
|
|
+ // 远程搜索调入区域
|
|
|
+ remoteAreaSearch(query) {
|
|
|
+ if (query !== "") {
|
|
|
+ this.loadingArea = true;
|
|
|
+ setTimeout(async () => {
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ data: { list },
|
|
|
+ } = await InRequestApi.getStockAreaPage({
|
|
|
+ areaName: query,
|
|
|
+ pageSize: 999,
|
|
|
+ });
|
|
|
+ this.areaList = list || [];
|
|
|
+ } catch (error) {
|
|
|
+ console.error("搜索调入区域失败:", error);
|
|
|
+ this.areaList = [];
|
|
|
+ } finally {
|
|
|
+ this.loadingArea = false;
|
|
|
+ }
|
|
|
+ }, 200);
|
|
|
+ } else {
|
|
|
+ this.areaList = [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 加载区域列表
|
|
|
+ async loadAreaList(warehouseId) {
|
|
|
+ this.loadingArea = true;
|
|
|
+ try {
|
|
|
+ // 通过erpId找到仓库的完整数据
|
|
|
+ console.log("warehouseList的长度", this.warehouseList.length);
|
|
|
+ const warehouseRow = this.warehouseList.find(
|
|
|
+ (w) => w.erpId === warehouseId
|
|
|
+ );
|
|
|
+ // 获取仓库的id
|
|
|
+ const wmsStockId = warehouseRow ? warehouseRow.id : warehouseId;
|
|
|
+ const {
|
|
|
+ data: { list },
|
|
|
+ } = await InRequestApi.getStockAreaPage({
|
|
|
+ wmsStockId: wmsStockId,
|
|
|
+ pageSize: 9999,
|
|
|
+ });
|
|
|
+ this.areaList = list || [];
|
|
|
+ } catch (error) {
|
|
|
+ console.error("加载区域列表失败:", error);
|
|
|
+ this.areaList = [];
|
|
|
+ } finally {
|
|
|
+ this.loadingArea = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 加载货位列表
|
|
|
+ async loadLocationList(warehouseId, areaCode) {
|
|
|
+ this.loadingLocation = true;
|
|
|
+ try {
|
|
|
+ // 通过areaCode找到区域的完整数据
|
|
|
+ const area = this.areaList.find((w) => w.areaCode === areaCode);
|
|
|
+ // 获取区域的id
|
|
|
+ const wmsStockAreaId = area ? area.id : areaCode;
|
|
|
+
|
|
|
+ const {
|
|
|
+ data: { list },
|
|
|
+ } = await InRequestApi.getStockLocationPage({
|
|
|
+ wmsStockAreaId: wmsStockAreaId,
|
|
|
+ pageSize: 9999,
|
|
|
+ });
|
|
|
+ this.locationList = list || [];
|
|
|
+ } catch (error) {
|
|
|
+ console.error("加载货位列表失败:", error);
|
|
|
+ this.locationList = [];
|
|
|
+ } finally {
|
|
|
+ this.loadingLocation = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
// remoteWarehouse(query) {
|
|
|
// if (query !== "") {
|
|
|
// const that = this;
|
|
|
@@ -983,6 +1150,9 @@ export default {
|
|
|
if (id) {
|
|
|
this.formLoading = true;
|
|
|
try {
|
|
|
+ /* 2. 等仓库列表回来 */
|
|
|
+ await this.loadWarehouseList();
|
|
|
+
|
|
|
const res = await InRequestApi.getInRequest(id);
|
|
|
res.data.businessType = res.data.businessType
|
|
|
? res.data.businessType.toString()
|
|
|
@@ -994,10 +1164,30 @@ export default {
|
|
|
? res.data.priority.toString()
|
|
|
: "0";
|
|
|
res.data.status = res.data.status ? res.data.status.toString() : "0";
|
|
|
+ res.data.areaCode = res.data.areaCode
|
|
|
+ ? res.data.areaCode.toString()
|
|
|
+ : undefined;
|
|
|
+ res.data.locationCode = res.data.locationCode
|
|
|
+ ? res.data.locationCode.toString()
|
|
|
+ : undefined;
|
|
|
res.data.list = res.data.list || [];
|
|
|
this.formData = res.data;
|
|
|
this.dialogTitle = "修改";
|
|
|
- // 附件列表
|
|
|
+
|
|
|
+ /* 3. 现在仓库列表有了,再加载区域/货位 */
|
|
|
+ if (
|
|
|
+ this.formData.businessType === "13" &&
|
|
|
+ this.formData.warehouseId
|
|
|
+ ) {
|
|
|
+ await this.loadAreaList(this.formData.warehouseId);
|
|
|
+ if (this.formData.areaCode) {
|
|
|
+ await this.loadLocationList(
|
|
|
+ this.formData.warehouseId,
|
|
|
+ this.formData.areaCode
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.uploadFiles = this.formData.filesListVos;
|
|
|
} finally {
|
|
|
this.formLoading = false;
|
|
|
@@ -1040,6 +1230,12 @@ export default {
|
|
|
// 拼接文件ID
|
|
|
data.fileId = fileIds.join(",");
|
|
|
|
|
|
+ // 只有businessType === "13"时才提交areaCode和locationCode
|
|
|
+ if (data.businessType !== "13") {
|
|
|
+ delete data.areaCode;
|
|
|
+ delete data.locationCode;
|
|
|
+ }
|
|
|
+
|
|
|
// 修改的提交;
|
|
|
if (data.id) {
|
|
|
await InRequestApi.updateInRequest(data);
|
|
|
@@ -1152,6 +1348,8 @@ export default {
|
|
|
erpErrMsg: undefined,
|
|
|
erpBackId: undefined,
|
|
|
list: [],
|
|
|
+ areaCode: undefined,
|
|
|
+ locationCode: undefined,
|
|
|
};
|
|
|
this.resetForm("formRef");
|
|
|
},
|