spring
2 天以前 a3800bf1aa5a19997bf78434b891798a3ed84632
src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue
@@ -21,6 +21,7 @@
                     <el-select
                        v-model="form.approveDeptId"
                        placeholder="选择部门"
                @change="handleDeptChange"
                     >
                        <el-option
                           v-for="user in productOptions"
@@ -216,6 +217,7 @@
const emit = defineEmits(['close'])
import useUserStore from "@/store/modules/user";
import { getCurrentDate } from "@/utils/index.js";
import log from "@/views/monitor/job/log.vue";
const userStore = useUserStore();
const dialogFormVisible = ref(false);
@@ -278,7 +280,17 @@
function removeApproverNode(index) {
  approverNodes.value.splice(index, 1)
}
// 处理部门选择变化
const handleDeptChange = (deptId) => {
  if (deptId) {
    const selectedDept = productOptions.value.find(dept => dept.deptId === deptId);
    if (selectedDept) {
      form.value.approveDeptName = selectedDept.deptName;
    }
  } else {
    form.value.approveDeptName = '';
  }
};
// 打开弹框
const openDialog = (type, row) => {
  operationType.value = type;
@@ -286,7 +298,6 @@
   userListNoPageByTenantId().then((res) => {
    userList.value = res.data;
  });
  getProductOptions();
   form.value = {}
   approverNodes.value = [
      { id: 1, userId: null }
@@ -296,6 +307,9 @@
  
  // 获取当前用户信息并设置部门ID
  form.value.approveDeptId = userStore.currentDeptId
  // 加载部门选项,并在加载完成后设置部门名称
  getProductOptions();
  if (operationType.value === 'edit') {
    fileList.value = row.commonFileList
    form.value.tempFileIds = fileList.value.map(file => file.id)
@@ -318,8 +332,18 @@
  }
}
const getProductOptions = () => {
  getDept().then((res) => {
  return getDept().then((res) => {
    productOptions.value = res.data;
    // 如果已有部门ID,自动设置部门名称(用于验证)
    if (form.value.approveDeptId && productOptions.value.length > 0) {
      const matchedDept = productOptions.value.find(dept =>
        dept.deptId == form.value.approveDeptId ||
        String(dept.deptId) === String(form.value.approveDeptId)
      );
      if (matchedDept) {
        form.value.approveDeptName = matchedDept.deptName;
      }
    }
  });
};
function convertIdToValue(data) {