hookehuyr

feat(teacher/formPage): 添加作业类型选择并调整频次为周期

- 新增 VanCheckboxGroup 组件支持
- 在作业设置中添加作品类型多选框
- 将频次相关字段和逻辑改为周期
- 更新样式类名以匹配周期字段
...@@ -39,6 +39,7 @@ declare module 'vue' { ...@@ -39,6 +39,7 @@ declare module 'vue' {
39 VanCell: typeof import('vant/es')['Cell'] 39 VanCell: typeof import('vant/es')['Cell']
40 VanCellGroup: typeof import('vant/es')['CellGroup'] 40 VanCellGroup: typeof import('vant/es')['CellGroup']
41 VanCheckbox: typeof import('vant/es')['Checkbox'] 41 VanCheckbox: typeof import('vant/es')['Checkbox']
42 + VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup']
42 VanCircle: typeof import('vant/es')['Circle'] 43 VanCircle: typeof import('vant/es')['Circle']
43 VanCol: typeof import('vant/es')['Col'] 44 VanCol: typeof import('vant/es')['Col']
44 VanConfigProvider: typeof import('vant/es')['ConfigProvider'] 45 VanConfigProvider: typeof import('vant/es')['ConfigProvider']
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2025-01-20 10:00:00 3 * @Date: 2025-01-20 10:00:00
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2025-06-25 16:27:12 5 + * @LastEditTime: 2025-09-30 15:46:22
6 * @FilePath: /mlaj/src/views/teacher/formPage.vue 6 * @FilePath: /mlaj/src/views/teacher/formPage.vue
7 * @Description: 教师作业新增表单页面 7 * @Description: 教师作业新增表单页面
8 --> 8 -->
...@@ -41,18 +41,29 @@ ...@@ -41,18 +41,29 @@
41 <!-- 作业设置 --> 41 <!-- 作业设置 -->
42 <div class="mb-6"> 42 <div class="mb-6">
43 <h3 class="section-title">{{ pageTitle }}</h3> 43 <h3 class="section-title">{{ pageTitle }}</h3>
44 +
45 + <!-- 作品类型选择 - 只在设置作业时显示 -->
46 + <div v-if="$route.query.type === 'homework'" class="mb-4">
47 + <label class="setting-label">作业类型</label>
48 + <van-checkbox-group v-model="formData.attachment_type" direction="horizontal" checked-color="#4caf50" icon-size="15px">
49 + <van-checkbox name="image" shape="square"><span class="text-sm">图文打卡</span></van-checkbox>
50 + <van-checkbox name="video" shape="square"><span class="text-sm">视频打卡</span></van-checkbox>
51 + <van-checkbox name="audio" shape="square"><span class="text-sm">音频打卡</span></van-checkbox>
52 + </van-checkbox-group>
53 + </div>
54 +
44 <van-row gutter="10"> 55 <van-row gutter="10">
45 <van-col span="12"> 56 <van-col span="12">
46 - <label class="setting-label">{{ pageTitle === '设置作业' ? '作业' : '打卡' }}频次</label> 57 + <label class="setting-label">{{ pageTitle === '设置作业' ? '作业' : '打卡' }}周期</label>
47 <van-field 58 <van-field
48 - v-model="formData.frequency_text" 59 + v-model="formData.cycle_text"
49 is-link 60 is-link
50 readonly 61 readonly
51 - name="frequency_text" 62 + name="cycle_text"
52 - placeholder="请选择频次" 63 + placeholder="请选择周期"
53 :border="false" 64 :border="false"
54 - @click="showFrequencyPicker = true" 65 + @click="showCyclePicker = true"
55 - class="frequency-field" 66 + class="cycle-field"
56 /> 67 />
57 </van-col> 68 </van-col>
58 <van-col span="12"> 69 <van-col span="12">
...@@ -170,9 +181,9 @@ ...@@ -170,9 +181,9 @@
170 </div> 181 </div>
171 </div> 182 </div>
172 183
173 - <!-- 频次选择器 --> 184 + <!-- 周期选择器 -->
174 - <van-popup v-model:show="showFrequencyPicker" position="bottom"> 185 + <van-popup v-model:show="showCyclePicker" position="bottom">
175 - <van-picker :columns="frequencyOptions" @confirm="onFrequencyConfirm" @cancel="showFrequencyPicker = false" /> 186 + <van-picker :columns="cycleOptions" @confirm="onCycleConfirm" @cancel="showCyclePicker = false" />
176 </van-popup> 187 </van-popup>
177 188
178 <!-- 开始时间选择器 --> 189 <!-- 开始时间选择器 -->
...@@ -333,8 +344,8 @@ const formData = ref({ ...@@ -333,8 +344,8 @@ const formData = ref({
333 title: '', 344 title: '',
334 note: '', 345 note: '',
335 task_type: $route.query.type === 'homework' ? 'upload' : 'checkin', 346 task_type: $route.query.type === 'homework' ? 'upload' : 'checkin',
336 - frequency_text: '', 347 + cycle_text: '',
337 - frequency: '', 348 + cycle: '',
338 target_number: 1, 349 target_number: 1,
339 start_time: new Date(), 350 start_time: new Date(),
340 end_time: new Date(), 351 end_time: new Date(),
...@@ -347,13 +358,14 @@ const formData = ref({ ...@@ -347,13 +358,14 @@ const formData = ref({
347 class_name: '', 358 class_name: '',
348 class_id: '', 359 class_id: '',
349 // group_name: '' 360 // group_name: ''
361 + attachment_type: [] // 作品类型数组,用于设置作业时的多选
350 }); 362 });
351 363
352 // 加载状态 364 // 加载状态
353 const loading = ref(false); 365 const loading = ref(false);
354 366
355 // 弹窗显示状态 367 // 弹窗显示状态
356 -const showFrequencyPicker = ref(false); 368 +const showCyclePicker = ref(false);
357 const showStartTimePicker = ref(false); 369 const showStartTimePicker = ref(false);
358 const showEndTimePicker = ref(false); 370 const showEndTimePicker = ref(false);
359 const showCoursePicker = ref(false); 371 const showCoursePicker = ref(false);
...@@ -370,7 +382,7 @@ const endDate = ref(['2024', '12', '31']); ...@@ -370,7 +382,7 @@ const endDate = ref(['2024', '12', '31']);
370 const minDate = new Date(2020, 0, 1); 382 const minDate = new Date(2020, 0, 1);
371 const maxDate = new Date(2035, 11, 31); 383 const maxDate = new Date(2035, 11, 31);
372 384
373 -const frequencyOptions = ref([]); 385 +const cycleOptions = ref([]);
374 386
375 // 搜索值 387 // 搜索值
376 const courseSearchValue = ref(''); 388 const courseSearchValue = ref('');
...@@ -505,13 +517,13 @@ const formatDateTime = (date) => { ...@@ -505,13 +517,13 @@ const formatDateTime = (date) => {
505 }; 517 };
506 518
507 /** 519 /**
508 - * 频次选择确认 520 + * 周期选择确认
509 * @param {Object} option - 选中的选项 521 * @param {Object} option - 选中的选项
510 */ 522 */
511 -const onFrequencyConfirm = (option) => { 523 +const onCycleConfirm = (option) => {
512 - formData.value.frequency_text = option.selectedOptions[0].text; 524 + formData.value.cycle_text = option.selectedOptions[0].text;
513 - formData.value.frequency = option.selectedOptions[0].value; 525 + formData.value.cycle = option.selectedOptions[0].value;
514 - showFrequencyPicker.value = false; 526 + showCyclePicker.value = false;
515 }; 527 };
516 528
517 /** 529 /**
...@@ -836,7 +848,7 @@ onMounted(async () => { ...@@ -836,7 +848,7 @@ onMounted(async () => {
836 // 这里可以调用API获取课程、活动、年级、班级、小组等数据 848 // 这里可以调用API获取课程、活动、年级、班级、小组等数据
837 const { code, data } = await getTeacherFindSettingsAPI(); 849 const { code, data } = await getTeacherFindSettingsAPI();
838 if (code) { 850 if (code) {
839 - frequencyOptions.value = Object.entries(data.task_frequency).map(([value, text]) => ({ 851 + cycleOptions.value = Object.entries(data.task_cycle).map(([value, text]) => ({
840 text, 852 text,
841 value: String(value) // 确保值为字符串类型 853 value: String(value) // 确保值为字符串类型
842 })); 854 }));
...@@ -920,14 +932,14 @@ onMounted(async () => { ...@@ -920,14 +932,14 @@ onMounted(async () => {
920 margin-bottom: 8px; 932 margin-bottom: 8px;
921 } 933 }
922 934
923 -/* 频次选择 */ 935 +/* 周期选择 */
924 -.frequency-field { 936 +.cycle-field {
925 background: #f5f5f5; 937 background: #f5f5f5;
926 border-radius: 8px; 938 border-radius: 8px;
927 padding: 2px 0; 939 padding: 2px 0;
928 } 940 }
929 941
930 -:deep(.frequency-field .van-field__control) { 942 +:deep(.cycle-field .van-field__control) {
931 /* padding: 2px; */ 943 /* padding: 2px; */
932 text-align: center; 944 text-align: center;
933 } 945 }
......