فهرست منبع

修改出入库申请明细页面

chensibo 4 روز پیش
والد
کامیت
4f137db8c6
3فایلهای تغییر یافته به همراه222 افزوده شده و 108 حذف شده
  1. 2 2
      .env.dev
  2. 95 39
      src/views/rtkwms/inrequest/InRequestForm.vue
  3. 125 67
      src/views/wms/output/inrequest/components/InRequestForm.vue

+ 2 - 2
.env.dev

@@ -6,8 +6,8 @@ VUE_APP_TITLE = WMS开发环境
 
 # 芋道管理系统/开发环境
 # VUE_APP_BASE_API = 'http://192.168.1.94:48080'
-# VUE_APP_BASE_API = 'http://192.168.1.26:48080'
-VUE_APP_BASE_API = 'http://113.105.183.190:48028'
+VUE_APP_BASE_API = 'http://192.168.1.26:48080'
+# VUE_APP_BASE_API = 'http://113.105.183.190:48028'
 # VUE_APP_BASE_API = 'http://61.155.26.34:36936'
 # VUE_APP_BASE_API = 'http://127.0.0.1:48080'
 # VUE_APP_BASE_API = 'http://2227el9013.iok.la'

+ 95 - 39
src/views/rtkwms/inrequest/InRequestForm.vue

@@ -567,6 +567,12 @@ export default {
       dialogTitle: "",
       // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
       formLoading: false,
+      // 记录当前业务类型下选中的业务分类名称
+      selectedBusinessDescribe: "",
+      // 保存当前选中的业务类型整行字典数据
+      currentBusinessTypeRow: null,
+      // 保存当前选中的业务分类整行数据
+      currentBusinessDescribeRow: null,
       // 表单参数
       formData: {
         departmentNo: undefined,
@@ -949,14 +955,45 @@ export default {
         this.formData.list = [...this.formData.list];
       }
     },
-    changeBusinessDescribe(e) {
-      this.businessDescribeList.map((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.loading = true;
+        try {
+          const { data } = await InRequestApi.getSourceOrder({
+            businessType: this.formData.businessType,
+            businessDescribe: this.selectedBusinessDescribe,
+            businessCategory: selectedRow?.value,
+            pageSize: 999,
+          });
+          this.allSourceOrderNoList = data || [];
+          this.sourceOrderNoList = this.allSourceOrderNoList;
+        } finally {
+          this.loading = false;
         }
-      });
+      }
     },
     async changeBusinessType(value) {
+      // 1. 先拿到业务类型对应的整条字典
+      const dictRow =
+        this.getDictDatas("in_business_type").find((d) => d.value === value) ||
+        {};
+      this.currentBusinessTypeRow = dictRow; // 整条数据存起来
+
+      // 2. 原有逻辑保持不变
       this.formData.businessType = value;
       this.formData.businessDescribe = "";
       this.formData.businessCategory = "";
@@ -964,50 +1001,69 @@ 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.loading = true;
-        try {
-          const { data } = await InRequestApi.getSourceOrder({
-            businessType: value,
-            pageSize: 999,
-          });
-          this.allSourceOrderNoList = data || [];
-          this.sourceOrderNoList = this.allSourceOrderNoList;
-        } finally {
-          this.loading = false;
-        }
-      }
     },
     /** 初始化数据 */
     async initData(id) {
       this.formLoading = true;
       try {
+        /* 1. 拿主表数据 */
         const res = await InRequestApi.getRequest(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.receivePerson = res.data.receivePerson
-          ? Number(res.data.receivePerson)
-          : null;
-        // res.data.list = res.data.list || [];
-        this.formData = res.data;
-        // 附件列表
-        this.uploadFiles = this.formData.filesListVos;
+        const data = res.data;
+
+        /* 2. 把 number 字段统一转字符串 */
+        data.businessType && (data.businessType = String(data.businessType));
+        data.businessDescribe &&
+          (data.businessDescribe = String(data.businessDescribe));
+        data.priority && (data.priority = String(data.priority));
+        data.status && (data.status = String(data.status));
+        data.receivePerson && (data.receivePerson = Number(data.receivePerson));
+        data.list = data.list || [];
+
+        /* 3. 补业务分类下拉数据 */
+        if (data.businessType) {
+          const { data: describeList } = await InRequestApi.getDictByOrderType({
+            orderType: data.businessType,
+          });
+          this.businessDescribeList = describeList || [];
+        }
+
+        /* 4. 关键:如果后端也返回了业务分类名称,顺手把源单列表拉回来 */
+        if (data.businessType && data.businessDescribe) {
+          // 找到当前分类整行,拿 value 字段
+          const row = this.businessDescribeList.find(
+            (v) => v.label === data.businessDescribe
+          );
+          this.currentBusinessDescribeRow = row || null;
+
+          this.loading = true;
+          try {
+            const { data: sourceList } = await InRequestApi.getSourceOrder({
+              businessType: data.businessType,
+              businessDescribe: data.businessDescribe,
+              businessCategory: row?.value,
+              id, // 当前单据 id
+              pageSize: 999,
+            });
+            this.allSourceOrderNoList = sourceList || [];
+            this.sourceOrderNoList = this.allSourceOrderNoList;
+          } finally {
+            this.loading = false;
+          }
+        }
+
+        /* 5. 回填表单 */
+        this.formData = data;
+
+        /* 6. 附件列表 */
+        this.uploadFiles = data.filesListVos || [];
       } finally {
         this.formLoading = false;
       }

+ 125 - 67
src/views/wms/output/inrequest/components/InRequestForm.vue

@@ -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;
       }
     },
     /** 保存按钮 */