Ver código fonte

修复岗位和硬件类

pm 5 meses atrás
pai
commit
7a70811e81
2 arquivos alterados com 35 adições e 9 exclusões
  1. 29 8
      src/views/mes/hw/type/index.vue
  2. 6 1
      src/views/system/mars/index.vue

+ 29 - 8
src/views/mes/hw/type/index.vue

@@ -315,10 +315,11 @@ export default {
       });
     },
     /** 查询设备类型下拉树结构 */
-    getTreeselect() {
+    getTreeselect(id) {
       const data={
         current: 1,
-        size:-1
+        size:-1,
+        id:id
       }
       listHanrwareType(data).then((response) => {
         debugger;
@@ -384,22 +385,42 @@ export default {
       this.open = true;
       this.title = this.$t('mes.hardwareType.addHardwareType');
     },
-    /** 修改按钮操作 */
+    /** 修改按钮操作 - 修复版本 */
     handleUpdate(row) {
       this.reset();
-      this.getTreeselect();
-      if(row.parentTypeId == "0") {
-        this.form.parentTypeId = undefined;
-      }
+      this.getTreeselect(row.id);
+
+      // 修复:当父类型选中了自己时,不传递parentTypeId参数
       if (row != null) {
-        this.form.parentTypeId = row.id;
+        // 如果父类型ID等于当前行ID(选中了自己),设置为undefined
+        if (row.parentTypeId == row.id) {
+          this.form.parentTypeId = row.id;
+        }
+        // 如果父类型ID为"0"或null,也设置为undefined
+        else if (row.parentTypeId == "0" || row.parentTypeId == null || row.parentTypeId == undefined) {
+          this.form.parentTypeId = undefined;
+        }
+        // 其他情况,正常设置父类型ID
+        else {
+          this.form.parentTypeId = row.parentTypeId;
+        }
       }
+
       getHardwareTypeInfo(row.id).then((response) => {
         this.form = response.data;
+
+        // 修复:在获取数据后,再次检查并处理父类型ID
+        // 如果父类型选中了自己,确保设置为undefined
+        if (this.form.parentTypeId == this.form.id) {
+          this.form.parentTypeId = this.form.id;
+        }
+
         this.open = true;
         this.title = this.$t('mes.hardwareType.editHardwareType');
       });
     },
+
+
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate((valid) => {

+ 6 - 1
src/views/system/mars/index.vue

@@ -438,7 +438,12 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
-      listMarsDept(row.workstationId).then((response) => {
+      const data={
+        id:row.workstationId,
+        pageSize:-1,
+        pageNum:1
+      }
+      listMarsDept(data).then((response) => {
         this.deptOptions = this.handleTree(
           response.data.records,
           "workstationId",