47 9 months ago
parent
commit
f805810c07

+ 0 - 15
src/api/system/face/index.ts

@@ -1,15 +0,0 @@
-import request from '@/config/axios'
-
-export interface FaceVO {
-
-}
-
-// 查询人脸列表
-export const getFaceList = async () => {
-  return await request.get({ url: '/system/face/face-list' })
-}
-
-// 导入数据
-export const importdata = async () => {
-  return await request.get({ url: 'md/acs/import-data' })
-}

+ 1 - 0
src/api/system/studentAttendance/index.ts

@@ -10,6 +10,7 @@ export interface StudentAttendanceVO {
   clockInStatus: string // 打卡状态 0正常,1迟到、2早退、3缺勤、4请假
   remark: string // 备注原因
   studentName: string // 学生名称
+  importStatus: string // 导入状态 0未导入,1已导入
 }
 
 // 学生考勤记录 API

+ 194 - 0
src/views/system/studentAttendanceManage/studentFaceManage/StudentFaceForm.vue

@@ -0,0 +1,194 @@
+<template>
+  <Dialog v-model="dialogVisible" title="用户批量导入" width="400">
+    <el-upload
+      ref="uploadRef"
+      v-model:file-list="fileList"
+      :action="importUrl + '?updateSupport=' + updateSupport"
+      :auto-upload="false"
+      :disabled="formLoading"
+      :headers="uploadHeaders"
+      :on-error="submitFormError"
+      :on-success="submitFormSuccess"
+      accept=".xlsx, .xls"
+      drag
+    >
+      <Icon icon="ep:upload" />
+      <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+      <template #tip>
+        <div class="el-upload__tip text-center">
+          <!-- <div class="el-upload__tip">
+            <el-checkbox v-model="updateSupport" />
+            是否更新已经存在的用户数据
+          </div> -->
+          <span>仅允许导入 xlsx, xls 格式文件。</span>
+          <el-link
+            :underline="false"
+            style="font-size: 12px; vertical-align: baseline"
+            type="primary"
+            @click="importTemplate"
+          >
+            下载模板
+          </el-link>
+        </div>
+      </template>
+    </el-upload>
+    <el-upload
+      ref="uploadZipRef"
+      v-model:file-list="zipList"
+      drag
+      :action="importZipUrl + '?updateSupport=' + updateSupport"
+      :on-success="submitZipSuccess"
+      :auto-upload="false"
+      :disabled="formLoading"
+      :headers="uploadHeaders"
+      :on-error="submitFormError"
+      :http-request="httpRequest"
+      accept=".zip,.rar"
+    >
+      <Icon icon="ep:upload" />
+      <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+      <template #tip>
+        <div class="el-upload__tip text-center">
+          <span>仅允许导入 zip、rar 格式压缩包。</span>
+          <div class="el-upload__tip">
+            <el-checkbox v-model="updateSupport" />
+            是否更新已经存在的用户数据
+          </div>
+        </div>
+      </template>
+    </el-upload>
+    <template #footer>
+      <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
+      <el-button @click="dialogVisible = false">取 消</el-button>
+    </template>
+  </Dialog>
+</template>
+<script lang="ts" setup>
+// import * as faceApi from '@/api/system/face'
+import * as UserApi from '@/api/system/user'
+import { getAccessToken, getTenantId } from '@/utils/auth'
+import download from '@/utils/download'
+import {useUpload} from "@/components/UploadFile/src/useUpload";
+defineOptions({ name: 'SystemUserImportForm' })
+
+const message = useMessage() // 消息弹窗
+const {  httpRequest } = useUpload()
+const dialogVisible = ref(false) // 弹窗的是否展示
+const formLoading = ref(false) // 表单的加载中
+const uploadRef = ref()
+const uploadZipRef = ref()
+const importUrl =
+  import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/md/acs/import-data'
+const importZipUrl =
+  import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/md/acs/import-data'
+const uploadHeaders = ref() // 上传 Header 头
+const fileList = ref([]) // 文件列表
+const updateSupport = ref(0) // 是否更新已经存在的用户数据
+
+const zipList = ref([]) // 压缩文件列表
+
+
+/** 打开弹窗 */
+const open = () => {
+  dialogVisible.value = true
+  updateSupport.value = 0
+  fileList.value = []
+  resetForm()
+  zipList.value = [] // 压缩文件列表
+}
+defineExpose({ open }) // 提供 open 方法,用于打开弹窗
+
+/** 提交表单 */
+const submitForm = async () => {
+  // if (fileList.value.length == 0) {
+  //   message.error('请上传文件')
+  //   return
+  // }
+
+  // if (zipList.value.length === 0) {
+  //   message.error('请上传压缩包')
+  //   return
+  // }
+  if (fileList.value.length == 0 && zipList.value.length === 0) {
+    message.error('请上传文件或压缩包')
+    return
+  }
+
+  // 提交请求
+  uploadHeaders.value = {
+    Authorization: 'Bearer ' + getAccessToken(),
+    'tenant-id': getTenantId()
+  }
+  formLoading.value = true
+  uploadRef.value!.submit()
+  uploadZipRef.value!.submit()
+}
+console.log(fileList,'fileList');
+
+
+/** 文件上传成功 */
+const emits = defineEmits(['success'])
+const submitFormSuccess = (response: any) => {
+  if (response.code !== 0) {
+    message.error(response.msg)
+    formLoading.value = false
+    return
+  }
+  // 拼接提示语
+  const data = response.data;
+  console.log(response.data,'123');
+  let text = '上传成功数量:' + data.createUsernames.length + ';'
+  for (let username of data.createUsernames) {
+    text += '< ' + username + ' >'
+  }
+  text += '更新成功数量:' + data.updateUsernames.length + ';'
+  for (const username of data.updateUsernames) {
+    text += '< ' + username + ' >'
+  }
+  text += '更新失败数量:' + Object.keys(data.failureUsernames).length + ';'
+  for (const username in data.failureUsernames) {
+    text += '< ' + username + ': ' + data.failureUsernames[username] + ' >'
+  }
+  message.alert(text)
+  formLoading.value = false
+  dialogVisible.value = false
+  // 发送操作成功的事件
+  emits('success')
+}
+
+const submitZipSuccess = (response: any) => {
+  if (response.code !== 0) {
+    message.error(response.msg)
+    formLoading.value = false
+    return
+  }
+  // 处理上传成功的逻辑,例如解压压缩包,处理里面的文件等
+  message.success('压缩包上传成功')
+  formLoading.value = false
+  dialogVisible.value = false
+  // 发送操作成功的事件
+  emits('success')
+}
+
+/** 上传错误提示 */
+const submitFormError = (): void => {
+  message.error('上传失败,请您重新上传!')
+  formLoading.value = false
+}
+
+/** 重置表单 */
+const resetForm = async (): Promise<void> => {
+  // 重置上传状态和文件
+  formLoading.value = false
+  await nextTick()
+  uploadRef.value?.clearFiles()
+  uploadZipRef.value?.clearFiles()
+}
+
+/** 下载模板操作 */
+const importTemplate = async () => {
+  const res = await UserApi.getAttendanceTemplate()
+  console.log(res,'111');
+  download.excel(res, '用户导入模版.xls')
+}
+</script>

+ 67 - 35
src/views/system/studentAttendanceManage/studentFaceManage/index.vue

@@ -16,9 +16,9 @@
                @keyup.enter="handleQuery"
               class="!w-240px"
             />
-          </el-form-item>
+      </el-form-item>
 
-      <el-form-item label="创建时间" prop="createTime">
+      <!-- <el-form-item label="创建时间" prop="createTime">
             <el-date-picker
               v-model="queryParams.createTime"
               value-format="YYYY-MM-DD HH:mm:ss"
@@ -27,9 +27,9 @@
               end-placeholder="结束日期"
               class="!w-240px"
             />
-          </el-form-item>
+      </el-form-item> -->
 
-      <el-form-item label="打卡状态 " prop="clockInStatus">
+      <!-- <el-form-item label="打卡状态 " prop="clockInStatus">
         <el-select
           v-model="queryParams.clockInStatus"
           placeholder="请选择打卡状态 "
@@ -42,6 +42,18 @@
           <el-option :label="'缺勤'" :value="3" />
           <el-option :label="'请假'" :value="4" />
         </el-select>
+      </el-form-item> -->
+
+      <el-form-item label="导入状态" prop="importStatus">
+        <el-select
+          v-model="queryParams.importStatus"
+          placeholder="请选择导入状态"
+          clearable
+          class="!w-240px"
+        >
+          <el-option :label="'未导入'" :value="0" />
+          <el-option :label="'已导入'" :value="1" />
+        </el-select>
       </el-form-item>
 
       <el-form-item>
@@ -51,7 +63,7 @@
           type="primary"
           plain
           @click="openForm('create')"
-          v-hasPermi="['system:student-attendance:create']"
+          v-hasPermi="['system:student-attendance:query']"
         >
           <Icon icon="ep:plus" class="mr-5px" /> 新增
         </el-button>
@@ -60,10 +72,18 @@
           plain
           @click="handleExport"
           :loading="exportLoading"
-          v-hasPermi="['system:student-attendance:export']"
+          v-hasPermi="['system:student-attendance:query']"
         >
           <Icon icon="ep:download" class="mr-5px" /> 导出
         </el-button>
+        <el-button
+          type="primary"
+          plain
+          @click="handleImportzip"
+          v-hasPermi="['system:student-attendance:query']"
+        >
+          <Icon icon="ep:upload" class="mr-5px" /> 批量导入
+        </el-button>
       </el-form-item>
     </el-form>
   </ContentWrap>
@@ -76,14 +96,29 @@
       <el-table-column label="学生名称" align="center" prop="studentName" />
       <!-- <el-table-column label="工作间id" align="center" prop="deptId" /> -->
       <!-- <el-table-column label="日期" align="center" prop="date" /> -->
-      <el-table-column
+      <!-- <el-table-column
         label="打卡时间"
         align="center"
         prop="clockInTime"
         :formatter="dateFormatter"
         width="180px"
-      />
-      <el-table-column label="打卡状态 " align="center" prop="clockInStatus" >
+      /> -->
+      <el-table-column label="导入状态" align="center" prop="importStatus" width="180px">
+        <template #default="rowData">
+          <!-- <span v-if="rowData.row.importStatus === 0">未导入</span>
+          <span v-else>已导入</span> -->
+          <span :class="getStatusClass(rowData.row.importStatus)">
+            {{
+              rowData.row.importStatus === 0
+               ? '未导入'
+               :rowData.row.importStatus === 1
+               ? '已导入'
+                : '未知类型'
+            }}
+          </span>
+        </template>
+      </el-table-column>
+      <!-- <el-table-column label="打卡状态 " align="center" prop="clockInStatus" >
         <template #default="rowData">
           <span :class="getStatusClass(rowData.row.clockInStatus)">
             {{
@@ -101,7 +136,7 @@
             }}
           </span>
         </template>
-      </el-table-column>
+      </el-table-column> -->
       <!-- <el-table-column
         label="创建时间"
         align="center"
@@ -110,13 +145,14 @@
         width="180px"
       /> -->
       <el-table-column label="备注原因" align="center" prop="remark" />
+      <el-table-column label="详情" align="center" prop="detail" />
       <el-table-column label="操作" align="center" min-width="120px">
         <template #default="scope">
           <el-button
             link
             type="primary"
             @click="openForm('update', scope.row.id)"
-            v-hasPermi="['system:student-attendance:update']"
+            v-hasPermi="['system:student-attendance:query']"
           >
             编辑
           </el-button>
@@ -124,7 +160,7 @@
             link
             type="danger"
             @click="handleDelete(scope.row.id)"
-            v-hasPermi="['system:student-attendance:delete']"
+            v-hasPermi="['system:student-attendance:query']"
           >
             删除
           </el-button>
@@ -142,13 +178,20 @@
 
   <!-- 表单弹窗:添加/修改 -->
   <StudentAttendanceForm ref="formRef" @success="getList" />
+  <!-- 导出弹窗 -->
+  <!--批量导入弹窗-->
+  <StudentFaceForm ref="importFormzipRef" @success="getList" />
 </template>
 
 <script setup lang="ts">
-import { dateFormatter } from '@/utils/formatTime'
+// import { dateFormatter } from '@/utils/formatTime'
 import download from '@/utils/download'
 import { StudentAttendanceApi, StudentAttendanceVO } from '@/api/system/studentAttendance'
 import StudentAttendanceForm from './StudentAttendanceForm.vue'
+import StudentFaceForm from './StudentFaceForm.vue'
+import { useI18n } from 'vue-i18n'
+import { ref, reactive, onMounted } from 'vue'
+
 
 /** 学生考勤记录 列表 */
 defineOptions({ name: 'studentFaceManage' })
@@ -171,6 +214,7 @@ const queryParams = reactive({
   clockInStatus: undefined,
   createTime: [],
   remark: undefined,
+  importStatus: undefined,
 })
 const queryFormRef = ref() // 搜索的表单
 const exportLoading = ref(false) // 导出的加载中
@@ -233,19 +277,19 @@ const handleExport = async () => {
   }
 }
 
+/**批量导入按钮操作 */
+const importFormzipRef = ref()
+const handleImportzip = () => {
+  importFormzipRef.value.open()
+}
+
 // 状态颜色显示
 const getStatusClass = (status) => {
   switch (status) {
     case "0":
-      return 'status-normal';
+      return 'status-Imported';
     case "1":
-      return 'status-late';
-    case "2":
-      return 'status-early';
-    case "3":
-      return 'status-absent';
-    case "4":
-      return 'status-leave';
+      return 'status-Notimported';
     default:
       return 'status-unknown';
   }
@@ -258,26 +302,14 @@ onMounted(() => {
 </script>
 
 <style scoped>
-.status-normal {
+.status-Imported {
   color: green;
 }
 
-.status-late {
-  color: orange;
-}
-
-.status-early {
-  color: blue;
-}
-
-.status-absent {
+.status-Notimported {
   color: red;
 }
 
-.status-leave {
-  color: purple;
-}
-
 .status-unknown {
   color: gray;
 }

+ 1 - 0
src/views/system/workroomCollege/user/UserImportForm.vue

@@ -80,6 +80,7 @@ const submitForm = async () => {
   }
   formLoading.value = true
   uploadRef.value!.submit()
+  console.log('67890',uploadHeaders.value);
 }
 
 /** 文件上传成功 */

+ 76 - 15
src/views/system/workroomCollege/user/UserImportFormzip.vue

@@ -7,22 +7,21 @@
       :auto-upload="false"
       :disabled="formLoading"
       :headers="uploadHeaders"
-      
       :on-error="submitFormError"
-      
       :on-success="submitFormSuccess"
-      accept=".xlsx, .xls .zip"
+      accept=".xlsx, .xls"
       drag
+      name	= "excelFile"
     >
       <Icon icon="ep:upload" />
       <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
       <template #tip>
         <div class="el-upload__tip text-center">
-          <div class="el-upload__tip">
+          <!-- <div class="el-upload__tip">
             <el-checkbox v-model="updateSupport" />
             是否更新已经存在的用户数据
-          </div>
-          <span>仅允许导入 xlsx, xls, zip 格式文件。</span>
+          </div> -->
+          <span>仅允许导入 xlsx, xls 格式文件。</span>
           <el-link
             :underline="false"
             style="font-size: 12px; vertical-align: baseline"
@@ -34,6 +33,32 @@
         </div>
       </template>
     </el-upload>
+    <el-upload
+      ref="uploadZipRef"
+      v-model:file-list="zipList"
+      drag
+      :action="importUrl + '?updateSupport=' + updateSupport"
+      :on-success="submitZipSuccess"
+      :auto-upload="false"
+      :disabled="formLoading"
+      :headers="uploadHeaders"
+      :on-error="submitFormError"
+      :http-request="httpRequest"
+      accept=".zip,.rar"
+      name	= "imageFile"
+    >
+      <Icon icon="ep:upload" />
+      <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+      <template #tip>
+        <div class="el-upload__tip text-center">
+          <span>仅允许导入 zip、rar 格式压缩包。</span>
+          <div class="el-upload__tip">
+            <el-checkbox v-model="updateSupport" />
+            是否更新已经存在的用户数据
+          </div>
+        </div>
+      </template>
+    </el-upload>
     <template #footer>
       <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
       <el-button @click="dialogVisible = false">取 消</el-button>
@@ -41,39 +66,55 @@
   </Dialog>
 </template>
 <script lang="ts" setup>
-import * as faceApi from '@/api/system/face'
 import * as UserApi from '@/api/system/user'
 import { getAccessToken, getTenantId } from '@/utils/auth'
 import download from '@/utils/download'
-
+import {useUpload} from "@/components/UploadFile/src/useUpload";
 defineOptions({ name: 'SystemUserImportForm' })
 
 const message = useMessage() // 消息弹窗
-
+const {  httpRequest } = useUpload()
 const dialogVisible = ref(false) // 弹窗的是否展示
 const formLoading = ref(false) // 表单的加载中
 const uploadRef = ref()
+const uploadZipRef = ref()
 const importUrl =
-  import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/system/user/import'
+  import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/md/acs/import-data'
+const importZipUrl =
+  import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/md/acs/import-data'
 const uploadHeaders = ref() // 上传 Header 头
 const fileList = ref([]) // 文件列表
 const updateSupport = ref(0) // 是否更新已经存在的用户数据
 
+const zipList = ref([]) // 压缩文件列表
+
+
 /** 打开弹窗 */
 const open = () => {
   dialogVisible.value = true
   updateSupport.value = 0
   fileList.value = []
   resetForm()
+  zipList.value = [] // 压缩文件列表
 }
 defineExpose({ open }) // 提供 open 方法,用于打开弹窗
 
 /** 提交表单 */
 const submitForm = async () => {
-  if (fileList.value.length == 0) {
-    message.error('请上传文件')
+  // if (fileList.value.length == 0) {
+  //   message.error('请上传文件')
+  //   return
+  // }
+
+  // if (zipList.value.length === 0) {
+  //   message.error('请上传压缩包')
+  //   return
+  // }
+  if (fileList.value.length == 0 && zipList.value.length === 0) {
+    message.error('请上传文件或压缩包')
     return
   }
+
   // 提交请求
   uploadHeaders.value = {
     Authorization: 'Bearer ' + getAccessToken(),
@@ -81,18 +122,25 @@ const submitForm = async () => {
   }
   formLoading.value = true
   uploadRef.value!.submit()
+  uploadZipRef.value!.submit()
+  console.log('1234567890',uploadHeaders.value);
+  
 }
 
+
+
 /** 文件上传成功 */
 const emits = defineEmits(['success'])
 const submitFormSuccess = (response: any) => {
   if (response.code !== 0) {
     message.error(response.msg)
     formLoading.value = false
+    console.log(response.code,'12345');
     return
   }
   // 拼接提示语
-  const data = response.data
+  const data = response.data;
+  console.log(response.data,'123');
   let text = '上传成功数量:' + data.createUsernames.length + ';'
   for (let username of data.createUsernames) {
     text += '< ' + username + ' >'
@@ -112,6 +160,20 @@ const submitFormSuccess = (response: any) => {
   emits('success')
 }
 
+const submitZipSuccess = (response: any) => {
+  if (response.code !== 0) {
+    message.error(response.msg)
+    formLoading.value = false
+    return
+  }
+  // 处理上传成功的逻辑,例如解压压缩包,处理里面的文件等
+  message.success('压缩包上传成功')
+  formLoading.value = false
+  dialogVisible.value = false
+  // 发送操作成功的事件
+  emits('success')
+}
+
 /** 上传错误提示 */
 const submitFormError = (): void => {
   message.error('上传失败,请您重新上传!')
@@ -124,10 +186,9 @@ const resetForm = async (): Promise<void> => {
   formLoading.value = false
   await nextTick()
   uploadRef.value?.clearFiles()
+  uploadZipRef.value?.clearFiles()
 }
 
-
-
 /** 下载模板操作 */
 const importTemplate = async () => {
   const res = await UserApi.getAttendanceTemplate()

+ 2 - 0
src/views/system/workroomTeacher/dept/index.vue

@@ -131,6 +131,7 @@ export default defineComponent({
     const formRef = ref();
 
     const form = reactive({
+      id: '',
       supervisor: '',  
       phone: '',
       email: '',
@@ -238,6 +239,7 @@ export default defineComponent({
     const init = async () => {
       const res = await getUserDept();
       console.log('获取的数据:', res);
+      form.id = res.id;
       form.address = res.address;
       form.supervisor = res.user.nickname;
       form.phone = res.user.mobile;