Quellcode durchsuchen

表单修改和删除

lph vor 1 Jahr
Ursprung
Commit
f3b5cb6253

+ 9 - 0
ruoyi-ui/src/api/tablelist/commonTable.js

@@ -41,6 +41,15 @@ export function addTableData(data) {
     baseURL: process.env.VUE_APP_BASE_API3
   })
 }
+// 批量修改动态表单
+export function batchEdit(data) {
+  return request({
+    url: '/dragform/common/batchEdit',
+    method: 'put',
+    data: data,
+    baseURL: process.env.VUE_APP_BASE_API3
+  })
+}
 
 // 修改动态表单
 export function updateTableData(data) {

+ 1 - 0
ruoyi-ui/src/views/tableMange/index.vue

@@ -859,6 +859,7 @@ export default {
         // }
       }
       // 如果主键不包含显示,则添加至sql语句中
+      console.log(this.primaryKeyList, this.formData.primaryKey);
       let isNotInclude = this.primaryKeyList.find(
         (val) => !val.isShow && val.fieldName == this.formData.primaryKey
       );

+ 25 - 6
ruoyi-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -186,6 +186,7 @@ import {
   unionListTableData,
   getInfoBySqlKey,
   addTableData,
+  batchEdit,
 } from "@/api/tablelist/commonTable";
 import { getToken } from "@/utils/auth";
 import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
@@ -359,7 +360,9 @@ export default {
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map((item) => item.id);
+      this.ids = selection.map(
+        (item) => item[this.templateInfo.template?.primaryKey]
+      );
       this.single = selection.length != 1;
       this.multiple = !selection.length;
     },
@@ -448,10 +451,10 @@ export default {
      * */
     handleDelete(row) {
       let delIds = this.ids;
-
-      if (row.id != undefined && row.id != null) {
+      let primary = this.templateInfo.template?.primaryKey;
+      if (row[primary] != undefined && row[primary] != null) {
         delIds = [];
-        delIds.push(row.id);
+        delIds.push(row[primary]);
         // if (delIds.findIndex(item => item === row.id) == -1) {
         //   delIds.push(row.id);
         // }
@@ -461,9 +464,10 @@ export default {
           tableName: this.tableName,
         },
         conditionMap: {
-          id: delIds,
+          // id: delIds,
         },
       };
+      data.conditionMap[primary] = delIds;
       this.$modal
         .confirm('是否确认删除"' + delIds + '"的数据项?')
         .then(function () {
@@ -560,6 +564,22 @@ export default {
             addListMap: [values],
           };
           if (Object.keys(this.defaultValue).length) {
+            let updateData = {
+              // 基本参数
+              basicMap: {
+                // 表名
+                tableName: this.tableName,
+              },
+              conditionMap: {},
+              commMap: {},
+            };
+            updateData.conditionMap[this.templateInfo.template?.primaryKey] =
+              values[this.templateInfo.template?.primaryKey];
+            Object.keys(values).map((k) => {
+              updateData.commMap[k] = values[k];
+            });
+            console.log(values);
+            let res = await batchEdit(updateData);
             this.$modal.msgSuccess("修改成功");
             this.getList();
           } else {
@@ -567,7 +587,6 @@ export default {
             this.$modal.msgSuccess("添加成功");
             this.getList();
           }
-          console.log("123");
           this.defaultValue = {};
           this.open = false;
         })