index.vue 6.8 KB

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