Parcourir la source

fix: 数据统计补充提交

Zn il y a 1 an
Parent
commit
2708f5147d

+ 3 - 8
ruoyi-ui/src/views/relateTable/components/RelateTableCard.vue

@@ -9,13 +9,13 @@
     <el-table
       v-loading="loading"
       ref="singleTable"
-      :data="cardData.tableData"
+      :data="tableList"
       height="300"
       highlight-current-row
       @current-change="handleCurrentChange"
       style="width: 100%"
     >
-    <el-table-column
+      <el-table-column
         label="操作"
         align="center"
         class-name="small-padding fixed-width"
@@ -171,7 +171,7 @@ export default {
         
       if (this.templateInfo == {}) return;
       // 调用查询需要携带当前table的唯一标识
-      this.queryParams.queryMap.sqlKey = this.templateInfo.template.sqlKey;
+      this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
       this.queryParams.orderByColumn = camelCase(
         this.queryParams.orderByColumn || ""
       );
@@ -302,11 +302,6 @@ export default {
           this.$modal.msgError("表单校验失败,请规范填写数据");
         });
     },
-    toParentVal(){
-      console.log(123);
-      this.$emit('tansToParent', this.getList())
-      this.$emit('formtansToParent', this.templateInfo.where)
-    },
     // 取消按钮
     cancel() {
       this.open = false;

+ 148 - 7
ruoyi-ui/src/views/relateTable/index.vue

@@ -275,6 +275,40 @@
             </el-option>
             </el-select>
           </el-form-item>
+          <el-form-item label="时间格式" prop="timeFormate">
+            <el-select
+              v-model="tableItemForm.timeFormate"
+              placeholder="请选择时间格式"
+            >
+              <el-option
+                v-for="val in dict.type.sys_time_format"
+                :key="val.value"
+                :label="val.label"
+                :value="val.value"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item label="排序依赖字段">
+            <el-select
+              v-model="tableItemForm.orderByColumn"
+              placeholder="请选择排序依赖"
+            >
+              <el-option
+                v-for="val in orderByFieldList"
+                :key="val.fieldName"
+                :label="val.fieldDescription"
+                :value="val.tableName + '.' + val.fieldName"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item label="排序方式" v-show="tableItemForm.orderByColumn">
+            <el-radio v-model="tableItemForm.isAsc" :label="false"
+              >升序</el-radio
+            >
+            <el-radio v-model="tableItemForm.isAsc" :label="true"
+              >降序</el-radio
+            >
+          </el-form-item>
           <el-form-item label="展示字段:" prop="FieldList">
             <el-table
             :data="tableFieldList"
@@ -284,7 +318,6 @@
             max-height="500px"
             class="tablefiled"
             >
-            
             <el-table-column
               type="index"
               label="序号"
@@ -382,7 +415,7 @@
             </el-table-column>
             <el-table-column prop="isSearch" label="是否包含查询">
               <template slot-scope="scope">
-                <el-switch v-model="scope.row.isSearch"> </el-switch>
+                <el-switch v-model="scope.row.isSearch" @change="isSearchChange($event, scope.row,  scope.$index)"> </el-switch>
               </template>
             </el-table-column>
           </el-table>
@@ -394,6 +427,37 @@
         </el-form>
       </div>
     </el-dialog>
+
+    <!-- 是否包含查询字段 -->
+    <div class="isSearch">
+      <el-dialog
+      title="包含查询依赖值"
+      :visible.sync="isSearchDialog">
+      <el-select v-model="relyOption" placeholder="请选择依赖方式">
+        <el-option
+          v-for="item in relyOptions"
+          :key="item.value"
+          :label="item.label"
+          :value="item.value">
+        </el-option>
+      </el-select>
+      <el-input v-show="relyOption === '0'" v-model="relaVal" placeholder="请输入依赖内容"></el-input>
+
+      <el-select v-show="relyOption === '1'" v-model="relaVal" placeholder="请选择依赖字段">
+        <el-option
+          v-for="item in relyFileds.tableFieldList"
+          :key="item.fieldName"
+          :label="item.fieldDescription"
+          :value="item.fieldName">
+        </el-option>
+      </el-select>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="isSearchCancel">取 消</el-button>
+        <el-button type="primary" @click="isSearchBtn">确 定</el-button>
+      </span>
+      </el-dialog>
+    </div>
+    
   </div>
 </template>
 <script>
@@ -414,9 +478,28 @@ import json from "highlight.js/lib/languages/json";
 export default {
   name: "relateTable",
   components: { Treeselect },
-
+  dicts: ["sys_time_format", "table_statistic_type"],
   data() {
     return {
+      // 包含查询依赖字段dialog
+      isSearchDialog: false,
+      isSearchIndex: null,
+      // 依赖方式
+      relyOption: null,
+      relyOptions:[
+        {
+         value: '0',
+         label: '自定义依赖值'
+        },
+        {
+          value: '1',
+          label: '依赖其他字段'
+        }
+      ],
+      // 依赖值
+      relaVal: '',
+      // 上个表格名称及字段
+      relyFileds: {},
       addDragData:[],
       // 创建data需要的参数
       // data: {
@@ -474,6 +557,8 @@ export default {
         },
       ],
       searchFieldList: [],
+      // 依赖字段
+      relyFiledsList: [],
       // 修改row
       updataGroupRow:{},
       // 遮罩层
@@ -537,6 +622,9 @@ export default {
         title: "",
         tableName: "",
         selectFields: "",
+        isAsc: false,
+        timeFormate: "",
+        orderByColumn: "",
       },
       tableGroupList: [],
       // 成员表格提示
@@ -563,6 +651,9 @@ export default {
       databaseType: (state) => state.user.dataSource.databaseType,
       username: (state) => state.user.dataSource.username,
     }),
+    orderByFieldList() {
+      return this.tableFieldList;
+    },
   },
   watch: {
     'tableItemForm.tableName': function (val) {
@@ -585,6 +676,34 @@ export default {
     },
   },
   methods: {
+    // 是否包含查询switch
+    isSearchChange(status, row,index){
+      this.isSearchDialog = status
+      this.isSearchIndex = index
+    },
+    // 添加依赖字段取消
+    isSearchCancel(){
+      this.relyOption = null
+      this.relaVal = ''
+      this.isSearchDialog = false
+      this.tableFieldList[this.isSearchIndex].isSearch = false
+    },
+    isSearchBtn(){
+      console.log(this.relaVal);
+      console.log(this.relyFileds.tableName);
+      if(this.relyFileds.tableName !== undefined){
+        this.relyFiledsList.push({
+          tableName:this.relyFileds.tableName,
+          relaVal: this.relaVal
+        })
+      } else {
+        this.relyFiledsList.push({
+          relaVal: this.relaVal
+        })
+      }
+      console.log(this.relyFiledsList);
+      this.isSearchDialog = false
+    },
     // 获取路由表单数据
     async getMenuList() {
     let res = await listGroup();
@@ -837,6 +956,15 @@ export default {
               columns,
               searchFieldList,
             );
+            this.relyFiledsList.forEach((item,index)=>{
+              if(item.tableName){
+                searchFieldList[index] = searchFieldList[index]+':' + item.tableName+'.'+ item.relaVal
+              } else {
+                searchFieldList[index] = searchFieldList[index] + ':' + item.relaVal
+              }
+            })
+            console.log(searchFieldList);
+            // console.log(searchFieldList);
           // 判断是否有包含查询字段
           if (!searchFieldList.length) {
           this.$message.warning("请至少选择一个包含查询字段");
@@ -849,7 +977,9 @@ export default {
             formData: this.groupForm,
           }
           // 判断修改还是新增
-          if(this.relateTitle){    
+          if(this.relateTitle){ 
+            this.relyFileds.tableFieldList = this.tableFieldList
+            this.relyFileds.tableName = this.tableItemForm.tableName
             this.tableItemForm.rowId = Date.now();
                        
             this.groupList.push({tableFieldList: this.tableFieldList, tableItemForm: this.tableItemForm})
@@ -865,8 +995,8 @@ export default {
             tableKey: tableKey,
             dtTableName: this.tableItemForm.tableName,
             primaryKey: this.tableItemForm.selectFields,
-            orderByColumn: '',
-            sortOrder: false,
+            orderByColumn: this.tableItemForm.orderByColumn,
+            sortOrder: this.tableItemForm.isAsc,
             sqlKey: sqlKey,
             dtColumnName: columns, 
             timeFormat: 'yyyy-MM-dd',
@@ -897,13 +1027,16 @@ export default {
           this.isShowForm = false
           this.tableItemForm = {}
           this.tableFieldList = []
-
+          this.relyFiledsList = []
         } else {
           this.$message.error("请完善表单信息");
           return false;
         }
       });
     },
+    // confirmAddHandler(){
+    //   console.log(this.tableFieldList)
+    // },
     // 修改一个表格数据
     relateOne(row){
       // console.log(row);
@@ -1243,6 +1376,14 @@ export default {
 ::v-deep .el-dialog:not(.is-fullscreen){
   width: 900px !important;
 }
+.isSearch {
+  ::v-deep .el-dialog:not(.is-fullscreen){
+  width: 320px !important;
+  }
+  ::v-deep .el-input--medium .el-input__inner{
+    margin-bottom: 10px !important;
+  }
+}
 .tablefiled{
   ::v-deep .el-input--medium .el-input__inner{
     width: 70px !important;

+ 0 - 6
ruoyi-ui/src/views/relateTable/relateTableEdit.vue

@@ -120,12 +120,6 @@ export default {
       console.log(`第${index}个关联表的${row}行选中了,tableId:${tableId}`);
       // 更新对应card数据,并清空后续表格数据
     },
-    tansToParent(val){
-      console.log(val)
-    },
-    formtansToParent(val){
-      console.log(val);
-    }
   },
 };
 </script>

+ 3 - 3
ruoyi-ui/src/views/tableMange/index.vue

@@ -1599,7 +1599,7 @@ export default {
               dragTableStyleList: this.$refs.styleTableRef.getSaveData(),
             };
 
-            this.dragTableStatisticList?.forEach((item) => {
+            this.dragTableStatisticList.forEach((item) => {
               if (this.tId == "") {
                 item.tableKey = this.tableKey;
                 this.staticSqlKey = uuidv4();
@@ -1647,12 +1647,12 @@ export default {
               res = await addDragTable(data);
 
               this.dragTableStatisticList.forEach((item) => {
-                item.tableKey = this.tableKey;
+                item.tableKey = this.uuid;
               });
               if (res.code == 200 && this.dragTableStatisticList.length !== 0) {
                 // 新增统计数据
                 res1 = addStatistic({
-                  tableKey: this.tableKey,
+                  tableKey: this.uuid,
                   dragTableStatisticList: this.dragTableStatisticList,
                   tableSqlList: this.tableSqlList,
                   searchFieldList: this.searchFieldList,

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

@@ -338,7 +338,7 @@ export default {
         .finally((fes) => {
           if (this.templateInfo == {}) return;
           // 调用查询需要携带当前table的唯一标识
-          this.queryParams.queryMap.sqlKey = this.templateInfo.template.sqlKey;
+          this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
           this.queryParams.orderByColumn = camelCase(
             this.queryParams.orderByColumn || ""
           );
@@ -691,7 +691,7 @@ export default {
         .catch((res) => {
           this.$modal.msgError("表单校验失败,请规范填写数据");
         });
-        
+
     },
     // 使用提交数据类型的按钮获取数据
     tempSubBtn(getData) {