Przeglądaj źródła

!74 hotfix-0.9.7.2
Merge pull request !74 from Foming/dev

Foming 3 lat temu
rodzic
commit
adb14afc85

+ 5 - 0
report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java

@@ -85,7 +85,12 @@ public class TokenFilter implements Filter {
             return;
         }
 
+
         if (SLASH.equals(uri) || SLASH.concat(BusinessConstant.SLASH).equals(uri)) {
+            if (BusinessConstant.SLASH.equals(uri)) {
+                response.sendRedirect("/index.html");
+                return;
+            }
             response.sendRedirect(SLASH + "/index.html");
             return;
         }

+ 3 - 3
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/controller/ReportController.java

@@ -43,11 +43,11 @@ public class ReportController extends GaeaBaseController<ReportParam, Report, Re
         return new ReportDto();
     }
 
-    @GetMapping("/copy")
+    @PostMapping("/copy")
     @Permission(code = "copy", name = "复制")
     @GaeaAuditLog(pageTitle = "复制")
-    public ResponseBean copy(@RequestParam("reportId") Long reportId) {
-        reportService.copy(reportId);
+    public ResponseBean copy(@RequestBody ReportDto dto) {
+        reportService.copy(dto);
         return ResponseBean.builder().build();
     }
 }

+ 2 - 2
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/ReportService.java

@@ -21,7 +21,7 @@ public interface ReportService extends GaeaBaseService<ReportParam, Report> {
 
     /**
      * 复制大屏
-     * @param reportId
+     * @param dto
      */
-    void copy(Long reportId);
+    void copy(ReportDto dto);
 }

+ 15 - 11
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/impl/ReportServiceImpl.java

@@ -3,7 +3,9 @@ package com.anjiplus.template.gaea.business.modules.report.service.impl;
 import com.anji.plus.gaea.constant.BaseOperationEnum;
 import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
 import com.anji.plus.gaea.exception.BusinessException;
+import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
 import com.anji.plus.gaea.utils.GaeaBeanUtils;
+import com.anjiplus.template.gaea.business.code.ResponseCode;
 import com.anjiplus.template.gaea.business.enums.ReportTypeEnum;
 import com.anjiplus.template.gaea.business.modules.dashboard.dao.entity.ReportDashboard;
 import com.anjiplus.template.gaea.business.modules.dashboard.service.ReportDashboardService;
@@ -16,6 +18,7 @@ import com.anjiplus.template.gaea.business.modules.report.service.ReportService;
 import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel;
 import com.anjiplus.template.gaea.business.modules.reportexcel.service.ReportExcelService;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -107,10 +110,16 @@ public class ReportServiceImpl implements ReportService {
     }
 
     @Override
-    public void copy(Long reportId) {
-        Report report = selectOne(reportId);
+    public void copy(ReportDto dto) {
+        if (null == dto.getId()) {
+            throw BusinessExceptionBuilder.build(ResponseCode.NOT_NULL, "id");
+        }
+        if (StringUtils.isBlank(dto.getReportCode())) {
+            throw BusinessExceptionBuilder.build(ResponseCode.NOT_NULL, "报表编码");
+        }
+        Report report = selectOne(dto.getId());
         String reportCode = report.getReportCode();
-        Report copyReport = copyReport(report);
+        Report copyReport = copyReport(report, dto);
         //复制主表数据
         insert(copyReport);
         String copyReportCode = copyReport.getReportCode();
@@ -150,17 +159,12 @@ public class ReportServiceImpl implements ReportService {
         }
     }
 
-    private Report copyReport(Report report){
+    private Report copyReport(Report report, ReportDto dto){
         //复制主表数据
         Report copyReport = new Report();
         GaeaBeanUtils.copyAndFormatter(report, copyReport);
-        copyReport.setId(null);
-        String copyReportCode = copyReport.getReportCode().concat("_").concat(String.valueOf(System.currentTimeMillis()));
-        if (copyReportCode.length() >= 100) {
-            copyReportCode = copyReportCode.substring(0, 100);
-        }
-        copyReport.setReportCode(copyReportCode);
-        copyReport.setReportName(copyReport.getReportName().concat("_copy"));
+        copyReport.setReportCode(dto.getReportCode());
+        copyReport.setReportName(dto.getReportName());
         return copyReport;
     }
 

+ 6 - 4
report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java

@@ -97,11 +97,13 @@ public class FileUtil {
             if (!file.getParentFile().exists()) {
                 file.getParentFile().mkdirs();
             }
-            FileWriter fw = new FileWriter(filePath);
-            BufferedWriter bw = new BufferedWriter(fw);
+            FileOutputStream outputStream = new FileOutputStream(filePath);
+            OutputStreamWriter outputWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
+            BufferedWriter bw = new BufferedWriter(outputWriter);
             bw.write(content);
             bw.close();
-            fw.close();
+            outputWriter.close();
+            outputStream.close();
         } catch (Exception e) {
             log.error("写入文件失败", e);
             throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage());
@@ -178,7 +180,7 @@ public class FileUtil {
         try {
             out = new FileOutputStream(dstFile);
             CheckedOutputStream cos = new CheckedOutputStream(out, new CRC32());
-            zipOut = new ZipOutputStream(cos);
+            zipOut = new ZipOutputStream(cos, StandardCharsets.UTF_8);
             String baseDir = "";
             compress(srcFile, zipOut, baseDir);
         } catch (IOException e) {

+ 2 - 2
report-ui/src/api/reportmanage.js

@@ -42,8 +42,8 @@ export function reportDetail(data) {
 export function reportCopy(data) {
   return request({
     url: '/report/copy',
-    method: 'get',
-    params: { reportId: data.id }
+    method: 'post',
+    data
   })
 }
 

+ 1 - 0
report-ui/src/views/bigscreenDesigner/designer/components/dynamicForm.vue

@@ -344,6 +344,7 @@ export default {
       } else {
         this.$set(this.formData, key, val);
       }
+
       this.$emit("onChanged", this.formData);
       // key为当前用户操作的表单组件
       for (let i = 0; i < this.options.length; i++) {

+ 19 - 9
report-ui/src/views/bigscreenDesigner/designer/index.vue

@@ -199,7 +199,9 @@
               'background-origin': 'initial',
               'background-clip': 'initial'
             }"
-            @click.self="setOptionsOnClickScreen"  @drop="widgetOnDragged($event)" @dragover="dragOver($event)"
+            @click.self="setOptionsOnClickScreen"
+            @drop="widgetOnDragged($event)"
+            @dragover="dragOver($event)"
           >
             <div v-if="grade" class="bg-grid"></div>
             <widget
@@ -332,7 +334,7 @@ export default {
       },
       // 大屏的标记
       screenCode: "",
-      dragWidgetCode:'',   //从工具栏拖拽的组件code
+      dragWidgetCode: "", //从工具栏拖拽的组件code
       // 大屏画布中的组件
       widgets: [
         {
@@ -663,16 +665,16 @@ export default {
     getPXUnderScale(px) {
       return this.bigscreenScaleInWorkbench * px;
     },
-    dragStart( widgetCode) {
-        this.dragWidgetCode =widgetCode;
+    dragStart(widgetCode) {
+      this.dragWidgetCode = widgetCode;
     },
     dragEnd() {
-        this.dragWidgetCode=''
+      this.dragWidgetCode = "";
     },
-    dragOver(evt){
-      evt.preventDefault()
-      evt.stopPropagation()
-      evt.dataTransfer.dropEffect = 'copy'
+    dragOver(evt) {
+      evt.preventDefault();
+      evt.stopPropagation();
+      evt.dataTransfer.dropEffect = "copy";
     },
     // 拖动一个组件放到工作区中去,在拖动结束时,放到工作区对应的坐标点上去
     widgetOnDragged(evt) {
@@ -819,9 +821,14 @@ export default {
     },
     // 将当前选中的组件,右侧属性值更新
     widgetValueChanged(key, val) {
+      console.log("key", key);
+      console.log("val", val);
+      console.log(this.widgetOptions);
       if (this.screenCode == "screen") {
         let newSetup = new Array();
         this.dashboard = this.deepClone(val);
+        console.log("asd", this.dashboard);
+        console.log(this.widgetOptions);
         if (this.bigscreenWidth != this.dashboard.width) {
           this.bigscreenWidth = this.dashboard.width;
         }
@@ -833,9 +840,12 @@ export default {
             el.value = this.bigscreenWidth;
           } else if (el.name == "height") {
             el.value = this.bigscreenHeight;
+          } else if (this.dashboard.hasOwn(el.name)) {
+            el["value"] = this.dashboard[el.name];
           }
           newSetup.push(el);
         });
+        console.log(newSetup);
         this.widgetOptions.setup = newSetup;
       } else {
         for (let i = 0; i < this.widgets.length; i++) {

+ 1 - 1
report-ui/src/views/layout/components/Sidebar/index.vue

@@ -3,7 +3,7 @@
     <div class="admin-title" @click="goBigScreen">
       <div class="con">
         <img src="../../../../../static/logo-dp.png" width="50" />
-        <span class="version">V0.9.7</span>
+        <span class="version">V0.9.7.2</span>
       </div>
     </div>
     <el-menu

+ 84 - 0
report-ui/src/views/reportManage/components/copyDialog.vue

@@ -0,0 +1,84 @@
+<!--
+ * @Descripttion: 
+ * @version: 
+ * @Author: qianlishi
+ * @Date: 2022-05-17 16:55:05
+ * @LastEditors: qianlishi
+ * @LastEditTime: 2022-05-17 17:38:54
+-->
+<template>
+  <el-dialog
+    class="tree_dialog"
+    title="报表管理--复制"
+    width="30%"
+    :close-on-click-modal="false"
+    center
+    :visible.sync="visib"
+    :before-close="close"
+  >
+    <el-form
+      :model="form"
+      :rules="rules"
+      ref="ruleForm"
+      label-width="100px"
+      class="demo-ruleForm"
+    >
+      <el-form-item label="报表名称" prop="reportName">
+        <el-input v-model="form.reportName" />
+      </el-form-item>
+      <el-form-item label="报表编码" prop="reportCode">
+        <el-input v-model="form.reportCode" />
+      </el-form-item>
+    </el-form>
+    <div slot="footer" style="text-align: center">
+      <el-button type="danger" plain @click="close">取消</el-button>
+      <el-button type="primary" plain @click="save">保存</el-button>
+    </div>
+  </el-dialog>
+</template>
+<script>
+import { reportCopy } from "@/api/reportmanage";
+export default {
+  props: {
+    visib: Boolean,
+    rowData: Object
+  },
+  data() {
+    return {
+      form: {},
+      rules: {
+        reportName: [
+          { required: true, message: "请输入报表名称", trigger: "blur" }
+        ],
+        reportCode: [
+          { required: true, message: "请输入报表编码", trigger: "blur" }
+        ]
+      }
+    };
+  },
+  watch: {
+    visib(val) {
+      this.form = this.deepClone(this.rowData);
+      this.form.reportCode = this.form.reportCode + "_" + Date.now();
+    }
+  },
+  methods: {
+    save() {
+      this.$refs.ruleForm.validate(async valid => {
+        if (valid) {
+          console.log(this.form);
+          const { code } = await reportCopy(this.form);
+          if (code != "200") {
+            return;
+          }
+          this.$message.success("复制成功");
+          this.close();
+        }
+      });
+    },
+    close() {
+      this.$emit("close");
+    }
+  }
+};
+</script>

+ 21 - 8
report-ui/src/views/reportManage/index.vue

@@ -4,7 +4,7 @@
  * @Author: qianlishi
  * @Date: 2021-12-11 14:48:27
  * @LastEditors: qianlishi
- * @LastEditTime: 2022-05-15 10:44:58
+ * @LastEditTime: 2022-05-17 17:38:44
 -->
 <template>
   <anji-crud ref="listPage" :option="crudOption">
@@ -15,6 +15,7 @@
         :reportName="reportNameForShareDialog"
         @handleClose="visibleForShareDialog = false"
       />
+      <copyDialog :visib.sync="copyVisible" :rowData="rowData" @close="close" />
     </template>
   </anji-crud>
 </template>
@@ -28,13 +29,15 @@ import {
   reportCopy
 } from "@/api/reportmanage";
 import Share from "./components/share";
+import copyDialog from "./components/copyDialog.vue";
 import { validateEngOrNum } from "@/utils/validate";
 import { verificationSet } from "@/api/report";
 export default {
   name: "Report",
   components: {
     anjiCrud: require("@/components/AnjiPlus/anji-crud/anji-crud").default,
-    Share
+    Share,
+    copyDialog
   },
   data() {
     return {
@@ -306,7 +309,11 @@ export default {
             }
           }
         }
-      }
+      },
+
+      // 复制
+      copyVisible: false,
+      rowData: {}
     };
   },
 
@@ -358,11 +365,17 @@ export default {
     },
     //复制
     async copyReport(val) {
-      const { code } = await reportCopy(val);
-      if (code != "200") {
-        return;
-      }
-      this.$message.success("复制成功");
+      this.copyVisible = true;
+      this.rowData = val;
+      // const { code } = await reportCopy(val);
+      // if (code != "200") {
+      //   return;
+      // }
+      // this.$message.success("复制成功");
+      // this.$refs.listPage.handleQueryForm("query");
+    },
+    close() {
+      this.copyVisible = false;
       this.$refs.listPage.handleQueryForm("query");
     }
   }