|
@@ -0,0 +1,133 @@
|
|
|
+<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
+<template class="visible-xs">
|
|
|
+ <el-form
|
|
|
+ ref="formRef"
|
|
|
+ :model="formData"
|
|
|
+ :rules="formRules"
|
|
|
+ v-loading="formLoading"
|
|
|
+ :id="userId"
|
|
|
+ >
|
|
|
+ <el-row style="margin-top: 5vw;">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="日期" prop="date">
|
|
|
+ <el-date-picker
|
|
|
+ class="!w-full"
|
|
|
+ v-model="formData.date"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ type="dates"
|
|
|
+ placeholder="选择日期"
|
|
|
+ :disabled-date="disabledDate"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="备注原因" prop="remark">
|
|
|
+ <el-input v-model="formData.remark" placeholder="请输入备注原因" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row type="flex" justify="center" align="middle" style="margin-top: 5vw;">
|
|
|
+ <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
|
|
+ <el-button style="margin-left: 10px;" @click="cancelForm">取 消</el-button>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+</template>
|
|
|
+<script setup lang="ts">
|
|
|
+import { FormRules } from 'element-plus'
|
|
|
+import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
|
|
|
+import { StudentAttendanceApi, StudentAttendanceVO } from '@/api/system/studentAttendance'
|
|
|
+
|
|
|
+/** 学生考勤记录 表单 */
|
|
|
+defineOptions({ name: 'StudentExcused' })
|
|
|
+
|
|
|
+//获取登录人员信息
|
|
|
+const userInfo = ref({} as ProfileVO)
|
|
|
+const getUserInfo = async () => {
|
|
|
+ const users = await getUserProfile()
|
|
|
+ userInfo.value = users;
|
|
|
+ userId.value = users.id;
|
|
|
+}
|
|
|
+const userId = ref('')
|
|
|
+
|
|
|
+const { t } = useI18n() // 国际化
|
|
|
+const message = useMessage() // 消息弹窗
|
|
|
+const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
+const formRef = ref() // 表单的 ref
|
|
|
+const formData = ref({
|
|
|
+ id: undefined,
|
|
|
+ studentId: undefined,
|
|
|
+ studentName: undefined,
|
|
|
+ userNumber: undefined,
|
|
|
+ supervisor: undefined,
|
|
|
+ deptId: undefined,
|
|
|
+ deptName: undefined,
|
|
|
+ date: undefined,
|
|
|
+ clockInTime: undefined,
|
|
|
+ clockInStatus: undefined,
|
|
|
+ remark: undefined,
|
|
|
+})
|
|
|
+const formRules = reactive<FormRules>({
|
|
|
+ date: [{ required: true, message: '日期不能为空', trigger: 'blur' }],
|
|
|
+ remark:[{ required: true, message: '备注原因不能为空', trigger: 'blur' }],
|
|
|
+})
|
|
|
+
|
|
|
+/** 日期选择器的禁用日期 */
|
|
|
+const disabledDate = (date) => {
|
|
|
+ return date.getTime() < new Date().setHours(0, 0, 0, 0); // 禁用今天之前的日期
|
|
|
+ // return date.getTime() <= new Date().setHours(0, 0, 0, 0); // 禁用今天之前的日期,包括今天
|
|
|
+};
|
|
|
+
|
|
|
+const clockInStatuE = ref('2') // 打卡状态
|
|
|
+/** 提交表单 */
|
|
|
+const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
+const submitForm = async () => {
|
|
|
+ formData.value.clockInStatus = clockInStatuE.value
|
|
|
+ // 校验表单
|
|
|
+ await formRef.value.validate()
|
|
|
+ // 提交请求
|
|
|
+ formLoading.value = true
|
|
|
+ try {
|
|
|
+ const data = formData.value as unknown as StudentAttendanceVO;
|
|
|
+ const dates = Array.isArray(formData.value.date) ? formData.value.date : [];
|
|
|
+ for (const date of dates) {
|
|
|
+ const submissionData = { ...data, date }; // 为每个日期创建新的提交数据
|
|
|
+ await StudentAttendanceApi.createStudentAttendance(submissionData);
|
|
|
+ }
|
|
|
+ message.success(t('提交成功'));
|
|
|
+ // 发送操作成功的事件
|
|
|
+ emit('success');
|
|
|
+ } finally {
|
|
|
+ formLoading.value = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 取消表单 */
|
|
|
+const cancelForm = () => {
|
|
|
+ formRef.value.resetFields()
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ await getUserInfo()
|
|
|
+ // await getStudentAttendance();
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.visible-xs{ //电脑端css
|
|
|
+
|
|
|
+display: none;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+@media (max-width: 767px) { //移动端css
|
|
|
+
|
|
|
+.visible-xs{
|
|
|
+
|
|
|
+display: block !important;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+</style>
|