移入其他项目或作业队功能 - Vue 项目员工管理系统
<n-button type='warning' @click='handleOtherTeam' size='small' v-if='props.isteam'>移入到其他作业队 <n-button type='warning' @click='handleOtherProject' size='small' v-else>移入到其他项目
const props = defineProps({ projectId: { type: String, default: null, }, OwnChange: { type: Boolean, }, isteam: { type: Boolean, default: false, }, });
//移入到其他项目
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() {
try {
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;
}
} catch (error) {
console.error(error);
}
} 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('请填写完整信息!'); } }); }
原文地址: https://www.cveoy.top/t/topic/gIhx 著作权归作者所有。请勿转载和采集!