Browse Source

关联表处理

chenc 3 years ago
parent
commit
362a9b6130

+ 4 - 2
packages/KFormDesign/index.vue

@@ -257,6 +257,7 @@ export default {
   },
   data() {
     return {
+      businessTableHC:"",//用来记录关联的数据库表
       tableColumnList:[],//数据表字段集合
       formData: {}, //表单数据
       locale: zhCN,
@@ -469,10 +470,11 @@ export default {
         // 设置selectItem的值
           this.selectItem = record;
         ///获取表字段的下拉数据
-        //判断字段下拉数据是否有集合
-        if(!this.tableColumnList||this.tableColumnList.length<=0){//没有则查询
+        //判断字段下拉数据是否有集合 或者关联的数据库表有改动
+        if(!this.tableColumnList||this.tableColumnList.length<=0||(this.formData.businessTable!=this.businessTableHC)){//没有则查询
               //获取表字段下拉数据接口
               getTableColumnList(this.formData.businessTable).then(res=>{
+                this.businessTableHC=this.formData.businessTable;
                 this.tableColumnList=res.data.result;//表字段下拉数据
               });
         }

+ 4 - 4
packages/KFormDesign/module/operatingArea.vue

@@ -10,12 +10,12 @@
     <!-- 头部操作按钮区域 start -->
     <!-- 操作左侧区域 start -->
     <div class="left-btn-box">
-      <a-tooltip title="保存">
+      <!-- <a-tooltip title="保存">
         <a v-if="toolbars.includes('save')" @click="$emit('handleSave')">
           <a-icon type="save" />
           <span v-if="showToolbarsText">保存</span>
         </a>
-      </a-tooltip>
+      </a-tooltip> -->
 
       <a-tooltip title="预览">
         <a v-if="toolbars.includes('preview')" @click="$emit('handlePreview')">
@@ -51,7 +51,7 @@
         </a>
       </a-tooltip>
 
-      <a-tooltip title="生成代码">
+      <!-- <a-tooltip title="生成代码">
         <a
           v-if="toolbars.includes('exportCode')"
           @click="$emit('handleOpenCodeModal')"
@@ -59,7 +59,7 @@
           <a-icon type="code" />
           <span v-if="showToolbarsText">生成代码</span>
         </a>
-      </a-tooltip>
+      </a-tooltip> -->
 
       <a-tooltip title="清空">
         <a v-if="toolbars.includes('reset')" @click="$emit('handleReset')">

+ 18 - 3
packages/KFormDesign/module/queryModal.vue

@@ -11,12 +11,18 @@
     width="850px"
   >
     <a-row :gutter="24">
-      <a-col :md="24" :sm="24">
+      <a-col :md="4" :sm="24">
         <!-- <div class="copy-btn-box-9136076486841527"> -->
           数据库表名:
-          <a-input placeholder="请输入表名" style="width:20%;" v-model="businessTable" />&nbsp;
+          <!-- <a-input placeholder="请输入表名" style="width:20%;" v-model="businessTable" />&nbsp; -->
+          
         <!-- </div> -->
       </a-col>
+      <a-col :md="18" :sm="24">
+        <a-select v-model="businessTable" style="width: 30%" placeholder="请选择数据库表名" allowClear show-search >
+            <a-select-option v-for="(item) in tableList"  :key="item.tableName" :value="item.tableName">{{item.tableName}}{{item.tableComment}}</a-select-option>
+          </a-select>
+      </a-col>
     </a-row>
     <a-row :gutter="24" v-if="dataSource.length>0">
       <a-col :md="24" :sm="24">
@@ -38,7 +44,7 @@
   </a-modal>
 </template>
 <script>
-import { getFormByBusinessTable } from "../../api/api";
+import { getFormByBusinessTable,getTableList } from "../../api/api";
 /*
  * author kcz
  * date 2019-11-20
@@ -48,6 +54,7 @@ export default {
   name: "queryModal",
   data() {
     return {
+      tableList:[],
       dataSource:[],
       columns:[
         {
@@ -77,6 +84,14 @@ export default {
       formData: {}
     };
   },
+  created(){
+    //获取数据库表名下拉数据
+    getTableList().then(res=>{
+      if(res.data.success){
+        this.tableList=res.data.result;
+      }
+    });
+  },
   methods: {
     handleCancel() {
       this.visible = false;