index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!-- 学生列表 -->
  2. <template>
  3. <v-card class="px-3">
  4. <!-- 筛选条件 -->
  5. <div class="d-flex justify-space-between mt-8 mb-10">
  6. <div class="d-flex align-center">
  7. <Autocomplete class="mr-3" v-model="query.schoolDeptId" :item="schoolDepartmentItem"></Autocomplete>
  8. <TextInput class="mr-3" v-model="query.name" :item="studentNameItem" @enter="handleSearch()"></TextInput>
  9. <v-btn color="primary" class="half-button ml-3" @click="handleSearch()">查 询</v-btn>
  10. <v-btn class="half-button ml-3" prepend-icon="mdi-refresh" variant="outlined" color="primary" @click="handleReset">重 置</v-btn>
  11. <v-btn class="half-button ml-3" prepend-icon="mdi-refresh" variant="outlined" color="warning" @click="handleSearch(true)">刷 新</v-btn>
  12. </div>
  13. <!-- <v-btn :loading="exportLoading" prepend-icon="mdi-export-variant" color="primary" variant="tonal" class="ml-3" @click="null">导出</v-btn> -->
  14. </div>
  15. <!-- 列表 -->
  16. <div class="mt-5" style="min-height: 500px;">
  17. <CtTable
  18. :items="tableData"
  19. :headers="headers"
  20. :loading="loading"
  21. :elevation="0"
  22. :is-tools="false"
  23. :showPage="true"
  24. :total="total"
  25. :page-info="query"
  26. itemKey="id"
  27. @pageHandleChange="handleChangePage"
  28. >
  29. <template #studentName="{ item }">
  30. <div class="d-flex align-center defaultLink" @click="studentDetails(item.id)">
  31. <v-avatar size="40" :image="getUserAvatar(item?.person?.avatar, item?.person?.sex)"></v-avatar>
  32. <span class="ml-3">{{ item?.person?.name }}</span>
  33. </div>
  34. </template>
  35. <template #actions="{ item }">
  36. <v-btn color="primary" variant="text" @click="studentDetails(item.id)">详情</v-btn>
  37. <v-btn color="primary" variant="text" @click="handleReport(item)">实习报告</v-btn>
  38. </template>
  39. </CtTable>
  40. </div>
  41. <v-navigation-drawer v-model="showDetail" absolute location="right" rounded temporary width="700" class="pa-5">
  42. <div class="resume-header" style="height: 60px;">
  43. <div class="resume-title">{{ itemData?.person?.name }} - 实习报告</div>
  44. <Autocomplete v-model="enterpriseId" :item="enterpriseItem" @change="handleEnterprise"></Autocomplete>
  45. </div>
  46. <div v-if="report && report.length > 0" class="mt-5">
  47. <div v-for="item in report" :key="item.date" class="mb-3">
  48. <div class="color-666">日期:{{ item.date }}</div>
  49. <div class="d-flex flex-wrap">
  50. <img
  51. v-for="(src, index) in item.arr"
  52. :key="index"
  53. :src="src"
  54. @click="handlePreview(item.arr, index)"
  55. class="cursor-pointer"
  56. style="width: 200px; height: 250px;"
  57. />
  58. </div>
  59. </div>
  60. </div>
  61. <Empty v-else :elevation="false" :message="!enterpriseId ? '请选择要查看的实习企业' : '暂无实习报告'" />
  62. </v-navigation-drawer>
  63. </v-card>
  64. <PreviewImage v-if="showPreview" :initialIndex="initialIndex" :urlList="urlsList" @close="handleClosePreview" />
  65. </template>
  66. <script setup>
  67. defineOptions({name: 'studentList-index'})
  68. import { ref, onMounted } from 'vue'
  69. import Snackbar from '@/plugins/snackbar'
  70. import { getUserAvatar } from '@/utils/avatar'
  71. import { studentList, getSchoolOrganizationList, getStudentPracticeReportById, getStudentPracticeCompanyList } from '@/api/school'
  72. import { formatName } from '@/utils/getText'
  73. const loading = ref(false)
  74. const query = ref({
  75. pageSize: 10,
  76. pageNo: 1,
  77. schoolId: JSON.parse(localStorage.getItem('schoolInfo'))?.schoolId,
  78. name: null,
  79. schoolDeptId: null
  80. })
  81. const studentNameItem = ref({
  82. type: 'text',
  83. width: 300,
  84. label: '请输入学生姓名搜索',
  85. clearable: false,
  86. hideDetails: true
  87. })
  88. const enterpriseId = ref(null)
  89. const enterpriseItem = ref({
  90. width: 300,
  91. items: [],
  92. clearable: true,
  93. hideDetails: true,
  94. label: '请选择实习企业',
  95. itemText: 'name',
  96. itemValue: 'id'
  97. })
  98. const headers = [
  99. { title: '学生姓名', key: 'studentName', sortable: false },
  100. { title: '所属院系', key: 'schoolDept.name', sortable: false },
  101. { title: '所属专业', key: 'major.nameCn', sortable: false },
  102. { title: '所在班级', key: 'schoolClass.name', sortable: false },
  103. { title: '学号', key: 'studentNo', sortable: false },
  104. { title: '紧急联系人', key: 'emergencyContactName', sortable: false },
  105. { title: '紧急联系人电话', key: 'emergencyContactPhone', sortable: false },
  106. { title: '操作', key: 'actions', sortable: false }
  107. ]
  108. // 学生列表
  109. const tableData = ref([]); const total = ref(0)
  110. const getData = async (isRefresh = false) => {
  111. const result = await studentList(query.value)
  112. tableData.value = result.list || []
  113. total.value = result.total
  114. if (isRefresh) Snackbar.success('刷新成功')
  115. }
  116. // 分页
  117. const handleChangePage = (val) => {
  118. query.value.pageNo = val
  119. getData()
  120. }
  121. // 查询
  122. const handleSearch = (refresh = false) => {
  123. query.value.pageNo = 1
  124. getData(refresh)
  125. }
  126. // 重置
  127. const handleReset = () => {
  128. query.value.pageNo = 1
  129. query.value.name = null
  130. query.value.schoolDeptId = null
  131. getData()
  132. }
  133. const schoolInfo = ref(localStorage.getItem('schoolInfo') ? JSON.parse(localStorage.getItem('schoolInfo')) : {})
  134. const schoolDepartmentItem = ref({ width: 300, items: [], clearable: false, hideDetails: true, label: '请选择院系', itemText: 'name', itemValue: 'id' })
  135. // 院系列表
  136. const getSchoolDepartment = async () => {
  137. const schoolId = schoolInfo.value?.schoolId || null
  138. if (!schoolId) return Snackbar.warning('获取学校信息失败!')
  139. const data = await getSchoolOrganizationList({ schoolId, type: 0 })
  140. schoolDepartmentItem.value.items = data || []
  141. }
  142. onMounted(() => {
  143. getSchoolDepartment()
  144. getData()
  145. })
  146. const studentDetails = (id) => {
  147. if (id) window.open(`/recruit/teacher/studentList/detail/${id}`)
  148. }
  149. // 实习报告
  150. const showDetail = ref(false)
  151. const report = ref([])
  152. const itemData = ref({})
  153. const handleReport = async (item) => {
  154. enterpriseId.value = null
  155. report.value = []
  156. itemData.value = item
  157. enterpriseItem.value.items = []
  158. const data = await getStudentPracticeCompanyList({ userId: item.userId })
  159. enterpriseItem.value.items = data ? data.map(e => {
  160. return { name: formatName(e.anotherName || e.name), id: e.id }
  161. }) : []
  162. showDetail.value = true
  163. }
  164. const handleEnterprise = async (id) => {
  165. report.value = []
  166. if (!id) return
  167. const data = await getStudentPracticeReportById({ enterpriseId: id, userId: itemData.value.userId })
  168. if (!data || !Object.keys(data).length) return
  169. for (let item in data) {
  170. report.value.push({ date: item, arr: data[item].map(e => e.url) })
  171. }
  172. }
  173. // 图片预览
  174. const showPreview = ref(false)
  175. const initialIndex = ref(0)
  176. const urlsList = ref([])
  177. const handlePreview = (arr, index) => {
  178. urlsList.value = arr
  179. initialIndex.value = index
  180. showPreview.value = true
  181. }
  182. const handleClosePreview = () => {
  183. showPreview.value = false
  184. initialIndex.value = 0
  185. urlsList.value = []
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .title {
  190. color: var(--color-333);
  191. font-weight: 600;
  192. font-size: 16px;
  193. }
  194. .left {
  195. min-width: 200px;
  196. }
  197. </style>