Browse Source

前端代码更新

sr 4 years ago
parent
commit
8bd6d9592b

+ 18 - 0
ruoyi-ui/src/api/system/table.js

@@ -0,0 +1,18 @@
+import request from '@/utils/request'
+
+// 获取表单数据
+export function getQueryList(data) {
+  return request({
+    url: '/boman-system/p/cs/queryList',
+    method: 'POST',
+    data
+  })
+}
+// 获取表单查询字段、按钮、表头
+export function getTableQuery(data) {
+  return request({
+    url: '/boman-system/p/cs/getTableQuery',
+    method: 'POST',
+    data
+  })
+}

+ 126 - 0
ruoyi-ui/src/components/DynamicForm/index.vue

@@ -0,0 +1,126 @@
+<template>
+  <el-form class="dynamic-form" ref="dynamic-form" :model="config">
+    <el-form-item :label="item.columnComment" v-for="item in formConfig" :prop="item.columnName">
+      <!-- 输入框 -->
+      <el-input v-if="item.htmlType == 'input'" v-model="config[item.columnName]" :placeholder="'请输入'+item.columnComment"
+        clearable @keyup.enter.native="handleQuery" />
+      <!-- 多行输入框 -->
+      <el-input v-if="item.htmlType == 'textarea'" type="textarea" v-model="config[item.columnName]" :placeholder="'请输入'+item.columnComment"
+        clearable @keyup.enter.native="handleQuery" />
+      <!-- 下拉框 -->
+      <el-select v-model="config[item.columnName]" v-if="item.htmlType == 'select'" filterable :placeholder="'请输入'+item.columnComment">
+        <el-option v-for="itemChild in item.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictLabel" :value="itemChild.dictValue">
+        </el-option>
+      </el-select>
+      <!-- 复选框 -->
+      <el-checkbox-group v-model="config[item.columnName]" v-if="item.htmlType == 'checkbox'">
+        <el-checkbox v-for="itemChild in item.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictLabel"
+          :value="itemChild.dictValue"></el-checkbox>
+      </el-checkbox-group>
+      <!-- 单选框 -->
+      <el-radio-group v-model="config[item.columnName]" v-if="item.htmlType == 'radio'">
+        <el-radio v-for="itemChild in item.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictLabel" :value="itemChild.dictValue"></el-radio>
+      </el-radio-group>
+      <!-- 时间控件 -->
+      <el-date-picker v-model="config[item.columnName]" v-if="item.htmlType == 'datetime'" type="date" :placeholder="'请输入'+item.columnComment">
+      </el-date-picker>
+      <!-- 上传图片 -->
+      <el-upload v-if="item.htmlType == 'imageUpload'" :headers="{Authorization: 'Bearer ' + getToken()}" :action="defaultSettings.urls+'/boman-file/upload'" list-type="picture-card"
+        :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
+        <i class="el-icon-plus"></i>
+      </el-upload>
+      <el-dialog :visible.sync="dialogVisible" v-if="item.htmlType == 'imageUpload'">
+        <img width="100%" :src="dialogImageUrl" alt="">
+      </el-dialog>
+      <!-- 上传文件 -->
+      <el-upload action="#" v-if="item.htmlType == 'fileUpload'" list-type="picture-card" :auto-upload="false">
+        <i slot="default" class="el-icon-plus"></i>
+        <div slot="file" slot-scope="{file}">
+          <img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
+          <span class="el-upload-list__item-actions">
+            <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
+              <i class="el-icon-zoom-in"></i>
+            </span>
+            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
+              <i class="el-icon-download"></i>
+            </span>
+            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
+              <i class="el-icon-delete"></i>
+            </span>
+          </span>
+        </div>
+      </el-upload>
+      <el-dialog :visible.sync="dialogVisible" v-if="item.htmlType == 'fileUpload'">
+        <img width="100%" :src="dialogImageUrl" alt="">
+      </el-dialog>
+    </el-form-item>
+  </el-form>
+</template>
+
+<script>
+  const defaultSettings = require('@/settings.js')
+  import Editor from '@/components/Editor';
+  import { getToken } from "@/utils/auth";
+  export default {
+    data() {
+      return {
+        defaultSettings,
+        dialogImageUrl: '',
+        dialogVisible: false,
+        disabled: false
+      }
+    },
+    components: {
+      Editor
+    },
+    props: {
+      formConfig: {
+        type: Object,
+        required: true
+      },
+      config: {
+        type: Object,
+        required: true
+      }
+    },
+    mounted() {
+      console.log(this.formConfig, this.config)
+      // this.setDefaultValue()
+    },
+    methods: {
+      getToken() {
+        return getToken()
+      },
+      handleRemove(file, fileList) {
+        console.log(file, fileList);
+      },
+      handlePictureCardPreview(file) {
+        this.dialogImageUrl = file.url;
+        this.dialogVisible = true;
+      },
+      handleDownload(file) {
+        console.log(file);
+      },
+      handleQuery() {
+        this.$emit('btns')
+      },
+      setDefaultValue() {
+        const formData = { ...this.config
+        }
+        // 设置默认值
+        this.formConfig.formItemList.forEach(({
+          key,
+          value
+        }) => {
+          if (formData[key] === undefined || formData[key] === null) {
+            formData[key] = value
+          }
+        })
+        this.$emit('input', formData)
+      }
+    }
+  }
+</script>
+
+<style>
+</style>

+ 3 - 0
ruoyi-ui/src/layout/components/Navbar.vue

@@ -28,6 +28,7 @@
       <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
         <div class="avatar-wrapper">
           <img :src="avatar" class="user-avatar">
+		  <span></span>
           <i class="el-icon-caret-bottom" />
         </div>
         <el-dropdown-menu slot="dropdown">
@@ -67,6 +68,8 @@ export default {
     RuoYiGit,
     RuoYiDoc
   },
+  mounted() {
+  },
   computed: {
     ...mapGetters([
       'sidebar',

+ 2 - 0
ruoyi-ui/src/main.js

@@ -21,6 +21,7 @@ import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels,
 import Pagination from "@/components/Pagination";
 // 自定义表格工具扩展
 import RightToolbar from "@/components/RightToolbar"
+import DynamicForm from "@/components/DynamicForm"
 
 // 全局方法挂载
 Vue.prototype.getDicts = getDicts
@@ -48,6 +49,7 @@ Vue.prototype.msgInfo = function (msg) {
 // 全局组件挂载
 Vue.component('Pagination', Pagination)
 Vue.component('RightToolbar', RightToolbar)
+Vue.component('DynamicForm', DynamicForm)
 
 Vue.use(permission)
 

+ 3 - 0
ruoyi-ui/src/settings.js

@@ -1,5 +1,8 @@
 module.exports = {
   title: '博曼办公协作',
+  // urls: `http://192.168.101.11:8090`,
+  urls: `http://192.168.101.110:8080`,
+  // urls: `http://192.168.101.10:8080`,
 
   /**
    * 侧边栏主题 深色主题theme-dark,浅色主题theme-light

+ 155 - 81
ruoyi-ui/src/views/system/table/index.vue

@@ -1,78 +1,144 @@
 <template>
- <div class="table_total">
-   <div class="table_header">
-     <p>单表</p>
-     <el-divider></el-divider>
-     <div class="table_headerBtun">
-          <el-button type="primary" plain v-for="(item,index) in 7" :key="index">新增</el-button>
-     </div>
-   </div>
-   <!-- 内容 -->
-   <div class="table_nav">
-    <el-collapse v-model="activeNames" @change="handleChange">
-      <el-collapse-item :title="title" :name="index" v-for="(item,index) in 4" :key="index">
-        <el-form :model="queryParams" ref="queryForm" :inline="true"  >
-          <el-row :gutter="0">
-            <el-col :span="6" v-for="(item,index) in 12" :key="index">
-              <el-form-item :label="labletit" prop="dictName">
-               <el-input
-              v-model="queryParams.dictName"
-              placeholder="请输入字典名称"
-              clearable
-              size="small"
-              @keyup.enter.native="handleQuery"
-              />
-             </el-form-item>
-          </el-col>
-          </el-row>
-        </el-form>
-      </el-collapse-item>
-
-    </el-collapse>
-   </div>
-
- </div>
+  <div class="table_total">
+    <div class="table_header">
+      <!-- <p>单表</p>
+      <el-divider></el-divider> -->
+      <div class="table_headerBtun" v-if="queryData.buttonList">
+        <el-button type="primary" plain v-for="(item,index) in queryData.buttonList.split('')" :key="index">{{item | btnConversion}}</el-button>
+      </div>
+      <dynamic-form :config="queryParams" :formConfig="queryData.queryList" v-show="showSearch"/>
+      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
+        <el-form-item label="菜单名称" prop="menuName">
+          <el-input
+            v-model="queryParams.menuName"
+            placeholder="请输入菜单名称"
+            clearable
+            size="small"
+            @keyup.enter.native="handleQuery"
+          />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+    <!-- 内容 -->
+    <div class="table_nav">
+      <!-- <el-collapse v-model="activeNames" @change="handleChange">
+        <el-collapse-item :title="title" :name="index" v-for="(item,index) in 4" :key="index">
+          <el-form :model="queryParams" ref="queryForm" :inline="true">
+            <el-row :gutter="0">
+              <el-col :span="6" v-for="(item,index) in 12" :key="index">
+                <el-form-item :label="labletit" prop="dictName">
+                  <el-input v-model="queryParams.dictName" placeholder="请输入字典名称" clearable size="small"
+                    @keyup.enter.native="handleQuery" />
+                </el-form-item>
+              </el-col>
+            </el-row>
+          </el-form>
+        </el-collapse-item>
+
+      </el-collapse> -->
+    </div>
+
+  </div>
 
 </template>
 
 <script>
+  import {
+    getTableQuery
+  } from '@/api/system/table.js'
   export default {
     name: "index",
     data() {
       return {
-         activeNames: ['1'],
-         title:'单表1',
-         // 查询参数
-         queryParams: {
-           pageNum: 1,
-           pageSize: 10,
-           dictName: undefined,
-           dictType: undefined,
-           status: undefined
-         },
-         labletit:'查询参数1233'
+        // 显示搜索条件
+        showSearch: true,
+        activeNames: ['1'],
+        title: '单表1',
+        queryData: {},
+        // 查询参数
+        queryParams: {
+          pageNum: 1,
+          pageSize: 10,
+        },
+        labletit: '查询参数1233'
       };
     },
+    filters:{
+      btnConversion(val) {
+        switch(val){
+          case 'A':
+          return '新增';
+          case 'M':
+          return '修改';
+          case 'D':
+          return '删除';
+          case 'Q':
+          return '查询';
+          case 'S':
+          return '提交';
+          case 'U':
+          return '反提交';
+          case 'I':
+          return '导入';
+          case 'E':
+          return '导出';
+        }
+      }
+    },
+    mounted() {
+      this.init()
+    },
     methods: {
+      resetQuery() {
+
+      },
+      /** 搜索按钮操作 */
+      handleQuery() {
+        this.getList();
+      },
+      getList() {
+
+      },
+      init() {
+        getTableQuery({
+          table: 'obj_test'
+        }).then(res => {
+          let data = res.data
+          this.queryData = data
+          for(let item of data.queryList){
+            this.queryParams[item.columnName] = ''
+          }
+
+        })
+      },
       handleChange(val) {
-              console.log(val);
-            }
+        console.log(val);
+      }
     },
   };
 </script>
 
 
-<style  lang="scss">
-  .table_header{
-    .el-divider--horizontal{
+<style lang="scss">
+  .table_header {
+    .el-divider--horizontal {
       margin-top: 16px;
     }
+    .table_headerBtun{
+      margin-bottom: 20px;
+    }
   }
-  .table_nav{
-    .el-collapse-item__wrap{
+
+  .table_nav {
+    .el-collapse-item__wrap {
       border-bottom: 0;
     }
-    .el-collapse-item__header{
+
+    .el-collapse-item__header {
       border-bottom: 0;
       font-size: 15px;
       font-family: PingFang SC;
@@ -80,10 +146,12 @@
       color: #3C8DBC;
       line-height: 36px;
     }
-    .el-form-item__content{
+
+    .el-form-item__content {
       width: 55%;
     }
-    .el-collapse{
+
+    .el-collapse {
       border-top: 0;
     }
   }
@@ -92,26 +160,30 @@
 
 
 <style scoped lang="scss">
-  .app-main{
-     // background-color: #eef0ff !important;
+  .app-main {
+    // background-color: #eef0ff !important;
   }
-  .table_total{
-     background-color: #eef0ff;
-     height: 100%;
-     padding: 20px;
-     // 头部
-     .table_header{
-        background-color: #fff;
-        border-radius: 6px;
-        padding: 23px;
-        margin-bottom: 20px;
-      p{
-         font-size: 15px;
-         font-weight: bold;
-         color: #3C8DBC;
-         line-height: 36px;
-        }
-      p::before{
+
+  .table_total {
+    background-color: #eef0ff;
+    min-height: calc(100vh - 94px);
+    padding: 20px;
+
+    // 头部
+    .table_header {
+      background-color: #fff;
+      border-radius: 6px;
+      padding: 23px 23px 0px;
+      margin-bottom: 20px;
+
+      p {
+        font-size: 15px;
+        font-weight: bold;
+        color: #3C8DBC;
+        line-height: 36px;
+      }
+
+      p::before {
         content: "";
         display: block;
         width: 18px;
@@ -120,15 +192,17 @@
         border-radius: 3px;
 
       }
-     }
-     // 内容
-     .table_nav{
-       background-color: #fff;
-       border-radius: 6px;
-       padding: 23px;
-     }
+    }
+
+    // 内容
+    .table_nav {
+      background-color: #fff;
+      border-radius: 6px;
+      padding: 23px;
+    }
   }
-  p{
+
+  p {
     margin: 0;
 
   }

+ 1 - 3
ruoyi-ui/vue.config.js

@@ -34,9 +34,7 @@ module.exports = {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://192.168.101.11:8090`,
-        // target: `http://192.168.101.110:8080`,
-        // target: `http://192.168.101.10:8080`,
+        target: defaultSettings.urls,
         changeOrigin: true,
         pathRewrite: {
           ['^' + process.env.VUE_APP_BASE_API]: ''