招标文件修改

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