ListView.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <a-table
  3. ref="table"
  4. :columns="columns"
  5. :data-source="dataSource"
  6. :row-key="(record) => record.collegeId"
  7. bordered
  8. :expand-row-by-click="true"
  9. :pagination="false"
  10. size="small"
  11. >
  12. <template #bodyCell="{ column, text, record }">
  13. <template v-if="column.dataIndex === 'publishTime'">{{ formatTimestamp(text) }}</template>
  14. <template v-if="column.dataIndex === 'action'">
  15. <a-popover v-model:visible="popoverVisible[record.iiiiiindex]" title="提示" trigger="click">
  16. <template #content>
  17. <a-button style="margin-right: 10px" type="primary" @click="handleOk(record)">选择
  18. </a-button>
  19. <a-button @click="()=>{ popoverVisible[record.iiiiiindex] = false}">取消</a-button>
  20. </template>
  21. <a-button size="small" style="margin-right: 5px">选择</a-button>
  22. </a-popover>
  23. </template>
  24. </template>
  25. </a-table>
  26. <div style="display: flex; width: 100%; justify-content: flex-end; margin-top: 10px">
  27. <a-pagination
  28. v-model:current="pagination.current"
  29. v-model:pageSize="pagination.size"
  30. :total="pagination.total"
  31. show-less-items
  32. @change="handlerChange"
  33. />
  34. </div>
  35. </template>
  36. <script setup>
  37. import tool from '@/utils/tool'
  38. import {ref, onMounted} from 'vue'
  39. import {EyeOutlined, EditOutlined, SnippetsOutlined, DeleteOutlined} from '@ant-design/icons-vue'
  40. import {courceDownList} from '@/api/courseinfo'
  41. import {useRouter} from 'vue-router'
  42. import collegeApi from '@/api/college'
  43. const router = useRouter()
  44. const popoverVisible = ref({})
  45. const emit = defineEmits(['handleSelectFile'])
  46. //发布按钮状态
  47. const releaseVisible = ref(false)
  48. const loading = ref(false) // 列表loading
  49. const dataSource = ref([])
  50. const formState = ref({
  51. name: '',
  52. loacl: ''
  53. }) // 列表loading
  54. const columns = [
  55. {
  56. title: '资源名称',
  57. dataIndex: 'fileName',
  58. sorter: true,
  59. width: '20%'
  60. },
  61. {
  62. title: '状态',
  63. dataIndex: 'verifyStatusName',
  64. sorter: true,
  65. width: '10%'
  66. },
  67. {
  68. title: '更新时间',
  69. dataIndex: 'uploadTime',
  70. sorter: true,
  71. width: '20%'
  72. },
  73. {
  74. title: '操作',
  75. dataIndex: 'action',
  76. width: '5%'
  77. }
  78. ]
  79. // tool.formatTimestamp()
  80. const formatTimestamp = (time) => {
  81. return tool.formatTimestamp(time)
  82. }
  83. const pagination = reactive({
  84. size: 10,
  85. current: 1,
  86. total: 0
  87. })
  88. const onChangeCurrent = (current) => {
  89. router.push({
  90. path: '/' + current
  91. })
  92. }
  93. const handleOk = (item) => {
  94. popoverVisible.value[item.iiiiiindex] = false
  95. console.log('选择了什么', item)
  96. emit('handleSelectFile', item)
  97. }
  98. const handlerChange = (page, pageSize) => {
  99. pagination.size = pageSize
  100. pagination.current = page
  101. getList()
  102. }
  103. const publishedData = ref()
  104. //发布确定
  105. // 上传资源模态框
  106. const uploadModalVisible = ref(false)
  107. // 详情按钮点击事件
  108. const handleDetail = (record) => {
  109. console.log('查看详情', record)
  110. // 在这里添加查看详情的逻辑
  111. }
  112. // 编辑按钮点击事件
  113. const handleEdit = (record) => {
  114. console.log('编辑记录', record)
  115. // 在这里添加编辑记录的逻辑
  116. emit('handleEdit', record)
  117. }
  118. // 上架按钮点击事件
  119. const handleShelf = (record) => {
  120. console.log('上架记录', record)
  121. // 在这里添加上架记录的逻辑
  122. }
  123. // 删除按钮点击事件
  124. const handleDelete = (record) => {
  125. console.log('删除记录', record)
  126. // 在这里添加删除记录的逻辑
  127. }
  128. const getList = () => {
  129. courceDownList({...pagination}).then((data) => {
  130. if (data.code == 200) {
  131. let list = []
  132. for (let i = 0; i < data.data.records.length; i++) {
  133. let item = data.data.records[i]
  134. item.iiiiiindex = i
  135. list.push(item)
  136. }
  137. dataSource.value = list
  138. pagination.current = data.data.current
  139. pagination.size = data.data.size
  140. pagination.total = data.data.total
  141. }
  142. // data.records
  143. })
  144. }
  145. const setList = (search) => {
  146. formState.value = search
  147. pagination.current = 1
  148. courceDownList({...pagination, ...search}).then((data) => {
  149. if (data.code == 200) {
  150. dataSource.value = data.data.records
  151. pagination.current = data.data.current
  152. pagination.size = data.data.size
  153. pagination.total = data.data.total
  154. }
  155. // data.records
  156. })
  157. }
  158. // 重置按钮点击事件
  159. onMounted(() => {
  160. // getListData()
  161. getList()
  162. })
  163. defineExpose({
  164. setList
  165. })
  166. </script>
  167. <style scoped>
  168. .desc p {
  169. margin-bottom: 1em;
  170. }
  171. </style>