招标文件修改

This commit is contained in:
吴红兵
2026-03-15 17:39:50 +08:00
parent 9b60b7f29c
commit 7e0371134b

View File

@@ -255,7 +255,6 @@
</el-select>
<el-button
type="primary"
:loading="randomSelectLoading"
:disabled="randomCandidates.length < 2 || isViewMode"
style="margin-left: 12px"
@click="handleRandomSelect"
@@ -307,7 +306,7 @@ import {
} from '/@/api/purchase/bidfile';
import { getRequirementFiles } from '/@/api/purchase/purchasingfiles';
import { currElTabIsSave } from '/@/api/order/order-key-vue';
import { searchTeachers, randomSelectRepresentor } from '/@/api/purchase/purchasingrequisition';
import { searchTeachers } from '/@/api/purchase/purchasingrequisition';
// ==================== Props & Emits ====================
@@ -437,9 +436,9 @@ const selectedRepresentor = ref<string>('');
const candidatesOptions = ref<any[]>([]);
const candidatesLoading = ref(false);
const randomCandidates = ref<string[]>([]);
const selectedCandidatesMap = ref<Map<string, any>>(new Map()); // 存储已选候选人的完整信息
const currentRepresentor = ref<any>(null);
const representorType = ref<string>('purchase_rep');
const randomSelectLoading = ref(false);
// ==================== 计算属性 ====================
@@ -763,43 +762,41 @@ const searchCandidates = async (query: string) => {
};
const onCandidatesChange = (teacherNos: string[]) => {
// 保留已选中的选项,防止清空搜索时选项丢失
const selectedMap = new Map<string, any>();
randomCandidates.value.forEach((no) => {
const existing = candidatesOptions.value.find((item) => item.teacherNo === no);
// 保留已选中的候选人的完整信息
const newMap = new Map<string, any>();
teacherNos.forEach((no) => {
// 先从已有映射中查找
const existing = selectedCandidatesMap.value.get(no);
if (existing) {
selectedMap.set(no, existing);
newMap.set(no, existing);
} else {
// 从当前选项列表中查找
const fromOptions = candidatesOptions.value.find((item) => item.teacherNo === no);
if (fromOptions) {
newMap.set(no, fromOptions);
}
}
});
// 如果新选中的选项中有不在当前选项列表中的,需要从之前的结果中找
if (teacherNos.length > 0 && currentRepresentor.value) {
const currentNo = currentRepresentor.value.teacherNo;
if (teacherNos.includes(currentNo)) {
selectedMap.set(currentNo, currentRepresentor.value);
}
}
selectedCandidatesMap.value = newMap;
};
const handleRandomSelect = async () => {
const handleRandomSelect = () => {
if (randomCandidates.value.length < 2) {
ElMessage.warning('请至少选择2名候选人');
return;
}
try {
randomSelectLoading.value = true;
const res = await randomSelectRepresentor(effectivePurchaseId.value, randomCandidates.value.join(','));
if (res.code === 0 && res.data) {
currentRepresentor.value = res.data;
ElMessage.success(`随机抽取成功:${res.data.realName}`);
} else {
ElMessage.error(res.msg || '随机抽取失败');
}
} catch (e: any) {
ElMessage.error(e?.msg || '随机抽取失败');
} finally {
randomSelectLoading.value = false;
// 从已选择的候选人中随机抽取
const candidates = Array.from(selectedCandidatesMap.value.values());
if (candidates.length === 0) {
ElMessage.warning('未找到候选人信息');
return;
}
const randomIndex = Math.floor(Math.random() * candidates.length);
const selected = candidates[randomIndex];
currentRepresentor.value = selected;
ElMessage.success(`随机抽取成功:${selected.realName || selected.name}`);
};
// ==================== 生命周期 ====================