index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <a-card>
  3. <!-- 标签页 -->
  4. <a-tabs v-model:activeKey="formState.verifyStatus" @change="tabChange">
  5. <a-tab-pane key="0" tab="未发布"></a-tab-pane>
  6. <a-tab-pane key="1" tab="待审核"></a-tab-pane>
  7. <a-tab-pane key="2" tab="已发布"></a-tab-pane>
  8. <a-tab-pane key="4" tab="回收站"></a-tab-pane>
  9. </a-tabs>
  10. <!-- 搜索和操作区域 -->
  11. <a-row :gutter="16" style="margin-bottom: 16px">
  12. <a-col :span="8">
  13. <a-input v-model:value="searchValue" placeholder="请输入资源名称" style="width: 200px" />
  14. <a-button type="primary" style="margin-left: 8px" @click="handleSearch">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="handleReset">重置</a-button>
  16. </a-col>
  17. <a-col :span="16" style="text-align: right">
  18. <a-button type="primary" @click="showUploadModal">+ 上传资源</a-button>
  19. </a-col>
  20. </a-row>
  21. <!-- 表格 -->
  22. <a-table
  23. :columns="currentColumns"
  24. :data-source="dataSource"
  25. :pagination="false"
  26. :loading="loading"
  27. bordered
  28. :row-key="(record) => record.id"
  29. >
  30. <template #bodyCell="{ column, text, record }">
  31. <template
  32. v-if="
  33. ['fileName', 'collegeIdName', 'majorIdName', 'courseTypeName', 'suffix', 'uploadTime'].includes(
  34. column.dataIndex
  35. )
  36. "
  37. >
  38. <div class="multiLine-ellipsis" :title="text">{{ text || '-' }}</div>
  39. </template>
  40. <!-- 状态列 -->
  41. <template v-if="column.key === 'verifyStatus'">
  42. <span v-if="record.verifyStatus === '0'">
  43. <a-badge status="processing" text="处理中" />
  44. </span>
  45. <span v-else-if="record.verifyStatus === 'uploaded'">
  46. <a-badge status="success" text="已上传" />
  47. </span>
  48. <span v-else-if="record.verifyStatus === '1'">
  49. <a-badge status="default" text="待审核" />
  50. </span>
  51. <span v-else-if="record.verifyStatus === '2'">
  52. <a-badge status="success" text="已发布" />
  53. </span>
  54. <span v-else-if="record.verifyStatus === '4'">
  55. <a-badge status="error" text="已删除" />
  56. </span>
  57. </template>
  58. <!-- 操作列 -->
  59. <template v-else-if="column.key === 'action'">
  60. <div class="editable-cell">
  61. <template v-if="formState.verifyStatus === '0'">
  62. <a @click="handlePublish(record)">发布</a>
  63. <a-divider type="vertical" />
  64. <a-dropdown>
  65. <a class="ant-dropdown-link">
  66. 更多
  67. <DownOutlined />
  68. </a>
  69. <template #overlay>
  70. <a-menu>
  71. <a-menu-item>
  72. <a href="javascript:;">播放</a>
  73. </a-menu-item>
  74. <a-menu-item>
  75. <a href="javascript:;">下载</a>
  76. </a-menu-item>
  77. <a-menu-item>
  78. <a href="javascript:;">删除</a>
  79. </a-menu-item>
  80. </a-menu>
  81. </template>
  82. </a-dropdown>
  83. </template>
  84. <template v-else-if="formState.verifyStatus === '1'">
  85. <a @click="handleAudit(record)">审核</a>
  86. <a-divider type="vertical" />
  87. <a-dropdown>
  88. <a class="ant-dropdown-link">
  89. 更多
  90. <DownOutlined />
  91. </a>
  92. <template #overlay>
  93. <a-menu>
  94. <a-menu-item>
  95. <a href="javascript:;">播放</a>
  96. </a-menu-item>
  97. <a-menu-item>
  98. <a href="javascript:;">下载</a>
  99. </a-menu-item>
  100. <a-menu-item>
  101. <a href="javascript:;">删除</a>
  102. </a-menu-item>
  103. </a-menu>
  104. </template>
  105. </a-dropdown>
  106. </template>
  107. <template v-else-if="formState.verifyStatus === '2'">
  108. <a @click="handlePermission(record)">权限</a>
  109. <a-divider type="vertical" />
  110. <a-dropdown>
  111. <a class="ant-dropdown-link">
  112. 更多
  113. <DownOutlined />
  114. </a>
  115. <template #overlay>
  116. <a-menu>
  117. <a-menu-item>
  118. <a href="javascript:;">播放</a>
  119. </a-menu-item>
  120. <a-menu-item>
  121. <a href="javascript:;">下载</a>
  122. </a-menu-item>
  123. <a-menu-item>
  124. <a href="javascript:;" @click="edit(record)">编辑</a>
  125. </a-menu-item>
  126. <a-menu-item>
  127. <a href="javascript:;">删除</a>
  128. </a-menu-item>
  129. </a-menu>
  130. </template>
  131. </a-dropdown>
  132. </template>
  133. <template v-else-if="formState.verifyStatus === '4'">
  134. <a @click="handleRestore(record)">恢复</a>
  135. <a-divider type="vertical" />
  136. <a-dropdown>
  137. <a class="ant-dropdown-link">
  138. 更多
  139. <DownOutlined />
  140. </a>
  141. <template #overlay>
  142. <a-menu>
  143. <a-menu-item>
  144. <a href="javascript:;">播放</a>
  145. </a-menu-item>
  146. <a-menu-item>
  147. <a href="javascript:;">下载</a>
  148. </a-menu-item>
  149. <a-menu-item>
  150. <a href="javascript:;">删除</a>
  151. </a-menu-item>
  152. </a-menu>
  153. </template>
  154. </a-dropdown>
  155. </template>
  156. </div>
  157. </template>
  158. </template>
  159. </a-table>
  160. <div class="dis-flex-end margin-top">
  161. <CustomPagination
  162. :total="pagination.total"
  163. :current="pagination.pageNum"
  164. :pageSize="pagination.pageSize"
  165. :showQuickJumper="true"
  166. :showSizeChanger="true"
  167. :showTotal="(total) => `共 ${total} 条数据`"
  168. @change="handlePageChange"
  169. @showSizeChange="handlePageSizeChange"
  170. />
  171. </div>
  172. <!-- 资源上传模态框 -->
  173. <resourceUpload
  174. :visible="uploadModalVisible"
  175. @close="uploadModalVisible = false"
  176. @getList="getList"
  177. ></resourceUpload>
  178. <!-- 发布模态框 -->
  179. <releaseModal
  180. :isState="isState"
  181. v-if="releaseVisible"
  182. @close="releaseVisible = false"
  183. @confirm="confirm"
  184. ></releaseModal>
  185. </a-card>
  186. </template>
  187. <script setup>
  188. import { ref, onMounted } from 'vue'
  189. import { DownOutlined } from '@ant-design/icons-vue'
  190. import releaseModal from './releaseModal.vue'
  191. import resourceUpload from './resourceUpload.vue'
  192. import resourceAuditApi from '@/api/resourceAudit.js'
  193. import CustomPagination from '@/components/customPagination.vue'
  194. import tool from '@/utils/tool'
  195. const headers = ref({
  196. token: tool.data.get('TOKEN')
  197. })
  198. const action = ref('http://192.168.31.80:9003/api/webapp/dev/file/uploadMinioReturnId')
  199. // 数据源
  200. const dataSource = ref([])
  201. // const activeKey = ref('0')
  202. //发布按钮状态
  203. const releaseVisible = ref(false)
  204. const loading = ref(false) // 列表loading
  205. const isState = ref(0) // 列表loading
  206. // 搜索值
  207. const searchValue = ref('')
  208. const pagination = reactive({
  209. pageSize: 10,
  210. pageNum: 1,
  211. total: 0
  212. })
  213. const formState = reactive({
  214. fileName: null,
  215. verifyStatus: '0',
  216. resourcesId: null
  217. })
  218. // 列定义
  219. const columnsUnpublished = [
  220. {
  221. title: '编号',
  222. align: 'center',
  223. dataIndex: 'fileId',
  224. key: 'fileId'
  225. },
  226. {
  227. title: '资源名称',
  228. align: 'center',
  229. dataIndex: 'fileName',
  230. key: 'fileName'
  231. },
  232. {
  233. title: '课件格式',
  234. align: 'center',
  235. dataIndex: 'suffix',
  236. key: 'suffix'
  237. },
  238. {
  239. title: '上传时间',
  240. dataIndex: 'uploadTime',
  241. align: 'center',
  242. key: 'uploadTime'
  243. },
  244. {
  245. title: '状态',
  246. align: 'center',
  247. key: 'verifyStatus'
  248. },
  249. {
  250. title: '操作',
  251. align: 'center',
  252. key: 'action'
  253. }
  254. ]
  255. const columnsPending = [
  256. {
  257. title: '编号',
  258. dataIndex: 'id',
  259. align: 'center',
  260. key: 'id'
  261. },
  262. {
  263. title: '资源名称',
  264. align: 'center',
  265. dataIndex: 'fileName',
  266. key: 'fileName'
  267. },
  268. {
  269. title: '所属院系',
  270. align: 'center',
  271. dataIndex: 'collegeIdName',
  272. key: 'collegeIdName'
  273. },
  274. {
  275. title: '所属专业',
  276. align: 'center',
  277. dataIndex: 'majorIdName',
  278. key: 'majorIdName'
  279. },
  280. {
  281. title: '课程类型',
  282. align: 'center',
  283. dataIndex: 'courseTypeName',
  284. key: 'courseTypeName'
  285. },
  286. {
  287. title: '课件格式',
  288. align: 'center',
  289. dataIndex: 'suffix',
  290. key: 'suffix'
  291. },
  292. {
  293. title: '上传时间',
  294. align: 'center',
  295. dataIndex: 'uploadTime',
  296. key: 'uploadTime'
  297. },
  298. {
  299. title: '状态',
  300. align: 'center',
  301. key: 'verifyStatus'
  302. },
  303. {
  304. title: '操作',
  305. align: 'center',
  306. key: 'action'
  307. }
  308. ]
  309. const columnsPublished = [...columnsPending]
  310. const columnsRecycle = [...columnsPending]
  311. const currentColumns = computed(() => {
  312. switch (formState.verifyStatus) {
  313. case '0':
  314. return columnsUnpublished
  315. case '1':
  316. return columnsPending
  317. case '2':
  318. return columnsPublished
  319. case '4':
  320. return columnsRecycle
  321. default:
  322. return []
  323. }
  324. })
  325. const getListData = () => {
  326. loading.value = true
  327. let params = {
  328. current: pagination.pageNum,
  329. size: pagination.pageSize,
  330. verifyStatus: formState.verifyStatus,
  331. fileName: formState.fileName
  332. }
  333. resourceAuditApi
  334. .page(params)
  335. .then((res) => {
  336. console.log(res, '资源审核列表')
  337. dataSource.value = res.data.records
  338. pagination.total = res.data.total
  339. loading.value = false
  340. })
  341. .catch((err) => {
  342. console.log(err)
  343. dataSource.value = []
  344. pagination.total = 0
  345. loading.value = false
  346. })
  347. }
  348. const getList = () => {
  349. getListData()
  350. }
  351. // 方法
  352. const handleSearch = () => {
  353. console.log('Search:', searchValue.value)
  354. }
  355. const handleReset = () => {
  356. searchValue.value = ''
  357. }
  358. const tabChange = () => {
  359. dataSource.value = []
  360. getListData()
  361. }
  362. const publishedData = ref()
  363. //发布
  364. const handlePublish = (record) => {
  365. publishedData.value = record
  366. isState.value = 0
  367. releaseVisible.value = true
  368. }
  369. //发布确定
  370. const confirm = (obj) => {
  371. console.log(obj, '传回来的数据')
  372. let params = {
  373. courseAuditId: publishedData.value.courseAuditId,
  374. fileId: publishedData.value.fileId,
  375. collegeId: publishedData.value.collegeId,
  376. majorId: publishedData.value.majorId,
  377. courseType: obj.courseType,
  378. courseName: obj.courseName,
  379. courseDesc: obj.courseDesc,
  380. coverImageId: obj.coverImageId
  381. }
  382. resourceAuditApi
  383. .release(params)
  384. .then((res) => {
  385. console.log(res, '资源审核列表')
  386. })
  387. .catch((err) => {
  388. console.log(err)
  389. dataSource.value = []
  390. pagination.total = 0
  391. loading.value = false
  392. })
  393. }
  394. const handleAudit = (record) => {
  395. console.log('Audit:', record)
  396. }
  397. const handlePermission = (record) => {
  398. console.log('Permission:', record)
  399. }
  400. const handleRestore = (record) => {
  401. console.log('Restore:', record)
  402. }
  403. //课程编辑
  404. const edit = (record) => {
  405. console.log('Restore:', record)
  406. releaseVisible.value = true
  407. isState.value = 1
  408. }
  409. // 上传资源模态框
  410. const uploadModalVisible = ref(false)
  411. // 显示上传模态框
  412. const showUploadModal = () => {
  413. uploadModalVisible.value = true
  414. }
  415. // 翻页
  416. const handlePageChange = (page) => {
  417. pagination.pageNum = page
  418. getListData()
  419. }
  420. // 每页条数
  421. const handlePageSizeChange = (pageNum, size) => {
  422. pagination.pageNum = 1
  423. pagination.pageSize = size
  424. getListData()
  425. }
  426. onMounted(() => {
  427. getListData()
  428. })
  429. </script>
  430. <style scoped>
  431. .editable-cell {
  432. position: relative;
  433. }
  434. .ant-dropdown-link {
  435. margin-left: 8px;
  436. }
  437. .upload-area {
  438. border: 2px dashed #3ca9f5;
  439. padding: 40px;
  440. text-align: center;
  441. }
  442. .upload-area p {
  443. margin: 10px 0;
  444. }
  445. .file-item {
  446. display: flex;
  447. align-items: center;
  448. margin: 10px 0;
  449. }
  450. .file-item .ant-progress {
  451. flex: 1;
  452. margin: 0 10px;
  453. }
  454. </style>