rui.jiang 1 gadu atpakaļ
vecāks
revīzija
db786f9974

+ 9 - 1
src/api/performance.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2024-06-03 09:29:50
- * @LastEditTime: 2024-06-06 16:00:28
+ * @LastEditTime: 2024-06-07 16:11:24
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/api/performance。.js
@@ -111,3 +111,11 @@ export function analysisErrEdit(data) {
     data,
   });
 }
+//分析详情 接口/analysis/analysisDetail
+export function analysisDetail(data) {
+  return request({
+    url: "/energy-manage-service/analysis/analysisDetail",
+    method: "post",
+    data,
+  });
+}

+ 17 - 2
src/api/system.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2024-05-20 09:36:55
- * @LastEditTime: 2024-05-22 09:13:09
+ * @LastEditTime: 2024-06-11 10:01:44
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/api/system.js
@@ -141,7 +141,6 @@ export function getDetailRoleAuth(data) {
   });
 }
 //更新角色菜单权限
-
 export function updateRolePermission(data) {
   return request({
     url: "/energy-manage-service/sysrole/updateRolePermission",
@@ -149,6 +148,22 @@ export function updateRolePermission(data) {
     data,
   });
 }
+//角色获取组织架构权限
+export function getRoleOrganization(data) {
+  return request({
+    url: "/energy-manage-service/sysrole/getRoleOrganization",
+    method: "post",
+    data,
+  });
+}
+//更新角色数据权限
+export function updateRoleOrganization(data) {
+  return request({
+    url: "/energy-manage-service/sysrole/updateRoleOrganization",
+    method: "post",
+    data,
+  });
+}
 
 //获取菜单列表
 export function getAllMenu(data) {

BIN
src/assets/upload.png


+ 64 - 19
src/components/Tinymce.vue

@@ -14,7 +14,6 @@ import { quillEditor } from "vue-quill-editor";
 import "quill/dist/quill.core.css";
 import "quill/dist/quill.snow.css";
 import "quill/dist/quill.bubble.css";
-import Quill from "quill";
 
 export default {
   components: {
@@ -37,12 +36,13 @@ export default {
                 { indent: "-1" },
                 { indent: "+1" },
               ],
-              ["link", "image", "video"],
+              ["link", "image", "video", "custom-file"], // 添加自定义文件图标
               ["clean"],
             ],
             handlers: {
-              image: this.imageHandler,
+              // image: this.imageHandler,
               video: this.videoHandler,
+              "custom-file": this.fileHandler, // 自定义文件处理函数
             },
           },
         },
@@ -51,7 +51,7 @@ export default {
   },
   methods: {
     onEditorReady(editor) {
-      // Any additional setup for the editor can be done here
+      console.log(editor, "editor");
     },
     imageHandler() {
       const input = document.createElement("input");
@@ -64,16 +64,18 @@ export default {
         if (file) {
           const formData = new FormData();
           formData.append("file", file);
-
-          try {
-            const response = await this.uploadImage(formData);
-            const url = response.data.url; // 根据你的实际响应数据结构
-            const quill = this.$refs.quillEditor.quill;
-            const range = quill.getSelection();
-            quill.insertEmbed(range.index, "image", url);
-          } catch (error) {
-            console.error("Image upload failed", error);
-          }
+          const quill = this.$refs.quillEditor.quill;
+          const range = quill.getSelection();
+          quill.insertEmbed(range.index, "image", formData);
+          // try {
+          //   const response = await this.uploadImage(formData);
+          //   const url = response.data.url; // 根据你的实际响应数据结构
+          //   const quill = this.$refs.quillEditor.quill;
+          //   const range = quill.getSelection();
+          //   quill.insertEmbed(range.index, "image", url);
+          // } catch (error) {
+          //   console.error("Image upload failed", error);
+          // }
         }
       };
     },
@@ -91,7 +93,7 @@ export default {
 
           try {
             const response = await this.uploadVideo(formData);
-            const url = response.data.url; // 根据你的实际响应数据结构
+            const url = response.data.url;
             const quill = this.$refs.quillEditor.quill;
             const range = quill.getSelection();
             quill.insertEmbed(range.index, "video", url);
@@ -101,9 +103,39 @@ export default {
         }
       };
     },
+    fileHandler() {
+      const input = document.createElement("input");
+      input.setAttribute("type", "file");
+      input.setAttribute("accept", ".doc,.docx,.pdf");
+      input.click();
+
+      input.onchange = async () => {
+        const file = input.files[0];
+        if (file) {
+          const formData = new FormData();
+          formData.append("file", file);
+          const quill = this.$refs.quillEditor.quill;
+          const range = quill.getSelection();
+          quill.insertText(
+            range.index,
+            `File uploaded: ${file.name} (URL: ${formData})`
+          );
+          // try {
+          //   const response = await this.uploadFile(formData);
+          //   const url = response.data.url;
+          //   const quill = this.$refs.quillEditor.quill;
+          //   const range = quill.getSelection();
+          //   quill.insertText(
+          //     range.index,
+          //     `File uploaded: ${file.name} (URL: ${url})`
+          //   );
+          // } catch (error) {
+          //   console.error("File upload failed", error);
+          // }
+        }
+      };
+    },
     async uploadImage(formData) {
-      // 在这里实现你的图片上传逻辑
-      // 示例:使用 axios 进行上传
       const response = await axios.post("/api/upload/image", formData, {
         headers: {
           "Content-Type": "multipart/form-data",
@@ -112,8 +144,6 @@ export default {
       return response;
     },
     async uploadVideo(formData) {
-      // 在这里实现你的视频上传逻辑
-      // 示例:使用 axios 进行上传
       const response = await axios.post("/api/upload/video", formData, {
         headers: {
           "Content-Type": "multipart/form-data",
@@ -121,10 +151,25 @@ export default {
       });
       return response;
     },
+    async uploadFile(formData) {
+      const response = await axios.post("/api/upload/file", formData, {
+        headers: {
+          "Content-Type": "multipart/form-data",
+        },
+      });
+      return response;
+    },
   },
 };
 </script>
 
 <style scoped>
 /* 添加你需要的样式 */
+::v-deep .ql-snow.ql-toolbar .ql-custom-file {
+  background: url("../assets/upload.png");
+  background-size: 16px 16px;
+  background-position: center center;
+  background-repeat: no-repeat;
+  /*background: red;*/
+}
 </style>

+ 46 - 2
src/utils/getMenu.js

@@ -1,11 +1,12 @@
 /*
  * @Author: your name
  * @Date: 2024-05-21 14:21:20
- * @LastEditTime: 2024-05-21 17:36:17
+ * @LastEditTime: 2024-06-11 14:20:54
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/utils/getMenu.js
  */
+//角色菜单权限筛选
 export const checkListFn = (data) => {
   let list = [];
   recursiveFind(data);
@@ -24,7 +25,8 @@ export const checkListFn = (data) => {
 };
 
 // data 是一个树形数组结构数据,checkIdList是一个一维数组
-// 需求:递归循环data,data.permissionId在checkIdList这个数组中,父级节点和祖先节点的permissionId也需要push到新的一维数组,这个方法如何改?
+// 需求:递归循环data,data.permissionId在checkIdList这个数组中,父级节点和祖先节点的permissionId也需要push到新的一维数组。
+//角色菜单权限筛选
 export const getcheckListFn = (checkIdList, data) => {
   let list = [];
   console.log(checkIdList, "checkIdList");
@@ -52,3 +54,45 @@ export const getcheckListFn = (checkIdList, data) => {
 
   return list;
 };
+//角色数据权限筛选
+export const checkDataAuthTreeFn = (data) => {
+  let list = [];
+  recursiveFind(data);
+  function recursiveFind(data) {
+    data.forEach((item) => {
+      if (item.checked === 1) {
+        list.push(item.codeNumber);
+      }
+      if (item.children && item.children.length > 0) {
+        recursiveFind(item.children); // 递归遍历子节点
+      }
+    });
+  }
+  return list;
+};
+//角色数据权限筛选
+export const getCheckDataAuthTreeFn = (checkIdList, data) => {
+  let list = [];
+  function recursiveFind(node, ancestors = []) {
+    if (checkIdList.includes(node.codeNumber)) {
+      // 将当前节点的 codeNumber 加入到列表中
+      list.push({ codeNumber: node.codeNumber, codeType: node.type });
+      // 将当前节点的祖先节点的 codeNumber 加入到列表中
+      ancestors.forEach((ancestor) => {
+        list.push({ codeNumber: ancestor.codeNumber, codeType: node.type });
+      });
+    }
+    // 递归遍历子节点
+    if (node.children && node.children.length > 0) {
+      node.children.forEach((child) => {
+        recursiveFind(child, [...ancestors, node]);
+      });
+    }
+  }
+  // 从根节点开始递归遍历
+  data.forEach((root) => {
+    recursiveFind(root);
+  });
+
+  return list;
+};

+ 24 - 17
src/views/dataAdministration/index.vue

@@ -109,18 +109,25 @@
           width="150"
         >
           <template slot-scope="scope">
-            <el-button @click="handleEdit(scope.row)" type="text" size="small"
+            <el-button
+              v-if="
+                scope.row.transferState !== -1 &&
+                (scope.row.transferAddr !== null ||
+                  scope.row.transferAddr !== '')
+              "
+              @click="handleEdit(scope.row)"
+              type="text"
+              size="small"
               >编辑</el-button
             >
             <el-button @click="handleClick(scope.row)" type="text" size="small"
               >下载</el-button
             >
-
             <el-button
               v-if="
                 scope.row.transferState == -1 &&
-                (scope.row.transferFileAddr === null ||
-                  scope.row.transferFileAddr === '')
+                (scope.row.transferAddr === null ||
+                  scope.row.transferAddr === '')
               "
               @click="editTransferState(scope.row, '转换')"
               type="text"
@@ -186,11 +193,11 @@
             <el-col :span="11">
               <el-form-item
                 :label="item.transferTypeName + ':'"
-                :prop="'transferFileAddr_' + index"
+                :prop="'transferAddr_' + index"
                 :rules="getFileAddrRules(index)"
               >
                 <el-input
-                  v-model="item.transferFileAddr"
+                  v-model="item.transferAddr"
                   :placeholder="'请输入' + item.transferTypeName"
                   size="small"
                 ></el-input>
@@ -260,7 +267,7 @@
                   newEditForm.dataTransferTypePathDtoList[0].transferTypeName +
                   ':'
                 "
-                prop="dataTransferTypePathDtoList.0.transferFileAddr"
+                prop="dataTransferTypePathDtoList.0.transferAddr"
               >
                 <!-- :rules="{
                   required: true,
@@ -272,7 +279,7 @@
                 <el-input
                   disabled
                   v-model="
-                    newEditForm.dataTransferTypePathDtoList[0].transferFileAddr
+                    newEditForm.dataTransferTypePathDtoList[0].transferAddr
                   "
                   :placeholder="
                     '请输入' +
@@ -386,7 +393,7 @@ export default {
   data() {
     return {
       editTransferStateForm: {
-        transferFileAddr: "",
+        transferAddr: "",
       },
       editTransferStateTitle: "",
       editTransferStateLoading: false,
@@ -471,8 +478,7 @@ export default {
         if (valid) {
           this.loadingViewEdit = true;
           dataTransfer({
-            dataTransferFileAddr:
-              this.editTransferStateForm.dataTransferTypePath,
+            dataTransferAddr: this.editTransferStateForm.dataTransferTypePath,
             dataTransferType: this.editTransferStateForm.transferType,
             batchCode: this.editTransferStateForm.batchCode,
           })
@@ -510,6 +516,7 @@ export default {
       };
       this.editNuedialog = false;
       this.loadingViewEdit = false;
+      this.getTableList();
     },
     editly(formName) {
       this.$refs[formName].validate((valid) => {
@@ -518,7 +525,7 @@ export default {
           editTimeGranularityQuery({
             timeGranularity:
               this.newEditForm.dataTransferTypePathDtoList[0].timeGranularity,
-            transferType:
+            dataTransferType:
               this.newEditForm.dataTransferTypePathDtoList[0].transferType,
             batchCode: this.newEditForm.batchCode,
           })
@@ -527,7 +534,7 @@ export default {
                 message: "编辑成功",
                 type: "success",
               });
-              this.getTableList();
+
               this.editCancel();
             })
             .catch((error) => {
@@ -552,9 +559,9 @@ export default {
       ];
     },
     validateFileAddr(rule, value, callback) {
-      // 判断是否至少有一项 transferFileAddr 有值
+      // 判断是否至少有一项 transferAddr 有值
       const hasFileAddr = this.newform.dataTransferTypePathDtoList.some(
-        (item) => item.transferFileAddr
+        (item) => item.transferAddr
       );
       if (!hasFileAddr) {
         callback(new Error("请至少填写一个数据路径"));
@@ -563,9 +570,9 @@ export default {
       }
     },
     validateTimeGranularity(rule, value, callback, index) {
-      // 判断对应的 transferFileAddr 有值,则对应的 timeGranularity 也必须有值
+      // 判断对应的 transferAddr 有值,则对应的 timeGranularity 也必须有值
       const currentItem = this.newform.dataTransferTypePathDtoList[index];
-      if (currentItem.transferFileAddr && !currentItem.timeGranularity) {
+      if (currentItem.transferAddr && !currentItem.timeGranularity) {
         callback(new Error("请填写时间粒度"));
       } else {
         callback();

+ 71 - 3
src/views/performance/assetssDetail.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2024-05-27 09:25:45
- * @LastEditTime: 2024-06-03 11:19:17
+ * @LastEditTime: 2024-06-12 09:23:05
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/assetssDetail.vue
@@ -9,8 +9,36 @@
 <template>
   <div class="global-variable">
     <h2 style="text-align: center">分析历史记录总览</h2>
+    <el-form
+      :model="formInfo"
+      :rules="rules"
+      ref="formInfo"
+      label-width="100px"
+      class="demo-ruleForm"
+    >
+      <el-form-item label="分析类型" prop="analysisTypeCode">
+        <el-select v-model="formInfo.analysisTypeCode" size="small">
+          <el-option
+            v-for="item in analysisTypeList"
+            :key="item.typeCode"
+            :label="item.typeName"
+            :value="item.typeCode"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="机组编号" prop="fieldEngineCode">
+        <el-select v-model="formInfo.fieldEngineCode" size="small">
+          <el-option
+            v-for="item in windEngineGroupList"
+            :key="item"
+            :label="item"
+            :value="item"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+    </el-form>
     <el-button type="primary" @click="() => $router.go(-1)">返回</el-button>
-    <h4>分析时间:2020-04-20 10:10:10</h4>
+    <h4>分析时间:2020-04-20 10:10:10{{}}</h4>
     <el-card class="box-card analysisType">
       <el-row>
         <el-col :span="12">
@@ -29,12 +57,52 @@
   </div>
 </template>
 <script>
+import { analysisDetail, analysisEditQuery } from "@/api/performance";
 export default {
   data() {
     return {
-      // htmlSrc: require("@/assets/html/A01.html"),
+      analysisTypeList: [],
+      windEngineGroupList: [],
+      detailInfo: {},
+      formInfo: {
+        fieldEngineCode: null,
+        analysisTypeCode: null,
+      },
+      rules: {},
     };
   },
+  created() {
+    //获取分析 分析类型、机组编号 列表
+    this.getWindCodeList();
+    //获取详情信息
+    // this.getDetailInfo();
+  },
+  methods: {
+    async getDetailInfo() {
+      try {
+        const response = await analysisDetail({
+          batchCode: this.$route.query.batchCode,
+          analysisTypeCode: this.formInfo.analysisTypeCode,
+          fieldEngineCode: this.formInfo.fieldEngineCode,
+        });
+        this.detailInfo = response.data;
+      } catch (error) {
+        console.error(error);
+      }
+    },
+    async getWindCodeList() {
+      try {
+        const response = await analysisEditQuery({
+          batchCode: this.$route.query.batchCode,
+        });
+        this.analysisTypeList = response.data.analysisTypeList;
+        this.windEngineGroupList = response.data.windEngineGroupList;
+        this.getDetailInfo();
+      } catch (error) {
+        console.error(error);
+      }
+    },
+  },
 };
 </script>
 <style scoped lang="scss">

+ 6 - 2
src/views/performance/assetssMag.vue

@@ -189,10 +189,14 @@ export default {
       });
     },
     //分析详情
-    handleAssetssDetail() {
+    handleAssetssDetail(row) {
       this.$router.push({
         path: "/home/performance/assetssDetail",
-        query: { id: 123, name: "John" },
+        query: {
+          batchCode: row.batchCode,
+          analysisTypeCode: row.analysisTypeCode,
+          fieldEngineCode: row.fieldEngineCode,
+        },
       });
     },
     abnormalDialog(row, title) {

+ 0 - 5
src/views/performance/components/abnormalDetail.vue

@@ -113,8 +113,6 @@
 </template>
 
 <script>
-import Treeselect from "@riophae/vue-treeselect";
-import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import {
   analysisErrQuery,
   analysisErrAdd,
@@ -124,9 +122,6 @@ import {
 } from "@/api/performance";
 
 export default {
-  components: {
-    Treeselect,
-  },
   props: {
     batchCode: String,
   },

+ 86 - 0
src/views/system/roleMag/components/dataAuth.vue

@@ -0,0 +1,86 @@
+<!--
+ * @Author: your name
+ * @Date: 2024-06-11 09:36:36
+ * @LastEditTime: 2024-06-11 14:18:11
+ * @LastEditors: bogon
+ * @Description: In User Settings Edit
+ * @FilePath: /dashengmag/performance-test/src/views/system/roleMag/components/dataAuth.vue
+-->
+<template>
+  <div>
+    <el-tree
+      :data="menuList"
+      show-checkbox
+      default-expand-all
+      node-key="codeNumber"
+      ref="tree"
+      highlight-current
+      :props="defaultProps"
+    >
+    </el-tree>
+  </div>
+</template>
+
+<script>
+import { getRoleOrganization } from "@/api/system.js";
+import {
+  checkDataAuthTreeFn,
+  getCheckDataAuthTreeFn,
+} from "@/utils/getMenu.js";
+
+export default {
+  props: {
+    treeObj: {
+      type: Object,
+      required: true,
+    },
+  },
+  data() {
+    return {
+      menuList: [],
+      defaultProps: {
+        children: "children",
+        label: "codeName",
+      },
+    };
+  },
+  watch: {
+    treeObj: {
+      handler() {
+        this.getMenuList();
+      },
+      deep: true,
+      immediate: true,
+    },
+  },
+  created() {
+    // this.getMenuList();
+  },
+  methods: {
+    getMenuList() {
+      getRoleOrganization({ roleId: this.treeObj.roleId }).then((res) => {
+        this.menuList = res.data;
+        this.updateTreeCheckState(this.menuList);
+      });
+    },
+    getCheckTreeKey() {
+      const result = getCheckDataAuthTreeFn(
+        this.$refs.tree.getCheckedKeys(),
+        this.menuList
+      );
+      return {
+        organizationCodes: result,
+        roleIdAuth: this.treeObj.roleId,
+      };
+    },
+    updateTreeCheckState(checkList) {
+      console.log("回显数据权限内容");
+      if (this.$refs.tree) {
+        this.$refs.tree.setCheckedKeys(checkDataAuthTreeFn(checkList));
+      }
+    },
+  },
+};
+</script>
+
+<style scoped lang="scss"></style>

+ 53 - 23
src/views/system/roleMag/index.vue

@@ -244,11 +244,13 @@
             ></el-input>
           </el-form-item>
         </el-form>
-        <el-tabs type="border-card" class="tabs">
-          <el-tab-pane label="功能权限"
+        <el-tabs v-model="activeName" type="border-card" class="tabs">
+          <el-tab-pane label="功能权限" name="1"
             ><MenuTree ref="menuTreeRef" :treeObj="treeObj"></MenuTree
           ></el-tab-pane>
-          <el-tab-pane label="数据权限">数据权限</el-tab-pane>
+          <el-tab-pane label="数据权限" name="2"
+            ><DataAuthTree ref="dataAuthRef" :treeObj="treeObj"></DataAuthTree
+          ></el-tab-pane>
         </el-tabs>
         <span slot="footer" class="dialog-footer">
           <el-button
@@ -276,6 +278,7 @@
 
 <script>
 import MenuTree from "./components/menuTree.vue";
+import DataAuthTree from "./components/dataAuth.vue";
 import {
   getRoleTableList,
   updateRoleAvailable,
@@ -284,12 +287,14 @@ import {
   editRole,
   deleteRoleInfo,
   updateRolePermission,
+  updateRoleOrganization,
   getDetailRoleAuth,
 } from "@/api/system.js";
 import { dictType } from "@/api/dict.js";
 export default {
   components: {
     MenuTree,
+    DataAuthTree,
   },
   data() {
     return {
@@ -297,6 +302,7 @@ export default {
         roleId: null,
         checkList: [],
       },
+      activeName: "1",
       loadingView: false,
       //角色类型
       stateOPtions: [],
@@ -358,26 +364,50 @@ export default {
     editAuthMenu(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          const { permissionIds, roleId } =
-            this.$refs.menuTreeRef.getCheckTreeKey();
-          if (!permissionIds) {
-            this.$message({
-              message: "至少要选择一个菜单",
-              type: "warning",
-            });
+          if (this.activeName === "1") {
+            const { permissionIds, roleId } =
+              this.$refs.menuTreeRef.getCheckTreeKey();
+            if (!permissionIds) {
+              this.$message({
+                message: "至少要选择一个菜单权限",
+                type: "warning",
+              });
+            } else {
+              this.loadingView = true;
+              updateRolePermission({ permissionIds, roleId })
+                .then((res) => {
+                  this.$message({
+                    message: "菜单权限修改成功",
+                    type: "success",
+                  });
+                  this.getTableList();
+                  this.loadingView = false;
+                  this.unusualdialog = false;
+                })
+                .catch(() => {});
+            }
           } else {
-            this.loadingView = true;
-            updateRolePermission({ permissionIds, roleId })
-              .then((res) => {
-                this.$message({
-                  message: "权限修改成功",
-                  type: "success",
-                });
-                this.getTableList();
-                this.loadingView = false;
-                this.unusualdialog = false;
-              })
-              .catch(() => {});
+            const { organizationCodes, roleIdAuth } =
+              this.$refs.dataAuthRef.getCheckTreeKey();
+            if (organizationCodes.length === 0) {
+              this.$message({
+                message: "至少要选择一个数据权限",
+                type: "warning",
+              });
+            } else {
+              this.loadingView = true;
+              updateRoleOrganization({ organizationCodes, roleId: roleIdAuth })
+                .then((res) => {
+                  this.$message({
+                    message: "数据权限修改成功",
+                    type: "success",
+                  });
+                  this.getTableList();
+                  this.loadingView = false;
+                  this.unusualdialog = false;
+                })
+                .catch(() => {});
+            }
           }
         } else {
           return false;
@@ -420,7 +450,6 @@ export default {
         });
       }
     },
-
     rowStyle() {
       return "text-align:center";
     },
@@ -531,6 +560,7 @@ export default {
     },
     //权限修改按钮
     editAuth(row) {
+      this.activeName = "1";
       this.editRoleAuth.roleCode = row.roleCode;
       this.editRoleAuth.roleName = row.roleDescription;
       getDetailRoleAuth({ roleId: row.id })

+ 2 - 2
vue.config.js

@@ -66,8 +66,8 @@ module.exports = {
       "/api": {
         // target: "http://192.168.5.4:16200", // 石月
         // target: "http://192.168.50.235:16200", //内网
-        // target: "http://192.168.5.15:16200",
-        target: "http://106.120.102.238:16600", //外网
+        target: "http://192.168.5.15:16200",
+        // target: "http://106.120.102.238:16600", //外网
         changeOrigin: true,
         pathRewrite: {
           "^/api": "", // 需要regit write重写的,