Эх сурвалжийг харах

数据库建模新增和修改问题处理

lph 1 жил өмнө
parent
commit
2fc5fc869d

+ 9 - 0
ruoyi-ui/src/api/dragform/tableList.js

@@ -8,4 +8,13 @@ export function listTable(query) {
     params: query,
     baseURL: process.env.VUE_APP_BASE_API3
   })
+}
+// 查询拖拽表格列表
+export function dragTableList(query) {
+  return request({
+    url: '/system/table/dragTableList',
+    method: 'get',
+    params: query,
+    baseURL: process.env.VUE_APP_BASE_API3
+  })
 }

+ 5 - 1
ruoyi-ui/src/views/dragform/index.vue

@@ -491,7 +491,11 @@ export default {
     handleUpdate(row) {
       const fId = row.fId || this.ids;
       sessionStorage.setItem("fid", fId);
-      this.$router.replace("system/fromModel/index");
+      // this.$router.replace("system/fromModel/index");
+      this.$router.push({
+        path: "/system/fromModel/index/system/fromModel/index",
+        query: { fId },
+      });
     },
     /** 提交按钮 */
     submitForm() {

+ 42 - 44
ruoyi-ui/src/views/system/fromModel/index.vue

@@ -1,13 +1,13 @@
 <template>
-    <div>
-      <k-form-design 
+  <div>
+    <k-form-design
       :showHead="false"
       @save="handleSave"
       @exportCode="handCode"
       ref="kfd"
-      />
-    </div>
-  </template>
+    />
+  </div>
+</template>
 <script>
 // 生成HTML的
 let codeHtmlFront = `<!DOCTYPE html>
@@ -28,8 +28,8 @@ let codeHtmlFront = `<!DOCTYPE html>
   <script src="http://unpkg.com/k-form-design/lib/k-form-design.umd.min.js"><\/script>
   <script>
     let jsonData = `;
-    
-    let codeHtmlLast = `
+
+let codeHtmlLast = `
     let vm = new Vue({
       el: '.app',
       data: {
@@ -61,11 +61,11 @@ let codeHtmlFront = `<!DOCTYPE html>
   <\/script>
 </body>
 
-</html>`
-import { addForm ,getForm,updateForm} from "@/api/dragform/form";
+</html>`;
+import { addForm, getForm, updateForm } from "@/api/dragform/form";
 
 export default {
-  name:'fromModel',
+  name: "fromModel",
   data() {
     return {
       fid: null,
@@ -73,57 +73,55 @@ export default {
   },
   methods: {
     handleSave(values) {
-      // console.log(values);
       var jsonData = JSON.parse(values);
       //
       var editorHtmlJson =
-          codeHtmlFront + JSON.stringify(jsonData) + codeHtmlLast;
+        codeHtmlFront + JSON.stringify(jsonData) + codeHtmlLast;
       // console.log(this.fid)
-      if(!this.fid){
+      if (!this.fid) {
         addForm({
-          dfName:'1',
-          dfNickname:'1',
-          dfVueTemplate:values,
-          dfHtmlTemplate:editorHtmlJson.toString(),
-        }).then((res)=>{
+          dfName: "1",
+          dfNickname: "1",
+          dfVueTemplate: values,
+          dtId: JSON.parse(values).config.tdId,
+          dfHtmlTemplate: editorHtmlJson.toString(),
+        }).then((res) => {
           console.log(res);
-          this.$message(res.msg)
-        })
-      }else{
+          this.$message(res.msg);
+        });
+      } else {
         updateForm({
-          dfName:'1',
-          dfNickname:'1',
-          dfVueTemplate:values,
-          dfHtmlTemplate:editorHtmlJson.toString(),
-          fId:this.fid
-        }).then((res)=>{
-          console.log(res)
-          this.$message(res.msg)
-        })
+          dfName: "1",
+          dfNickname: "1",
+          dfVueTemplate: values,
+          dfHtmlTemplate: editorHtmlJson.toString(),
+          dtId: JSON.parse(values).config.tdId,
+          fId: this.fid,
+        }).then((res) => {
+          console.log(res);
+          this.$message(res.msg);
+        });
       }
-      
-    
     },
-
+    handCode() {},
   },
   mounted() {
-    const fid = sessionStorage.getItem('fid');
+    const fid = this.$route.query.fId;
 
-    if(!fid)return;
+    if (!fid) return;
     this.fid = fid;
-    
-    getForm(fid).then(response => {
-      console.log(response)
-      const jsonData = JSON.parse(response.data.dfVueTemplate)
-      this.$refs.kfd.handleSetData(jsonData)
+
+    getForm(fid).then((response) => {
+      console.log(response);
+      const jsonData = JSON.parse(response.data.dfVueTemplate);
+      this.$refs.kfd.handleSetData(jsonData);
     });
   },
 };
 </script>
 
 <style>
-  aside{
-    width: 340px !important;
-  }
+aside {
+  width: 340px !important;
+}
 </style>
-

+ 6 - 2
ruoyi-ui/src/views/tool/datasheet/index.vue

@@ -206,7 +206,7 @@ export default {
     };
   },
   created() {
-    if (this.$route.query.tableName && this.$route.query.tableComment) {
+    if (this.$route.query.tableName) {
       this.isEdited = true;
       this.info();
     } else {
@@ -284,6 +284,7 @@ export default {
       // console.log(this.tableform)
       if (tem.raw.listClass === "success") {
         this.Inoputdisabled[scope.$index] = true; // 禁用长度输入框
+        scope.row.fieldLength = "";
         this.tableform["fieldLength" + scope.$index].required = false; // 禁用长度输入框的校验
         return this.$set(
           this.experienceDataForm,
@@ -425,8 +426,11 @@ export default {
               this.$emit("ok");
               Object.keys(this.form).forEach((key) => (this.form[key] = ""));
               this.experienceData = [];
-              // 新增成功之后关闭当前页面
               this.$tab.closePage();
+              // 新增成功之后关闭当前页面
+              // this.$router.replace({
+              //   path: "/data/datamodeling",
+              // });
             }
           })
           .catch((err) => {