饭卡、外校、宿舍
This commit is contained in:
parent
819800bef2
commit
e0eae6fa1c
|
@ -12,6 +12,7 @@ enum Api {
|
|||
importExcel = '/CEES/ceesDormitoryInfo/importExcel',
|
||||
exportXls = '/CEES/ceesDormitoryInfo/exportXls',
|
||||
selectBySex = '/CEES/ceesDormitoryInfo/selectBySex',
|
||||
setDormAndSubjectBatch = '/CEES/ceesDormitoryInfo/setDormAndSubjectBatch',
|
||||
}
|
||||
/**
|
||||
* 根据性别查询住宿信息
|
||||
|
@ -61,6 +62,47 @@ export const batchDelete = (params, handleSuccess) => {
|
|||
},
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 批量设置学科
|
||||
* @param params
|
||||
*/
|
||||
export const setDormAndSubject = (params, handleSuccess) => {
|
||||
console.log(params);
|
||||
|
||||
// 学科选项映射
|
||||
const subjectOptions = [
|
||||
{ label: '语文', value: 1 },
|
||||
{ label: '地理', value: 4 },
|
||||
{ label: '历史', value: 7 },
|
||||
{ label: '政治', value: 8 },
|
||||
];
|
||||
|
||||
// 获取当前选中的学科名称
|
||||
const selectedSubject = subjectOptions.find((item) => item.value === params.majorId)?.label || '';
|
||||
const redSubject = `<span style="color: red">${selectedSubject}</span>`;
|
||||
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: `设置学科`,
|
||||
content: `是否为选中宿舍数据设置为${redSubject}学科宿舍`,
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp
|
||||
.post(
|
||||
{
|
||||
url: Api.setDormAndSubjectBatch,
|
||||
data: params,
|
||||
},
|
||||
{ joinParamsToUrl: true }
|
||||
)
|
||||
.then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
|
|
|
@ -48,7 +48,7 @@ export const searchFormSchema: FormSchema[] = [
|
|||
{
|
||||
label: '宿舍信息',
|
||||
field: 'dormitory',
|
||||
component: 'Input',
|
||||
component: 'JInput',
|
||||
},
|
||||
{
|
||||
label: '所属学科',
|
||||
|
@ -58,6 +58,8 @@ export const searchFormSchema: FormSchema[] = [
|
|||
options: [
|
||||
{ label: '语文', value: 1 },
|
||||
{ label: '地理', value: 4 },
|
||||
{ label: '历史', value: 7 },
|
||||
{ label: '政治', value: 8 },
|
||||
],
|
||||
},
|
||||
ifShow: ({ values }) => {
|
||||
|
@ -85,6 +87,7 @@ export const formSchema: FormSchema[] = [
|
|||
{ label: '女', value: 1 },
|
||||
],
|
||||
},
|
||||
defaultValue: 1,
|
||||
dynamicRules: ({ model, schema }) => {
|
||||
return [{ required: true, message: '请选择男/女!' }];
|
||||
},
|
||||
|
@ -93,6 +96,7 @@ export const formSchema: FormSchema[] = [
|
|||
label: '宿舍人数',
|
||||
field: 'dormitoryNum',
|
||||
component: 'InputNumber',
|
||||
defaultValue: 4,
|
||||
dynamicRules: ({ model, schema }) => {
|
||||
return [{ required: true, message: '请输入宿舍人数!' }];
|
||||
},
|
||||
|
@ -108,6 +112,7 @@ export const formSchema: FormSchema[] = [
|
|||
{ label: '已满', value: 1 },
|
||||
],
|
||||
},
|
||||
defaultValue: 0,
|
||||
dynamicRules: ({ model, schema }) => {
|
||||
return [{ required: true, message: '请选择宿舍状态' }];
|
||||
},
|
||||
|
@ -124,9 +129,9 @@ export const formSchema: FormSchema[] = [
|
|||
{ label: '政治', value: 8 },
|
||||
],
|
||||
},
|
||||
dynamicRules: ({ model, schema }) => {
|
||||
return [{ required: true, message: '请选择所属学科!' }];
|
||||
},
|
||||
//dynamicRules: ({ model, schema }) => {
|
||||
// return [{ required: true, message: '请选择所属学科!' }];
|
||||
//},
|
||||
},
|
||||
// TODO 主键隐藏字段,目前写死为ID
|
||||
{
|
||||
|
|
|
@ -7,9 +7,37 @@
|
|||
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||
<a-button type="primary" @click="batchHandleDelete" v-if="hasPermission('dormitory:batchDelete')"
|
||||
>批量删除
|
||||
<a-dropdown>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="openModalSubject">
|
||||
<Icon icon="ant-design:usergroup-add-outlined" />
|
||||
批量设置宿舍学科
|
||||
</a-menu-item>
|
||||
<a-modal title="批量设置宿舍学科" v-model:visible="visible" @ok="handleOk" @cancel="handleCancel" width="400">
|
||||
<a-form :model="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }" label-align="left">
|
||||
<a-form-item label="所属学科" name="majorId" :rules="[{ required: true, message: '请选择学科' }]">
|
||||
<a-select v-model:value="form.majorId" placeholder="请选择学科" style="width: 100%">
|
||||
<a-select-option v-for="item in options" :key="item.value" :value="item.value">
|
||||
{{ item.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<a-menu-item key="1" @click="batchHandleDelete" v-if="hasPermission('dormitory:batchDelete')">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
批量删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button
|
||||
>批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<!--<a-button type="primary" @click="batchHandleDelete" v-if="hasPermission('dormitory:batchDelete')">批量删除 </a-button>-->
|
||||
<!-- 高级查询 -->
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
|
@ -44,7 +72,7 @@
|
|||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import CeesDormitoryInfoModal from './components/CeesDormitoryInfoModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema } from './CeesDormitoryInfo.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './CeesDormitoryInfo.api';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, setDormAndSubject } from './CeesDormitoryInfo.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
|
@ -88,6 +116,37 @@
|
|||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
const visible = ref(false);
|
||||
|
||||
const form = reactive({
|
||||
majorId: null,
|
||||
});
|
||||
|
||||
const options = [
|
||||
{ label: '语文', value: 1 },
|
||||
{ label: '地理', value: 4 },
|
||||
{ label: '历史', value: 7 },
|
||||
{ label: '政治', value: 8 },
|
||||
];
|
||||
|
||||
const openModalSubject = () => {
|
||||
visible.value = true;
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
};
|
||||
|
||||
const handleOk = async () => {
|
||||
if (!form.majorId) {
|
||||
message.warning('请选择学科');
|
||||
return;
|
||||
}
|
||||
console.log('选择的学科 ID:', form.majorId);
|
||||
// 调用后端接口设置
|
||||
await setDormAndSubject({ ids: selectedRowKeys.value, majorId: form.majorId }, handleSuccess);
|
||||
visible.value = false;
|
||||
};
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ enum Api {
|
|||
confirmCheckIn = '/cees/ceesWaiTeacher/confirmCheckIn',
|
||||
batchGroup = '/cees/ceesWaiTeacher/batchGroup',
|
||||
batchMealCard = '/cees/ceesWaiTeacher/batchMealCard',
|
||||
clearMealCardData = '/cees/ceesWaiTeacher/clearMealCardData',
|
||||
}
|
||||
|
||||
export const updateDormitory = (id, dormitory) => defHttp.get({ url: Api.updateDormitory, params: { id, dormitory } }); // ✅ 将参数包装为独立的对象 });
|
||||
|
@ -115,6 +116,26 @@ export const batchMealCard = (params, handleSuccess) => {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量清空饭卡
|
||||
* @param params
|
||||
*/
|
||||
export const clearMealCardData = (params, handleSuccess) => {
|
||||
console.log('params', params);
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认清空饭卡数据',
|
||||
content: '是否清空选中的饭卡数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.post({ url: Api.clearMealCardData, data: params }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
//更新分组中间表
|
||||
export const updateGroupUser = (params) => {
|
||||
return defHttp.post({ url: Api.updateGroupUser, params });
|
||||
|
|
|
@ -22,11 +22,14 @@
|
|||
<Icon icon="ant-design:usergroup-add-outlined" />
|
||||
分组
|
||||
</a-menu-item>
|
||||
<TransactionOutlined />
|
||||
<a-menu-item key="1" @click="batchHandleMealCard">
|
||||
<Icon icon="ant-design:transaction-outlined" />
|
||||
分配饭卡
|
||||
</a-menu-item>
|
||||
<a-menu-item key="1" @click="batchClearMealCardData">
|
||||
<Icon icon="ant-design:transaction-outlined" />
|
||||
饭卡数据清空
|
||||
</a-menu-item>
|
||||
<a-menu-item key="1" @click="batchHandleDelete" v-if="hasPermission('waiTeacher:batchDelete')">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
|
@ -127,6 +130,7 @@
|
|||
confirmCheckIn,
|
||||
batchGroup,
|
||||
batchMealCard,
|
||||
clearMealCardData,
|
||||
} from './CeesWaiTeacher.api';
|
||||
import { selectBySex } from '/@/views/cees/dormitory/CeesDormitoryInfo.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
|
@ -335,7 +339,14 @@
|
|||
*/
|
||||
async function handleMealCardSuccess({ min, max }) {
|
||||
try {
|
||||
if (min == null || max == null || min > max) {
|
||||
const minVal = Number(min);
|
||||
const maxVal = Number(max);
|
||||
|
||||
console.log(minVal, maxVal);
|
||||
console.log(minVal > maxVal);
|
||||
|
||||
if (isNaN(minVal) || isNaN(maxVal) || minVal > maxVal) {
|
||||
console.log('111');
|
||||
message.warning('无效的饭卡范围');
|
||||
return;
|
||||
}
|
||||
|
@ -345,6 +356,17 @@
|
|||
message.error('添加失败');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 清空饭卡
|
||||
*/
|
||||
async function batchClearMealCardData() {
|
||||
try {
|
||||
await clearMealCardData({ ids: selectedRowKeys.value }, handleSuccess); // 调用后端接口
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
message.error('添加失败');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
|
@ -378,16 +400,27 @@
|
|||
|
||||
const handleConfirm = (actionType) => {
|
||||
const isConfirmAction = actionType === 'confirm';
|
||||
|
||||
// 用于记录宿舍选择
|
||||
let selectedDorm = record.dormitoryName;
|
||||
Modal.confirm({
|
||||
title: isConfirmAction ? '请核对信息!!!' : '',
|
||||
content: <ConfirmContent record={record} />,
|
||||
content: (
|
||||
<ConfirmContent
|
||||
record={record}
|
||||
selectedDorm={selectedDorm}
|
||||
onDormChange={(val) => (selectedDorm = val)} // 记录用户选的宿舍
|
||||
/>
|
||||
),
|
||||
okText: isConfirmAction ? '确认报到' : '取消报到',
|
||||
cancelText: isConfirmAction ? '取消' : '关闭',
|
||||
width: 800,
|
||||
onOk: () => {
|
||||
onOk: async () => {
|
||||
if (isConfirmAction) {
|
||||
updateStatus(record.id);
|
||||
await updateStatus(record.id);
|
||||
// 如果宿舍被修改,则再调用宿舍更新接口
|
||||
if (selectedDorm !== record.dormitoryName) {
|
||||
await updateDormitory(record.userId, selectedDorm);
|
||||
}
|
||||
} else {
|
||||
updateStatus(record.id, 'un');
|
||||
}
|
||||
|
@ -422,7 +455,7 @@
|
|||
|
||||
return actions;
|
||||
}
|
||||
const ConfirmContent = ({ record }) => (
|
||||
const ConfirmContent = ({ record, selectedDorm, onDormChange }) => (
|
||||
<Descriptions
|
||||
bordered
|
||||
size="small"
|
||||
|
@ -455,11 +488,13 @@
|
|||
<Descriptions.Item label="住宿信息">
|
||||
<div className="custom-select-wrapper">
|
||||
<select
|
||||
style={{ width: '100%' }}
|
||||
className="custom-select"
|
||||
value={record.dormitoryName}
|
||||
value={selectedDorm}
|
||||
disabled={record.dormitoryStatus === 0} // 根据status禁用
|
||||
onFocus={() => record.dormitoryStatus !== 0 && handleFocus(record)} // 禁用时不触发focus
|
||||
onChange={(e) => handleChange(record.userId, e.target.value, record)}
|
||||
onChange={(e) => onDormChange(e.target.value)}
|
||||
/*onChange={(e) => handleChange(record.userId, e.target.value, record)}*/
|
||||
>
|
||||
{/* 禁用状态显示提示 */}
|
||||
{record.dormitoryStatus === 0 ? (
|
||||
|
@ -550,10 +585,23 @@
|
|||
// console.log(' 组织代码:', dormitory.sysOrgCode);
|
||||
// console.log(' 宿舍编号:', dormitory.dormitoryNum);
|
||||
//});
|
||||
dormOptions.value = response.map((dormitory) => ({
|
||||
label: dormitory.dormitory,
|
||||
//dormOptions.value = response.map((dormitory) => ({
|
||||
// label: `${dormitory.dormitory} 剩余人数:${dormitory.dormitoryNum}`,
|
||||
// value: dormitory.id,
|
||||
//}));
|
||||
dormOptions.value = [
|
||||
// 空值选项(排第一位)
|
||||
{
|
||||
label: '不分配宿舍',
|
||||
value: null, // 或空字符串 '' 根据后端需求
|
||||
disabled: false, // 确保可选
|
||||
},
|
||||
// 正常宿舍数据
|
||||
...response.map((dormitory) => ({
|
||||
label: `${dormitory.dormitory} 剩余人数:${dormitory.dormitoryNum}`,
|
||||
value: dormitory.id,
|
||||
}));
|
||||
})),
|
||||
];
|
||||
} else {
|
||||
console.error('预期的响应应该是一个数组。');
|
||||
}
|
||||
|
|
|
@ -34,11 +34,17 @@
|
|||
|
||||
function handleOk() {
|
||||
const { min, max } = formState.value;
|
||||
if (min == null || max == null || min > max) {
|
||||
const minVal = Number(min);
|
||||
const maxVal = Number(max);
|
||||
|
||||
console.log(minVal, maxVal);
|
||||
console.log(minVal > maxVal);
|
||||
|
||||
if (isNaN(minVal) || isNaN(maxVal) || minVal > maxVal) {
|
||||
console.log('111');
|
||||
message.warning('请输入有效的饭卡最小值和最大值');
|
||||
return;
|
||||
}
|
||||
|
||||
emit('success', { min, max });
|
||||
closeModal();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue