listViewTeacher.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div v-if="visible">
  3. <a-table
  4. ref="table"
  5. :columns="columns"
  6. :data-source="dataSources"
  7. bordered
  8. :expand-row-by-click="true"
  9. :pagination="false"
  10. style="width: 100%; height: 600px"
  11. >
  12. <template #bodyCell="{ column, text, record }">
  13. <template v-if="column.dataIndex === 'action'">
  14. <span style="cursor: pointer" @click="handleIn(record)">进入</span>
  15. </template>
  16. <!-- <template v-if="column.dataIndex === 'action'">-->
  17. <!-- &lt;!&ndash; <a-button size="small" @click="handleDetail(record)" style="margin-right: 5px">详情</a-button>&ndash;&gt;-->
  18. <!-- &lt;!&ndash; <a-button size="small" @click="handleEdit(record)" style="margin-right: 5px">编辑</a-button>&ndash;&gt;-->
  19. <!-- <a-popover v-model:visible="popoverVisibles[record.collegeId]" title="确定删除?" trigger="click">-->
  20. <!-- <template #content>-->
  21. <!-- <a-button style="margin-right: 10px" type="primary" @click="handleShelf(record,1)">确定-->
  22. <!-- </a-button>-->
  23. <!-- <a-button @click="()=>{ popoverVisibles[record.collegeId] = false}">取消</a-button>-->
  24. <!-- </template>-->
  25. <!-- &lt;!&ndash; <a-button size="small" style="margin-right: 5px">选择</a-button>&ndash;&gt;-->
  26. <!-- <a-button size="small" @click="handleDelete(record)" style="margin-right: 5px">删除</a-button>-->
  27. <!-- </a-popover>-->
  28. <!-- </template>-->
  29. </template>
  30. </a-table>
  31. <div style="display: flex; width: 100%; justify-content: flex-end; margin-top: 10px">
  32. <a-pagination
  33. v-model:current="pagination.current"
  34. v-model:pageSize="pagination.size"
  35. :total="total"
  36. show-less-items
  37. @change="handlerChange"
  38. />
  39. </div>
  40. </div>
  41. </template>
  42. <script setup>
  43. import tool from '@/utils/tool'
  44. import {ref, onMounted} from 'vue'
  45. import {useRouter} from 'vue-router'
  46. import {parseTime} from "@/utils/exam";
  47. const router = useRouter()
  48. //网络
  49. import { getStudentTeacher } from '@/api/link'
  50. const emit = defineEmits(['handleIn'])
  51. //发布按钮状态
  52. const releaseVisible = ref(false)
  53. const loading = ref(false) // 列表loading
  54. const dataSources = ref([])
  55. const popoverVisible = ref({})
  56. const popoverVisibles = ref({})
  57. const visible = ref(true)
  58. const formState = ref({
  59. name: '',
  60. loacl: ''
  61. }) // 列表loading
  62. const columns = [
  63. {
  64. title: '老师名称',
  65. dataIndex: 'teacherName',
  66. // sorter: true,
  67. },
  68. {
  69. title: '操作',
  70. dataIndex: 'action',
  71. // sorter: true,
  72. width: '5%'
  73. },
  74. ]
  75. // tool.formatTimestamp()
  76. const formatDateTime = (val) => {
  77. if (!val) return ''
  78. return parseTime(val, '{y}-{m}-{d} {h}:{i}:{s}')
  79. }
  80. const formatTimestamp = (time) => {
  81. return tool.formatTimestamp(time)
  82. }
  83. const total = ref(0)
  84. const pagination = ref({
  85. size: 10,
  86. current: 1,
  87. })
  88. // const onChangeCurrent = (current) => {
  89. // router.push({
  90. // path: '/' + current
  91. // })
  92. // }
  93. const handleIn = (data) => {
  94. console.log('进入', data)
  95. emit("handleIn",data)
  96. }
  97. const handlerChange = (page, pageSize) => {
  98. console.log('分页参数', page, pageSize)
  99. // pagination.value.size = pageSize
  100. // pagination.value.current = page
  101. getList()
  102. }
  103. const handleOk = () => {
  104. visible.value = false
  105. }
  106. const open = () => {
  107. visible.value = true
  108. pagination.value.size = 10
  109. pagination.value.current = 1
  110. getList()
  111. }
  112. const close = () => {
  113. visible.value = false
  114. }
  115. const handleDetail = (record) => {
  116. console.log('查看详情', record)
  117. router.push({
  118. path: '/portal/courseDetails',
  119. query: {
  120. id: record.courseId
  121. }
  122. })
  123. // 在这里添加查看详情的逻辑
  124. }
  125. // 编辑按钮点击事件
  126. const handleEdit = (record) => {
  127. console.log('编辑记录', record)
  128. // 在这里添加编辑记录的逻辑
  129. emit('handleEdit', record)
  130. }
  131. // 上架按钮点击事件
  132. const handleShelf = (record,num) => {
  133. console.log('上架记录', record)
  134. popoverVisible.value[record.collegeId] = false
  135. // 在这里添加上架记录的逻辑
  136. // {
  137. // "courseId": "1948183431150227458",
  138. // "putawayStatus": 1
  139. // }
  140. // updateCourseStatus({courseId : record.courseId,putawayStatus : num}).then((res)=>{
  141. // getList()
  142. // })
  143. }
  144. // 删除按钮点击事件
  145. const handleDelete = (record) => {
  146. console.log('删除记录', record)
  147. // 在这里添加删除记录的逻辑
  148. }
  149. const getList = (id) => {
  150. const params = {
  151. // courseId: id,
  152. size : pagination.value.size,
  153. current : pagination.value.current
  154. }
  155. getStudentTeacher(params).then((data)=>{
  156. console.log('获取列表', data)
  157. dataSources.value = data.data.records
  158. pagination.value.current = data.data.current
  159. pagination.value.size = data.data.size
  160. total.value = data.data.total
  161. })
  162. }
  163. const setList = (search) => {
  164. console.log('获取列表 setList',search)
  165. // courseName: '',
  166. // collegeId: '',
  167. // majorId: '',
  168. // courseType: '',
  169. // loacl: []
  170. formState.value = search
  171. pagination.value.current = 1
  172. list({...pagination.value, ...formState.value}).then((data) => {
  173. if (data.code == 200) {
  174. dataSources.value = data.data.records
  175. pagination.value.current = data.data.current
  176. pagination.value.size = data.data.size
  177. total.value = data.data.total
  178. }
  179. // data.records
  180. })
  181. }
  182. // 重置按钮点击事件
  183. onMounted(() => {
  184. // getListData()
  185. // getList()
  186. pagination.value.size = 10
  187. pagination.value.current = 1
  188. getList()
  189. })
  190. // watch(
  191. // () => dataSources.value,
  192. // (newVal, oldVal) => {
  193. // console.log('数据源变化了 ', ' 新的 ',newVal, ' 旧的 ',oldVal)
  194. // },
  195. // { deep: true, immediate: true }
  196. // )
  197. defineExpose({
  198. open,close
  199. })
  200. </script>
  201. <style scoped>
  202. .desc p {
  203. margin-bottom: 1em;
  204. }
  205. </style>