Browse Source

禁用k-form-design的input的自动补全/更改表单拖拽的菜单路由的回显逻辑/fix:添加路由排序字段

lph 1 year ago
parent
commit
f7a169cfd4

File diff suppressed because it is too large
+ 0 - 0
ruoyi-ui/src/assets/styles/index.min.css


+ 13 - 0
ruoyi-ui/src/utils/other.js

@@ -21,4 +21,17 @@ export async function getUncommonTable() {
     );
   });
   return result
+}
+
+/**
+ * 禁止input自动补全
+ */
+export function inputDisableComplete() {
+  // 获取页面上所有的输入字段  
+  var inputs = document.getElementsByTagName('input');
+
+  // 遍历输入字段并将 autocomplete 属性设置为 off  
+  for (var i = 0; i < inputs.length; i++) {
+    inputs[i].setAttribute('autocomplete', 'off');
+  }
 }

+ 18 - 12
ruoyi-ui/src/views/system/tenant/index.vue

@@ -541,6 +541,7 @@ export default {
     bindDatasource(row) {
       this.currentTenantInfo = row;
       this.reset1();
+      this.dialogLoading = false;
       this.dataSourceOpen = true;
       this.dataSourceTitle = row.tenantName + "配置数据库";
       this.fromTenantId = row.tenantId;
@@ -603,19 +604,24 @@ export default {
                   tenantId: this.currentTenantInfo.tenantId,
                   password: "123456",
                 };
-                createTenant(data).then(async (res) => {
-                  if (res.code == 200) {
-                    let resp = await initTenantMenuData(
-                      this.currentTenantInfo.tenantId
-                    );
-                    if ((resp.code = 200)) {
-                      this.$modal.msgSuccess("新增成功");
-                      this.dataSourceOpen = false;
-                      // loading.close();
-                      this.getList();
+                createTenant(data)
+                  .then(async (res) => {
+                    if (res.code == 200) {
+                      let resp = await initTenantMenuData(
+                        this.currentTenantInfo.tenantId
+                      );
+                      if ((resp.code = 200)) {
+                        this.$modal.msgSuccess("新增成功");
+                        this.dataSourceOpen = false;
+
+                        // loading.close();
+                        this.getList();
+                      }
                     }
-                  }
-                });
+                  })
+                  .finally(() => {
+                    this.dialogLoading = fasle;
+                  });
               }
             });
           }

+ 60 - 12
ruoyi-ui/src/views/tableMange/index.vue

@@ -220,6 +220,7 @@
                 v-model="formData.routePath"
                 :options="menus"
                 :normalizer="normalizer"
+                @change="treeSelectChange"
                 :show-count="true"
                 placeholder="请选择父级路由"
               />
@@ -589,6 +590,7 @@ export default {
       loading: false, //表格加载
       tableDataList: [], //数据
       editData: {},
+      menuOrderNum: 0,
     };
   },
   computed: {
@@ -614,15 +616,16 @@ export default {
     primaryKeyList() {
       return this.tableFieldList.filter((item) => !item.isChildren);
     },
-    menuOrderNum() {
-      if (!this.formData.routePath) return 0;
-      let targetMenu = this.getTargetMenu(this.menus);
-      if (targetMenu.children?.length) {
-        return targetMenu.children.length;
-      } else {
-        return 0;
-      }
-    },
+    // menuOrderNum() {
+    //   if (!this.formData.routePath) return 0;
+    //   let targetMenu = this.getTargetMenu(this.menus);
+    //   console.log(targetMenu);
+    //   if (targetMenu.children?.length) {
+    //     return targetMenu.children.length;
+    //   } else {
+    //     return 0;
+    //   }
+    // },
   },
   watch: {
     tableName: function (val) {
@@ -639,8 +642,17 @@ export default {
         this.relationTableList = [];
       }
     },
+    "formData.routePath"(nval, oval) {
+      let targetMenu = this.getTargetMenu(this.menus);
+      this.menuOrderNum = targetMenu.children ? targetMenu.children.length : 0;
+    },
   },
   methods: {
+    // 树形控件change回调
+    treeSelectChange(val) {
+      //没有change事件
+      console.log("val", val);
+    },
     // 获取目标menu
     getTargetMenu(menus) {
       for (let i = 0; i < menus.length; i++) {
@@ -1305,7 +1317,31 @@ export default {
         let echoData = JSON.parse(res.data.echoData);
         this.tableName = echoData.tableName;
         this.tableFieldList = echoData.tableFieldData;
-        this.formData = echoData.formData;
+        let {
+          isShowList,
+          timeFormate,
+          orderByColumn,
+          isAsc,
+          primaryKey,
+          menuName,
+        } = echoData.formData;
+        Object.assign(this.formData, {
+          menuName,
+          isShowList,
+          timeFormate,
+          orderByColumn,
+          isAsc,
+          primaryKey,
+        });
+        this.formData.routePath = this.getParentMenuId(
+          res.data.menuId,
+          this.menus,
+          {}
+        );
+        if (!this.formData.routePath) {
+          this.$message.warning("该表格菜单路由已经删除,请重新配置");
+        }
+        // this.formData.routePath
         this.editData = res.data;
         let val = await getParticMenu(res.data.sqlKey);
         if (val.code == 200) {
@@ -1315,12 +1351,24 @@ export default {
         this.$message.error("数据回显失败");
       }
     },
+    // 获取父级menuId
+    getParentMenuId(menuId, menus, parentItem) {
+      for (let i = 0; i < menus.length; i++) {
+        let item = menus[i];
+        if (item.menuId == menuId) {
+          return parentItem?.menuId;
+        } else if (item.children?.length) {
+          return this.getParentMenuId(menuId, item.children, item);
+        }
+      }
+      return undefined;
+    },
   },
   created() {},
-  mounted() {
+  async mounted() {
     this.getAllTable();
     this.initDragTable();
-    this.getMenuList();
+    await this.getMenuList();
     if (this.$route.query.tId) {
       this.tId = this.$route.query.tId;
       this.initTableData(this.tId);

+ 2 - 0
ruoyi-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -205,6 +205,7 @@ import {
 import { getToken } from "@/utils/auth";
 import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
 import { camelCase } from "@/utils";
+import { inputDisableComplete } from "@/utils/other";
 
 export default {
   name: "listInfo",
@@ -450,6 +451,7 @@ export default {
         this.form.password = this.initPassword;
         this.$nextTick(() => {
           this.$refs.addFromRef.reset();
+          inputDisableComplete();
         });
       });
     },

Some files were not shown because too many files changed in this diff