ystl_myq 1 tydzień temu
rodzic
commit
e30fbff55e

+ 94 - 20
src/components/rankTable/draw.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-table :data="tableData" style="width: 100%">
+  <!-- <el-table :data="tableData" style="width: 100%">
     <el-table-column type="index" label="排名" width="80" fixed>
       <template #default="scope">
         <div v-if="scope.$index > 2" class="diamond">
@@ -9,29 +9,87 @@
           <img :src="RANK_IMG[scope.row.ranking - 1]" alt="" />
         </div>
       </template>
+</el-table-column>
+<el-table-column prop="deptName" :label="deptName" fixed width="150" />
+<el-table-column v-if="name" prop="assessmentObjectName" :label="name" fixed width="100" />
+<div v-for="(ita, itk) in tableData" :key="itk">
+  <el-table-column prop="deptName" :label="deptName" fixed width="150" />
+  <div v-for="(item, index) in ita.dimensionList" :key="item.dimId">
+    <el-table-column :label="`${item.dimName}(${item.soreRate}%)`">
+      <el-table-column v-for="(it, id) in item.quotaList" :key="it.quotaId" :prop="it.quotaScore"
+        :label="`${it.quotaName}(${it.quotaWeight}%)`" width="140" />
     </el-table-column>
-    <el-table-column prop="deptName" :label="deptName" fixed width="150" />
-    <el-table-column
-      v-if="name"
-      prop="assessmentObjectName"
-      :label="name"
-      fixed
+    <el-table-column :prop="item.totalSore" label="总分`" />
+  </div>
+</div>
+<el-table-column prop="allScore" label="总得分" fixed width="150" />
+</el-table> -->
+  <vxe-table
+    border
+    show-overflow
+    style="width: 100%"
+    height="400"
+    :data="tableData"
+    :merge-cells="mergeCells"
+  >
+    <vxe-column field="index" title="排名" width="80" fixed="left">
+      <template #default="scope">
+        <div
+          v-if="
+            scope._rowIndex == 0 &&
+            $route.name != 'workerDrak' &&
+            $route.name != 'workerRank'
+          "
+          class="text-center text-sm font-extrabold text-[#000000] pt-4"
+        >
+          平均得分
+        </div>
+        <div v-if="scope._rowIndex > 2" class="diamond">
+          {{ scope.row.ranking }}
+        </div>
+        <div v-else class="text-center">
+          <img :src="RANK_IMG[scope.row.ranking - 1]" alt="" />
+        </div>
+      </template>
+    </vxe-column>
+    <vxe-column
+      v-if="$route.name == 'workerDrak' || $route.name == 'workerRank'"
+      field="deptName"
+      :title="deptName"
+      fixed="left"
+      width="150"
+    />
+    <vxe-column
+      v-else
+      field="assessmentObjectName"
+      :title="deptName"
+      fixed="left"
+      width="150"
+    />
+    <vxe-column
+      v-if="$route.name == 'workerDrak' || $route.name == 'workerRank'"
+      field="assessmentObjectName"
+      fixed="left"
+      title="姓名"
       width="100"
     />
-    <div v-for="(item, index) in tableData.dimensionList" :key="index">
-      <el-table-column :label="`${item.dimName}(${item.soreRate}%)`">
-        <el-table-column
-          v-for="(it, id) in item.quotaList"
-          :key="id"
-          :prop="it.quotaScore"
-          :label="`${it.quotaName}(${it.quotaWeight}%)`"
-          width="140"
-        />
-      </el-table-column>
-      <el-table-column :prop="item.totalSore" label="总分`" />
+    <div v-for="(ita, itk) in tableData" :key="itk">
+      <!-- <vxe-column field="deptName" :title="deptName" width="150" /> -->
+      <div v-for="item in ita.dimensionList" :key="item.dimId">
+        <div v-for="it in item.quotaList" :key="it.quotaId">
+          <vxe-colgroup :title="`${item.dimName}(${item.soreRate}%)`">
+            <vxe-column
+              :field="it.quotaScore"
+              :title="`${it.quotaName}(${it.quotaWeight}%)`"
+              width="150"
+            />
+          </vxe-colgroup>
+          <vxe-column field="totalSore" title="总分" width="150" />
+        </div>
+      </div>
     </div>
-    <el-table-column prop="allScore" label="总得分" fixed width="150" />
-  </el-table>
+    <vxe-column field="allScore" title="总得分" fixed="right" width="150" />
+  </vxe-table>
 </template>
 
 <script lang="ts" setup>
@@ -39,14 +97,30 @@ import { computed, reactive, ref } from "vue";
 import rank1 from "@/assets/rank/rank1.png";
 import rank2 from "@/assets/rank/rank2.png";
 import rank3 from "@/assets/rank/rank3.png";
+import { useRoute } from "vue-router";
+const $route = useRoute();
 const RANK_IMG = [rank1, rank2, rank3];
 const tableData = ref([]);
 const deptName = ref("");
 const name = ref("");
+const mergeCells = ref([
+  // 合并第一行前两列
+  { row: 0, col: 0, rowspan: 1, colspan: 2 },
+  { row: 2, col: 1, rowspan: 0, colspan: 0 }
+]);
+const averageData = averageSore => {
+  if (tableData.value.length > 0) {
+    tableData.value.unshift({
+      dimensionList: [],
+      allScore: averageSore
+    });
+  }
+};
 const init = (item, deptNames, names) => {
   tableData.value = item;
   deptName.value = deptNames;
   name.value = names;
+  averageData(item.averageSore);
   console.log("item111", item);
   console.log("tableData", tableData.value);
 };

+ 85 - 65
src/components/rankTable/index.vue

@@ -1,100 +1,120 @@
 <template>
-  <el-table
-    :data="tableData"
-    class="mytTable"
+  <vxe-table
+    border
+    show-overflow
     style="width: 100%"
-    :span-method="arraySpanMethod"
+    height="400"
+    :data="tableData"
+    :merge-cells="mergeCells"
   >
-    <el-table-column
-      type="index"
-      label="排名"
-      width="80"
-      fixed
-      header-row-style="background-color: #F5F7FA;"
-    >
+    <vxe-column field="index" title="排名" width="80" fixed="left">
       <template #default="scope">
         <div
-          v-if="scope.$index === 0"
-          class="text-center text-sm font-extrabold text-[#000000]"
+          v-if="
+            scope._rowIndex == 0 &&
+            $route.name != 'workerDrak' &&
+            $route.name != 'workerRank'
+          "
+          class="text-center text-sm font-extrabold text-[#000000] pt-4"
         >
-          平均分
+          平均
         </div>
-        <div v-if="scope.$index > 3" class="diamond">
-          {{ scope.$index + 1 }}
+        <div v-if="scope._rowIndex > 2" class="diamond">
+          {{ scope.row.ranking }}
         </div>
-        <div v-if="scope.$index > 0" class="text-center">
-          <img :src="RANK_IMG[scope.$index - 1]" alt="" />
+        <div v-else class="text-center">
+          <img :src="RANK_IMG[scope.row.ranking - 1]" alt="" />
         </div>
       </template>
-    </el-table-column>
-    <el-table-column prop="deptName" :label="deptName" fixed width="150" />
-    <el-table-column
-      v-if="name"
-      prop="assessmentObjectName"
-      :label="name"
-      fixed
+    </vxe-column>
+    <vxe-column
+      v-if="$route.name == 'workerDrak' || $route.name == 'workerRank'"
+      field="deptName"
+      :title="tabTitle"
+      fixed="left"
+      width="150"
+    />
+    <vxe-column
+      v-else
+      field="assessmentObjectName"
+      :title="deptName"
+      fixed="left"
+      width="150"
+    />
+    <vxe-column
+      v-if="$route.name == 'workerDrak' || $route.name == 'workerRank'"
+      field="assessmentObjectName"
+      fixed="left"
+      title="姓名"
       width="100"
     />
-    <div v-for="(item, index) in tableData.dimensionList" :key="index">
-      <el-table-column :label="`${item.dimName}(${item.soreRate}%)`">
-        <el-table-column
-          v-for="(it, id) in item.quotaList"
-          :key="id"
-          :prop="it.quotaScore"
-          :label="`${it.quotaName}(${it.soreRate}%)`"
-          width="140"
-        />
-      </el-table-column>
-      <el-table-column :prop="item.totalSore" label="总分`" />
+    <div v-for="(ita, itk) in tableData" :key="itk">
+      <!-- <vxe-column field="deptName" :title="deptName" width="150" /> -->
+      <div v-for="item in ita.dimensionList" :key="item.dimId">
+        <div v-for="it in item.quotaList" :key="it.quotaId">
+          <vxe-colgroup :title="`${item.dimName}(${item.soreRate}%)`">
+            <vxe-column
+              :field="it.quotaScore"
+              :title="`${it.quotaName}(${it.quotaWeight}%)`"
+              width="150"
+            />
+          </vxe-colgroup>
+          <vxe-column field="totalSore" title="总分" width="150" />
+        </div>
+      </div>
     </div>
-    <el-table-column prop="allScore" label="总得分" fixed width="150" />
-  </el-table>
+    <vxe-column field="allScore" title="总得分" fixed="right" width="150" />
+  </vxe-table>
 </template>
 
 <script lang="ts" setup>
-import { computed, reactive, ref } from "vue";
+import { computed, reactive, ref, onMounted } from "vue";
 import rank1 from "@/assets/rank/rank1.png";
 import rank2 from "@/assets/rank/rank2.png";
 import rank3 from "@/assets/rank/rank3.png";
+import { useRoute } from "vue-router";
+const $route = useRoute();
 const RANK_IMG = [rank1, rank2, rank3];
 const deptName = ref("");
 const name = ref("");
 const tableData = ref();
-const tableHeaderColor = ({ row, column, rowIndex, columnIndex }) => {
-  // console.log("row", row);
-  // console.log("column", column);
-  // console.log("rowIndex", rowIndex);
-  // console.log("columnIndex", columnIndex);
-  // return "background:	#F5F5F5; color:#000000;";
-  return "aaaa";
-};
-const averageData = averageSore => {
-  if (tableData.value.length > 0) {
-    tableData.value.unshift({
-      dimensionList: [],
-      allScore: averageSore
-    });
+const tabTitle = ref("");
+const mergeCells = ref([
+  // 合并第一行前两列
+  { row: 0, col: 0, rowspan: 1, colspan: 2 },
+  { row: 2, col: 1, rowspan: 0, colspan: 0 }
+]);
+onMounted(() => {
+  cellTable();
+});
+const cellTable = () => {
+  if ($route.name == "workerDrak" || $route.name == "workerRank") {
+    mergeCells.value = [
+      { row: 0, col: 0, rowspan: 1, colspan: 3 },
+      { row: 2, col: 1, rowspan: 1, colspan: 3 }
+    ];
+  }
+  if ($route.name == "healthDrank" || $route.name == "healthRank") {
+    tabTitle.value = "医疗组";
+  } else {
+    tabTitle.value = "科室";
   }
 };
-
-const arraySpanMethod = ({ row, column, rowIndex, columnIndex }) => {
-  // 合并第一行的“排名”、“科室”和“姓名”
-  if (rowIndex === 0) {
-    if (columnIndex === 0) {
-      return [1, 3]; // “排名”合并三列
-    } else if (columnIndex === 1) {
-      return [0, 0]; // “科室”不显示
-    } else if (columnIndex === 2) {
-      return [0, 0]; // “姓名”不显示
+const averageData = averageSore => {
+  if ($route.name != "workerDrak" || $route.name != "workerRank") {
+    if (tableData.value.length > 0) {
+      tableData.value.unshift({
+        dimensionList: [],
+        allScore: averageSore
+      });
     }
   }
-  return [1, 1]; // 其他单元格正常显示
 };
 const init = (item, deptNames, names) => {
   tableData.value = item;
-  averageData(item.averageSore);
   deptName.value = deptNames;
   name.value = names;
+  averageData(item.averageSore);
   console.log("tableData.value", tableData.value);
   console.log("deptName.value", item);
 };

+ 82 - 25
src/views/evaluate/children/change/components/settingIndexDrawer.vue

@@ -55,7 +55,9 @@ const getIndexInfoApi = async id => {
   // console.log("1111", data);
   if (code === 200) {
     Object.assign(params, data);
-    params.personList = data.designatedPersonnel.split(",");
+    if (data.designatedPersonnel) {
+      params.personList = data.designatedPersonnel.split(",");
+    }
     if (isValidJSON(data.formula)) {
       if (params.formulaType == 0) {
         params.formula = JSON.parse(data.formula);
@@ -136,6 +138,40 @@ const conditionVerifyApi = async () => {
   }
 };
 // 计算
+// 多条件公式计算
+function reverseReplace(oldValue, dataObject) {
+  // 确保 formulaForm 是一个数组
+  if (!Array.isArray(oldValue)) {
+    throw new Error("formulaForm 应该是一个数组");
+  }
+  oldValue.forEach(item => {
+    // 遍历外部条件和内部条件的表达式
+    for (const key in dataObject) {
+      const value = dataObject[key];
+
+      if (typeof value === "string") {
+        // 如果字符串中包含当前name,则替换该值
+        if (value.includes(item.name)) {
+          dataObject[key] = value.replace(item.name, item.value);
+        }
+      } else if (Array.isArray(value)) {
+        // 如果是数组,递归替换数组中的每个对象
+        value.forEach(innerObj => {
+          for (const innerKey in innerObj) {
+            const innerValue = innerObj[innerKey];
+            if (
+              typeof innerValue === "string" &&
+              innerValue.includes(item.name)
+            ) {
+              innerObj[innerKey] = innerValue.replace(item.name, item.value);
+            }
+          }
+        });
+      }
+    }
+  });
+  return dataObject;
+}
 const countComputed = async () => {
   try {
     if (params.formulaType == 0) {
@@ -182,18 +218,10 @@ const countComputed = async () => {
         });
       }
     } else if (params.formulaType == 1) {
-      let aa = JSON.parse(JSON.stringify(addmanyChange));
-      aa.outerConditionValue = formulaForm.value[0].value;
-      formulaForm.value.map((item, index) => {
-        if (index > 0) {
-          delete aa.innerConditionExpression[index - 1].select;
-          aa.innerConditionExpression[
-            index - 1
-          ].scoreRuleMoreInnerVO[0].innerConditionValue = item.value;
-        }
-      });
+      const oldValue = addmanyChange;
+      let newValue = reverseReplace(formulaForm.value, oldValue);
       const { code, msg, data } =
-        await calculateScoreByConditionMoCondition(aa);
+        await calculateScoreByConditionMoCondition(newValue);
       if (code == 200) {
         grade.value = data;
       } else {
@@ -373,7 +401,6 @@ const count = item => {
   ElMessageBox.confirm("配置项确认保存?确认关闭", {
     type: "warning"
   }).then(() => {
-    params.scoreValue = params.formula.noConditionFormula;
     calculatorShow.value = false;
   });
   // try {
@@ -484,20 +511,50 @@ const addItemDataList = (
   });
 };
 // 多条件公式验证
+const keywords = ["目标值", "完成值", "挑战值", "增幅", "降幅"];
+// 处理字符串,提取关键词
+function extractKeywords(value) {
+  // 如果是字符串,处理包含的关键词
+  if (typeof value === "string") {
+    // 提取所有关键词
+    keywords.forEach(keyword => {
+      if (value.includes(keyword)) {
+        formulaForm.value.push({
+          name: keyword,
+          value: null // 可以根据需求赋值
+        });
+      }
+    });
+  }
+}
+// 遍历对象并处理
+function traverseObject(obj) {
+  if (obj && typeof obj === "object") {
+    for (const key in obj) {
+      if (obj.hasOwnProperty(key)) {
+        const value = obj[key];
+
+        // 如果值是字符串,调用提取函数
+        if (typeof value === "string") {
+          extractKeywords(value);
+        }
+
+        // 如果值是数组,递归处理
+        if (Array.isArray(value)) {
+          value.forEach(item => traverseObject(item));
+        }
+      }
+    }
+  }
+}
 const manyConditions = () => {
   dialogFormVisibleFormula.value = true;
   formulaForm.value = [];
-  console.log("1addmanyChange", addmanyChange);
-  formulaForm.value.push({
-    name: addmanyChange.outerConditionValue,
-    value: null
-  });
-  addmanyChange.innerConditionExpression.map((item, index) => {
-    formulaForm.value.push({
-      name: item.scoreRuleMoreInnerVO[0].innerConditionValue,
-      value: null
-    });
-  });
+  // 提取 addmanyChange 对象中的条件值
+  const oldValue = addmanyChange;
+  traverseObject(oldValue);
+  console.log("addmanyChange", formulaForm.value);
+  console.log("addmanyChange", addmanyChange);
 };
 // 计算器
 const jishuanqiRef = ref();
@@ -617,7 +674,7 @@ const handleRreeSelect = () => {
                   <div>
                     <el-text>得分 =</el-text>
                     <el-input
-                      v-model="params.scoreValue"
+                      v-model="params.formula.noConditionFormula"
                       class="ml-2 mr-2"
                       style="width: 240px"
                     />