Przeglądaj źródła

fix: 数据统计

Zn 1 rok temu
rodzic
commit
9ae3e61d69

+ 10 - 0
ruoyi-ui/src/api/tablelist/commonTable.js

@@ -198,3 +198,13 @@ export function listStatistic(query) {
     baseURL: process.env.VUE_APP_BASE_API3
   })
 }
+
+// 查询动态统计
+export function getStatisticList(query) {
+  return request({
+    url: '/system/statistic/getStatisticList',
+    method: 'get',
+    params: query,
+    baseURL: process.env.VUE_APP_BASE_API3
+  })
+}

+ 34 - 134
ruoyi-ui/src/views/tableMange/index.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="app-container">
     <el-row :gutter="20">
-      <el-col :span="18" :class="{ edit: menudata }">
       <el-col :span="18" :class="{ edit: menudata }">
         <el-card shadow="always" :body-style="{ padding: '20px' }">
           <template #header>
@@ -76,19 +75,6 @@
                   }"
                   v-model="scope.row.fieldDescription"
                 />
-                <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>
@@ -327,17 +313,9 @@
             >
               添加数据字段
             </el-button>
-<<<<<<< HEAD
             
             <!-- <el-button size="mini" type="primary" @click=countHandle>确定统计</el-button> -->
          
-=======
-
-            <el-button size="mini" type="primary" @click="countHandle"
-              >确定统计</el-button
-            >
-
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
             <el-table
               :data="dragTableStatisticList"
               border
@@ -444,20 +422,20 @@
             :content="item.statisticTitle"
             placement="top-start"
           >
-            <div class="title">{{ item.statisticTitle }}</div>
+            <div class="title">{{ item.statisticTitle ? item.statisticTitle : item.statisticDescription}}</div>
           </el-tooltip>
 
-          <el-tooltip
+          <!-- <el-tooltip
             class="item"
             effect="dark"
             :content="item.statisticDescription"
             placement="top-start"
           >
             <div class="description">{{ item.statisticDescription }}</div>
-          </el-tooltip>
+          </el-tooltip> -->
 
           <div class="type">
-            <div class="statisticType">{{ item.statisticType }}</div>
+            <!-- <div class="statisticType">{{ item.statisticType }}</div> -->
             <div class="count">统计结果</div>
           </div>
         </el-card>
@@ -621,32 +599,11 @@
     <el-dialog
       :title="staictitle"
       :visible.sync="isShowAddData"
-<<<<<<< HEAD
       width="30%">
       
       <el-form 
       label-width="100px" 
       :model="dataCountFormData">
-=======
-      width="30%"
-    >
-      <!-- <el-form label-width="100px" :model="dataCountFormData">
-        <el-form-item label="数据字段">
-          <el-select
-            v-model="dataCountFormData.datafield"
-            placeholder="请选择数据字段"
-          >
-            <el-option
-              v-for="item in dataArr"
-              :key="item.id"
-              :label="item.fieldName"
-              :value="item.fieldName"
-            >
-            </el-option>
-      width="30%"> -->
-
-      <el-form label-width="100px" :model="dataCountFormData">
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
         <el-form-item label="统计标题" prop="statisticTitle">
           <el-input v-model="dataCountFormData.statisticTitle"></el-input>
         </el-form-item>
@@ -660,8 +617,10 @@
               v-for="item in dataArr"
               :key="item.id"
               :label="item.fieldName"
-              :value="item.fieldName"
+              :value="item.tableName + '.'  + item.fieldName"
             >
+            <span style="float: left;margin-right: 5px">{{ item.tableName }}  </span>
+            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.fieldName }}</span>
             </el-option>
           </el-select>
         </el-form-item>
@@ -670,7 +629,6 @@
             <el-option label="数量" value="num"></el-option>
             <el-option label="状态" value="status"></el-option> -->
         <el-form-item label="统计类型">
-<<<<<<< HEAD
           <el-select 
           v-model="dataCountFormData.statisticType" 
           placeholder="请选择统计类型">
@@ -678,40 +636,6 @@
             <!-- <el-option label="状态" value="status"></el-option> -->
           </el-select>
         </el-form-item>
-=======
-          <el-select
-            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-select
-            v-model="dataCountFormData.statuscode"
-            placeholder="请选择状态码"
-          > -->
-        <!-- 
-        <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>
-        -->
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
 
         <el-form-item label="统计描述" prop="statisticDescription">
           <el-input v-model="dataCountFormData.statisticDescription"></el-input>
@@ -723,6 +647,7 @@
       <span slot="footer" class="dialog-footer">
         <el-button @click="closeAddDialog">取 消</el-button>
         <el-button v-if="staictitle == '修改统计数据字段'" type="primary" @click="upadtaData">确 定</el-button>
+
         <el-button v-else type="primary" @click="addData">确 定</el-button>
       </span>
     </el-dialog>
@@ -906,12 +831,8 @@ export default {
       menudata: false,
       // 显示添加字段对话框
       isShowAddData: false,
-<<<<<<< HEAD
       dataType : [],
       uuid: '',
-=======
-      dataType: [],
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
     };
   },
   computed: {
@@ -1005,7 +926,7 @@ export default {
       console.log(data);
       // 获取当前表单结构信息
       getListName(data).then((res) => {
-        console.log(res);
+        // console.log(res);
         this.tableFieldList = res.map((item, index) => {
           return {
             id: this.tableName + "_" + item.fieldName,
@@ -1027,6 +948,7 @@ export default {
             relationFieldList: [],
           };
         });
+        console.log(this.tableFieldList);
       });
     },
     // 关联表变化回调
@@ -1526,15 +1448,9 @@ export default {
     },
     // 创建回调
     async createHandle() {
-<<<<<<< HEAD
       // console.log(123);
       // this.sqlKey = uuidv4();
       this.isInputInvalid = true
-=======
-      console.log(123);
-      this.tableKey = uuidv4();
-      this.isInputInvalid = true;
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
       this.$refs.formData.validate(async (valid) => {
         if (valid) {
           // 检验表单合法性
@@ -1671,7 +1587,8 @@ export default {
             }
             this.staticSqlKey = uuidv4()
             this.dragTableStatisticList.forEach(item => {
-              let key = item.statisticType + '(' + this.tableName + '.' + item.statisticField + ')'+ ' as result'
+              console.log(item)
+              let key = item.statisticType + '(' + item.statisticField + ')'+ ' as result'
               this.tableSqlList.push({
                 tableSql: this.getStaticSQL(key), 
                 sqlKey: this.staticSqlKey, 
@@ -1681,14 +1598,8 @@ export default {
               item.tableKey = this.tableKey
             })
 
-<<<<<<< HEAD
             if(res.code == 200 && this.dragTableStatisticList.length !== 0){
               this.countHandle()
-=======
-            console.log("res", res);
-            if (res.code == 200) {
-              this.countHandle();
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
             }
             // 关闭当前页面
             if (this.tId) {
@@ -1803,32 +1714,28 @@ export default {
     },
     // 修改数据字段
     upadtaData(){
-      this.dragTableStatisticList = this.dragTableStatisticList.map(value => value.id == this.dataCountFormData.id ? this.dataCountFormData : value)
+      console.log(this.dataCountFormData);
+      // this.dragTableStatisticList = this.dragTableStatisticList.map(value => value.xid == this.dataCountFormData.xid || value.id == this.dataCountFormData.id ? this.dataCountFormData : value)
+      this.dragTableStatisticList.forEach((item, index) => {
+        console.log(this.dataCountFormData);
+        if(item?.id == this.dataCountFormData?.id){
+          this.dragTableStatisticList[index] = this.dataCountFormData
+        }else if(item?.xid == this.dataCountFormData?.xid){
+          this.dragTableStatisticList[index] = this.dataCountFormData
+        }
+      })
       this.isShowAddData = false
+      console.log(this.dragTableStatisticList)
       this.dataCountFormData = {}
     },
     // 添加数据字段
-<<<<<<< HEAD
     addData(){
+      console.log(this.dataCountFormData);
+      this.dataCountFormData.xid = Date.now()
       this.dataCountFormData.tableKey = this.tableKey
       this.dragTableStatisticList.push(this.dataCountFormData)
       this.isShowAddData = false
       this.dataCountFormData = {}
-=======
-    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.isShowAddData = false;
-      this.dataCountFormData = {};
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
     },
     // 关闭添加数据字段
     closeAddDialog() {
@@ -1836,7 +1743,6 @@ export default {
       this.dataCountFormData = {};
     },
     // 确定统计
-<<<<<<< HEAD
     countHandle(){
       addStatistic({
         dragTableStatisticList: this.dragTableStatisticList,
@@ -1849,10 +1755,14 @@ export default {
     },
     // 修改统计信息
     handleUpdateStat(row){
+      console.log(row);
       this.staictitle = '修改统计数据字段'
       this.dataCountFormData = row
+      this.dataCountFormData.xid = Date.now()
       this.addDataDialog()
       this.isShowAddData = true
+      console.log(this.dataCountFormData)
+      console.log(this.dragTableStatisticList);
     },
     // 删除统计信息
     handleDeleteStat(row){
@@ -1862,17 +1772,6 @@ export default {
           this.dragTableStatisticList.splice(index, 1);
         }
       })
-=======
-    // countHandle() {
-    //   if (this.datacountTable.length == 0) {
-    countHandle() {
-      if (this.dragTableStatisticList.length == 0) {
-        this.$message.warning("请确定统计数据字段");
-        return;
-        return;
-      }
-      console.log("确定统计");
->>>>>>> 6e9cfa0f11bfcd282d3ae391fde4b25bfa0231bd
     },
   },
   created() {},
@@ -1932,10 +1831,11 @@ export default {
 }
 .card {
   /* width:15%; */
-  flex-basis: 28%;
+  height:150px;
+  flex-basis: 15%;
   margin-bottom: 10px;
   margin-right: 15px;
-  min-width: 210px;
+  min-width: 180px;
   .title {
     /* width:20%; */
     font-size: 18px;
@@ -1958,13 +1858,13 @@ export default {
   }
   .type {
     float: right;
-    margin-top: 10px;
+    margin-top: 40px;
     .statisticType{
       font-size: 18px;
     }
   }
   .count {
-    font-size: 30px;
+    font-size: 25px;
   }
 }
 .mb8{

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

@@ -211,6 +211,7 @@ import {
   getInfoBySqlKey,
   addTableData,
   batchEdit,
+  getStatisticList
 } from "@/api/tablelist/commonTable";
 import {getToken} from "@/utils/auth";
 import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
@@ -298,6 +299,8 @@ export default {
       jsonData: {},
       // 回显表格数据,
       defaultValue: {},
+      // 统计card
+      tableKey: '',
     };
   },
 
@@ -372,6 +375,7 @@ export default {
         .then((res) => {
           // 得到当前模版信息 --- sql columns queryWhere
           this.templateInfo = res.data.resultMap;
+
           this.queryParams.orderByColumn =
             res.data.resultMap.querySql.orderByColumn;
           this.sortOrder = JSON.parse(res.data.resultMap.querySql.sortOrder);
@@ -394,6 +398,7 @@ export default {
           );
           // 根据sql语句查询当前表数据
           unionListTableData(this.queryParams).then((res) => {
+            // console.log('unionListTableData');
             this.tableList = [];
             res.rows.forEach((item) => {
               this.tableList.push(item.resultMap);
@@ -409,6 +414,11 @@ export default {
             this.total = res.total;
             this.loading = false;
           });
+
+          // 查询统计信息
+          getStatisticList({queryMap: {tableKey: this.templateInfo.template.tableKey}}).then(res => {
+            console.log('getStatisticList', res);
+          })
         });
     },
     // 取消按钮