fangq 4 лет назад
Родитель
Сommit
166e771da1
1 измененных файлов с 13 добавлено и 15 удалено
  1. 13 15
      src/views/bank/autodata.vue

+ 13 - 15
src/views/bank/autodata.vue

@@ -11,7 +11,7 @@
       </el-select>
     </basic-container>
 
-    <div v-if="value">
+    <div v-if="show">
       <avue-crud :option="option"
                  :table-loading="loading"
                  :data="data"
@@ -53,6 +53,7 @@
   export default {
     data() {
       return {
+        show: false,
         value: '',
         tableList: [],
 
@@ -100,7 +101,7 @@
         return ids.join(",");
       }
     },
-    created() {
+    mounted() {
       // let data = {column:[{type:'input',label:'姓名',span:12,display:true,prop:'name',required:true,rules:[{required:true,message:'姓名必须填写'}]},{type:'input',label:'年齡',span:12,display:true,prop:'age'},{type:'input',label:'手機號',span:12,display:true,prop:'phone',maxlength:11},{type:'input',label:'住址',span:12,display:true,prop:'address'}],labelPosition:'right',labelSuffix:':',labelWidth:120,gutter:0,menuBtn:true,submitBtn:true,submitText:'提交',emptyBtn:true,emptyText:'清空',menuPosition:'center'};
       // this.option = data;
       this.initTableList();
@@ -110,25 +111,22 @@
         getTables(1, 500, {}).then(res => {
           const data = res.data.data;
           this.tableList = data.records;
-
+          if (this.tableList.length > 0){
+            this.value = this.tableList[0].id;
+            this.selectTable(this.value)
+          }
         });
       },
       selectTable(value){
+        let _this = this;
+        this.show = false;
         let table = this.getItemById(value);
-        /*let optionStr = table.columns.replace(/(s*?{s*?|s*?,s*?)(['"])?([a-zA-Z0-9]+)(['"])?:/g, '$1"$3":').replaceAll('\'', '\"');
-        optionStr = optionStr.replace('&gt;', '>')
-        optionStr = optionStr.replace(/\s*!/g, '')
-        // str.replace(/\s*!/g,"")
-        this.option = JSON.parse(optionStr, (k,v)=>{
-          if(k == 'change'){
-            return eval('"' + v + '"')
-          }
-          return v
-        })
-*/
         this.option = opStr2opObj(table.columns);
+        setTimeout(() => {
+          _this.show = true;
+          _this.onLoad(this.page)
+        }, 50)
 
-        this.onLoad(this.page)
       },
       getItemById(id){
         for (let i = 0; i < this.tableList.length; i++) {