-
+
+ 志愿 {{scope.row.indexs}}
+
+
{
+ getVolunteerDetail()
+ state.activePage = page
+ state.visible.showOrderSaveBtn = false
+ })
+ .catch(() => {})
+ }else{
+ state.activePage = page
+ }
+
}
function switchBatch(batch:string){
@@ -1252,35 +1266,53 @@ function confirmVolunteerDeleteEvent(majorInfo:any){
if(majorInfo.batch === '提前批'|| majorInfo.batch.includes('本科')){
flag = true
a = state.volunteerInfo.volunteerBenIndexMap.get(key)
+ // state.volunteerInfo.volunteerBenList = state.volunteerInfo.volunteerBenList.filter((item:any)=>item.id != a.id)
}else{
a = state.volunteerInfo.volunteerZhuanIndexMap.get(key)
+ // state.volunteerInfo.volunteerZhuanList = state.volunteerInfo.volunteerZhuanList.filter((item:any)=>item.id != a.id)
}
- axiosInstance({
- url: ApiConstant.Volunteer.volunteerDeleteBatch,
- method: 'post',
- data:{
- list:[a.id]
- },
- /*showLoading: false,//是否显示加载图标*/
- }).then((response) => {
- return response.data
- }).then((data) => {
- if(!data.success){
- ElMessage.error(data.message);
- return false
- }else{
- ElMessage.success('删除成功');
- //删除这个志愿明细key信息
- deleteVolunteerMapByKey(flag,key)
- //刷新志愿明细
- getVolunteerDetail()
- //关闭弹框
- //closeOtherMajorDialog()
- }
- }).catch((error: any) => {
- console.log(error);
- }).finally(() => {
+
+ console.log('confirmVolunteerDeleteEvent',a)
+ // 1. 获取当前志愿列表
+ const currentList = returnVolunteerList();
+ const oldIndex = currentList.findIndex((item:any)=>item.id === a.id);
+ // 2. 删除该支援数据
+ currentList.splice(oldIndex, 1);
+ // 3. 重算 indexs (志愿序号),确保 UI 上的 "志愿1, 志愿2" 显示正确
+ currentList.forEach((item: any, index: number) => {
+ item.indexs = index + 1;
});
+
+ // deleteVolunteerMapByKey(flag,key)
+ state.visible.showOrderSaveBtn = true
+
+
+ // axiosInstance({
+ // url: ApiConstant.Volunteer.volunteerDeleteBatch,
+ // method: 'post',
+ // data:{
+ // list:[a.id]
+ // },
+ // /*showLoading: false,//是否显示加载图标*/
+ // }).then((response) => {
+ // return response.data
+ // }).then((data) => {
+ // if(!data.success){
+ // ElMessage.error(data.message);
+ // return false
+ // }else{
+ // ElMessage.success('删除成功');
+ // //删除这个志愿明细key信息
+ // deleteVolunteerMapByKey(flag,key)
+ // //刷新志愿明细
+ // getVolunteerDetail()
+ // //关闭弹框
+ // //closeOtherMajorDialog()
+ // }
+ // }).catch((error: any) => {
+ // console.log(error);
+ // }).finally(() => {
+ // });
}
//判断是storge/本科/专科 的志愿表map里删除
@@ -1540,12 +1572,14 @@ function handlerVolunteerSwitch(){
function closeOtherVolunteerDialog(){
state.visible.showOtherVolunteerDialog = false
}
+
//导出志愿信息
function handlerVolunteerExport(){
if(getScoreInfo() && state.volunteerInfo.id){
window.open('https://www.yitisheng.vip/volunteer/preview?id='+state.volunteerInfo.id+"&type=2")
}
}
+
// 切换志愿顺序
function handleSwitchVolunteer(now:any,endIndexs:any){
//state.switchVolunteerIndex
@@ -1644,7 +1678,7 @@ const initSortable = () => {
currentList.forEach((item: any, index: number) => {
item.indexs = index + 1;
});
-
+ console.log(currentList)
// 4. 显示保存按钮
state.visible.showOrderSaveBtn = true;
@@ -1672,35 +1706,60 @@ watch(() => state.selectForm.batchPaneName, () => {
// [新增] 保存排序事件
const handleSaveVolunteerOrder = () => {
- const currentList = returnVolunteerList();
-
+ // const tiqianList = state.volunteerInfo.volunteerTiQianList;
+ if(state.visible.showOrderSaveBtn){
+ ElMessageBox.confirm(
+ '确定保存新的志愿信息吗?',
+ '提示',
+ {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning',
+ }
+ )
+ .then(() => {
+ confirmSaveVolunteerOrder()
+ })
+ .catch(() => {})
+ }
+};
+
+const confirmSaveVolunteerOrder = () =>{
+ const benList = state.volunteerInfo.volunteerBenList;
+ const zhuanList = state.volunteerInfo.volunteerZhuanList;
// 提取需要的参数,通常只需要 id 和新的 indexs
- const sortData = currentList.map((item: any) => ({
- id: item.id || item.calculationMajorId, // 根据你实际的ID字段调整
+ const benSortData = benList.map((item: any) => ({
+ id: item.id,
+ calculationMajorId: item.calculationMajorId, // 根据你实际的ID字段调整
indexs: item.indexs
})).filter((item: any) => item.id); // 过滤掉空行
- // 这里调用你的后端接口
- // 模拟调用
- console.log('提交保存的数据:', sortData);
-
- /*
+ const zhuanSortData = zhuanList.map((item: any) => ({
+ id: item.id,
+ calculationMajorId: item.calculationMajorId, // 根据你实际的ID字段调整
+ indexs: item.indexs
+ })).filter((item: any) => item.id); // 过滤掉空行
+
+ const sortData = [...benSortData, ...zhuanSortData]
+ const calculationMajorIdList = sortData.map((item)=>item.calculationMajorId)
axiosInstance({
- url: ApiConstant.Volunteer.saveOrder, // 替换为你的保存排序接口
+ url: ApiConstant.Volunteer.saveFilledVolunteer, // 替换为你的保存排序接口
method: 'post',
- data: sortData
+ data: {
+ volunteerId: state.volunteerInfo.id,
+ calculationMajorIdList: calculationMajorIdList
+ },
}).then(res => {
- if(res.data.success){
+ if(res.data.success){
ElMessage.success('志愿顺序保存成功');
state.visible.showOrderSaveBtn = false; // 隐藏按钮
getVolunteerDetail(); // 重新获取最新数据
- }
+ }
+ }).catch(error => {
+ ElMessage.error('保存失败,请稍后重试');
+ console.error('保存志愿顺序出错:', error);
});
- */
- // 临时模拟成功
- ElMessage.success('顺序已保存 (演示)');
- state.visible.showOrderSaveBtn = false;
-};
+}