Просмотр исходного кода

统计card显示隐藏;数据统计功能增加字段

Zn 1 год назад
Родитель
Сommit
50de8e53c7

+ 16 - 0
ruoyi-ui/src/components/RightToolbar/index.vue

@@ -1,6 +1,9 @@
 <template>
   <div class="top-right-btn" :style="style">
     <el-row>
+      <el-tooltip class="item" effect="dark" :content="showCount ? '隐藏统计' : '显示统计'" placement="top" v-if="counts">
+        <el-button size="mini" circle icon="el-icon-data-analysis" @click="toggleCount()" />
+      </el-tooltip>
       <el-tooltip class="item" effect="dark" :content="showSearch ? '隐藏搜索' : '显示搜索'" placement="top" v-if="search">
         <el-button size="mini" circle icon="el-icon-search" @click="toggleSearch()" />
       </el-tooltip>
@@ -39,6 +42,10 @@ export default {
       type: Boolean,
       default: true,
     },
+    showCount: {
+      type: Boolean,
+      default: true,
+    },
     columns: {
       type: Array,
     },
@@ -46,6 +53,10 @@ export default {
       type: Boolean,
       default: true,
     },
+    counts: {
+      type: Boolean,
+      default: false,
+    },
     gutter: {
       type: Number,
       default: 10,
@@ -69,6 +80,11 @@ export default {
     }
   },
   methods: {
+    // 统计
+    toggleCount() {
+      console.log(12456)
+      this.$emit("update:showCount", !this.showCount);
+    },
     // 搜索
     toggleSearch() {
       this.$emit("update:showSearch", !this.showSearch);

+ 24 - 0
ruoyi-ui/src/views/relateTable/index.vue

@@ -125,6 +125,11 @@
           >新增</el-button
         >
 
+        <div class="nameipt">
+          <span>表格组名:</span><el-input v-model="groupname" placeholder="请输入表格组名"></el-input>
+          <span class="desc">描述:</span><el-input v-model="groupdescribe" placeholder="请输入相关描述"></el-input>
+        </div>
+
         <el-table
           :data="tableDataList"
           border
@@ -337,6 +342,8 @@ export default {
         theRelateField: "",
         executeOptions: [],
       },
+      groupname: '',
+      groupdescribe: ''
     };
   },
   created() {
@@ -554,4 +561,21 @@ export default {
   display: flex;
   justify-content: center;
 }
+
+::v-deep .el-table{
+  margin-top: 10px;
+}
+.nameipt{
+  display: inline;
+  margin-left: 10px;
+  ::v-deep .el-input--medium .el-input__inner{
+  width: 30%;
+  }
+  ::v-deep .el-input--medium{
+  display: inline;
+  }
+}
+.desc{
+  margin-left: 10px;
+}
 </style>

+ 12 - 2
ruoyi-ui/src/views/system/tenant/index.vue

@@ -400,9 +400,10 @@ export default {
         ],
         databaseName: [
           { required: true, message: "数据库名不能为空", trigger: "blur" },
+          { validator: this.databaseNameValidator, trigger: "blur"  }
         ],
         tenantAccount: [
-          { required: true, message: "租户账号不能为空", trigger: "change" },
+          { required: true, message: "租户管理员账号不能为空", trigger: "change" },
           { validator: this.tenantAccountValidator, trigger: "blur" },
         ],
         databaseIp: [
@@ -448,6 +449,15 @@ export default {
         callback();
       }
     },
+    // 数据库名称校验规则
+    databaseNameValidator(rule, value, callback){
+      let regex = /^[a-z][a-z0-9]*$/; 
+      if (regex.test(value)) {  
+        callback(); // 输入内容符合规则  
+      } else {  
+        callback(new Error("只能包含小写字母和数字,且以小写字母开头"));
+      }  
+    },
     // 数据源类型改变回调
     dataSourceTypeChange(type) {
       this.$nextTick(() => {
@@ -676,7 +686,7 @@ export default {
         });
       }
       getDataSourceInfo(qar).then((res) => {
-        console.log(res);
+        // console.log(res);
       });
     },
     handleTest() {

+ 108 - 48
ruoyi-ui/src/views/tableMange/index.vue

@@ -63,7 +63,9 @@
             <el-table-column prop="fieldDescription" label="字段描述">
               <template slot-scope="scope">
                 <!-- <el-form-item size="normal" prop="fieldDescription"> -->
-                <el-input v-model="scope.row.fieldDescription"></el-input>
+                <input  :class="{isNullDesc : scope.row.fieldDescription == ''&& scope.row.isShow && isInputInvalid ? true : false, ipt:true}" v-model="scope.row.fieldDescription" />
+
+                <!-- <el-input v-model="scope.row.fieldDescription" /> -->
                 <!-- </el-form-item> -->
               </template>
             </el-table-column>
@@ -168,6 +170,11 @@
                 <el-switch v-model="scope.row.isExport"> </el-switch>
               </template>
             </el-table-column>
+            <!-- <el-table-column prop="isCount" label="是否统计">
+              <template slot-scope="scope">
+                <el-switch v-model="scope.row.isCount"> </el-switch>
+              </template>
+            </el-table-column> -->
             <!-- <el-table-column
           label="操作"
           align="center"
@@ -288,7 +295,7 @@
               class="inline-large-button"
               icon="el-icon-plus"
               size="mini"
-              @click="isShowAddData = true"
+              @click="addDataDialog"
             >
               添加数据字段
             </el-button>
@@ -296,38 +303,45 @@
             <el-button size="mini" type="primary" @click=countHandle>确定统计</el-button>
          
             <el-table
-              :data="datacountTable"
+              :data="dragTableStatisticList"
               border
               class="mb10"
               style="width: 100%">
               <el-table-column
-                prop="number"
+                type="index"
                 label="序号"
-                width="50">
+                width="50"
+                class-name="allowDrag"
+                >
+              </el-table-column>
+              <el-table-column
+                prop="statisticTitle"
+                label="统计标题"
+                width="83">
               </el-table-column>
               <el-table-column
-                prop="datafield"
-                label="数据字段"
+                prop="statisticField"
+                label="统计数据"
                 width="80">
               </el-table-column>
               <el-table-column
-                prop="type"
-                label="类型"
+                prop="statisticType"
+                label="统计类型"
                 width="50">
               </el-table-column>
-              <el-table-column
+              <!-- <el-table-column
                 prop="statuscode"
                 label="状态码"
                 width="70">
-              </el-table-column>
+              </el-table-column> -->
               <el-table-column
-                prop="title"
-                label="标题"
-                width="83">
+                prop="statisticDescription"
+                label="统计描述"
+                width="150">
               </el-table-column>
               <el-table-column
-                prop="description"
-                label="描述"
+                prop="statisticObject"
+                label="统计对象"
                 width="150">
               </el-table-column>
             </el-table>
@@ -501,42 +515,45 @@
       <el-form 
       label-width="100px" 
       :model="dataCountFormData">
-        <el-form-item label="数据字段">
+        <el-form-item label="统计标题" prop="statisticTitle">
+          <el-input v-model="dataCountFormData.statisticTitle"></el-input>
+        </el-form-item>
+
+        <el-form-item label="统计数据">
           <el-select 
-          v-model="dataCountFormData.datafield" 
-          placeholder="请选择数据字段">
+          v-model="dataCountFormData.statisticField" 
+          placeholder="请选择统计字段">
             <el-option 
             v-for="item in dataArr"
             :key="item.id"
             :label="item.fieldName" 
             :value="item.fieldName">
-          </el-option>
+            </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="类型">
+        <el-form-item label="统计类型">
           <el-select 
-          v-model="dataCountFormData.type" 
-          placeholder="请选择类型">
-            <el-option label="数量" value="num"></el-option>
-            <el-option label="状态" value="status"></el-option>
+          v-model="dataCountFormData.statisticType" 
+          placeholder="请选择统计类型">
+            <el-option v-for="item in dataType" :key="item.dictCode" :label="item.dictLabel" :value="item.dictLabel"></el-option>
+            <!-- <el-option label="状态" value="status"></el-option> -->
           </el-select>
         </el-form-item>
-
-        <el-form-item label="状态码" v-show="dataCountFormData.type === 'status' ">
+<!-- 
+        <el-form-item label="状态码" v-show="dataCountFormData.statisticType === 'status' ">
           <el-select 
           v-model="dataCountFormData.statuscode" 
           placeholder="请选择状态码">
             <el-option label="已完成" value="1"></el-option>
             <el-option label="未完成" value="0"></el-option>
           </el-select>
-        </el-form-item>
+        </el-form-item> -->
 
-        <el-form-item label="标题" prop="title">
-          <el-input v-model="dataCountFormData.title"></el-input>
+        <el-form-item label="统计描述" prop="statisticDescription">
+          <el-input v-model="dataCountFormData.statisticDescription"></el-input>
         </el-form-item>
-
-        <el-form-item label="描述" prop="description">
-          <el-input v-model="dataCountFormData.description"></el-input>
+        <el-form-item label="统计对象" prop="statisticObject">
+          <el-input v-model="dataCountFormData.statisticObject"></el-input>
         </el-form-item>
       </el-form>
       <span slot="footer" class="dialog-footer">
@@ -574,11 +591,12 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import { v4 as uuidv4 } from "uuid";
 export default {
   name: "tableMange",
-  dicts: ["sys_time_format"],
+  dicts: ["sys_time_format", "table_statistic_type"],
   props: [],
   components: { Queryfrom, Treeselect },
   data() {
     return {
+      isInputInvalid: false,
       // 修改表格时的menuId
       menuId: "",
       // 修改表格的id
@@ -594,6 +612,7 @@ export default {
       // 当前table唯一标识
       sqlkey: "",
       // 表格的高度
+      tableKey: "",
       // tableHeight: document.documentElement.scrollHeight - 245 + "px",
       tableList: [], //所有表格列表
       tableFieldList: [], // 当前表格字段数据
@@ -650,6 +669,10 @@ export default {
           prop: "isExport",
           label: "是否导出",
         },
+        {
+          prop: "isCount",
+          label: "是否统计",
+        },
       ], //表头列表
 
       // 右侧筛选条件勾选数据
@@ -705,11 +728,12 @@ export default {
       // 数据统计对象
       dataCountFormData: {},
       // 数据统计表格
-      datacountTable: [],
+      dragTableStatisticList: [],
       // 是否切换到数据统计
       menudata: false,
       // 显示添加字段对话框
-      isShowAddData: false
+      isShowAddData: false,
+      dataType : [],
     };
   },
   computed: {
@@ -771,6 +795,11 @@ export default {
     },
   },
   methods: {
+
+    // 字段描述验证规则
+    // blurval(value){
+    //   this.isInputInvalid = value == '' ?  true : false;
+    // },
     // 树形控件change回调
     treeSelectChange(val) {
       //没有change事件
@@ -796,9 +825,10 @@ export default {
         databaseType: this.databaseType,
         tableName: this.tableName,
       };
-
+      console.log(data);
       // 获取当前表单结构信息
       getListName(data).then((res) => {
+        console.log(res)
         this.tableFieldList = res.map((item, index) => {
           return {
             id: this.tableName + "_" + item.fieldName,
@@ -1279,6 +1309,9 @@ export default {
     },
     // 创建回调
     async createHandle() {
+      console.log(123);
+      this.tableKey = uuidv4();
+      this.isInputInvalid = true
       this.$refs.formData.validate(async (valid) => {
         if (valid) {
           // 检验表单合法性
@@ -1369,7 +1402,7 @@ export default {
               tId: this.tId,
               dtName: this.formData.menuName,
               // menuId: this.formData.routePath,
-              // tableKey: this.formData.routePath, //  暂定
+              tableKey: this.tableKey, //  暂定
               dtTableName: this.tableName,
               primaryKey: this.formData.primaryKey,
               orderByColumn: this.formData.orderByColumn,
@@ -1414,6 +1447,10 @@ export default {
               res = await addDragTable(data);
             }
 
+            console.log('res', res);
+            if(res.code == 200){
+              this.countHandle()
+            }
             // 关闭当前页面
             if (this.tId) {
               if (res.code == 200) {
@@ -1510,16 +1547,18 @@ export default {
     tabhandleClick() {
       this.menudata = this.activeName === 'datacount' ? true : false;
     },
+    // 添加数据字段对话框
+    async addDataDialog() {
+      this.isShowAddData = true
+      this.dataType = await this.getDicts("table_statistic_type")
+      this.dataType = this.dataType.data
+      // console.log(this.dataType)
+    },
     // 添加数据字段
     addData(){
-      this.dataCountFormData.number =  this.datacountTable.length + 1
-      console.log(this.dataCountFormData)
-      this.dataCountFormData.type = this.dataCountFormData.type == 'num' ? '数量' : '状态'
-      if(this.dataCountFormData.type == 'status'){
-        this.dataCountFormData.statuscode = this.dataCountFormData.type == '1' ? '已完成' : '未完成'
-      }
-      
-      this.datacountTable.push(this.dataCountFormData)
+      this.dataCountFormData.tableKey = this.tableKey
+      this.dragTableStatisticList.push(this.dataCountFormData)
+      console.log(this.dragTableStatisticList)
       this.isShowAddData = false
       this.dataCountFormData = {}
     },
@@ -1530,11 +1569,13 @@ export default {
     },
     // 确定统计
     countHandle(){
-      if(this.datacountTable.length == 0){
+      if(this.dragTableStatisticList.length == 0){
         this.$message.warning("请确定统计数据字段");
         return
       }
       console.log('确定统计');
+
+      console.log(this.dragTableStatisticList);
     }
   },
   created() {},
@@ -1551,6 +1592,26 @@ export default {
 </script>
 
 <style scoped lang="scss">
+.ipt{
+  height: 36px;
+  line-height: 36px;
+  font-size: 14px;
+  width: 100%;
+  outline: none;
+  text-align: center;
+  background-color: #fff;
+  border: 1px solid #DCDFE6;
+  color: #606266;
+  display: inline-block;
+  border-radius: 4px;
+}
+.isNullDesc{
+  border-color: #FF4949 !important;
+}
+
+.ipt:focus{
+  border-color: #1890ff;
+}
 ::v-deep .right_card {
   min-height: 500px !important;
 }
@@ -1566,5 +1627,4 @@ export default {
 .mb10{
   margin-top: 10px;
 }
-
 </style>

+ 4 - 0
ruoyi-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -52,6 +52,7 @@
     </el-dialog>
     <Queryfrom
       :form-vals="templateInfo.where"
+      :showCount="showCount"
       @getList="getList"
       ref="mychild"
     />
@@ -108,6 +109,7 @@
         </el-button>
       </el-col>
       <right-toolbar
+        :showCount.sync="showCount"
         :showSearch.sync="showSearch"
         @queryTable="pageList"
       ></right-toolbar>
@@ -227,6 +229,8 @@ export default {
       single: true,
       // 非多个禁用
       multiple: true,
+      // 显示统计
+      showCount: true,
       // 显示搜索条件
       showSearch: true,
       // 总条数

+ 6 - 2
ruoyi-ui/src/views/tablelist/commonTable/queryfrom.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <div class="cardBox">
+    <div class="cardBox" v-show="showCount">
       <el-card 
         shadow="hover" 
         :body-style="{ padding: '20px'}" 
@@ -150,6 +150,7 @@
           </span>
         </span>
       </div>
+
     </el-form>
   </div>
 </template>
@@ -162,6 +163,9 @@ export default {
       type: Array,
       default: () => [],
     },
+    showCount : {
+      type: Boolean,
+    }
   },
   data() {
     return {
@@ -250,7 +254,7 @@ export default {
           type: '已完成',
           count: 20
         }
-      ]
+      ],
     };
   },
   watch: {