|
|
@@ -112,6 +112,7 @@
|
|
|
:disabled="
|
|
|
isFormDisabled || (formData.businessType ? false : true)
|
|
|
"
|
|
|
+ filterable
|
|
|
placeholder="请选择业务类型"
|
|
|
@change="changeBusinessDescribe"
|
|
|
>
|
|
|
@@ -597,6 +598,12 @@ export default {
|
|
|
dialogTitle: "",
|
|
|
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
formLoading: false,
|
|
|
+ // 记录当前业务类型下选中的业务分类名称
|
|
|
+ selectedBusinessDescribe: "",
|
|
|
+ // 保存当前选中的业务类型整行字典数据
|
|
|
+ currentBusinessTypeRow: null,
|
|
|
+ // 保存当前选中的业务分类整行数据
|
|
|
+ currentBusinessDescribeRow: null,
|
|
|
// 表单参数
|
|
|
formData: {
|
|
|
departmentNo: undefined,
|
|
|
@@ -1105,15 +1112,47 @@ export default {
|
|
|
// }
|
|
|
// });
|
|
|
// },
|
|
|
- changeBusinessDescribe(e) {
|
|
|
- (this.businessDescribeList || []).forEach((v) => {
|
|
|
- if (v.label === e) {
|
|
|
- this.formData.businessCategory = v.value;
|
|
|
+ async changeBusinessDescribe(e) {
|
|
|
+ // 1. 找到并存储选中的业务分类整行数据
|
|
|
+ const selectedRow =
|
|
|
+ (this.businessDescribeList || []).find((v) => v.label === e) || {};
|
|
|
+ this.currentBusinessDescribeRow = selectedRow;
|
|
|
+
|
|
|
+ // 2. 设置业务分类值
|
|
|
+ if (selectedRow) {
|
|
|
+ this.formData.businessCategory = selectedRow.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 记录选中的名称
|
|
|
+ this.selectedBusinessDescribe = e;
|
|
|
+
|
|
|
+ // 4. 调用源单接口
|
|
|
+ if (this.formData.businessType && this.selectedBusinessDescribe) {
|
|
|
+ this.loadingSourceOrder = true;
|
|
|
+ try {
|
|
|
+ const { data } = await InRequestApi.getSourceOrder({
|
|
|
+ businessType: this.formData.businessType,
|
|
|
+ businessDescribe: this.selectedBusinessDescribe,
|
|
|
+ businessCategory: this.currentBusinessDescribeRow.value,
|
|
|
+ id: this.$route.query.id || undefined,
|
|
|
+ pageSize: 999,
|
|
|
+ });
|
|
|
+ this.allSourceOrderNoList = data || [];
|
|
|
+ this.sourceOrderNoList = this.allSourceOrderNoList;
|
|
|
+ } finally {
|
|
|
+ this.loadingSourceOrder = false;
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
},
|
|
|
async changeBusinessType(value) {
|
|
|
- // 只更新businessType字段,避免覆盖整个formData
|
|
|
+ // 1. 先拿到业务类型对应的整条字典
|
|
|
+ const dictRow =
|
|
|
+ this.getDictDatas("inout_business_type").find(
|
|
|
+ (d) => d.value === value
|
|
|
+ ) || {};
|
|
|
+ this.currentBusinessTypeRow = dictRow; // 整条数据存起来
|
|
|
+
|
|
|
+ // 2. 原有逻辑保持不变
|
|
|
this.formData.businessType = value;
|
|
|
this.formData.businessDescribe = "";
|
|
|
this.formData.businessCategory = "";
|
|
|
@@ -1121,80 +1160,99 @@ export default {
|
|
|
this.formData.list = [];
|
|
|
this.sourceOrderNoList = [];
|
|
|
this.allSourceOrderNoList = [];
|
|
|
- // 重置表单校验状态
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.formRef.clearValidate();
|
|
|
- });
|
|
|
+ this.selectedBusinessDescribe = "";
|
|
|
+ this.currentBusinessDescribeRow = null; // 清空业务分类数据
|
|
|
+ this.$nextTick(() => this.$refs.formRef.clearValidate());
|
|
|
+
|
|
|
const { data } = await InRequestApi.getDictByOrderType({
|
|
|
orderType: value,
|
|
|
});
|
|
|
this.businessDescribeList = data;
|
|
|
- if (value) {
|
|
|
- this.loadingSourceOrder = true;
|
|
|
- try {
|
|
|
- const { data } = await InRequestApi.getSourceOrder({
|
|
|
- businessType: value,
|
|
|
- pageSize: 999,
|
|
|
- });
|
|
|
- this.allSourceOrderNoList = data || [];
|
|
|
- this.sourceOrderNoList = this.allSourceOrderNoList;
|
|
|
- } finally {
|
|
|
- this.loadingSourceOrder = false;
|
|
|
- }
|
|
|
- }
|
|
|
},
|
|
|
/** 初始化数据 */
|
|
|
async open(id) {
|
|
|
this.reset();
|
|
|
- // 修改时,设置数据
|
|
|
- if (id) {
|
|
|
- this.formLoading = true;
|
|
|
- try {
|
|
|
- /* 2. 等仓库列表回来 */
|
|
|
- await this.loadWarehouseList();
|
|
|
+ if (!id) {
|
|
|
+ // 新增
|
|
|
+ this.dialogTitle = "新增";
|
|
|
+ this.formData.list = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- const res = await InRequestApi.getInRequest(id);
|
|
|
- res.data.businessType = res.data.businessType
|
|
|
- ? res.data.businessType.toString()
|
|
|
- : "0";
|
|
|
- res.data.businessDescribe = res.data.businessDescribe
|
|
|
- ? res.data.businessDescribe.toString()
|
|
|
- : "";
|
|
|
- res.data.priority = res.data.priority
|
|
|
- ? 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 = "修改";
|
|
|
+ /* ---------- 编辑模式 ---------- */
|
|
|
+ this.dialogTitle = "修改";
|
|
|
+ this.formLoading = true;
|
|
|
+ try {
|
|
|
+ /* 1. 先保证仓库就位 */
|
|
|
+ await this.loadWarehouseList();
|
|
|
|
|
|
- /* 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
|
|
|
- );
|
|
|
- }
|
|
|
+ const res = await InRequestApi.getInRequest(id);
|
|
|
+ res.data.businessType = res.data.businessType
|
|
|
+ ? res.data.businessType.toString()
|
|
|
+ : "0";
|
|
|
+ res.data.businessDescribe = res.data.businessDescribe
|
|
|
+ ? res.data.businessDescribe.toString()
|
|
|
+ : "";
|
|
|
+ res.data.priority = res.data.priority
|
|
|
+ ? 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 || [];
|
|
|
+
|
|
|
+ /* 4. 补业务分类下拉数据(你原来缺的) */
|
|
|
+ if (res.data.businessType) {
|
|
|
+ const { data: describeList } = await InRequestApi.getDictByOrderType({
|
|
|
+ orderType: res.data.businessType,
|
|
|
+ });
|
|
|
+ this.businessDescribeList = describeList || [];
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 5. ★ 关键:如果后端也返回了业务分类名称,顺手把源单列表拉回来 */
|
|
|
+ if (res.data.businessType && res.data.businessDescribe) {
|
|
|
+ // 找到当前分类整行,拿 value 字段
|
|
|
+ const row = this.businessDescribeList.find(
|
|
|
+ (v) => v.label === res.data.businessDescribe
|
|
|
+ );
|
|
|
+ this.currentBusinessDescribeRow = row || null;
|
|
|
+
|
|
|
+ this.loadingSourceOrder = true;
|
|
|
+ try {
|
|
|
+ const { data: sourceList } = await InRequestApi.getSourceOrder({
|
|
|
+ businessType: res.data.businessType,
|
|
|
+ businessDescribe: res.data.businessDescribe,
|
|
|
+ businessCategory: row?.value,
|
|
|
+ id, // 当前单据 id
|
|
|
+ pageSize: 999,
|
|
|
+ });
|
|
|
+ this.allSourceOrderNoList = sourceList || [];
|
|
|
+ this.sourceOrderNoList = this.allSourceOrderNoList;
|
|
|
+ } finally {
|
|
|
+ this.loadingSourceOrder = false;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- this.uploadFiles = this.formData.filesListVos;
|
|
|
- } finally {
|
|
|
- this.formLoading = false;
|
|
|
+ this.formData = res.data;
|
|
|
+
|
|
|
+ /* 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
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- this.dialogTitle = "新增";
|
|
|
- this.formData.list = [];
|
|
|
+
|
|
|
+ this.uploadFiles = res.data.filesListVos;
|
|
|
+ } finally {
|
|
|
+ this.formLoading = false;
|
|
|
}
|
|
|
},
|
|
|
/** 保存按钮 */
|