index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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 type="index" width="50" />
  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" />
  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="url" >
  117. <template #default="{ row }">
  118. <div class="demo-image__preview" v-if="queryParams" >
  119. <el-image
  120. style="width: 40px; height:40px;margin-right: 5px"
  121. class="h-80px w-80px"
  122. lazy
  123. :src="row.photo"
  124. :preview-src-list="[row.photo]"
  125. preview-teleported
  126. fit="cover"
  127. />
  128. </div>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="备注" align="center" prop="remark" />
  132. <!-- <el-table-column label="操作" align="center" min-width="120px">-->
  133. <!-- <template #default="scope">-->
  134. <!-- <el-button-->
  135. <!-- link-->
  136. <!-- type="primary"-->
  137. <!-- @click="openForm('update', scope.row.id)"-->
  138. <!-- v-hasPermi="['system:student-attendance:update']"-->
  139. <!-- >-->
  140. <!-- 编辑-->
  141. <!-- </el-button>-->
  142. <!-- <el-button-->
  143. <!-- link-->
  144. <!-- type="danger"-->
  145. <!-- @click="handleDelete(scope.row.id)"-->
  146. <!-- v-hasPermi="['system:student-attendance:delete']"-->
  147. <!-- >-->
  148. <!-- 删除-->
  149. <!-- </el-button>-->
  150. <!-- </template>-->
  151. <!-- </el-table-column>-->
  152. </el-table>
  153. <!-- 分页 -->
  154. <Pagination
  155. :total="total"
  156. v-model:page="queryParams.pageNo"
  157. v-model:limit="queryParams.pageSize"
  158. @pagination="getList"
  159. />
  160. </ContentWrap>
  161. <!-- 表单弹窗:添加/修改 -->
  162. <StudentAttendanceForm ref="formRef" @success="getList" />
  163. </template>
  164. <script setup lang="ts">
  165. import { dateFormatter } from '@/utils/formatTime'
  166. import download from '@/utils/download'
  167. import { StudentAttendanceApi, StudentAttendanceVO } from '@/api/system/studentAttendance'
  168. import StudentAttendanceForm from './StudentAttendanceForm.vue'
  169. import { DICT_TYPE } from '@/utils/dict'
  170. import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
  171. /** 学生考勤记录 列表 */
  172. defineOptions({ name: 'StudentAttendance' })
  173. const message = useMessage() // 消息弹窗
  174. const { t } = useI18n() // 国际化
  175. const userInfo = ref({} as ProfileVO)
  176. const getUserInfo = async () => {
  177. const users = await getUserProfile()
  178. console.log(users)
  179. userInfo.value = users
  180. }
  181. const loading = ref(true) // 列表的加载中
  182. const list = ref<StudentAttendanceVO[]>([]) // 列表的数据
  183. const total = ref(0) // 列表的总页数
  184. const queryParams = reactive({
  185. pageNo: 1,
  186. pageSize: 10,
  187. studentId: undefined,
  188. studentName: undefined,
  189. deptId: undefined,
  190. date: [],
  191. clockInTime: [],
  192. clockInTimeRange: [],
  193. clockInStatus: undefined,
  194. createTime: [],
  195. remark: undefined,
  196. })
  197. const queryFormRef = ref() // 搜索的表单
  198. const exportLoading = ref(false) // 导出的加载中
  199. /** 查询列表 */
  200. const getList = async () => {
  201. loading.value = true
  202. try {
  203. const data = await StudentAttendanceApi.getStudentAttendancePage(queryParams)
  204. console.log(data, 'data');
  205. list.value = data.list
  206. total.value = data.total
  207. } finally {
  208. loading.value = false
  209. }
  210. }
  211. /** 搜索按钮操作 */
  212. const handleQuery = () => {
  213. queryParams.pageNo = 1
  214. getList()
  215. }
  216. /** 重置按钮操作 */
  217. const resetQuery = () => {
  218. queryFormRef.value.resetFields()
  219. handleQuery()
  220. }
  221. /** 添加/修改操作 */
  222. const formRef = ref()
  223. const openForm = (type: string, id?: number) => {
  224. formRef.value.open(type, id)
  225. }
  226. /** 删除按钮操作 */
  227. const handleDelete = async (id: number) => {
  228. try {
  229. // 删除的二次确认
  230. await message.delConfirm()
  231. // 发起删除
  232. await StudentAttendanceApi.deleteStudentAttendance(id)
  233. message.success(t('common.delSuccess'))
  234. // 刷新列表
  235. await getList()
  236. } catch {}
  237. }
  238. /** 导出按钮操作 */
  239. const handleExport = async () => {
  240. try {
  241. // 导出的二次确认
  242. await message.exportConfirm()
  243. // 发起导出
  244. exportLoading.value = true
  245. const data = await StudentAttendanceApi.exportStudentAttendance(queryParams)
  246. download.excel(data, '学生考勤记录.xls')
  247. } catch {
  248. } finally {
  249. exportLoading.value = false
  250. }
  251. }
  252. // 状态颜色显示
  253. const getStatusClass = (status) => {
  254. switch (status) {
  255. case "0":
  256. return 'status-normal';
  257. case "1":
  258. return 'status-late';
  259. case "2":
  260. return 'status-early';
  261. case "3":
  262. return 'status-absent';
  263. case "4":
  264. return 'status-leave';
  265. default:
  266. return 'status-unknown';
  267. }
  268. };
  269. /** 初始化 **/
  270. onMounted(async () => {
  271. await getUserInfo()
  272. getList()
  273. })
  274. </script>
  275. <style scoped>
  276. .status-normal {
  277. color: green;
  278. }
  279. .status-late {
  280. color: orange;
  281. }
  282. .status-early {
  283. color: blue;
  284. }
  285. .status-absent {
  286. color: red;
  287. }
  288. .status-leave {
  289. color: purple;
  290. }
  291. .status-unknown {
  292. color: gray;
  293. }
  294. </style>