Forráskód Böngészése

:recycle: Refactoring code. 重构代码生产

冷冷 5 éve
szülő
commit
d2668b8fcd

+ 2 - 2
src/api/gen/gen.js

@@ -92,10 +92,10 @@ export function handleDown(table) {
 }
 
 
-export function getForm(tableName, dsId) {
+export function getForm(tableName, dsName) {
   return request({
     url: '/gen/form/info',
-    params: {tableName: tableName, dsId: dsId},
+    params: {tableName: tableName, dsName: dsName},
     method: 'get'
   })
 }

+ 8 - 0
src/const/crud/gen/gen.js

@@ -75,6 +75,14 @@ export const formOption = {
       label: '注释',
       prop: 'comments',
       placeholder: '可为空,加载表备注'
+    },{
+      label: '前端风格',
+      prop: 'style',
+      type: 'radio',
+      slot: true,
+      border:true,
+      span: 24,
+      dicUrl: '/admin/dict/type/style_type',
     }
   ]
 }

+ 0 - 3
src/main.js

@@ -18,12 +18,9 @@ import './styles/common.scss'
 import avueFormDesign from 'avue-plugin-formdesign'
 import basicContainer from './components/basic-container/main'
 // 插件 json 展示
-import vueJsonTreeView from 'vue-json-tree-view'
-
 Vue.use(router)
 
 Vue.use(avueFormDesign);
-Vue.use(vueJsonTreeView)
 
 Vue.use(VueAxios, axios)
 

+ 83 - 73
src/router/page/index.js

@@ -10,81 +10,91 @@ export default [{
     isTab: false,
     isAuth: false
   }
-},
-{
-  path: '/lock',
-  name: '锁屏页',
-  component: () =>
-    import(/* webpackChunkName: "page" */ '@/page/lock/index'),
-  meta: {
-    keepAlive: true,
-    isTab: false,
-    isAuth: false
-  }
-},
-{
-  path: '/404',
-  component: () =>
-    import(/* webpackChunkName: "page" */ '@/components/error-page/404'),
-  name: '404',
-  meta: {
-    keepAlive: true,
-    isTab: false,
-    isAuth: true
-  }
-
-},
-{
-  path: '/403',
-  component: () =>
-    import(/* webpackChunkName: "page" */ '@/components/error-page/403'),
-  name: '403',
-  meta: {
-    keepAlive: true,
-    isTab: false,
-    isAuth: false
-  }
-},
-{
-  path: '/500',
-  component: () =>
-    import(/* webpackChunkName: "page" */ '@/components/error-page/500'),
-  name: '500',
-  meta: {
-    keepAlive: true,
-    isTab: false,
-    isAuth: false
-  }
-},
-{
-  path: '/',
-  name: '主页',
-  redirect: '/wel'
-},
-{
-  path: '/myiframe',
+}, {
+  path: '/wel',
   component: Layout,
-  redirect: '/myiframe',
+  redirect: '/wel/index',
   children: [{
-    path: ':routerPath',
-    name: 'iframe',
+    path: 'index',
+    name: '首页',
     component: () =>
-      import(/* webpackChunkName: "page" */ '@/components/iframe/main'),
-    props: true
+      import(/* webpackChunkName: "views" */ '@/page/wel')
   }]
 },
-{
-  path: '*',
-  redirect: '/404'
-},
-{
-  path: '/authredirect',
-  name: '授权页',
-  component: () =>
-    import(/* webpackChunkName: "page" */ '@/page/login/authredirect'),
-  meta: {
-    keepAlive: true,
-    isTab: false,
-    isAuth: false
-  }
-}]
+  {
+    path: '/lock',
+    name: '锁屏页',
+    component: () =>
+      import(/* webpackChunkName: "page" */ '@/page/lock/index'),
+    meta: {
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
+    }
+  },
+  {
+    path: '/404',
+    component: () =>
+      import(/* webpackChunkName: "page" */ '@/components/error-page/404'),
+    name: '404',
+    meta: {
+      keepAlive: true,
+      isTab: false,
+      isAuth: true
+    }
+
+  },
+  {
+    path: '/403',
+    component: () =>
+      import(/* webpackChunkName: "page" */ '@/components/error-page/403'),
+    name: '403',
+    meta: {
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
+    }
+  },
+  {
+    path: '/500',
+    component: () =>
+      import(/* webpackChunkName: "page" */ '@/components/error-page/500'),
+    name: '500',
+    meta: {
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
+    }
+  },
+  {
+    path: '/',
+    name: '主页',
+    redirect: '/wel'
+  },
+  {
+    path: '/myiframe',
+    component: Layout,
+    redirect: '/myiframe',
+    children: [{
+      path: ':routerPath',
+      name: 'iframe',
+      component: () =>
+        import(/* webpackChunkName: "page" */ '@/components/iframe/main'),
+      props: true
+    }]
+  },
+  {
+    path: '*',
+    redirect: '/404'
+  },
+  {
+    path: '/authredirect',
+    name: '授权页',
+    component: () =>
+      import(/* webpackChunkName: "page" */ '@/page/login/authredirect'),
+    meta: {
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
+    }
+  }]

+ 3 - 13
src/router/views/index.js

@@ -1,15 +1,6 @@
 import Layout from '@/page/index/'
+
 export default [{
-  path: '/wel',
-  component: Layout,
-  redirect: '/wel/index',
-  children: [{
-    path: 'index',
-    name: '首页',
-    component: () =>
-            import(/* webpackChunkName: "views" */ '@/page/wel')
-  }]
-}, {
   path: '/info',
   component: Layout,
   redirect: '/info/index',
@@ -17,7 +8,7 @@ export default [{
     path: 'index',
     name: '个人信息',
     component: () =>
-            import(/* webpackChunkName: "page" */ '@/views/admin/user/info')
+      import(/* webpackChunkName: "page" */ '@/views/admin/user/info')
   }]
 }, {
   path: '/activti',
@@ -26,7 +17,6 @@ export default [{
   children: [{
     path: 'detail/:id',
     component: () =>
-            import(/* webpackChunkName: "views" */ '@/views/activiti/detail')
+      import(/* webpackChunkName: "views" */ '@/views/activiti/detail')
   }]
-
 }]

+ 12 - 4
src/views/gen/datasource.vue

@@ -79,15 +79,23 @@
         show()
       },
       handleUpdate: function (row, index, done) {
-        putObj(row).then(() => {
-          this.$message.success('修改成功')
+        putObj(row).then(res => {
+          if (res.data.data){
+            this.$message.success('修改成功')
+          }else {
+            this.$message.error('修改失败,数据源不可访问')
+          }
           done()
           this.getDsList(this.dsPage)
         })
       },
       handleSave: function (row, done) {
-        addObj(row).then(() => {
-          this.$message.success('添加成功')
+        addObj(row).then(res => {
+          if (res.data.data){
+            this.$message.success('添加成功')
+          }else {
+            this.$message.error('添加失败,数据源不可访问')
+          }
           done()
           this.getDsList(this.dsPage)
         })

+ 2 - 2
src/views/gen/design.vue

@@ -32,7 +32,7 @@
                     return false
                 }
                 let result = JSON.stringify(json)
-                postForm(result, params.tableName, params.dsId).then(response => {
+                postForm(result, params.tableName, params.dsName).then(response => {
                     this.$message.success('生成并保存成功')
                 })
             },
@@ -41,7 +41,7 @@
                 if (validatenull(params)) {
                     return false
                 }
-                getForm(params.tableName, params.dsId).then(response => {
+                getForm(params.tableName, params.dsName).then(response => {
                     if (!validatenull(response.data.data)) {
                         this.option = JSON.parse(response.data.data)
                     }

+ 5 - 5
src/views/gen/index.vue

@@ -21,12 +21,12 @@
       <el-row :gutter="20">
         <el-col :span="4">
           <div class="grid-content bg-purple">
-            <el-select v-model="q.id" placeholder="请选择数据源" @change="search">
+            <el-select v-model="q.dsName" placeholder="请选择数据源" @change="search">
               <el-option
                 v-for="item in dataSourceList"
                 :key="item.id"
                 :label="item.name"
-                :value="item.id"/>
+                :value="item.name"/>
             </el-select>
           </div>
         </el-col>
@@ -141,7 +141,7 @@
         })
       },
       handleDesign: function (row) {
-        this.$router.push({path: '/gen/design', query: {tableName: row.tableName, dsId: this.q.id}})
+        this.$router.push({path: '/gen/design', query: {tableName: row.tableName, dsName: this.q.dsName}})
       },
       handleDown: function (row) {
         this.formData.tableName = row.tableName
@@ -157,7 +157,7 @@
         this.getList(this.page)
       },
       gen(form,done) {
-        this.formData.id = this.q.id
+        this.formData.dsName = this.q.dsName
         handleDown(this.formData).then(() => {
           done()
           this.box = false
@@ -186,7 +186,7 @@
         this.boxBatch = true
       },
       batchGen(form,done) {
-        this.formBatchData.id = this.q.id
+        this.formBatchData.dsName = this.q.dsName
         handleDown(this.formBatchData).then(() => {
           done()
           this.boxBatch = false