<n-button type='warning' @click='handleOtherProject' size='small' v-else>移入到其他项目

<el-dialog v-model='showOtherProject' title='移入到其他项目' @close='handleCloseOtherProject' width='50%'>

// 移入到其他项目
const showOtherProject = ref(false);
const other = reactive({
  data1: {
    projectId: '',
    teamId: '',
  },
  data2: {
    projectId: [{ required: computed(() => props.isteam == false), message: '请选择项目' }],
    teamId: [{ required: computed(() => props.isteam == true), message: '请选择作业队' }],
  },
});
const OtherProjectOptions = ref([]);
const otherArr = ref([]);
const OtherProjectRef = ref();

async function handleOtherProject() {
  const res = await getProjectTree();
  const options = res.map((e) => {
    const arr = [
      {
        id: e.id,
        projectName: '项目部',
        count: e.count,
      },
    ];
    e.children = arr.concat(e.items);
    let counts = 0;
    e.children = e.children.map((ele) => {
      counts += ele.count;
      ele.nameAndCount = ele.projectName + `(${ele.count} 人)`;
      return ele;
    });
    e.nameAndCount = e.projectName + `(共 ${counts} 人)`;
    return e;
  });
  OtherProjectOptions.value = options.map((e) => {
    return {
      label: e.nameAndCount,
      value: e.id,
    };
  });

  otherArr.value = projectRef.value.xGrid
    .getCheckboxReserveRecords()
    .concat(projectRef.value.xGrid.getCheckboxRecords());
  if (otherArr.value.length == 0) {
    message.warning('至少勾选一名员工!');
  } else {
    showOtherProject.value = true;
  }
}

function handleCloseOtherProject() {
  showOtherProject.value = false;
  other.data1.projectId = '';
  other.data1.teamId = '';
}

async function confirmOtherProject() {
  OtherProjectRef.value.validate(async (errors) => {
    if (!errors) {
      await editProjectPositions({
        ids: otherArr.value.map((e) => e.id),
        projectId: props.isteam ? other.data1.teamId : other.data1.projectId,
      });
      projectRef.value.reloadData();
      showOtherProject.value = false;
      other.data1.projectId = '';
      other.data1.teamId = '';
      message.success('移入成功!');
    } else {
      message.error('请填写完整信息!');
    }
  });
}
员工移入其他项目或作业队

原文地址: http://www.cveoy.top/t/topic/gIvx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录