index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="用户昵称" prop="studentName">
  12. <el-input
  13. placeholder="请输入用户昵称 "
  14. v-model="queryParams.studentName"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="创建时间" prop="createTime">
  21. <el-date-picker
  22. v-model="queryParams.createTime"
  23. value-format="YYYY-MM-DD HH:mm:ss"
  24. type="datetimerange"
  25. start-placeholder="开始日期"
  26. end-placeholder="结束日期"
  27. class="!w-240px"
  28. />
  29. </el-form-item>
  30. <el-form-item label="打卡状态 " prop="clockInStatus">
  31. <el-select
  32. v-model="queryParams.clockInStatus"
  33. placeholder="请选择打卡状态 "
  34. clearable
  35. class="!w-240px"
  36. >
  37. <el-option :label="'正常'" :value="0" />
  38. <el-option :label="'未打卡'" :value="1" />
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  43. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  44. <el-button
  45. type="primary"
  46. plain
  47. @click="openForm('create')"
  48. v-hasPermi="['system:student-attendance:create']"
  49. >
  50. <Icon icon="ep:plus" class="mr-5px" /> 新增
  51. </el-button>
  52. <el-button
  53. type="success"
  54. plain
  55. @click="handleExport"
  56. :loading="exportLoading"
  57. v-hasPermi="['system:student-attendance:export']"
  58. >
  59. <Icon icon="ep:download" class="mr-5px" /> 导出
  60. </el-button>
  61. </el-form-item>
  62. </el-form>
  63. </ContentWrap>
  64. <!-- 列表 -->
  65. <ContentWrap>
  66. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  67. <el-table-column label="Id" align="center" prop="id" />
  68. <!-- <el-table-column label="学生id" align="center" prop="studentId" /> -->
  69. <el-table-column label="学生名称" align="center" prop="studentName" />
  70. <!-- <el-table-column label="工作间id" align="center" prop="deptId" /> -->
  71. <!-- <el-table-column label="日期" align="center" prop="date" /> -->
  72. <el-table-column label="学号" align="center" prop="userNumber" width="150" />
  73. <el-table-column
  74. v-if="userInfo.userType === '4'"
  75. label="工作间名称"
  76. align="center"
  77. prop="deptName"
  78. width="100"
  79. />
  80. <el-table-column
  81. label="打卡时间"
  82. align="center"
  83. prop="clockInTime"
  84. :formatter="dateFormatter"
  85. width="180px"
  86. />
  87. <el-table-column label="打卡类型" align="center" prop="clockInStatus">
  88. <template #default="scope">
  89. <dict-tag :type="DICT_TYPE.SYSTEM_STUDENT_ATTENDANCE_TYPE" :value="scope.row.clockInStatus" />
  90. </template>
  91. </el-table-column>
  92. <!-- <el-table-column label="打卡状态 " align="center" prop="clockInStatus" >
  93. <template #default="rowData">
  94. <span :class="getStatusClass(rowData.row.clockInStatus)">
  95. {{
  96. rowData.row.clockInStatus == 0
  97. ? '正常'
  98. : rowData.row.clockInStatus ==1
  99. ? '未打卡'
  100. : rowData.row.clockInStatus == 2
  101. ? '警告'
  102. : rowData.row.clockInStatus == 3
  103. ? '恢复正常'
  104. : '未知类型'
  105. }}
  106. </span>
  107. </template>
  108. </el-table-column> -->
  109. <!-- <el-table-column
  110. label="创建时间"
  111. align="center"
  112. prop="createTime"
  113. :formatter="dateFormatter"
  114. width="180px"
  115. /> -->
  116. <el-table-column label="备注原因" align="center" prop="remark" />
  117. <el-table-column label="操作" align="center" min-width="120px">
  118. <template #default="scope">
  119. <el-button
  120. link
  121. type="primary"
  122. @click="openForm('update', scope.row.id)"
  123. v-hasPermi="['system:student-attendance:update']"
  124. >
  125. 编辑
  126. </el-button>
  127. <el-button
  128. link
  129. type="danger"
  130. @click="handleDelete(scope.row.id)"
  131. v-hasPermi="['system:student-attendance:delete']"
  132. >
  133. 删除
  134. </el-button>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. <!-- 分页 -->
  139. <Pagination
  140. :total="total"
  141. v-model:page="queryParams.pageNo"
  142. v-model:limit="queryParams.pageSize"
  143. @pagination="getList"
  144. />
  145. </ContentWrap>
  146. <!-- 表单弹窗:添加/修改 -->
  147. <StudentAttendanceForm ref="formRef" @success="getList" />
  148. </template>
  149. <script setup lang="ts">
  150. import { dateFormatter } from '@/utils/formatTime'
  151. import download from '@/utils/download'
  152. import { StudentAttendanceApi, StudentAttendanceVO } from '@/api/system/studentAttendance'
  153. import StudentAttendanceForm from './StudentAttendanceForm.vue'
  154. import { DICT_TYPE } from '@/utils/dict'
  155. import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
  156. /** 学生考勤记录 列表 */
  157. defineOptions({ name: 'StudentAttendance' })
  158. const message = useMessage() // 消息弹窗
  159. const { t } = useI18n() // 国际化
  160. const userInfo = ref({} as ProfileVO)
  161. const getUserInfo = async () => {
  162. const users = await getUserProfile()
  163. console.log(users)
  164. userInfo.value = users
  165. }
  166. const loading = ref(true) // 列表的加载中
  167. const list = ref<StudentAttendanceVO[]>([]) // 列表的数据
  168. const total = ref(0) // 列表的总页数
  169. const queryParams = reactive({
  170. pageNo: 1,
  171. pageSize: 10,
  172. studentId: undefined,
  173. studentName: undefined,
  174. deptId: undefined,
  175. date: [],
  176. clockInTime: [],
  177. clockInTimeRange: [],
  178. clockInStatus: undefined,
  179. createTime: [],
  180. remark: undefined,
  181. })
  182. const queryFormRef = ref() // 搜索的表单
  183. const exportLoading = ref(false) // 导出的加载中
  184. /** 查询列表 */
  185. const getList = async () => {
  186. loading.value = true
  187. try {
  188. const data = await StudentAttendanceApi.getStudentAttendancePage(queryParams)
  189. console.log(data, 'data');
  190. list.value = data.list
  191. total.value = data.total
  192. } finally {
  193. loading.value = false
  194. }
  195. }
  196. /** 搜索按钮操作 */
  197. const handleQuery = () => {
  198. queryParams.pageNo = 1
  199. getList()
  200. }
  201. /** 重置按钮操作 */
  202. const resetQuery = () => {
  203. queryFormRef.value.resetFields()
  204. handleQuery()
  205. }
  206. /** 添加/修改操作 */
  207. const formRef = ref()
  208. const openForm = (type: string, id?: number) => {
  209. formRef.value.open(type, id)
  210. }
  211. /** 删除按钮操作 */
  212. const handleDelete = async (id: number) => {
  213. try {
  214. // 删除的二次确认
  215. await message.delConfirm()
  216. // 发起删除
  217. await StudentAttendanceApi.deleteStudentAttendance(id)
  218. message.success(t('common.delSuccess'))
  219. // 刷新列表
  220. await getList()
  221. } catch {}
  222. }
  223. /** 导出按钮操作 */
  224. const handleExport = async () => {
  225. try {
  226. // 导出的二次确认
  227. await message.exportConfirm()
  228. // 发起导出
  229. exportLoading.value = true
  230. const data = await StudentAttendanceApi.exportStudentAttendance(queryParams)
  231. download.excel(data, '学生考勤记录.xls')
  232. } catch {
  233. } finally {
  234. exportLoading.value = false
  235. }
  236. }
  237. // 状态颜色显示
  238. const getStatusClass = (status) => {
  239. switch (status) {
  240. case "0":
  241. return 'status-normal';
  242. case "1":
  243. return 'status-late';
  244. case "2":
  245. return 'status-early';
  246. case "3":
  247. return 'status-absent';
  248. case "4":
  249. return 'status-leave';
  250. default:
  251. return 'status-unknown';
  252. }
  253. };
  254. /** 初始化 **/
  255. onMounted(async () => {
  256. await getUserInfo()
  257. getList()
  258. })
  259. </script>
  260. <style scoped>
  261. .status-normal {
  262. color: green;
  263. }
  264. .status-late {
  265. color: orange;
  266. }
  267. .status-early {
  268. color: blue;
  269. }
  270. .status-absent {
  271. color: red;
  272. }
  273. .status-leave {
  274. color: purple;
  275. }
  276. .status-unknown {
  277. color: gray;
  278. }
  279. </style>