“ystl_myq” hai 2 semanas
pai
achega
55856d3972

+ 1 - 1
src/components/UserPageTable/index.vue

@@ -124,7 +124,7 @@ const getTime = day => {
     </el-table>
     <div>
       <div class="float-left mt-3 total">共{{ tableData.total }}条数据</div>
-      <div class="absolute right-0 mr-20 mt-3">
+      <div class="float-right right-0 mr-10 mt-3">
         <el-pagination
           v-model:current-page="tableData.params.pageNumber"
           v-model:page-size="tableData.params.pageSize"

+ 118 - 61
src/views/background/framework/roles/rolePower.vue

@@ -3,7 +3,7 @@ defineOptions({
   // name 作为一种规范最好必须写上并且和路由的name保持一致
   name: "rolePower"
 });
-import { ref, reactive } from "vue";
+import { ref, reactive, watch } from "vue";
 import { ElMessageBox, ElMessage } from "element-plus";
 import { Search } from "@element-plus/icons-vue";
 import addRole from "./components/addRole.vue";
@@ -94,13 +94,16 @@ const bgColor = ref(null);
 const lookRoles = item => {
   paramsPageUser.roleName = item.roleName;
   paramsPageUser.roleCode = item.roleCode;
-  bgColor.value = item.id;
+  bgColor.value = item.roleCode;
   rolesList.rolesName = item.roleName;
   Object.assign(rolesList.addPerson, item);
   getMenuListApi();
   postPageUserByRoleApi();
-  getMenuListCodeForRoleApi(item);
   getUserPermissionsByRoleCodeApi(item.roleCode);
+  setTimeout(() => {
+    // 查看角色权限
+    getMenuListCodeForRoleApi(item);
+  }, 500);
   Object.assign(roleParams, {
     roleName: "",
     roleSort: 0,
@@ -204,40 +207,41 @@ const postPageUserByRoleApi = async () => {
 const handleClick = (tab, event) => {
   console.log(tab, event);
 };
+// 查询角色的权限
+// 递归处理菜单回显判断并更新 show 和 allShow
+function updateMenuShow(menuList, data) {
+  menuList.forEach(menu => {
+    // 判断当前菜单的 menuCode 是否在 data 中
+    if (data.includes(menu.menuCode)) {
+      menu.show = true;
+    }
+
+    // 如果有子菜单,递归检查
+    if (menu.childrenRes && menu.childrenRes.length > 0) {
+      updateMenuShow(menu.childrenRes, data);
+
+      // 检查所有子菜单的 show 属性是否都为 true
+      const allChildrenShow = menu.childrenRes.every(
+        child => child.show === true
+      );
+      if (allChildrenShow) {
+        menu.allShow = true;
+        menu.show = true;
+      }
+    }
+  });
+}
 
-// const postAddMenuListApi = async () => {
-//   const { code } = await updateMenu({
-//     menuName: "指标库",
-//     menuType: "menu",
-//     parentCode: "",
-//     orderNum: 1,
-//     url: "",
-//     moduleUrl: "/indexDefine",
-//     icon: "",
-//     // remark: "",
-//     remark: "系统管理",
-//     menuCode: "menu340900015906103296"
-//   });
-// };
-// postAddMenuListApi();
-// {
-//     menuName: "新建模板",
-//     menuType: "menu",
-//     parentCode: "menu340271989673566208",
-//     orderNum: 0,
-//     url: "",
-//     moduleUrl: "/evaluate/children/change/components/newAdd",
-//     icon: "",
-//     remark: "",
-//     menuCode: ""
-//   }
 const getMenuListCodeForRoleApi = async item => {
-  console.log("item", item);
   const { code, data } = await getMenuListCodeForRole({
     roleCode: item.roleCode
   });
-  // console.log("菜单", data);
+  if (code == 200) {
+    roleParams.menuCodes = data;
+    updateMenuShow(menuListRoleList.value, data);
+  }
 };
+// 分页----------------
 const handleSizeChange = val => {
   paramsPageUser.pageSize = val;
   postPageUserByRoleApi();
@@ -246,6 +250,7 @@ const handleCurrentChange = val => {
   paramsPageUser.pageNumber = val;
   postPageUserByRoleApi();
 };
+// ------------------------
 // 查看角色菜单权限表
 const menuListRole = ref<any>([]);
 const menuListRoleList = ref<any>([]);
@@ -267,9 +272,13 @@ const getMenuListApi = async () => {
     modifiedMenuData.forEach(item => {
       item.allShow = false;
     });
+    // 忘记干嘛的了,递归错数据了
     function checkMenuCodes(menuItems) {
+      console.log("menuListRole-1111", menuListRole);
       menuListRole.value.forEach(item => {
+        console.log("item", item);
         const hasRole = menuListRole.value.includes(item.menuCode);
+        console.log("hasRole", hasRole);
         item.show = hasRole;
 
         // Recursively check children
@@ -286,18 +295,17 @@ const getMenuListApi = async () => {
         }
       });
     }
-    checkMenuCodes(modifiedMenuData);
+    // checkMenuCodes(modifiedMenuData);
+    // -------------------------------------
     menuListRoleList.value = modifiedMenuData;
-    console.log("菜单列表", menuListRoleList.value);
+    console.log("21312", menuListRoleList.value);
   }
 };
-// getMenuListApi();
 const getUserPermissionsByRoleCodeApi = async roleCode => {
   const { code, msg, data } = await getUserPermissionsByRoleCode({
     roleCode
   });
   if (code == 200) {
-    // getMenuListApi();
     menuListRole.value = data;
   }
 };
@@ -329,37 +337,75 @@ function collectMenuCodes(menu) {
     });
   }
 }
-function collectMenuShow(menu) {
-  // 添加当前菜单的 menuCode 到 roleParams.menuCodes
-  menu.show = false;
-  // 如果有子菜单,递归处理
-  if (menu.childrenRes && menu.childrenRes.length > 0) {
-    menu.childrenRes.forEach(child => {
-      collectMenuCodes(child);
-    });
-  }
+// function collectMenuShow(menu, allShow) {
+//   // 添加当前菜单的 menuCode 到 roleParams.menuCodes
+//   if (!allShow) {
+//     menu.show = true;
+//   } else {
+//     menu.show = false;
+//   }
+//   // 如果有子菜单,递归处理
+//   if (menu.childrenRes && menu.childrenRes.length > 0) {
+//     menu.childrenRes.forEach(child => {
+//       collectMenuCodes(child);
+//     });
+//   }
+// }
+function collectMenuShow(data, allShow) {
+  // 遍历 data 数组
+  data.forEach(item => {
+    // 设置当前项的 show 和 allShow 属性
+    if (!allShow) {
+      item.show = true;
+      roleParams.menuCodes.push(item.menuCode);
+    } else {
+      item.show = false;
+      console.log("data", data);
+      data.map(itCode => {
+        data.map(itCode => {
+          // 使用 filter 来过滤掉与 itCode.menuCode 相同的元素
+          roleParams.menuCodes = roleParams.menuCodes.filter(
+            j => j !== itCode.menuCode
+          );
+        });
+      });
+      // roleParams.menuCodes = []
+    }
+    // 如果存在子菜单 (childrenRes),则递归调用
+    if (item.childrenRes && item.childrenRes.length > 0) {
+      collectMenuShow(item.childrenRes, allShow);
+    }
+  });
 }
 const roleShowClick = (item, type: any) => {
   roleParams.roleName = rolesList.addPerson.roleName;
   roleParams.roleCode = rolesList.addPerson.roleCode;
-  console.log("角色", item);
   if (type) {
     // 不是全选
     if (item.show) {
-      roleParams.menuCodes.push(item.menuCode);
+      item.show = false;
+      console.log("menuListRoleList", menuListRoleList);
+      console.log("menuListRoleList", item);
+      menuListRoleList.value.map = row => {
+        if (row.menuCode == it.parentCode) {
+          row.allShow = !row.allShow;
+        }
+      };
+      roleParams.menuCodes.filter(it => it !== it.menuCode);
       postUpdateRoleApi();
     } else {
-      roleParams.menuCodes.filter(value => value !== item.menuCode);
+      item.show = true;
+      roleParams.menuCodes.push(item.menuCode);
       postUpdateRoleApi();
     }
   } else {
+    console.log("allShow", item);
     if (!item.allShow) {
-      collectMenuCodes(item);
+      collectMenuShow([item], item.allShow);
       postUpdateRoleApi();
     } else {
-      roleParams.menuCodes = [];
+      collectMenuShow([item], item.allShow);
       postUpdateRoleApi();
-      collectMenuShow(item);
     }
   }
 };
@@ -399,7 +445,7 @@ const roleShowClick = (item, type: any) => {
           <div
             :class="[
               'w-[100%] flex justify-between items-center mt-2 cursor-pointer',
-              { 'roles-bg': bgColor === item.id }
+              { 'roles-bg': bgColor === item.roleCode }
             ]"
           >
             <div
@@ -411,7 +457,9 @@ const roleShowClick = (item, type: any) => {
             <div class="flex justify-between items-center">
               <el-dropdown trigger="click">
                 <span>
-                  <el-icon><Operation /></el-icon>
+                  <el-icon>
+                    <Operation />
+                  </el-icon>
                 </span>
                 <template #dropdown>
                   <el-dropdown-menu class="setting">
@@ -447,7 +495,7 @@ const roleShowClick = (item, type: any) => {
           <div
             :class="[
               'w-[100%] flex justify-between items-center mt-2 cursor-pointer',
-              { 'roles-bg': bgColor === item.id }
+              { 'roles-bg': bgColor === item.roleCode }
             ]"
           >
             <div
@@ -459,7 +507,9 @@ const roleShowClick = (item, type: any) => {
             <div class="flex justify-between items-center">
               <el-dropdown trigger="click">
                 <span>
-                  <el-icon><Operation /></el-icon>
+                  <el-icon>
+                    <Operation />
+                  </el-icon>
                 </span>
                 <template #dropdown>
                   <el-dropdown-menu class="setting">
@@ -551,7 +601,7 @@ const roleShowClick = (item, type: any) => {
                     <input
                       v-model="row.show"
                       type="checkbox"
-                      @click="roleShowClick(row, (type = 1))"
+                      @click="roleShowClick(row, 1)"
                     />{{ row.menuName }}
                   </div>
                 </template>
@@ -566,7 +616,7 @@ const roleShowClick = (item, type: any) => {
                       <input
                         v-model="item1.show"
                         type="checkbox"
-                        @click="roleShowClick(row, (type = 1))"
+                        @click="roleShowClick(item1, 1)"
                       />{{ item1.menuName }}
                     </div>
                   </div>
@@ -578,7 +628,7 @@ const roleShowClick = (item, type: any) => {
                     <input
                       v-model="row.allShow"
                       type="checkbox"
-                      @click="roleShowClick(row, (type = 0))"
+                      @click="roleShowClick(row, 0)"
                     />{{ row.date }}全选
                   </div>
                 </template>
@@ -597,7 +647,7 @@ const roleShowClick = (item, type: any) => {
                         <input
                           v-model="item2.show"
                           type="checkbox"
-                          @click="roleShowClick(row, (type = 1))"
+                          @click="roleShowClick(item2, 1)"
                         />{{ item2.menuName }}
                       </div>
                     </div>
@@ -643,15 +693,22 @@ const roleShowClick = (item, type: any) => {
 }
 
 .infinite-list {
-  -ms-overflow-style: none; /* IE和Edge */
-  scrollbar-width: none; /* Firefox */
+  -ms-overflow-style: none;
+
+  /* IE和Edge */
+  scrollbar-width: none;
+
+  /* Firefox */
   // border: 1px solid red;
 }
 
 /* 隐藏滚动条 */
 .infinite-list::-webkit-scrollbar {
-  display: none; /* 对于 Webkit 浏览器(Chrome, Safari等) */
+  display: none;
+
+  /* 对于 Webkit 浏览器(Chrome, Safari等) */
 }
+
 // ::v-deep .el-dropdown {
 //   line-height: 1;
 // }

+ 35 - 35
src/views/evaluate/children/change/components/importIndex.vue

@@ -48,41 +48,41 @@ const handleClose = () => {
 };
 // 添加部门保存
 const saveDepartment = () => {
-  ElMessageBox.confirm("不保存,更新的信息将会丢失", "需要保存吗?", {
-    type: "warning"
-  })
-    .then(async () => {
-      indexParams.tableIndex.forEach(async item => {
-        indexParams.Relation.indId = item.id;
-        indexParams.Relation.indName = item.name;
-        const { code, msg, data } = await postAddRelationList([
-          indexParams.Relation
-        ]);
-        if (code === 200) {
-          if (data.successList.length > 0) {
-            $emit("handClickInit");
-            console.log("11111", indexParams.parentList);
-            ElMessage({
-              message: "导入成功",
-              type: "success"
-            });
-          }
-          if (data.failList.length > 0) {
-            console.log("11111", data.failList);
-            ElMessage({
-              message: `指标${data.failList[0].indName}重复导入`,
-              type: "error"
-            });
-          }
-        } else {
-          ElMessage.error(msg);
-        }
-      });
-      dialogVisibleAdd.value = false;
-    })
-    .catch(() => {
-      // catch error
-    });
+  indexParams.tableIndex.forEach(async item => {
+    indexParams.Relation.indId = item.id;
+    indexParams.Relation.indName = item.name;
+    const { code, msg, data } = await postAddRelationList([
+      indexParams.Relation
+    ]);
+    if (code === 200) {
+      if (data.successList.length > 0) {
+        $emit("handClickInit");
+        console.log("11111", indexParams.parentList);
+        ElMessage({
+          message: "导入成功",
+          type: "success"
+        });
+      }
+      if (data.failList.length > 0) {
+        console.log("11111", data.failList);
+        ElMessage({
+          message: `指标${data.failList[0].indName}重复导入`,
+          type: "error"
+        });
+      }
+    } else {
+      ElMessage.error(msg);
+    }
+  });
+  dialogVisibleAdd.value = false;
+  // ElMessageBox.confirm("不保存,更新的信息将会丢失", "需要保存吗?", {
+  //   type: "warning"
+  // })
+  //   .then(async () => {
+  //   })
+  //   .catch(() => {
+  //     // catch error
+  //   });
 };
 const open = row => {
   console.log("item", row);

+ 7 - 4
src/views/evaluate/children/change/components/newAdd.vue

@@ -283,7 +283,6 @@ const importIndexDialog = row => {
   importIndexRef.value.open(row);
 };
 const importIndexOne = async row => {
-  // console.log("row", row);
   let formula = JSON.stringify({
     noConditionFormula: ""
   });
@@ -292,8 +291,8 @@ const importIndexOne = async row => {
     const res = await postAddRelationList([
       {
         dimId: row.id,
-        indId: row.tpId,
-        tpId: data.id,
+        indId: data.id,
+        tpId: row.tpId,
         formula,
         scoreStandard: 0
       }
@@ -358,7 +357,10 @@ const onUpdate = (e: DraggableEvent) => {};
 //     order
 //   });
 // };
+
 const postUpdateApi = async () => {
+  console.log();
+  // indexOf.indName = indexOf.name
   const { code, msg } = await postUpdate(indexOf);
   if (code == 200) {
     getListByApi(indexOf.dimId);
@@ -400,6 +402,7 @@ const editConfig = ref<any>({
 });
 const tableVxeRef = ref();
 const editClosedEvent = ({ row, column }) => {
+  console.log("row", row);
   const $table = tableVxeRef.value;
   if ($table) {
     Object.assign(indexOf, row);
@@ -551,7 +554,7 @@ const editClosedEvent = ({ row, column }) => {
               @edit-closed="editClosedEvent"
             >
               <vxe-column
-                field="name"
+                field="indName"
                 fixed
                 title="指标名称"
                 :edit-render="{ name: 'input' }"

+ 17 - 13
src/views/evaluate/children/change/components/settingIndexDrawer.vue

@@ -305,6 +305,11 @@ const watchFormulaType = value => {
   }
 };
 const lookRoles = item => {
+  console.log("item", item);
+  console.log("params", params);
+  if (isValidJSON(params.formula)) {
+    params.formula = JSON.parse(params.formula);
+  }
   bgColor.value = item.id;
   params.formula.noConditionFormula =
     params.formula.noConditionFormula + item.name;
@@ -424,8 +429,6 @@ const addItemDataList = (
   indexList: number,
   item
 ) => {
-  console.log(index, itemList);
-  console.log(item);
   addmanyChange.innerConditionExpression[
     index
   ].scoreRuleMoreInnerVO[0].scoreRules.push({
@@ -461,7 +464,7 @@ const manyConditions = () => {
       v-model="drawer"
       :direction="direction"
       :before-close="handleClose"
-      size="600px"
+      size="700px"
     >
       <template #header>
         <h4>指标设置</h4>
@@ -711,10 +714,10 @@ const manyConditions = () => {
                     >
                       <div class="mt-3">
                         <div class="flex">
-                          <el-text class="w-[30px]" type="primary">
+                          <el-text class="w-[15px]" type="primary">
                             {{ index + 1 }}
                           </el-text>
-                          <div class="w-[40px] ml-2">
+                          <div class="w-[40px] ml-4">
                             {{ item.startValue }}
                           </div>
                           <div class="mr-2">
@@ -753,12 +756,12 @@ const manyConditions = () => {
                           v-for="(itemVO, indexOV) in item.scoreRuleMoreInnerVO"
                           :key="indexOV"
                         >
-                          <div class="flex mt-2 ml-7">
+                          <div class="flex mt-2 ml-20">
                             <div class="mr-2">条件值{{ index + 1 }} =</div>
                             <el-input
                               v-model="itemVO.innerConditionValue"
-                              class="ml-2"
-                              style="width: 240px"
+                              class="ml-2 mr-6"
+                              style="width: 208px"
                             />
                             <el-text
                               type="danger"
@@ -772,8 +775,9 @@ const manyConditions = () => {
                           <div
                             v-for="(itemList, indexList) in itemVO.scoreRules"
                             :key="indexList"
+                            class="ml-3"
                           >
-                            <div class="flex mt-2 ml-7 items-center">
+                            <div class="flex mt-2 ml-16 items-center">
                               <div class="text_border">{{ indexList + 1 }}</div>
                               <!-- manyChange.dataList[index].dataList -->
                               <div class="w-[40px] ml-2">
@@ -806,14 +810,14 @@ const manyConditions = () => {
                                 style="width: 80px"
                               />
                               <div
-                                class="w-[100px] ml-2 mr-2 flex justify-between items-center"
+                                class="w-[150px] ml-2 mr-2 flex justify-between items-center"
                               >
                                 <div>得分</div>
                                 <div>=</div>
                                 <el-input
                                   v-model="itemList.score"
                                   class="ml-2"
-                                  style="width: 50px"
+                                  style="width: 80px"
                                 />
                               </div>
                               <el-text
@@ -827,7 +831,7 @@ const manyConditions = () => {
                             </div>
                             <div
                               v-if="indexList + 1 == itemVO.scoreRules.length"
-                              class="ml-7 mt-1 text-xs cursor-pointer"
+                              class="ml-16 mt-2 text-xs cursor-pointer"
                             >
                               <el-text
                                 type="primary"
@@ -851,7 +855,7 @@ const manyConditions = () => {
                       </div>
                       <div
                         v-if="item?.scoreRuleMoreInnerVO?.length == 0"
-                        class="ml-7 mt-1 text-xs cursor-pointer"
+                        class="ml-20 mt-2 text-xs cursor-pointer"
                       >
                         <el-text
                           type="primary"