ソースを参照

fix: bug修改-人员树结构有bug

ystl_myq 1 週間 前
コミット
8b553e6b32

+ 64 - 24
src/api/department.ts

@@ -36,33 +36,73 @@ export const treeDept = ref([]);
 export const postListTreeWithUserApi = async () => {
   const res = await postListTreeWithUser();
   treeDept.value = transformData(res.data);
+  console.log("treeDept.value", transformData(res.data));
+  console.log("treeDept", res.data);
 };
+// const transformData = data => {
+//   return data.map(item => {
+//     // 新的结构
+//     const newItem = {
+//       userName: item.deptName || item.realName, // 使用deptName或userName
+//       userCode: item.deptCode || item.userCode, // 使用deptCode或userCode
+//       children: [] // 初始化children数组
+//     };
+
+//     // 合并childrenRes和childrenUserRes
+//     const childrenRes = item.childrenRes ? transformData(item.childrenRes) : [];
+//     const childrenUserRes = item.childrenUserRes
+//       ? item.childrenUserRes.map(user => ({
+//           userName: user.userName,
+//           userCode: user.userCode
+//         }))
+//       : [];
+
+//     newItem.children = [...childrenRes, ...childrenUserRes]; // 合并两个子项
+
+//     return newItem; // 返回处理后的新对象
+//   });
+// };
 const transformData = data => {
-  // 基本的转换逻辑
-  return data.map(item => {
-    // 初始化一个转换后的项目
-    const transformedItem = {
-      userName: item.deptName || item.userName, // 使用 deptName 或 userName
-      userCode: item.deptCode || item.userCode, // 使用 deptCode 或 userCode
-      children: [] // 用于存储子部门和用户数据
-    };
+  // 检查data是否存在且是数组且长度大于0
+  if (Array.isArray(data) && data.length > 0) {
+    return data.map(item => {
+      let newItem = {
+        userNameNew: item.realName || item.deptName || "", // 优先使用realName,其次使用deptName
+        userCodeNew: item.userCode || item.deptCode || "", // 优先使用userCode,其次使用deptCode
+        children: [] // 初始化children为一个空数组
+      };
+
+      // 确保childrenUserRes和childrenRes存在
+      const childrenUserRes = Array.isArray(item.childrenUserRes)
+        ? item.childrenUserRes
+        : [];
+      const childrenRes = Array.isArray(item.childrenRes)
+        ? item.childrenRes
+        : [];
+
+      // 处理子部门
+      const renRes = childrenRes.map(itEes => ({
+        userNameNew: itEes.deptName || "", // 使用deptName
+        userCodeNew: itEes.deptCode || "", // 使用deptCode
+        children: transformData(itEes.childrenRes) // 递归处理子部门
+      }));
+
+      // 处理用户
+      const userRes = childrenUserRes.map(itEes => ({
+        userNameNew: itEes.realName || "", // 使用realName
+        userCodeNew: itEes.userCode || "", // 使用userCode
+        jobTitle: itEes.jobTitle || "", // 包含职位信息
+        hospitalCode: itEes.hospitalCode || "", // 包含医院代码
+        children: transformData(itEes.childrenUserRes) // 递归处理用户子项
+      }));
 
-    // 递归处理子部门数据(childrenRes)
-    if (item.childrenRes && Array.isArray(item.childrenRes)) {
-      transformedItem.children.push(...transformData(item.childrenRes)); // 合并所有子部门
-    }
+      // 合并两个子项
+      newItem.children = [...renRes, ...userRes];
 
-    // 处理当前部门的用户数据(childrenUserRes)
-    if (item.childrenUserRes && Array.isArray(item.childrenUserRes)) {
-      item.childrenUserRes.forEach(user => {
-        // 将每个用户添加到 children 数组
-        transformedItem.children.push({
-          userName: user.userName,
-          userCode: user.userCode
-        });
-      });
-    }
+      return newItem; // 返回新的结构
+    });
+  }
 
-    return transformedItem;
-  });
+  // 如果数据无效,返回空数组
+  return [];
 };

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

@@ -47,33 +47,50 @@ const handleClose = () => {
   //   });
 };
 // 添加部门保存
-const saveDepartment = () => {
-  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);
+const saveDepartment = async () => {
+  const { code, msg, data } = await postAddRelationList(indexParams.tableIndex);
+  if (code === 200) {
+    if (data.successList.length > 0) {
+      $emit("handClickInit");
+      ElMessage({
+        message: "导入成功",
+        type: "success"
+      });
+    }
+    if (data.failList.length > 0) {
+      data.failList.map(it => {
         ElMessage({
-          message: `指标${data.failList[0].indName}重复导入`,
+          message: `指标${it.indName}重复导入`,
           type: "error"
         });
-      }
-    } else {
-      ElMessage.error(msg);
+      });
     }
-  });
+  } else {
+    ElMessage.error(msg);
+  }
+  // indexParams.tableIndex.forEach(async item => {
+  //   indexParams.Relation.indId = item.id;
+  //   indexParams.Relation.indName = item.name;
+  // 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"
@@ -97,9 +114,26 @@ const open = row => {
 const selectedNums = ref(0);
 const handleSelectionChange = selectedRows => {
   // this.selectedRows = selectedRows;
+  indexParams.tableIndex = [];
   selectedNums.value = selectedRows.length;
-  indexParams.tableIndex = selectedRows;
-  console.log("选中的行:", selectedRows);
+  selectedRows.forEach(item => {
+    indexParams.tableIndex.push({
+      dimId: indexParams.Relation.dimId,
+      indId: item.id,
+      tpId: "",
+      indName: item.name,
+      scoreRule: "",
+      targetValue: "",
+      finalValue: "",
+      challengeValue: "",
+      startValue: "",
+      datasoure: "",
+      weight: "",
+      scoreValue: ""
+    });
+  });
+  // indexParams.tableIndex = selectedRows;
+  console.log("选中的行:", indexParams.tableIndex);
 };
 
 const getQuotaPageListApi = async () => {

+ 316 - 0
src/views/evaluate/children/change/components/jishuanqi.vue

@@ -0,0 +1,316 @@
+<template>
+  <div>
+    <el-dropdown
+      ref="dropdown"
+      placement="bottom-start"
+      trigger="click"
+      @visible-change="handleMouseLeave"
+      @close="handleClose"
+      @mouseleave="handleMouseLeave"
+    >
+      <span class="el-dropdown-link">
+        <el-input
+          v-model="params.formula.noConditionFormula"
+          @blur="handleMouseLeave"
+          @change="handleMouseLeave"
+        />
+      </span>
+      <template #dropdown>
+        <div
+          class="w-[500px] compute h-64 mt-1 ml-12 flex justify-evenly items-center"
+          style="user-select: none"
+        >
+          <div class="w-1/3 h-60 pl-1 bg-white rounded-md">
+            <div class="w-[100%] text-xs mt-2">
+              <div><el-text type="info">:::变量</el-text></div>
+            </div>
+            <div v-for="item in rolesList.data" :key="item.id">
+              <div
+                :class="[
+                  'cursor-pointer text-xs mt-1',
+                  { bgBack: bgColor === item.id }
+                ]"
+                @click="lookRoles(item)"
+              >
+                <el-text class="">{{ item.name }}</el-text>
+              </div>
+            </div>
+          </div>
+          <div class="w-3/5 ml-2 h-60 flex flex-col">
+            <div class="w-[100%] text-xs h-24 bg-white rounded-md">
+              <div class="p-1"><el-text>得分 = </el-text></div>
+              <!-- style="height: 95px" -->
+              <el-input
+                v-model="params.formula.noConditionFormula"
+                :rows="3"
+                disabled
+                type="textarea"
+                placeholder='示例:"完成值" / "目标值" * 100'
+              />
+            </div>
+            <div class="w-[100%] h-32 mt-2 rounded-md flex flex-col">
+              <div class="flex justify-between h-8">
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('1')"
+                >
+                  1
+                </div>
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('2')"
+                >
+                  2
+                </div>
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('3')"
+                >
+                  3
+                </div>
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('+')"
+                >
+                  +
+                </div>
+                <div
+                  class="h-full w-[50px] text-white bg-orange-400 mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="remove"
+                >
+                  x
+                </div>
+              </div>
+              <div class="flex justify-between h-8 mt-1">
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('4')"
+                >
+                  4
+                </div>
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('5')"
+                >
+                  5
+                </div>
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('6')"
+                >
+                  6
+                </div>
+                <div
+                  class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="countNumber('-')"
+                >
+                  -
+                </div>
+                <div
+                  class="text-xs h-full w-[50px] text-white bg-orange-400 mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                  @click="removeVoid"
+                >
+                  清空
+                </div>
+              </div>
+              <div class="flex justify-between h-16 mt-1">
+                <div>
+                  <div class="flex justify-between">
+                    <div
+                      class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                      @click="countNumber('7')"
+                    >
+                      7
+                    </div>
+                    <div
+                      class="h-full ml-1 w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                      @click="countNumber('8')"
+                    >
+                      8
+                    </div>
+                    <div
+                      class="h-full ml-2 w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                      @click="countNumber('9')"
+                    >
+                      9
+                    </div>
+                    <div
+                      class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                      @click="countNumber('*')"
+                    >
+                      *
+                    </div>
+                  </div>
+                  <div class="flex mt-1 justify-between">
+                    <div
+                      class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                      @click="countNumber('0')"
+                    >
+                      0
+                    </div>
+                    <div
+                      class="h-full ml-1 w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                      @click="countNumber('.')"
+                    >
+                      .
+                    </div>
+                    <div
+                      class="h-full ml-2 w-[50px] bg-white mx-1 flex justify-between items-center rounded-lg cursor-pointer"
+                    >
+                      <div
+                        class="w-1/2 h-full text-center border-r text-gray-100"
+                        @click="countNumber('(')"
+                      >
+                        <span class="text-black"> (</span>
+                      </div>
+                      <div
+                        class="w-1/2 h-full text-center"
+                        @click="countNumber(')')"
+                      >
+                        )
+                      </div>
+                    </div>
+                    <div
+                      class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
+                      @click="countNumber('/')"
+                    >
+                      /
+                    </div>
+                  </div>
+                </div>
+                <div
+                  class="h-full mr-1 w-[50px] text-white flex justify-center items-center rounded-lg cursor-pointer areYouOK"
+                  @click="count"
+                >
+                  确认
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </template>
+    </el-dropdown>
+  </div>
+</template>
+
+<script setup lang="ts">
+import { reactive, ref, onMounted } from "vue";
+const dropdown = ref();
+const $emit = defineEmits(["handClick", "clickIndex"]);
+const $props = defineProps({
+  index: {
+    type: Number
+  },
+  indexList: {
+    type: Number
+  },
+  outerConditionValue: {
+    type: String
+  }
+});
+onMounted(() => {
+  if ($props.outerConditionValue) {
+    params.formula.noConditionFormula = $props.outerConditionValue;
+  }
+});
+const bgColor = ref(null);
+const rolesList = reactive({
+  data: [
+    { name: "完成值 / 目标值", id: 1 },
+    { name: "完成值 - 目标值", id: 2 },
+    { name: "目标值 - 完成值", id: 3 },
+    { name: "门槛值", id: 4 },
+    { name: "目标值", id: 5 },
+    { name: "挑战值", id: 6 },
+    { name: "完成值", id: 7 },
+    { name: "增幅", id: 8 },
+    { name: "降幅", id: 9 }
+  ],
+  value: "",
+  num: null
+});
+const params = reactive({
+  formula: {
+    noConditionFormula: ""
+  }
+});
+const lookRoles = item => {
+  bgColor.value = item.id;
+  params.formula.noConditionFormula =
+    params.formula.noConditionFormula + item.name;
+};
+// 字符拼接
+const countNumber = (item: string) => {
+  params.formula.noConditionFormula = params.formula.noConditionFormula + item;
+};
+// 清空
+const removeVoid = () => {
+  params.formula.noConditionFormula = "";
+};
+// 清除
+const remove = () => {
+  if (params.formula.noConditionFormula.length > 0) {
+    params.formula.noConditionFormula = params.formula.noConditionFormula.slice(
+      0,
+      -1
+    );
+  }
+};
+// 确认
+const count = item => {
+  $emit(
+    "handClick",
+    params.formula.noConditionFormula,
+    $props.index,
+    $props.indexList
+  );
+};
+const handleClose = () => {
+  console.log("关闭");
+};
+const handleMouseLeave = blo => {
+  if (!blo) {
+    $emit(
+      "handClick",
+      params.formula.noConditionFormula,
+      $props.index,
+      $props.indexList
+    );
+  }
+};
+defineExpose({
+  params
+});
+</script>
+
+<style lang="scss" scoped>
+.compute {
+  background-color: #f3f3f3;
+  border-radius: 5px;
+}
+
+.text-color {
+  color: #f3f3f3;
+}
+
+.areYouOK {
+  background-color: #409eff;
+}
+
+.bgBack {
+  background-color: #f3f3f3;
+}
+
+.text_border {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 14px;
+  height: 14px;
+  // margin-top: 5px;
+  margin-right: 5px;
+  font-size: 12px;
+  border: 1px solid gray;
+  border-radius: 50%;
+}
+</style>

+ 0 - 1
src/views/evaluate/children/change/components/newAdd.vue

@@ -584,7 +584,6 @@ const editClosedEvent = ({ row, column }) => {
                 :edit-render="{ name: 'input' }"
               />
               <vxe-column
-                v-if="item.scoreValue"
                 field="scoreValue"
                 title="分值"
                 :edit-render="{ name: 'input' }"

+ 61 - 6
src/views/evaluate/children/change/components/settingIndexDrawer.vue

@@ -8,6 +8,7 @@ import {
   calculateScoreByConditionMoCondition
 } from "@/api/templateInfo";
 import { conditionVerify } from "@/api/formula";
+import jishuanqi from "./jishuanqi.vue";
 import type { DrawerProps, FormItemProps, FormProps } from "element-plus";
 // const itemLabelPosition = ref<FormItemProps["labelPosition"]>("");
 const drawer = ref(false);
@@ -120,7 +121,9 @@ const conditionVerifyApi = async () => {
     let result = str.replace(regex, match => {
       return `${match}`;
     });
-  } catch (err) {}
+  } catch (err) {
+    //
+  }
 };
 // 计算
 const countComputed = async () => {
@@ -273,11 +276,11 @@ const timer = ref("");
 const compute = [
   {
     value: 0,
-    label: "无公式计算"
+    label: "无条件公式"
   },
   {
     value: 1,
-    label: "多公式计算"
+    label: "多条件公式"
   }
 ];
 const bgColor = ref(null);
@@ -463,6 +466,28 @@ const manyConditions = () => {
     });
   });
 };
+// 计算器
+const jishuanqiRef = ref();
+const countNoConditionFormula = item => {
+  addmanyChange.outerConditionValue = item;
+};
+const jishuanqiRef1 = ref();
+const countNoConditionFormula1 = (item, index) => {
+  addmanyChange.innerConditionExpression[index].endValue = item;
+};
+const jishuanqiRef2 = ref();
+const countNoConditionFormula2 = (item, index) => {
+  // innerConditionValue
+  addmanyChange.innerConditionExpression[
+    index
+  ].scoreRuleMoreInnerVO[0].innerConditionValue = item;
+};
+const jishuanqiRef3 = ref();
+const countNoConditionFormula3 = (item, index, indexList) => {
+  addmanyChange.innerConditionExpression[
+    index
+  ].scoreRuleMoreInnerVO[0].scoreRules[indexList].endValue = item;
+};
 </script>
 
 <template>
@@ -707,10 +732,15 @@ const manyConditions = () => {
                 <div class="w-full">
                   <div class="flex items-center">
                     <el-text>条件值 = </el-text>
-                    <el-input
+                    <!-- <el-input
                       v-model="addmanyChange.outerConditionValue"
                       class="ml-2"
                       style="width: 240px"
+                    /> -->
+                    <jishuanqi
+                      ref="jishuanqiRef"
+                      :outerConditionValue="addmanyChange.outerConditionValue"
+                      @handClick="countNoConditionFormula"
                     />
                   </div>
                   <div class="w-full mt-2">
@@ -749,7 +779,17 @@ const manyConditions = () => {
                             <el-option label="数值" value="数值" />
                             <el-option label="公式" value="公式" />
                           </el-select>
+                          <jishuanqi
+                            v-if="item.select == '公式'"
+                            ref="jishuanqiRef"
+                            :index="index"
+                            :outerConditionValue="item.endValue"
+                            class="ml-2 mr-5"
+                            style="width: 80px"
+                            @handClick="countNoConditionFormula1"
+                          />
                           <el-input
+                            v-else
                             v-model="item.endValue"
                             class="ml-2 mr-5"
                             style="width: 80px"
@@ -766,11 +806,15 @@ const manyConditions = () => {
                         >
                           <div class="flex mt-2 ml-20">
                             <div class="mr-2">条件值{{ index + 1 }} =</div>
-                            <el-input
-                              v-model="itemVO.innerConditionValue"
+                            <jishuanqi
+                              ref="jishuanqiRef"
+                              :index="index"
+                              :outerConditionValue="itemVO.innerConditionValue"
                               class="ml-2 mr-6"
                               style="width: 208px"
+                              @handClick="countNoConditionFormula2"
                             />
+                            <!-- <el-input v-model="itemVO.innerConditionValue" class="ml-2 mr-6" style="width: 208px" /> -->
                             <el-text
                               type="danger"
                               @click="dataleListItemAll(item, index)"
@@ -812,7 +856,18 @@ const manyConditions = () => {
                                 <el-option label="数值" value="数值" />
                                 <el-option label="公式" value="公式" />
                               </el-select>
+                              <jishuanqi
+                                v-if="itemList.select == '公式'"
+                                ref="jishuanqiRef"
+                                :index="index"
+                                :indexList="indexList"
+                                :outerConditionValue="itemList.endValue"
+                                class="ml-2"
+                                style="width: 80px"
+                                @handClick="countNoConditionFormula3"
+                              />
                               <el-input
+                                v-else
                                 v-model="itemList.endValue"
                                 class="ml-2"
                                 style="width: 80px"