Przeglądaj źródła

fix: 修改考核指标多条件修改

username 3 miesięcy temu
rodzic
commit
47197f7ae1

+ 11 - 3
src/components/formula/manyFormula.vue

@@ -24,8 +24,17 @@ const $props = defineProps({
 onMounted(() => {
   if ($props.formulaJSON) {
     nextTick(() => {
-      Object.assign(addmanyChange, JSON.parse($props.formulaJSON));
-      console.log("多公式", addmanyChange);
+      if (typeof $props.formulaJSON === "string") {
+        Object.assign(addmanyChange, JSON.parse($props.formulaJSON));
+      } else {
+        Object.assign(addmanyChange, $props.formulaJSON);
+      }
+      console.log(
+        "多公式",
+        addmanyChange,
+        "$props.formulaJSON",
+        $props.formulaJSON
+      );
     });
     // let a = JSON.parse($props.formulaJSON);
   }
@@ -400,7 +409,6 @@ const countComputed = async () => {
     <div class="flex items-center">
       <el-text>条件值 = </el-text>
       <jishuanqi
-        v-if="addmanyChange.outerConditionValue"
         ref="jishuanqiRef"
         :outerConditionValue="addmanyChange.outerConditionValue"
         @handClick="countNoConditionFormula"

+ 57 - 7
src/views/evaluate/children/change/components/settingIndexDrawer.vue

@@ -275,7 +275,6 @@ function calculateScore(inputString) {
 }
 
 const countComputed = async () => {
-  console.log("params", params.formulaType);
   try {
     if (params.formulaType == 0) {
       const formula = JSON.stringify(params.formula);
@@ -324,6 +323,11 @@ const countComputed = async () => {
         });
       }
     } else if (params.formulaType == 1) {
+      // 判断是公式还是数字
+      if (containsKeywordInScore(addmanyChange.outerConditionValue, GONG_SHI)) {
+        addmanyChange.outerConditionValueExpress =
+          addmanyChange.outerConditionValue;
+      }
       let oldValue = JSON.parse(JSON.stringify(addmanyChange));
       // Object.assign(oldValue, addmanyChange);
       const formulaPar = JSON.stringify(oldValue);
@@ -339,11 +343,54 @@ const countComputed = async () => {
         // }
         // 暂时注释上面代码,不知道会不会影响到其他业务逻辑,待验证
         if (formulaForm.value && Array.isArray(formulaForm.value) && oldValue) {
-          for (const item of formulaForm.value) {
-            if (oldValue.outerConditionValueExpress === item.name) {
-              oldValue.outerConditionValue = item.value;
-              break;
+          const keywordss = [
+            "完成值",
+            "目标值",
+            "门槛值",
+            "挑战值",
+            "增幅",
+            "降幅",
+            "上期完成值",
+            "上上期完成值"
+          ];
+          if (
+            keywordss.find(item => oldValue.outerConditionValueExpress == item)
+          ) {
+            for (const item of formulaForm.value) {
+              if (oldValue.outerConditionValueExpress === item.name) {
+                oldValue.outerConditionValue = item.value;
+                break;
+              }
             }
+          } else {
+            const keywords = [
+              "完成值",
+              "目标值",
+              "门槛值",
+              "挑战值",
+              "增幅",
+              "降幅",
+              "上期完成值",
+              "上上期完成值"
+            ];
+            let str = oldValue.outerConditionValueExpress;
+            // 创建一个正则表达式,匹配这些关键词
+            const regex = new RegExp(keywords.join("|"), "g");
+            let result = str.replace(regex, match => {
+              // 在 formulaForm.value 中查找匹配的项
+              let matchedItem = formulaForm.value.find(
+                item => item.name === match
+              );
+
+              // 如果找到匹配项,返回其 value,否则返回原始匹配值
+              if (matchedItem) {
+                return matchedItem.value; // 替换为对应的值
+              }
+              return match; // 如果没有匹配项,返回原始匹配值
+            });
+            // calculator.calculate(result);
+            // grade.value = calculator.get();
+            oldValue.outerConditionValue = eval(result).toFixed(2);
           }
         }
         if (oldValue.innerConditionExpression.length > 0) {
@@ -378,6 +425,7 @@ const countComputed = async () => {
           });
         }
         // let newValue = reverseReplace(formListNum, oldValue);
+        console.log(oldValue, "oldValue--最终传值");
         const { code, msg, data } =
           await calculateScoreByConditionMoCondition(oldValue);
         if (code == 200) {
@@ -402,7 +450,7 @@ const countComputed = async () => {
 // 判断是否为json
 function isValidJSON(str) {
   try {
-    if (!str.includes("\\")) {
+    if (!str.includes("\\\\")) {
       return JSON.parse(str);
     } else {
       return JSON.parse(JSON.parse(str));
@@ -495,6 +543,7 @@ const open = row => {
       }
     ]
   });
+  console.log("打印是否触发数据");
   getIndexInfoApi(row.id);
   calculatorShow.value = true;
 };
@@ -883,7 +932,6 @@ const changeAddMay = () => {
   let addmanyChangeOldVal = JSON.parse(JSON.stringify(addmanyChange));
   addmanyChange.innerConditionExpression.forEach((item, index, arr) => {
     if (index + 1 <= arr.length) {
-      console.log("12312", addmanyChangeOldVal.innerConditionExpression);
       if (item.endValue) {
         if (addmanyChangeOldVal.innerConditionExpression.length > 1) {
           addmanyChangeOldVal.innerConditionExpression[index + 1].startValue =
@@ -1293,6 +1341,7 @@ const changeValueInput = val => {
                               v-model="item.endValue"
                               class="ml-2 mr-5"
                               style="width: 80px"
+                              @blur="changeAddMay"
                             />
                           </div>
                           <el-text v-if="item.scoreRuleMoreInnerVO.length == 0"
@@ -1418,6 +1467,7 @@ const changeValueInput = val => {
                                   v-model="itemList.endValue"
                                   class="ml-2"
                                   style="width: 80px"
+                                  @blur="changeAddMay"
                                 />
                               </div>
                               <div

+ 9 - 1
src/views/evaluate/children/change/mould/editIndex.vue

@@ -230,6 +230,11 @@ const postUpdateApi = async () => {
     // ElMessage.error(msg);
   }
 };
+// 切换公式类型
+// 监听formulaType变化
+const watchFormulaType = value => {
+  console.log("formulaOne", formulaOne);
+};
 </script>
 
 <template>
@@ -304,7 +309,10 @@ const postUpdateApi = async () => {
               label-position="top"
               prop="sourceValue"
             >
-              <el-select v-model="formLabelAlign.formulaType">
+              <el-select
+                v-model="formLabelAlign.formulaType"
+                @change="watchFormulaType"
+              >
                 <el-option label="无条件公式" :value="0" />
                 <el-option label="多条件公式" :value="1" />
               </el-select>

+ 12 - 1
src/views/indexData/components/addDialog.vue

@@ -57,11 +57,22 @@ const close = () => {
 
 // 指标名称
 const restaurants = ref([]);
+const filterDuplicateSourceValues = arr => {
+  const seen = new Map();
+  return arr.filter(item => {
+    const sourceValue = item.sourceValue;
+    if (!seen.has(sourceValue)) {
+      seen.set(sourceValue, true);
+      return true;
+    }
+    return false;
+  });
+};
 const querySearch = (queryString: string, cb: any) => {
   const results = queryString
     ? restaurants.value.filter(createFilter(queryString))
     : restaurants.value;
-  cb(results);
+  cb(filterDuplicateSourceValues(results));
 };
 const createFilter = (queryString: string) => {
   return restaurant => {

+ 9 - 1
src/views/indexData/components/editDrawer.vue

@@ -83,7 +83,8 @@ const confirmClick = () => {
           "YYYY-MM-DD"
         );
       }
-      const { code, msg } = await editListApi(formLabelAlign);
+      console.log("formLabelAlign", formLabelAlign, "formLabelAlign.userId");
+      const { code, msg } = await editListApi({ ...formLabelAlign });
       saveLoading.value = false;
       if (code === 200) {
         ElMessage({
@@ -163,11 +164,17 @@ const handleDept = async val => {
   }
 };
 const handleUser = val => {
+  formLabelAlign.userId = val;
   userSelect.value.forEach(item => {
     if (item.hospitalCode === val) {
       formLabelAlign.userName = item.realName;
+    } else {
+      formLabelAlign.userName = "";
     }
   });
+  if (!val) {
+    formLabelAlign.userId = "";
+  }
 };
 </script>
 
@@ -219,6 +226,7 @@ const handleUser = val => {
                 @node-click="handleNodeDeptClick"
               />
             </el-form-item>
+            {{ formLabelAlign.userId }}
             <el-form-item label="员工名称" label-position="top">
               <el-select
                 v-model="formLabelAlign.userId"