Browse Source

fix: 1.1bug

ystl_myq 1 month ago
parent
commit
b3e645f2bc

File diff suppressed because it is too large
+ 0 - 0
src/assets/svg/公式计算.svg


BIN
src/assets/公式计算.png


+ 175 - 76
src/views/evaluate/children/change/components/editMould.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { ref, reactive, watch, computed, onMounted } from "vue";
+import { ref, reactive, watch, computed, onMounted, nextTick } from "vue";
 import { ElMessageBox, ElMessage } from "element-plus";
 import { useRoute } from "vue-router";
 import {
@@ -17,6 +17,11 @@ const dalongTitle = ref("");
 const direction = ref<DrawerProps["direction"]>("rtl");
 const ruleFormRef = ref();
 const dimWeight = ref(false);
+const oldIndexList = reactive({
+  // 分数
+  indLimitScore: []
+});
+// 分数
 const formLabelAlign = reactive({
   id: "",
   list: [
@@ -44,14 +49,10 @@ const formLabelAlign = reactive({
 });
 // 存储指标变量,修改指标最高值时使用
 const changeIndexList = ref([]);
-const newAddItem = ref();
-const handleClose = (done: () => void) => {
-  done();
+const handleClose = () => {
+  Object.assign(formLabelAlign, {});
   drawer.value = false;
 };
-function cancelClick() {
-  drawer.value = false;
-}
 function confirmClick() {
   ruleFormRef.value.validate((valid: boolean) => {
     if (valid) {
@@ -67,7 +68,8 @@ function confirmClick() {
 const titleName = ref("");
 const indexList = ref([]);
 const open = (row: any, title: string, order: number) => {
-  console.log("编辑", row, title);
+  Object.assign(formLabelAlign, {});
+  oldIndexList.indLimitScore = [];
   dalongTitle.value = title;
   if (title == "新建") {
     titleName.value = "新建考核维度";
@@ -91,15 +93,25 @@ const open = (row: any, title: string, order: number) => {
   }
   if (title == "编辑") {
     titleName.value = "编辑考核维度";
-    Object.assign(formLabelAlign, {
-      ...row,
-      order
-    });
+    // 深拷贝对象防止父子通信的双向绑定
+    Object.assign(
+      formLabelAlign,
+      JSON.parse(
+        JSON.stringify({
+          ...row,
+          order
+        })
+      )
+    );
     formLabelAlign.tableData.map(item => {
       item["indNameIndex"] = item.indName;
     });
     changeIndexList.value = formLabelAlign.tableData;
     indexList.value = formLabelAlign.tableData.reduce((acc, current) => {
+      // 检查 current.indLimitScore 是否为空,如果为空则跳过
+      if (!current.indLimitScore) {
+        return acc; // 直接返回当前的结果数组,不做任何操作
+      }
       // 找到当前项的 indLimitScore 是否已经存在于结果数组中
       let found = acc.find(
         group => group[0].indLimitScore === current.indLimitScore
@@ -111,14 +123,11 @@ const open = (row: any, title: string, order: number) => {
         // 如果没有找到,创建一个新的数组并将当前项加入
         acc.push([current]);
       }
-
       return acc;
     }, []);
-    // indexList.value.map(item => {
-    //   item.map(it => {
-    //     it["indNameIndex"] = "";
-    //   });
-    // });
+    indexList.value.map(item => {
+      oldIndexList.indLimitScore.push(item[0].indLimitScore);
+    });
     watchTableData();
   }
   drawer.value = true;
@@ -180,7 +189,6 @@ const remarkValueValue = computed({
 // 分割————————————————————————————————————————————
 // 新建维度
 const postAddDimensionApi = async () => {
-  console.log("新建维度", formLabelAlign);
   const { code, msg } = await postAddDimension(formLabelAlign);
   if (code === 200) {
     ElMessage({
@@ -200,12 +208,12 @@ const postAddDimensionApi = async () => {
 const postUpdateDeptApi = async () => {
   const { code, msg } = await postUpdateDept(formLabelAlign);
   if (code === 200) {
-    ElMessage({
-      message: "更新成功",
-      type: "success"
-    });
-    $emit("handClick", formLabelAlign.tpId);
-    drawer.value = false;
+    // ElMessage({
+    //   message: "更新成功",
+    //   type: "success"
+    // });
+    // $emit("handClick", formLabelAlign.tpId);
+    // drawer.value = false;
   } else {
     ElMessage({
       message: msg,
@@ -214,29 +222,44 @@ const postUpdateDeptApi = async () => {
   }
 };
 const handClose = (indName, ind, indId) => {
-  // console.log("item", ind, indId);
-  indexList.value[ind].splice(indId, 1);
-  if (indexList.value[ind].length == 0) {
-    indexList.value.splice(ind, 1);
-  }
   let newIndName = indName;
   newIndName.indLimitScore = null;
-  formLabelAlign.tableData.push(newIndName);
+  nextTick(() => {
+    formLabelAlign.tableData.push(newIndName);
+    indexList.value[ind].splice(indId, 1);
+    if (indexList.value[ind].length == 0) {
+      console.log("oldIndexList", oldIndexList.indLimitScore);
+      oldIndexList.indLimitScore[ind] = 1;
+      indexList.value.splice(ind, 1);
+      console.log("newold", oldIndexList.indLimitScore);
+    }
+    if (indexList.value[ind]?.length > 0 && !indexList.value[ind][0].id) {
+      indexList.value[ind].splice(0, 1);
+    }
+  });
 };
 const delteIndex = (index, item) => {
-  indexList.value[index].map(it => {
-    it.indLimitScore = null;
-    formLabelAlign.tableData.push(it);
+  nextTick(() => {
+    indexList.value[index].map(it => {
+      if (it.id) {
+        it.indLimitScore = null;
+        formLabelAlign.tableData.push(it);
+      }
+    });
+    indexList.value.splice(index, 1);
+    oldIndexList.indLimitScore.splice(index, 1);
   });
-  indexList.value.splice(index, 1);
 };
 const addIndex = () => {
-  indexList.value.push([
-    {
-      indNameIndex: "",
-      indLimitScore: null
-    }
-  ]);
+  nextTick(() => {
+    indexList.value.push([
+      {
+        indNameIndex: "",
+        indLimitScore: null
+      }
+    ]);
+    oldIndexList.indLimitScore.push(1);
+  });
 };
 const watchTableData = () => {
   const idsToDelete = new Set();
@@ -251,32 +274,63 @@ const watchTableData = () => {
     item => !idsToDelete.has(item.id)
   );
   formLabelAlign.tableData = filteredTableData;
-  console.log("tableDatatableData", filteredTableData);
 };
 const handChangeIndex = (ind, val) => {
-  changeIndexList.value.map(item => {
-    if (item.id == val) {
-      formLabelAlign.tableData;
-      indexList.value[ind].push(item);
-      watchTableData();
-    }
+  // <!--select使用交互有bug,响应式数据加载慢-- >
+  // changeIndexList.value.map(item => {
+  //   if (item.id == val) {
+  //     nextTick(() => {
+  //       indexList.value[ind].push(item);
+  //       watchTableData();
+  //     });
+  //   }
+  // });
+  nextTick(() => {
+    indexList.value[ind].push(val);
+    watchTableData();
   });
 };
 const postUpdateApi = async () => {
-  indexList.value.map(item => {
+  let codeList = [];
+  let successList = [];
+  console.log("数据", indexList.value);
+  indexList.value.map((item, index) => {
     item.map(async (item1, index1, arr1) => {
       if (item1.id) {
-        item1.indLimitScore = arr1[item.length - 1].indLimitScore;
+        item1.indLimitScore = oldIndexList.indLimitScore[index];
         const { code } = await postUpdate(item1);
+        codeList.push(item1.id);
+        if (code == 200) {
+          successList.push(code);
+        }
       }
     });
   });
+  if (successList.length == codeList.length) {
+    ElMessage({
+      message: "更新成功",
+      type: "success"
+    });
+    $emit("handClick", formLabelAlign.tpId);
+    drawer.value = false;
+  }
   console.log("indexList", indexList.value);
 };
 defineExpose({
   open
 });
-const value = ref("");
+// 输入验证方法
+const validateInput = ind => {
+  // 转换输入为数字
+  console.log("ind", ind);
+  const num = parseFloat(oldIndexList.indLimitScore[ind]);
+
+  // 如果输入不是有效的数字,或者小于等于0,清空输入框
+  if (isNaN(num) || num <= 0) {
+    ElMessage.error("请输入大于0的数字,且不能为空");
+    oldIndexList.indLimitScore[ind] = 1;
+  }
+};
 </script>
 
 <template>
@@ -339,30 +393,66 @@ const value = ref("");
                     class="mx-1"
                     type="danger"
                     @click="delteIndex(ind, int)"
-                    ><el-icon> <Delete /> </el-icon
-                  ></el-text>
+                  >
+                    <el-icon>
+                      <Delete />
+                    </el-icon>
+                  </el-text>
                   <el-text class="mx-1">不超过</el-text>
+                  <!-- <el-input v-model="int[int.length - 1].indLimitScore" size="small" style="width: 45px" /> -->
                   <el-input
-                    v-model="int[int.length - 1].indLimitScore"
+                    v-model="oldIndexList.indLimitScore[ind]"
                     size="small"
-                    style="width: 30px"
+                    style="width: 45px"
+                    @input="validateInput(ind)"
                   />
                   <el-text class="mx-1">分</el-text>
-                  <!-- <el-select v-model="int[int.length - 1].indNameIndex" placeholder="Select" style="width: 140px" -->
-                  <el-select
-                    v-model="int[int.length - 1].indNameIndex"
-                    placeholder="Select"
-                    style="width: 140px"
-                    filterable
-                    @change="handChangeIndex(ind, $event)"
-                  >
-                    <el-option
-                      v-for="item in formLabelAlign.tableData"
-                      :key="item.id"
-                      :label="item.indName"
-                      :value="item.id"
-                    />
-                  </el-select>
+                  <!-- select使用交互有bug,响应式数据加载慢,拿不到最新数据 -->
+                  <!-- <el-select v-model="int[int.length - 1].indNameIndex" placeholder="请选择指标" style="width: 140px"
+                    filterable @change="handChangeIndex(ind, $event)">
+                    <el-option v-for="item in formLabelAlign.tableData" :key="item.id" :label="item.indNameIndex"
+                      :value="item.id" />
+                  </el-select> -->
+                  <el-dropdown trigger="click" placement="bottom-start">
+                    <span class="el-dropdown-link">
+                      <el-input
+                        v-model="int[int.length - 1].indNameIndex"
+                        style="width: 140px"
+                      />
+                    </span>
+                    <template #dropdown>
+                      <el-dropdown-menu>
+                        <div
+                          v-if="formLabelAlign.tableData.length > 0"
+                          style="max-height: 300px"
+                        >
+                          <el-scrollbar>
+                            <div
+                              v-if="formLabelAlign.tableData.length > 0"
+                              class="p-2"
+                            >
+                              <div
+                                v-for="item in formLabelAlign.tableData"
+                                :key="item.id"
+                                class="w-full h-8 flex items-center justify-center text-center cursor-pointer hoverBlue p-2"
+                                @click="handChangeIndex(ind, item)"
+                              >
+                                <!-- <el-text class="mx-1" type="info"> -->
+                                {{ item.indName }}
+                                <!-- </el-text> -->
+                              </div>
+                            </div>
+                          </el-scrollbar>
+                        </div>
+                        <div
+                          v-else
+                          class="w-[150px] h-10 flex items-center justify-center"
+                        >
+                          <el-text class="mx-1" type="info">暂无数据</el-text>
+                        </div>
+                      </el-dropdown-menu>
+                    </template>
+                  </el-dropdown>
                   <span v-for="(indName, indId) in int" :key="indId">
                     <el-tag
                       v-if="indName.indName"
@@ -375,11 +465,6 @@ const value = ref("");
                     </el-tag>
                   </span>
                 </div>
-                <!-- <el-text size="large" type="primary">
-                  <el-icon>
-                    <Plus />
-                  </el-icon>
-                </el-text> -->
                 <el-tag type="primary" @click="addIndex">
                   <el-icon> <Plus /> </el-icon>添加
                 </el-tag>
@@ -428,10 +513,24 @@ const value = ref("");
       </template>
       <template #footer>
         <div>
-          <el-button @click="cancelClick">取消</el-button>
+          <el-button @click="handleClose">取消</el-button>
           <el-button type="primary" @click="confirmClick">确认</el-button>
         </div>
       </template>
     </el-drawer>
   </div>
 </template>
+<style scoped lang="scss">
+.hoverBlue {
+  overflow: hidden;
+  font-size: 14px;
+  color: #999;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.hoverBlue:hover {
+  color: #4285f4 !important;
+  background-color: #99999912;
+}
+</style>

+ 18 - 5
src/views/evaluate/children/change/components/settingIndexDrawer.vue

@@ -68,7 +68,7 @@ const params = reactive({
   startValue: "",
   datasoure: "",
   weight: "",
-  valueScore: 0,
+  valueScore: null,
   scoreValue: "",
   formula: {
     noConditionFormula: ""
@@ -443,8 +443,8 @@ const open = row => {
     dimId: "",
     indId: "",
     valueInput: "",
-    designatedPersonnel: "",
     scoreStandard: 0,
+    designatedPersonnel: "",
     remark: "",
     scoreRule: "",
     targetValue: "",
@@ -454,8 +454,8 @@ const open = row => {
     startValue: "",
     datasoure: "",
     weight: "",
+    valueScore: null,
     scoreValue: "",
-    personList: "",
     formula: {
       noConditionFormula: ""
     }
@@ -902,6 +902,11 @@ const changeAddMay = () => {
 const formulaFocus = () => {
   calculatorShow.value = true;
 };
+const changeValueInput = val => {
+  if (val == 4 || val == "4") {
+    params.valueScore = 0;
+  }
+};
 // { deep: true };
 </script>
 
@@ -920,7 +925,11 @@ const formulaFocus = () => {
         <div>
           <el-form label-position="top" label-width="auto" :model="params">
             <el-form-item label="完成值录入人" label-position="top">
-              <el-select v-model="params.valueInput" placeholder="请选择">
+              <el-select
+                v-model="params.valueInput"
+                placeholder="请选择"
+                @change="changeValueInput"
+              >
                 <el-option label="被考核人" :value="0" />
                 <!-- <el-option label="上级" :value="1" /> -->
                 <el-option label="指定人员" :value="2" />
@@ -939,7 +948,11 @@ const formulaFocus = () => {
                 @check-change="handleRreeSelect()"
               />
             </el-form-item>
-            <el-form-item label="完成值计算方式" label-position="top">
+            <el-form-item
+              v-if="params.valueInput == 4"
+              label="完成值计算方式"
+              label-position="top"
+            >
               <el-radio-group v-model="params.valueScore">
                 <el-radio :value="0" size="large">统计计算</el-radio>
                 <el-radio :value="1" size="large">累加计算</el-radio>

+ 2 - 1
src/views/evaluate/children/change/manage/addExam.vue

@@ -91,6 +91,7 @@ const saveDepartment = () => {
         ElMessage.error("请选择考核周期的具体时间");
         return false;
       }
+      console.log("考核周期", form.listArr);
       form.assessmentObjectList = transformArrayFormat(form.listArr);
       if (timeType.value == "月度") {
         form.cycleValue = dayjs(new Date(form.cycleValue)).format("YYYY-MM");
@@ -114,7 +115,7 @@ const saveDepartment = () => {
         $emit("addHandClick");
         dialogVisibleAdd.value = false;
       } else {
-        ElMessage.error(msg);
+        // ElMessage.error(msg);
       }
     }
   });

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

@@ -290,6 +290,7 @@ const postUpdateApi = async () => {
               </el-select>
             </el-form-item>
             <el-form-item
+              v-if="formLabelAlign.scoreStandard === 1"
               label="公式类型"
               label-position="top"
               prop="sourceValue"
@@ -300,7 +301,10 @@ const postUpdateApi = async () => {
               </el-select>
             </el-form-item>
             <el-form-item
-              v-if="formLabelAlign.formulaType == 0"
+              v-if="
+                formLabelAlign.formulaType == 0 &&
+                formLabelAlign.scoreStandard === 1
+              "
               label="设置"
               label-position="top"
               prop="sourceValue"
@@ -319,7 +323,10 @@ const postUpdateApi = async () => {
               </div>
             </el-form-item>
             <el-form-item
-              v-else
+              v-if="
+                formLabelAlign.formulaType == 1 &&
+                formLabelAlign.scoreStandard === 1
+              "
               label="设置"
               label-position="top"
               prop="sourceValue"

+ 6 - 2
src/views/evaluate/children/change/mould/manageObject.vue

@@ -19,6 +19,7 @@ import {
 import editIndex from "./editIndex.vue";
 import { getTemplateInfoList } from "@/api/templateInfo";
 import { useRouter } from "vue-router";
+import iconEdit from "@/assets/公式计算.png";
 import { ElMessage, ElMessageBox } from "element-plus";
 import {
   treeDept,
@@ -1748,9 +1749,12 @@ const selectAllChangeEvent = row => {
               </el-dropdown>
             </template>
             <template #default="{ row }">
-              <el-icon @click="editIndexOpen(row)">
+              <div class="w-5 h-5">
+                <img :src="iconEdit" alt="" @click="editIndexOpen(row)" />
+              </div>
+              <!-- <el-icon @click="editIndexOpen(row)">
                 <Edit />
-              </el-icon>
+              </el-icon> -->
             </template>
           </vxe-column>
         </vxe-table>

Some files were not shown because too many files changed in this diff