This commit is contained in:
ywyonui 2025-08-23 01:35:44 +08:00
commit 565a87e1bf
4 changed files with 621 additions and 46 deletions

View File

@ -13,7 +13,7 @@ export const bjFindByNjId = async (params: any) => {
// 所有教师
export const jsFindAll = async () => {
return await get("/api/js/findAll");
return await get("/api/js/findAllBasicInfo");
};
// 所有职务

View File

@ -78,7 +78,7 @@ const [register, { getValue, setValue, setSchema }] = useForm({
component: "BasicDataPicker",
componentProps: {
api: findDicTreeByPidApi,
param: { pid: 100 },
param: { pid: 88 },
rangeKey: "dictionaryValue",
savaKey: "dictionaryCode",
onChange: (e: any) => {

View File

@ -128,6 +128,15 @@
</view>
</scroll-view>
<!-- 发布中遮罩层 -->
<view v-if="isPublishing" class="publishing-overlay">
<view class="publishing-content">
<uni-icons type="spinner-cycle" size="40" color="#007aff" class="spinner"></uni-icons>
<text class="publishing-text">发布中...</text>
<text class="publishing-tip">请勿关闭页面或进行其他操作</text>
</view>
</view>
<template #bottom>
<view class="bottom-actions">
<button class="action-btn cancel-btn" @click="handleCancel">
@ -512,4 +521,93 @@ const handlePublish = async () => {
.confirm-btn:disabled {
opacity: 0.6;
}
/* iOS兼容性样式 */
:deep(.uni-datetime-picker) {
z-index: 9999 !important;
}
:deep(.uni-datetime-picker__container) {
z-index: 9999 !important;
}
:deep(.uni-datetime-picker__mask) {
z-index: 9998 !important;
}
:deep(.uni-datetime-picker__content) {
z-index: 9999 !important;
}
/* 确保时间选择器在iOS上正确显示 */
:deep(.uni-datetime-picker__picker) {
z-index: 10000 !important;
}
/* iOS Safari 特殊处理 */
@supports (-webkit-touch-callout: none) {
:deep(.uni-datetime-picker) {
position: fixed !important;
z-index: 99999 !important;
}
:deep(.uni-datetime-picker__container) {
position: fixed !important;
z-index: 99999 !important;
}
}
/* 发布中遮罩层样式 */
.publishing-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.publishing-content {
background-color: white;
padding: 30px;
border-radius: 15px;
text-align: center;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
max-width: 280px;
width: 90%;
}
.spinner {
margin-bottom: 15px;
animation: spin 1s linear infinite;
}
.publishing-text {
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
display: block;
}
.publishing-tip {
font-size: 14px;
color: #999;
display: block;
line-height: 1.4;
}
/* 旋转动画 */
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>

View File

@ -43,7 +43,7 @@
</view>
<!-- 具体选择 -->
<view class="filter-row" v-if="selectType && datas.length > 0">
<view class="filter-row" v-if="selectType && datas.length > 0 && selectType !== 1">
<view class="filter-label">{{ getSecondSelectLabel() }}</view>
<view class="multi-select-container">
<view class="selected-items-display" @click="showMultiSelectModal">
@ -55,6 +55,11 @@
</view>
</view>
<!-- 所有老师提示 -->
<view class="filter-tip" v-if="selectType === 1">
<text class="tip-text">💡 提示选择"所有老师"将直接加载所有教师数据</text>
</view>
<!-- 多选弹窗 -->
<view v-if="showModal" class="modal-overlay" @click="hideMultiSelectModal">
<view class="modal-content" @click.stop>
@ -175,9 +180,10 @@ const showModal = ref(false); // 控制多选弹窗的显示
//
const selectTypeOptions = [
{ value: 1, label: '所有老师' },
{ value: 2, label: '科目' },
{ value: 3, label: '班主任' },
{ value: 4, label: '职务' }
{ value: 2, label: '按科目' },
{ value: 3, label: '按班主任' },
{ value: 4, label: '按职务' },
{ value: 5, label: '按年级' }
];
//
@ -209,6 +215,8 @@ const getSecondSelectLabel = () => {
return '年级';
case 4:
return '具体职务';
case 5:
return '年级/班级';
default:
return '请选择';
}
@ -234,11 +242,21 @@ const onSelectTypeChange = async (e: any) => {
selectTwoType.value = [];
selectedTeachers.value = [];
if (selectType.value === 1 || selectType.value === 3) {
// ""
if (selectType.value === 1) {
await loadAllTeachersFromStorage();
return;
}
//
if (selectType.value === 3 || selectType.value === 5) {
//
await loadNjData();
} else if (selectType.value === 2) {
//
await loadKmData();
} else if (selectType.value === 4) {
//
await loadZwData();
}
};
@ -274,6 +292,321 @@ const confirmMultiSelect = () => {
loadTeachers();
};
// localStorage
const loadAllTeachersFromStorage = async () => {
try {
isLoading.value = true;
console.log('=== 开始从localStorage加载所有教师数据 ===');
// localStorage
const storageData = uni.getStorageSync('app-common');
console.log('localStorage原始数据:', storageData);
console.log('storageData的类型:', typeof storageData);
if (!storageData) {
console.warn('localStorage中没有找到app-common数据');
uni.showToast({ title: '未找到app-common数据', icon: 'none' });
return;
}
// storageData
let parsedData;
if (typeof storageData === 'string') {
try {
parsedData = JSON.parse(storageData);
console.log('解析后的数据:', parsedData);
} catch (parseError) {
console.error('解析localStorage数据失败:', parseError);
uni.showToast({ title: '数据格式错误', icon: 'none' });
return;
}
} else {
parsedData = storageData;
}
console.log('parsedData的类型:', typeof parsedData);
console.log('parsedData是否为对象:', typeof parsedData === 'object');
console.log('parsedData的所有属性:', Object.keys(parsedData || {}));
console.log('parsedData的data属性:', parsedData?.data);
console.log('parsedData的allJs属性:', parsedData?.allJs);
// allJsparsedData
let allJsData;
if (parsedData.data && parsedData.data.allJs) {
allJsData = parsedData.data.allJs;
console.log('从parsedData.data.allJs获取数据');
} else if (parsedData.allJs) {
allJsData = parsedData.allJs;
console.log('从parsedData.allJs获取数据');
} else {
console.warn('localStorage中没有找到allJs数据');
console.warn('可用的属性:', Object.keys(parsedData));
uni.showToast({ title: '未找到教师数据(allJs)', icon: 'none' });
return;
}
console.log('allJs数据结构:', allJsData);
// allJsresult
if (!allJsData.result) {
console.warn('allJs中没有result字段');
uni.showToast({ title: '教师数据结构错误', icon: 'none' });
return;
}
const allTeachers = allJsData.result;
console.log('从localStorage加载的所有教师数据:', allTeachers);
console.log('教师数据长度:', allTeachers.length);
console.log('教师数据类型:', typeof allTeachers);
console.log('是否为数组:', Array.isArray(allTeachers));
if (!Array.isArray(allTeachers)) {
console.warn('allJs.result不是数组格式');
uni.showToast({ title: '教师数据格式错误', icon: 'none' });
return;
}
if (allTeachers.length === 0) {
console.warn('allJs.result数组为空');
uni.showToast({ title: '教师数据为空', icon: 'none' });
return;
}
//
console.log('第一个教师数据结构:', allTeachers[0]);
console.log('第二个教师数据结构:', allTeachers[1]);
//
selectedTeachers.value = allTeachers.map((item: any, index: number) => {
const teacher = {
id: item.id || item.jsId,
jsxm: item.jsxm || item.name || item.label,
jsId: item.id || item.jsId,
dzzw: item.dzzw || '',
qtzw: item.qtzw || ''
};
//
console.log(`教师${index + 1}处理后数据:`, teacher);
return teacher;
});
console.log('=== 从localStorage加载教师数据完成 ===');
console.log('处理后的所有教师数据:', selectedTeachers.value);
console.log('最终教师数量:', selectedTeachers.value.length);
} catch (error: any) {
console.error('从localStorage加载教师数据失败:', error);
console.error('错误详情:', error.message);
console.error('错误堆栈:', error.stack);
uni.showToast({ title: '加载教师数据失败', icon: 'none' });
} finally {
isLoading.value = false;
}
};
// localStorageID
const loadTeachersByNjIdFromStorage = async () => {
try {
isLoading.value = true;
console.log('=== 开始从localStorage按年级加载教师数据 ===');
console.log('选中的年级ID:', selectTwoType.value);
// localStorage
const storageData = uni.getStorageSync('app-common');
console.log('localStorage原始数据:', storageData);
if (!storageData) {
console.warn('localStorage中没有找到app-common数据');
uni.showToast({ title: '未找到app-common数据', icon: 'none' });
return;
}
// storageData
let parsedData;
if (typeof storageData === 'string') {
try {
parsedData = JSON.parse(storageData);
console.log('解析后的数据:', parsedData);
} catch (parseError) {
console.error('解析localStorage数据失败:', parseError);
uni.showToast({ title: '数据格式错误', icon: 'none' });
return;
}
} else {
parsedData = storageData;
}
// allJsparsedData
let allJsData;
if (parsedData.data && parsedData.data.allJs) {
allJsData = parsedData.data.allJs;
console.log('从parsedData.data.allJs获取数据');
} else if (parsedData.allJs) {
allJsData = parsedData.allJs;
console.log('从parsedData.allJs获取数据');
} else {
console.warn('localStorage中没有找到allJs数据');
console.warn('可用的属性:', Object.keys(parsedData));
uni.showToast({ title: '未找到教师数据(allJs)', icon: 'none' });
return;
}
console.log('从localStorage加载的所有教师数据:', allJsData);
console.log('教师数据长度:', allJsData.length);
// allJsresult
if (!allJsData.result) {
console.warn('allJs中没有result字段');
uni.showToast({ title: '教师数据结构错误', icon: 'none' });
return;
}
const teacherArray = allJsData.result;
console.log('教师数组数据:', teacherArray);
console.log('教师数组长度:', teacherArray.length);
// ID
const filteredTeachers = teacherArray.filter((teacher: any) => {
const hasNjId = selectTwoType.value.includes(teacher.njId);
console.log(`教师${teacher.jsxm || teacher.name}的年级ID:`, teacher.njId, '是否匹配:', hasNjId);
return hasNjId;
});
console.log('按年级过滤后的教师数据:', filteredTeachers);
console.log('过滤后教师数量:', filteredTeachers.length);
//
selectedTeachers.value = filteredTeachers.map((item: any) => ({
id: item.id || item.jsId,
jsxm: item.jsxm || item.name || item.label,
jsId: item.id || item.jsId,
dzzw: item.dzzw || '',
qtzw: item.qtzw || ''
}));
console.log('=== 从localStorage按年级加载教师数据完成 ===');
console.log('最终处理后的年级教师数据:', selectedTeachers.value);
console.log('最终教师数量:', selectedTeachers.value.length);
} catch (error: any) {
console.error('从localStorage按年级加载教师数据失败:', error);
console.error('错误详情:', error.message);
console.error('错误堆栈:', error.stack);
uni.showToast({ title: '加载教师数据失败', icon: 'none' });
} finally {
isLoading.value = false;
}
};
// localStorageID
const loadTeachersByZwIdFromStorage = async () => {
try {
isLoading.value = true;
console.log('=== 开始从localStorage按职务加载教师数据 ===');
console.log('选中的职务ID:', selectTwoType.value);
console.log('职务类型:', zwType.value === 1 ? '党政职务' : '其他职务');
// localStorage
const storageData = uni.getStorageSync('app-common');
console.log('localStorage原始数据:', storageData);
if (!storageData) {
console.warn('localStorage中没有找到app-common数据');
uni.showToast({ title: '未找到app-common数据', icon: 'none' });
return;
}
// storageData
let parsedData;
if (typeof storageData === 'string') {
try {
parsedData = JSON.parse(storageData);
console.log('解析后的数据:', parsedData);
} catch (parseError) {
console.error('解析localStorage数据失败:', parseError);
uni.showToast({ title: '数据格式错误', icon: 'none' });
return;
}
} else {
parsedData = storageData;
}
// parsedData.data.allJs
if (!parsedData.data || !parsedData.data.allJs) {
console.warn('localStorage中没有找到教师数据');
console.warn('可用的属性:', Object.keys(parsedData || {}));
uni.showToast({ title: '未找到教师数据', icon: 'none' });
return;
}
const allJsData = parsedData.data.allJs;
console.log('allJs数据结构:', allJsData);
// allJsresult
if (!allJsData.result) {
console.warn('allJs中没有result字段');
uni.showToast({ title: '教师数据结构错误', icon: 'none' });
return;
}
const teacherArray = allJsData.result;
console.log('教师数组数据:', teacherArray);
console.log('教师数组长度:', teacherArray.length);
// ID
const selectedZwId = selectTwoType.value[0]; //
const filteredTeachers = teacherArray.filter((teacher: any) => {
let hasZwId = false;
if (zwType.value === 1) {
// dzzw
if (teacher.dzzw) {
const dzzwArray = teacher.dzzw.split(',');
hasZwId = dzzwArray.includes(selectedZwId);
}
console.log(`教师${teacher.jsxm || teacher.name}的党政职务:`, teacher.dzzw, '是否匹配职务ID:', selectedZwId, '结果:', hasZwId);
} else if (zwType.value === 2) {
// qtzw
if (teacher.qtzw) {
const qtzwArray = teacher.qtzw.split(',');
hasZwId = qtzwArray.includes(selectedZwId);
}
console.log(`教师${teacher.jsxm || teacher.name}的其他职务:`, teacher.qtzw, '是否匹配职务ID:', selectedZwId, '结果:', hasZwId);
}
return hasZwId;
});
console.log('按职务过滤后的教师数据:', filteredTeachers);
console.log('过滤后教师数量:', filteredTeachers.length);
//
selectedTeachers.value = filteredTeachers.map((item: any) => ({
id: item.id || item.jsId,
jsxm: item.jsxm || item.name || item.label,
jsId: item.id || item.jsId,
dzzw: item.dzzw || '',
qtzw: item.qtzw || ''
}));
console.log('=== 从localStorage按职务加载教师数据完成 ===');
console.log('最终处理后的职务教师数据:', selectedTeachers.value);
console.log('最终教师数量:', selectedTeachers.value.length);
} catch (error: any) {
console.error('从localStorage按职务加载教师数据失败:', error);
console.error('错误详情:', error.message);
console.error('错误堆栈:', error.stack);
uni.showToast({ title: '加载教师数据失败', icon: 'none' });
} finally {
isLoading.value = false;
}
};
//
const loadNjData = async () => {
try {
@ -367,39 +700,82 @@ const loadKmData = async () => {
//
const loadZwData = async () => {
try {
const result:any = await zwFindAllApi();
console.log('职务API返回结果:', result);
console.log('=== 开始加载职务数据 ===');
//
let allZwData = [];
if (Array.isArray(result)) {
allZwData = result;
} else if (result && typeof result === 'object') {
//
if (Array.isArray(result.result)) {
allZwData = result.result;
} else if (result.resultCode === 1 && Array.isArray(result.result)) {
allZwData = result.result;
} else if (Array.isArray(result.data)) {
allZwData = result.data;
} else {
console.warn('职务数据格式异常:', result);
allZwData = [];
// localStorage
const storageData = uni.getStorageSync('app-common');
let zwData = null;
if (storageData) {
let parsedData;
if (typeof storageData === 'string') {
try {
parsedData = JSON.parse(storageData);
} catch (parseError) {
console.error('解析localStorage数据失败:', parseError);
}
} else {
console.warn('职务数据格式异常:', result);
allZwData = [];
parsedData = storageData;
}
//
if (parsedData?.data?.zw) {
zwData = parsedData.data.zw;
console.log('从localStorage找到职务数据缓存');
}
}
// getZwListByLx
if (!zwData) {
console.log('localStorage中没有职务数据开始调用getZwListByLx获取并缓存');
try {
// getZwListByLx
const { useCommonStore } = await import('@/store/modules/common');
const commonStore = useCommonStore();
//
const dzZwResult = await commonStore.getZwListByLx({ zwlx: '党政职务' });
const qtZwResult = await commonStore.getZwListByLx({ zwlx: '其他职务' });
console.log('党政职务API返回结果:', dzZwResult);
console.log('其他职务API返回结果:', qtZwResult);
//
zwData = {
'党政职务': { result: dzZwResult.result || [] },
'其他职务': { result: qtZwResult.result || [] }
};
console.log('getZwListByLx获取的职务数据已按类型分组:', zwData);
} catch (apiError) {
console.error('调用getZwListByLx失败:', apiError);
uni.showToast({ title: '获取职务数据失败', icon: 'none' });
return;
}
}
//
const filteredData = allZwData.filter((item: any) => {
let filteredData = [];
if (zwType.value === 1) {
return item.zwlx === '1' || item.zwlx === '党政职务' || item.zwlx === 'A' || item.zwlx === 'dzzw';
} else if (zwType.value === 2) {
return item.zwlx === '2' || item.zwlx === '其他职务' || item.zwlx === 'B' || item.zwlx === 'qtzw';
//
if (zwData['党政职务'] && zwData['党政职务'].result) {
filteredData = zwData['党政职务'].result;
console.log('党政职务数据:', filteredData);
}
} else if (zwType.value === 2) {
//
if (zwData['其他职务'] && zwData['其他职务'].result) {
filteredData = zwData['其他职务'].result;
console.log('其他职务数据:', filteredData);
}
}
if (filteredData.length === 0) {
console.warn('没有找到对应类型的职务数据');
uni.showToast({ title: '未找到对应类型的职务数据', icon: 'none' });
return;
}
return true;
});
// sortsort
const sortedData = filteredData.sort((a: any, b: any) => {
@ -417,7 +793,9 @@ const loadZwData = async () => {
value: item.id || item.value
}));
console.log('=== 职务数据加载完成 ===');
console.log('处理后的职务数据:', datas.value);
} catch (error) {
console.error('加载职务数据失败:', error);
uni.showToast({ title: '加载职务数据失败', icon: 'none' });
@ -426,7 +804,21 @@ const loadZwData = async () => {
//
const loadTeachers = async () => {
if (!selectType.value || !selectTwoType.value.length) return;
if (!selectType.value) return;
// ""localStorage
if (selectType.value === 5 && selectTwoType.value.length > 0) {
await loadTeachersByNjIdFromStorage();
return;
}
// ""localStorage
if (selectType.value === 4 && selectTwoType.value.length > 0) {
await loadTeachersByZwIdFromStorage();
return;
}
if (!selectTwoType.value.length) return;
isLoading.value = true;
try {
@ -436,11 +828,7 @@ const loadTeachers = async () => {
for (const selectedValue of selectTwoType.value) {
let result:any;
if (selectType.value === 1) {
result = await jsFindByNjIdOrBjIdApi({
njOrBjId: selectedValue
});
} else if (selectType.value === 2) {
if (selectType.value === 2) {
result = await jsFindByKmIdApi({
kmId: selectedValue
});
@ -448,11 +836,6 @@ const loadTeachers = async () => {
result = await jsFindByBzrNjIdApi({
njId: selectedValue
});
} else if (selectType.value === 4) {
result = await jsFindByZwIdApi({
zwId: selectedValue,
zwType: zwType.value.toString()
});
}
console.log('教师API返回结果:', result);
@ -560,9 +943,87 @@ const handleConfirm = () => {
};
//
onMounted(() => {
//
onMounted(async () => {
//
await ensureTeacherDataCached();
});
//
const ensureTeacherDataCached = async () => {
try {
console.log('=== 开始确保教师数据已缓存 ===');
// localStorage
const storageData = uni.getStorageSync('app-common');
let hasTeacherData = false;
let hasZwData = false;
if (storageData) {
let parsedData;
if (typeof storageData === 'string') {
try {
parsedData = JSON.parse(storageData);
} catch (parseError) {
console.error('解析localStorage数据失败:', parseError);
}
} else {
parsedData = storageData;
}
//
if (parsedData?.data?.allJs?.result && parsedData.data.allJs.result.length > 0) {
hasTeacherData = true;
console.log('localStorage中已有教师数据数量:', parsedData.data.allJs.result.length);
}
//
if (parsedData?.data?.zw) {
hasZwData = true;
console.log('localStorage中已有职务数据');
}
}
// API
if (!hasTeacherData) {
console.log('localStorage中没有教师数据开始获取并缓存');
// getAllJs
const { useCommonStore } = await import('@/store/modules/common');
const commonStore = useCommonStore();
try {
const result = await commonStore.getAllJs();
console.log('成功获取教师数据并写入缓存:', result);
} catch (error) {
console.error('获取教师数据失败:', error);
}
}
// getZwListByLx
if (!hasZwData) {
console.log('localStorage中没有职务数据开始获取并缓存');
try {
// getZwListByLx
const { useCommonStore } = await import('@/store/modules/common');
const commonStore = useCommonStore();
//
await commonStore.getZwListByLx({ zwlx: '党政职务' });
await commonStore.getZwListByLx({ zwlx: '其他职务' });
console.log('成功获取职务数据并写入缓存');
} catch (error) {
console.error('获取职务数据失败:', error);
}
}
console.log('=== 确保教师数据已缓存完成 ===');
} catch (error) {
console.error('确保教师数据缓存过程中出错:', error);
}
};
</script>
<style lang="scss" scoped>
@ -640,6 +1101,22 @@ onMounted(() => {
cursor: pointer;
}
.filter-tip {
margin-top: 10px;
padding: 8px 12px;
background-color: #e6f7ff;
border: 1px solid #91d5ff;
border-radius: 6px;
font-size: 13px;
color: #1890ff;
display: flex;
align-items: center;
}
.tip-text {
margin-left: 5px;
}
.modal-overlay {
position: fixed;
top: 0;