浏览代码

需求--分享权限控制

qianming 3 年之前
父节点
当前提交
1f206bd220

+ 1 - 0
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/controller/ReportDashboardController.java

@@ -101,6 +101,7 @@ public class ReportDashboardController {
 
     @PostMapping("/share")
     @GaeaAuditLog(pageTitle = "分享")
+    @Permission(code = "bigScreenManage", name = "分享报表")
     public ResponseBean share(@Validated @RequestBody ReportShareDto dto) {
         return ResponseBean.builder().data(reportShareService.insertShare(dto)).build();
     }

+ 13 - 0
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/controller/ReportExcelController.java

@@ -10,8 +10,11 @@ import com.anjiplus.template.gaea.business.modules.reportexcel.controller.dto.Re
 import com.anjiplus.template.gaea.business.modules.reportexcel.controller.param.ReportExcelParam;
 import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel;
 import com.anjiplus.template.gaea.business.modules.reportexcel.service.ReportExcelService;
+import com.anjiplus.template.gaea.business.modules.reportshare.controller.dto.ReportShareDto;
+import com.anjiplus.template.gaea.business.modules.reportshare.service.ReportShareService;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 /**
@@ -27,6 +30,9 @@ public class ReportExcelController extends GaeaBaseController<ReportExcelParam,
     @Autowired
     private ReportExcelService reportExcelService;
 
+    @Autowired
+    private ReportShareService reportShareService;
+
     @Override
     public GaeaBaseService<ReportExcelParam, ReportExcel> getService() {
         return reportExcelService;
@@ -75,4 +81,11 @@ public class ReportExcelController extends GaeaBaseController<ReportExcelParam,
 //        return ResponseBean.builder().code(ResponseCode.SUCCESS_CODE)
 //                .build();
 //    }
+
+    @PostMapping("/share")
+    @GaeaAuditLog(pageTitle = "excel分享")
+    @Permission(code = "reportExcel", name = "分享报表")
+    public ResponseBean share(@Validated @RequestBody ReportShareDto dto) {
+        return ResponseBean.builder().data(reportShareService.insertShare(dto)).build();
+    }
 }

+ 3 - 0
report-core/src/main/resources/db/migration/V1.0.23__add_excelshare_authority.sql

@@ -0,0 +1,3 @@
+INSERT INTO `aj_report`.`access_authority`(`parent_target`, `target`, `target_name`, `action`, `action_name`, `sort`, `enable_flag`, `delete_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `version`) VALUES ('report', 'excelManage', '表格报表', 'share', '分享报表', 231, 1, 0, 'admin', now(), 'admin', now(), 1);
+
+INSERT INTO `aj_report`.`access_role_authority`(`role_code`, `target`, `action`) VALUES ('root', 'excelManage', 'share');

+ 8 - 0
report-ui/src/api/reportShare.js

@@ -16,6 +16,14 @@ export function reportShareAdd(data) {
   })
 }
 
+export function excelShareAdd(data) {
+  return request({
+    url: 'reportExcel/share',
+    method: 'post',
+    data
+  })
+}
+
 export function reportShareDelay(data) {
   return request({
     url: 'reportShare/shareDelay',

+ 34 - 21
report-ui/src/components/AnjiPlus/anji-crud/anji-crud.vue

@@ -269,16 +269,19 @@
             >
               <template slot-scope="scope">
                 <div v-if="option.rowButtons.length <= 2">
-                  <el-button
-                    v-for="(item, index) in option.rowButtons"
-                    :key="index"
-                    v-permission="item.permission"
-                    :disabled="isDisabledButton(item, scope.row)"
-                    :type="item.type || 'text'"
-                    size="small"
-                    @click="item.click(scope.row)"
+                  <template v-for="(item, index) in option.rowButtons">
+                    <el-button
+                      v-if="isHide(item, scope.row)"
+                      :key="index"
+                      v-permission="item.permission"
+                      :disabled="isDisabledButton(item, scope.row)"
+                      :type="item.type || 'text'"
+                      size="small"
+                      @click="item.click(scope.row)"
                     >{{ handlegetLable(scope.row, item.label) }}</el-button
-                  >
+                    >
+                  </template>
+
                 </div>
                 <div v-else>
                   <el-button
@@ -299,20 +302,22 @@
                     </span>
                     <el-dropdown-menu slot="dropdown">
                       <el-dropdown-item class="clearfix">
-                        <el-button
-                          v-for="(item, index) in option.rowButtons.filter(
+                        <template v-for="(item, index) in option.rowButtons.filter(
                             (el, index) => index > 0
-                          )"
-                          :key="index"
-                          v-permission="item.permission"
-                          :type="item.type || 'text'"
-                          :disabled="isDisabledButton(item, scope.row)"
-                          size="small"
-                          @click="item.click(scope.row)"
+                          )">
+                          <el-button
+                            v-if="isHide(item, scope.row)"
+                            :key="index"
+                            v-permission="item.permission"
+                            :type="item.type || 'text'"
+                            :disabled="isDisabledButton(item, scope.row)"
+                            size="small"
+                            @click="item.click(scope.row)"
                           >{{
-                            handlegetLable(scope.row, item.label)
-                          }}</el-button
-                        >
+                              handlegetLable(scope.row, item.label)
+                            }}</el-button
+                          >
+                        </template>
                       </el-dropdown-item>
                     </el-dropdown-menu>
                   </el-dropdown>
@@ -665,6 +670,14 @@ export default {
         return !!item.disabled;
       }
     },
+    // 是否显示
+    isHide(item, row) {
+      if (typeof item.isHide === "function") {
+        return item.isHide(row);
+      } else {
+        return !item.isHide;
+      }
+    },
     // 弹框被关闭时的回调事件
     editDialogClosedEvent(value) {
       // 把列表页中弹框打开标记改成已关闭

+ 2 - 3
report-ui/src/views/excelreport/components/share.vue

@@ -90,7 +90,7 @@
   </el-dialog>
 </template>
 <script>
-import { reportShareAdd } from "@/api/reportShare";
+import { excelShareAdd } from "@/api/reportShare";
 import { getDictList } from "@/api/dict-data"; // 获取数据字典
 import Dictionary from "@/components/Dictionary/index";
 export default {
@@ -175,8 +175,7 @@ export default {
       this.dialogForm.reportType = this.reportType;
       this.dialogForm.reportCode = this.reportCode;
       this.dialogForm.shareUrl = window.location.href;
-      console.log(this.dialogForm)
-      const { code, data } = await reportShareAdd(this.dialogForm);
+      const { code, data } = await excelShareAdd(this.dialogForm);
       if (code != "200") return;
       this.shareLinkFlag1 = false;
       this.$message({

+ 1 - 1
report-ui/src/views/excelreport/index.vue

@@ -64,7 +64,7 @@
                   class="view"
                   type="text"
                   @click="share(item)"
-                  v-permission="'bigScreenManage:share'"
+                  v-permission="'excelManage:share'"
                 />
                 <el-button
                   icon="el-icon-view"

+ 3 - 1
report-ui/src/views/reportManage/components/share.vue

@@ -91,6 +91,7 @@
 </template>
 <script>
 import { reportShareAdd } from "@/api/reportShare";
+import { excelShareAdd } from "@/api/reportShare";
 import { getDictList } from "@/api/dict-data"; // 获取数据字典
 import Dictionary from "@/components/Dictionary/index";
 export default {
@@ -175,7 +176,8 @@ export default {
       this.dialogForm.reportType = this.reportType;
       this.dialogForm.reportCode = this.reportCode;
       this.dialogForm.shareUrl = window.location.href;
-      const { code, data } = await reportShareAdd(this.dialogForm);
+      const urlType = this.reportType == 'report_screen' ? reportShareAdd(this.dialogForm) : excelShareAdd(this.dialogForm)
+      const { code, data } = await urlType
       if (code != "200") return;
       this.shareLinkFlag1 = false;
       this.$message({

+ 25 - 0
report-ui/src/views/reportManage/index.vue

@@ -123,6 +123,17 @@ export default {
           {
             label: "分享",
             permission: "bigScreenManage:share",
+            isHide: (row) => {
+              return row.reportType == 'report_screen'
+            },
+            click: this.shareReport
+          },
+          {
+            label: "分享",
+            permission: "excelManage:share",
+            isHide: (row) => {
+              return row.reportType == 'report_excel'
+            },
             click: this.shareReport
           },
           {
@@ -361,6 +372,20 @@ export default {
       this.reportTypeForShareDialog = val.reportType;
       this.visibleForShareDialog = true;
     },
+    checkReport(val) {
+      if ("report_screen" == val.reportType) {
+        return true;
+      }else {
+        return false;
+      }
+    },
+    checkExcel(val) {
+      if ("report_excel" == val.reportType) {
+        return true;
+      }else {
+        return false;
+      }
+    },
     //复制
     async copyReport(val) {
       this.copyVisible = true;