From dee7d67bcc091ccf50f8894be74b389b9a8de75a Mon Sep 17 00:00:00 2001 From: ywyonui Date: Thu, 11 Sep 2025 18:59:56 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=B0=83=E6=95=B4=E5=B0=B1=E9=A4=90?= =?UTF-8?q?=E7=82=B9=E5=90=8D=202=E3=80=81=E5=A2=9E=E5=8A=A0=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E5=A7=93=E5=90=8D=E6=8E=92=E5=BA=8F=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + pnpm-lock.yaml | 8 + src/api/base/jcApi.ts | 27 +- src/api/base/xsApi.ts | 15 ++ src/pages.json | 6 + src/pages/base/service/index.vue | 2 +- src/pages/view/routine/jc/bzList.vue | 152 +++++++++++ src/pages/view/routine/jc/components/dm.vue | 243 ++++++++---------- .../view/routine/jc/components/dmList.vue | 57 +--- src/pages/view/routine/jc/detail.vue | 139 +++++----- src/store/modules/data.ts | 9 +- src/utils/pinyinUtil.ts | 50 ++++ 12 files changed, 450 insertions(+), 259 deletions(-) create mode 100644 src/api/base/xsApi.ts create mode 100644 src/pages/view/routine/jc/bzList.vue create mode 100644 src/utils/pinyinUtil.ts diff --git a/package.json b/package.json index b7b4126..3d05ba0 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "lodash": "4.17.21", "pinia": "2.0.23", "pinia-plugin-persist-uni": "1.2.0", + "pinyin-pro": "^3.27.0", "qrcode": "^1.5.3", "uview-plus": "3.1.20", "vconsole": "3.15.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3cd3276..14a76ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,6 +74,9 @@ importers: pinia-plugin-persist-uni: specifier: 1.2.0 version: 1.2.0(pinia@2.0.23(typescript@4.8.3)(vue@3.2.45))(vue@3.2.45) + pinyin-pro: + specifier: ^3.27.0 + version: 3.27.0 qrcode: specifier: ^1.5.3 version: 1.5.4 @@ -2965,6 +2968,9 @@ packages: typescript: optional: true + pinyin-pro@3.27.0: + resolution: {integrity: sha512-Osdgjwe7Rm17N2paDMM47yW+jUIUH3+0RGo8QP39ZTLpTaJVDK0T58hOLaMQJbcMmAebVuK2ePunTEVEx1clNQ==} + pirates@4.0.7: resolution: {integrity: sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==} engines: {node: '>= 6'} @@ -7626,6 +7632,8 @@ snapshots: optionalDependencies: typescript: 4.8.3 + pinyin-pro@3.27.0: {} + pirates@4.0.7: {} pixelmatch@4.0.2: diff --git a/src/api/base/jcApi.ts b/src/api/base/jcApi.ts index 6a9e339..d3ea2fb 100644 --- a/src/api/base/jcApi.ts +++ b/src/api/base/jcApi.ts @@ -1,5 +1,12 @@ import { get, post } from '@/utils/request' +/** + * 就餐标准分页查询 + */ +export const jcBzFindPageApi = async (params: any) => { + return await get('/api/jcBz/findPage', params) +} + /** * 获取就餐标准列表 */ @@ -8,16 +15,16 @@ export const getJcBzListApi = async (params: any) => { } /** - * 获取就餐清单列表 + * 获取就餐清单分页查询 */ -export const getJcQdListApi = async (params: any) => { +export const jcQdFindPageApi = async (params: any) => { return await get('/api/jcQd/findPage', params) } /** * 获取就餐点名分页 */ -export const getJcDmPageApi = async (params: any) => { +export const jcDmFindPageApi = async (params: any) => { return await get('/api/jcDm/findPage', params) } @@ -60,20 +67,6 @@ export const getJcPtListApi = async (params: any) => { return await get('/api/jcPt/findPage', params) } -/** - * 【教师端专用】根据班级ID获取学生点名数据 - * 返回两组学生数据:已缴费和未缴费/未报名 - */ -export const getClassStudentDmDataApi = async (bjId: string, njId: string) => { - try { - const response = await get('/mobile/js/jc/getClassStudentDmData', { bjId, njId }) - return response - } catch (error) { - console.error('获取班级学生点名数据失败:', error) - throw error - } -} - /** * 【教师端专用】提交就餐点名数据 * 包含:点名教师ID、点名时间、学生列表、陪餐教师列表等 diff --git a/src/api/base/xsApi.ts b/src/api/base/xsApi.ts new file mode 100644 index 0000000..25efa6e --- /dev/null +++ b/src/api/base/xsApi.ts @@ -0,0 +1,15 @@ +import { get, post } from "@/utils/request"; + +/** + * 分页查询未选课的学生 + */ +export function findPageByNoXk(params: any) { + return get('/api/xs/findPageByNoXk', params); +} + +/** +* 分页查询未报名就餐的学生 +*/ +export function findPageByNoJc(params: any) { + return get('/api/xs/findPageByNoJc', params); +} diff --git a/src/pages.json b/src/pages.json index 7a60dab..9732333 100644 --- a/src/pages.json +++ b/src/pages.json @@ -614,6 +614,12 @@ "backgroundColor": "#f4f5f7" } }, + { + "path": "pages/view/routine/jc/bzList", + "style": { + "navigationBarTitleText": "就餐标准列表" + } + }, { "path": "pages/view/routine/jc/index", "style": { diff --git a/src/pages/base/service/index.vue b/src/pages/base/service/index.vue index 477b033..49091ae 100644 --- a/src/pages/base/service/index.vue +++ b/src/pages/base/service/index.vue @@ -303,7 +303,7 @@ const sections = reactive([ text: "就餐点名", show: true, permissionKey: "routine-jcdm", // 就餐点名权限编码 - path: "/pages/view/routine/jc/index", + path: "/pages/view/routine/jc/bzList", }, { id: "r9", diff --git a/src/pages/view/routine/jc/bzList.vue b/src/pages/view/routine/jc/bzList.vue new file mode 100644 index 0000000..2daca83 --- /dev/null +++ b/src/pages/view/routine/jc/bzList.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/pages/view/routine/jc/components/dm.vue b/src/pages/view/routine/jc/components/dm.vue index 68d3cc3..2e577c7 100644 --- a/src/pages/view/routine/jc/components/dm.vue +++ b/src/pages/view/routine/jc/components/dm.vue @@ -80,22 +80,22 @@ 学生状态列表 - 刷新 + 刷新 - {{ xsLb.length }} + {{ rsData.zrs }} 总人数 - {{ hqZtSl('D') }} - 未缴费 + {{ rsData.bmRs }} + 报名就餐 - {{ hqZtSl('E') }} - 未报名 + {{ rsData.unBmRs }} + 未报名就餐 {{ hqZtSl('A') }} @@ -112,36 +112,36 @@ - + - - 已缴费学生 ({{ yjfXs.length }}人) - + + 已报名学生 ({{ bmXsList.length }}人) + - - {{ student.xm }} + + {{ xs.xm }} - {{ hqZtWz(student.jcZt) }} + {{ hqZtWz(xs.jcZt) }} @@ -152,33 +152,33 @@ - - 未缴费/未报名学生 ({{ wjfXs.length }}人) - + + 未报名学生 ({{ unBmXsList.length }}人) + - - {{ student.xm }} + + {{ xs.xm }} - {{ hqZtWz(student.jcZt) }} + {{ hqZtWz(xs.jcZt) }} @@ -187,7 +187,7 @@ - + 暂无学生数据 @@ -254,11 +254,14 @@ import { ref, computed } from 'vue' import NjBjPicker from '@/pages/components/NjBjPicker/index.vue' import BasicJsPicker from '@/components/BasicJsPicker/Picker.vue' import DmPsComponent from '@/pages/components/dmPs/index.vue' -import { getClassStudentDmDataApi, submitJcDmDataApi } from '@/api/base/jcApi' +import { findPageByNoJc } from "@/api/base/xsApi"; +import { jcQdFindPageApi, submitJcDmDataApi } from '@/api/base/jcApi' import { imagUrl } from "@/utils"; +import { sortChinese } from "@/utils/pinyinUtil" import { useUserStore } from '@/store/modules/user' +import { useDataStore } from '@/store/modules/data' const { getJs } = useUserStore() - +const { getJcBz } = useDataStore(); /** * 就餐点名组件 * 功能: @@ -279,10 +282,16 @@ const props = withDefaults(defineProps<{ const curNj = ref(null); const curBj = ref(null); -const xsLb = ref([]) // 学生列表 const xzJs = ref([]) // 选择的教师 const jzZt = ref(false) // 加载状态 +// 人数 +const rsData = ref({ + zrs: 0, + bmRs: 0, + unBmRs: 0 +}) + // 状态选择相关 const ztXzK = ref(false) // 状态选择可见 const yjfZtXz = ref>([ @@ -317,25 +326,20 @@ const dmPsRef = ref(null); // 计算属性 const kTj = computed(() => { - return curBj.value && yjfXs.value.length > 0 // 改为检查已缴费学生数量 + return curBj.value && bmXsList.value.length > 0 // 改为检查已缴费学生数量 }) -// 已缴费学生列表(有就餐清单且jfZt为B) -const yjfXs = computed(() => { - return xsLb.value.filter(student => student.studentType === 'paid') -}) - -// 未缴费/未报名学生列表 -const wjfXs = computed(() => { - return xsLb.value.filter(student => student.studentType === 'unpaid') -}) +// 已报名学生列表 +const bmXsList = ref([]); +// 未报名学生列表 +const unBmXsList = ref([]); // 方法 // 改变了年级班级 const changeNjBj = async (nj: any, bj: any) => { curNj.value = nj curBj.value = bj - await jzXsLb() + await loadXsList() }; // 处理照片变化 @@ -435,40 +439,39 @@ const sxJsLb = () => { console.log('刷新教师列表') } -const jzXsLb = async () => { +// 加载学生列表 +const loadXsList = async () => { if (!curBj.value) return jzZt.value = true try { - // 使用新的API接口获取班级学生点名数据 - const response = await getClassStudentDmDataApi( - curBj.value.key, - curNj.value.key - ) - - if (response.result) { - // 合并已缴费和未缴费学生列表 - const paidStudents = response.result.paidStudents || [] - const unpaidStudents = response.result.unpaidStudents || [] - - // 为每个学生设置默认就餐状态 - const allStudents = [ - ...paidStudents.map((student: any) => ({ - ...student, - jcZt: 'A', // 已缴费学生默认正常状态 - studentType: 'paid' - })), - ...unpaidStudents.map((student: any) => ({ - ...student, - jcZt: student.hasJcQd ? 'D' : 'E', // 未缴费或未报名 - studentType: 'unpaid' - })) - ] - - xsLb.value = allStudents - } else { - xsLb.value = [] + const params = { + bzId: getJcBz.id, + bjId: curBj.value.key, + njId: curNj.value.key, + pageNo: 1, + rows: 1000 } + const resQd = await jcQdFindPageApi(params); + bmXsList.value = (resQd.rows || []).map((item: any) => { + return { + ...item, + jcZt: 'A', + xm: (item.xsxm || item.xm || '').trim() + } + }); + bmXsList.value = sortChinese(bmXsList.value, 'xm'); + console.log('学生清单列表', bmXsList.value); + const resUn = await findPageByNoJc(params); + unBmXsList.value = resUn.rows || []; + unBmXsList.value = sortChinese(unBmXsList.value, 'xm'); + + console.log('未报名学生列表', unBmXsList.value); + rsData.value = { + zrs: (resQd.records || 0) + (resUn.records || 0), + bmRs: (resQd.records || 0), + unBmRs: (resUn.records || 0), + }; } catch (error) { console.error('加载学生列表失败:', error) uni.showToast({ @@ -480,10 +483,6 @@ const jzXsLb = async () => { } } -const sxXsLb = () => { - jzXsLb() -} - const hqXsZtLx = (status: string) => { switch (status) { case 'A': @@ -519,18 +518,7 @@ const hqZtWz = (status: string) => { } const hqZtSl = (status: string) => { - return xsLb.value.filter(s => s.jcZt === status).length -} - -// 获取学生类型文本 -const hqXsLxWz = (student: any) => { - if (student.studentType === 'paid') { - return '已缴费' - } else if (student.jcZt === 'E') { - return '未报名' - } else { - return '未缴费' - } + return bmXsList.value.filter((s:any) => s.jcZt === status).length } // 获取状态对应的样式类 @@ -551,21 +539,9 @@ const getStatusClass = (status: string) => { } } -// 获取学生类型对应的样式类 -const getTypeClass = (studentType: string) => { - switch (studentType) { - case 'paid': - return 'cor-success' - case 'unpaid': - return 'cor-warning' - default: - return 'cor-666' - } -} - // 打开状态选择器 -const dkZtXz = (student: any, type: 'paid' | 'unpaid') => { - dqXs.value = student +const dkZtXz = (xs: any, type: 'paid' | 'unpaid') => { + dqXs.value = xs // 根据学生类型设置对应的状态选项 if (type === 'paid') { @@ -575,7 +551,7 @@ const dkZtXz = (student: any, type: 'paid' | 'unpaid') => { } // 找到当前状态在选项中的索引 - const currentIndex = dqZtXz.value.findIndex(option => option.value === student.jcZt) + const currentIndex = dqZtXz.value.findIndex(option => option.value === xs.jcZt) mqXz.value = [currentIndex >= 0 ? currentIndex : 0] ztXzK.value = true } @@ -596,7 +572,7 @@ const qrXzZt = (e: any) => { } const tjDm = async () => { - if (!curBj.value || yjfXs.value.length === 0) { // 改为检查已缴费学生数量 + if (!curBj.value || bmXsList.value.length === 0) { // 改为检查已缴费学生数量 uni.showToast({ title: '请先选择班级或有已缴费学生', icon: 'none' @@ -635,24 +611,28 @@ const tjDm = async () => { bjmc: curBj.value.title, njmc: curNj.value.title, dmJsId: getJs.id || '', // 点名教师ID - dmTime: new Date(), + jcTime: new Date(), + zrs: rsData.value.zrs, + sdRs: hqZtSl('A'), + qjRs: hqZtSl('B'), + qqRs: hqZtSl('C'), // 媒体文件地址 zp: photoUrls, // 照片字段,逗号分隔的字符串 sp: videoUrls, // 视频字段,逗号分隔的字符串 - xsList: yjfXs.value.map(student => ({ - xsId: student.id, - xsXm: student.xm, // 传入学生姓名 - jcZt: student.jcZt || 'A', - jcQdId: student.jcQdInfo?.qdId, - jcBzId: student.jcQdInfo?.bzId, - jzId: student.jcQdInfo?.jzId, - tx: student.xstx // 传入学生头像 + xsList: bmXsList.value.map((qd:any) => ({ + xsId: qd.xsId, + xsXm: qd.xm, // 传入学生姓名 + jcZt: qd.jcZt || 'A', + jcQdId: qd.id, + jcBzId: qd.bzId, + jzId: qd.jzId, + tx: qd.xstx // 传入学生头像 })), - ptJsList: xzJs.value.map(teacher => ({ - jsId: teacher.value, - jsXm: teacher.label, - pcZt: teacher.pcZt || 'A', // 添加陪餐状态 - tx: teacher.headPic // 传入教师头像 + ptJsList: xzJs.value.map(js => ({ + jsId: js.value, + jsXm: js.label, + pcZt: js.pcZt || 'A', // 添加陪餐状态 + tx: js.headPic // 传入教师头像 })) } @@ -668,7 +648,8 @@ const tjDm = async () => { // 重置表单 curNj.value = null curBj.value = null - xsLb.value = [] + bmXsList.value = []; + unBmXsList.value = []; xzJs.value = [] mediaData.value = { photoList: [], @@ -782,28 +763,28 @@ const tjDm = async () => { color: #666; } -.student-section { +.xs-section { margin-bottom: 30rpx; } -.student-list { +.xs-list { margin-bottom: 30rpx; } -.student-grid { +.xs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20rpx; } -.student-item { +.xs-item { position: relative; border-radius: 16rpx; box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); transition: all 0.2s; } -.student-item:hover { +.xs-item:hover { transform: translateY(-2rpx); box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15); } @@ -820,7 +801,7 @@ const tjDm = async () => { box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05); } -.student-avatar { +.xs-avatar { width: 80rpx; height: 80rpx; border-radius: 50%; @@ -881,7 +862,7 @@ const tjDm = async () => { color: #eb2f96; } -.student-type { +.xs-type { padding: 6rpx 16rpx; border-radius: 8rpx; display: inline-block; @@ -1096,4 +1077,4 @@ const tjDm = async () => { .teacher-name { margin-bottom: 16rpx; } - + \ No newline at end of file diff --git a/src/pages/view/routine/jc/components/dmList.vue b/src/pages/view/routine/jc/components/dmList.vue index 488bac3..0fde5b0 100644 --- a/src/pages/view/routine/jc/components/dmList.vue +++ b/src/pages/view/routine/jc/components/dmList.vue @@ -9,26 +9,18 @@ 班级: - + 时间范围: - + {{ getTimeRangeText() }} @@ -45,10 +37,7 @@ - + 📋 暂无点名记录 请选择班级和时间范围进行搜索 @@ -81,7 +70,7 @@ {{ formatTime(data.jcTime) }} - + 查看详情 → @@ -95,10 +84,10 @@ import { ref, onMounted, computed } from "vue"; import { useLayout } from "@/components/BasicListLayout/hooks/useLayout"; import NjBjPicker from "@/pages/components/NjBjPicker/index.vue"; -import { getJcDmPageApi } from "@/api/base/jcApi"; +import { jcDmFindPageApi } from "@/api/base/jcApi"; import { useDataStore } from "@/store/modules/data"; -const { setData } = useDataStore(); +const { setData, getJcBz } = useDataStore(); // 接收外部传入属性 const props = withDefaults( @@ -123,7 +112,7 @@ const hasSearched = ref(false); const [register, { reload, setParam }] = useLayout({ api: async (params: any) => { try { - const res = await getJcDmPageApi(params); + const res = await jcDmFindPageApi(params); console.log("API返回数据:", res); // 调试日志 // 确保数据正确赋值 @@ -208,6 +197,7 @@ const searchRecords = async () => { // 设置搜索参数并重新加载 setParam({ + bzId: getJcBz.id, njId: selectedClass.value.njId, bjId: selectedClass.value.bjId, startTime: startTime.value + " 00:00:00", @@ -233,22 +223,6 @@ const goToDetail = (dm: any) => { }); }; -const exportRecords = () => { - if (dmRecords.value.length === 0) { - uni.showToast({ - title: "暂无数据可导出", - icon: "none", - }); - return; - } - - // 实现导出逻辑 - uni.showToast({ - title: "导出功能开发中", - icon: "none", - }); -}; - const formatDate = (dateStr: string) => { if (!dateStr) return ""; const date = new Date(dateStr); @@ -359,6 +333,7 @@ onMounted(() => { .records-header { padding: 0 30rpx; margin-bottom: 20rpx; + .section-title { font-size: 32rpx; font-weight: bold; @@ -386,10 +361,6 @@ onMounted(() => { transition: all 0.3s ease; } - - - - .card-footer { text-align: right; padding-top: 16rpx; @@ -452,7 +423,7 @@ onMounted(() => { display: flex; align-items: center; margin-bottom: 16rpx; - + &:last-child { margin-bottom: 0; } diff --git a/src/pages/view/routine/jc/detail.vue b/src/pages/view/routine/jc/detail.vue index 5389352..671fab4 100644 --- a/src/pages/view/routine/jc/detail.vue +++ b/src/pages/view/routine/jc/detail.vue @@ -68,68 +68,68 @@ - + - 学生状态列表 ({{ dmDetail.xsList.length }}人) + 学生状态列表 ({{ rsData.zrs }}人) - {{ dmDetail.xsList.length }} + {{ rsData.zrs }} 总人数 - {{ getStatusCount('A') }} + {{ rsData.bmRs }} + 报名就餐 + + + {{ rsData.unBmRs }} + 未报名就餐 + + + {{ hqZtSl('A') }} 正常 - {{ getStatusCount('B') }} + {{ hqZtSl('B') }} 请假 - {{ getStatusCount('C') }} + {{ hqZtSl('C') }} 缺勤 - - {{ getStatusCount('D') }} - 未缴费 - - - {{ getStatusCount('E') }} - 未报名 - - + - - 已缴费学生 ({{ yjfXs.length }}人) - + + 已报名学生 ({{ dmXsList.length }}人) + - - {{ student.xsXm }} + + {{ xs.xsXm }} - {{ getStatusText(student.jcZt) }} + {{ getStatusText(xs.jcZt) }} @@ -139,32 +139,32 @@ - - 未缴费/未报名学生 ({{ wjfXs.length }}人) - + + 未报名学生 ({{ unBmXsList.length }}人) + - - {{ student.xsXm }} + + {{ xs.xsXm }} - {{ getStatusText(student.jcZt) }} + {{ getStatusText(xs.jcZt) }} @@ -173,7 +173,7 @@ - + 暂无学生数据 @@ -193,6 +193,8 @@ import { ref, onMounted, watch, computed } from 'vue' import { getJcDmDetailApi } from '@/api/base/jcApi' import { useDataStore } from '@/store/modules/data' +import { imagUrl } from "@/utils"; +import { sortChinese } from "@/utils/pinyinUtil" const { getData } = useDataStore() // 响应式数据 @@ -200,21 +202,16 @@ const loading = ref(false) const dmDetail = ref(null) const error = ref('') -// 计算属性 -// 已缴费学生列表(状态为A、B、C的学生) -const yjfXs = computed(() => { - if (!dmDetail.value?.xsList) return [] - return dmDetail.value.xsList.filter((student: any) => - ['A', 'B', 'C'].includes(student.jcZt) - ) -}) +// 点名学生 +const dmXsList = ref([]); +// 未报名学生 +const unBmXsList = ref([]); -// 未缴费/未报名学生列表(状态为D、E的学生) -const wjfXs = computed(() => { - if (!dmDetail.value?.xsList) return [] - return dmDetail.value.xsList.filter((student: any) => - ['D', 'E'].includes(student.jcZt) - ) +// 人数 +const rsData = ref({ + zrs: 0, + bmRs: 0, + unBmRs: 0 }) // 方法 @@ -228,7 +225,18 @@ const loadDetail = async () => { const response = await getJcDmDetailApi(getData.id) if (response.result) { - dmDetail.value = response.result + dmDetail.value = response.result; + dmXsList.value = response.result.dmXsList || []; + dmXsList.value = sortChinese(dmXsList.value, 'xsXm'); + unBmXsList.value = response.result.unBmXsList || []; + unBmXsList.value = sortChinese(unBmXsList.value, 'xsxm'); + + rsData.value = { + zrs: unBmXsList.value.length + dmXsList.value.length, + bmRs: dmXsList.value.length, + unBmRs: unBmXsList.value.length, + } + } else { error.value = response.message || '获取详情失败' } @@ -240,6 +248,10 @@ const loadDetail = async () => { } } +const hqZtSl = (status: string) => { + return dmXsList.value.filter((s:any) => s.jcZt === status).length +} + const formatDateTime = (dateStr: string) => { if (!dateStr) return '' const date = new Date(dateStr) @@ -252,11 +264,6 @@ const formatDateTime = (dateStr: string) => { return `${year}-${month}-${day} ${hours}:${minutes}` } -const getStatusCount = (status: string) => { - if (!dmDetail.value?.xsList) return 0 - return dmDetail.value.xsList.filter((s: any) => s.jcZt === status).length -} - const getStatusText = (status: string) => { switch (status) { case 'A': @@ -383,7 +390,7 @@ onMounted(() => { border-bottom: 1px solid #f0f0f0; } -.student-section { +.xs-section { margin-bottom: 30rpx; } @@ -463,24 +470,24 @@ onMounted(() => { color: #666; } -.teacher-list, .student-list { +.teacher-list, .xs-list { margin-bottom: 30rpx; } -.teacher-grid, .student-grid { +.teacher-grid, .xs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20rpx; } -.teacher-item, .student-item { +.teacher-item, .xs-item { position: relative; border-radius: 16rpx; box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); transition: all 0.2s; } -.teacher-item:hover, .student-item:hover { +.teacher-item:hover, .xs-item:hover { transform: translateY(-2rpx); box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15); } @@ -497,7 +504,7 @@ onMounted(() => { box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05); } -.teacher-avatar, .student-avatar { +.teacher-avatar, .xs-avatar { width: 80rpx; height: 80rpx; border-radius: 50%; diff --git a/src/store/modules/data.ts b/src/store/modules/data.ts index 45588c8..8c5ad4d 100644 --- a/src/store/modules/data.ts +++ b/src/store/modules/data.ts @@ -9,6 +9,7 @@ export const useDataStore = defineStore({ global: {}, file: {}, xs: {}, // 学生专用 + jcBz: {}, // 就餐标准 }), getters: { getData(): any { @@ -28,7 +29,10 @@ export const useDataStore = defineStore({ }, getXs(): any { return this.xs; - } + }, + getJcBz(): any { + return this.jcBz; + }, }, actions: { setData(data: any) { @@ -48,6 +52,9 @@ export const useDataStore = defineStore({ }, setXs(data: any) { this.xs = data; + }, + setJcBz(data: any) { + this.jcBz = data; } }, persist: { diff --git a/src/utils/pinyinUtil.ts b/src/utils/pinyinUtil.ts new file mode 100644 index 0000000..21e21e4 --- /dev/null +++ b/src/utils/pinyinUtil.ts @@ -0,0 +1,50 @@ +// utils/pinyinUtils.ts +import { pinyin } from 'pinyin-pro'; + +/** + * 将汉字转换为拼音 + * @param text 需要转换的汉字文本 + * @returns 拼音字符串 + */ +export function chineseToPinyin(text: string): string { + try { + return pinyin(text, { toneType: 'none', type: 'array', mode: 'surname' }).join(''); + } catch (error) { + console.error('拼音转换失败:', error); + return text; + } +} + +/** + * 获取汉字首字母 + * @param text 需要转换的汉字文本 + * @returns 首字母字符串 + */ +export function getFirstLetter(text: string): string { + try { + return pinyin(text, { pattern: 'first', toneType: 'none' }); + } catch (error) { + console.error('首字母提取失败:', error); + return text; + } +} + +/** + * 中文排序函数 + * @param list 需要排序的数组 + * @param key 排序字段(如果是对象数组) + * @returns 排序后的数组 + */ +export function sortChinese(list: any, key?: string) { + return list.sort((a:any, b: any) => { + const textA = key ? a[key] : a as unknown as string; + const textB = key ? b[key] : b as unknown as string; + + const pinyinA = chineseToPinyin(textA); + const pinyinB = chineseToPinyin(textB); + + return pinyinA.localeCompare(pinyinB, 'zh-Hans-CN', { + sensitivity: 'accent' + }); + }); +} \ No newline at end of file