myResources.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. <template>
  2. <a-card v-if="visible">
  3. <a-button type="primary" style="margin-left: 0px" @click="handleBack">返回</a-button>
  4. <!-- 标签页 -->
  5. <a-tabs v-model:activeKey="formState.verifyStatus" @change="tabChange">
  6. <a-tab-pane key="0,3" tab="未发布" v-if="!pageType"></a-tab-pane>
  7. <a-tab-pane key="1" tab="待审核"></a-tab-pane>
  8. <a-tab-pane key="2" tab="已发布"></a-tab-pane>
  9. <!-- <a-tab-pane key="3" tab="已审核" v-if="pageType == 'economize'"></a-tab-pane> -->
  10. <a-tab-pane key="4" tab="回收站"></a-tab-pane>
  11. </a-tabs>
  12. <!-- 搜索和操作区域 -->
  13. <a-row :gutter="16" style="margin-bottom: 16px">
  14. <a-col :span="18">
  15. <a-input v-model:value="formState.fileName" placeholder="请输入资源名称" style="width: 150px" />
  16. <a-cascader
  17. style="width: 200px; margin-left: 8px"
  18. v-model:value="majorIdName"
  19. :options="collegeMajorOptions"
  20. :fieldNames="{ label: 'name', value: 'id', children: 'children' }"
  21. placeholder="请选择院系"
  22. changeOnSelect
  23. @change="changeCollegeMajor"
  24. />
  25. <!-- <a-select
  26. v-model:value="formState.majorId"
  27. style="width: 150px; margin-left: 8px"
  28. :fieldNames="{ label: 'majorName', value: 'majorCode' }"
  29. :options="majorOptions"
  30. placeholder="请选择专业"
  31. /> -->
  32. <a-cascader
  33. style="width: 200px; margin-left: 8px"
  34. v-model:value="resourceName"
  35. :options="resourceTypeOptions"
  36. :fieldNames="{ label: 'name', value: 'id', children: 'children' }"
  37. placeholder="请选择资源类型"
  38. changeOnSelect
  39. @change="changeCollegeResource"
  40. />
  41. <!-- <a-select
  42. v-model:value="formState.resourceType"
  43. style="width: 150px; margin-left: 8px"
  44. :options="resourceTypeOptions"
  45. :fieldNames="{ label: 'name', value: 'id', children: 'children' }"
  46. placeholder="请选择资源类型"
  47. /> -->
  48. <a-select
  49. v-model:value="formState.suffix"
  50. style="width: 150px; margin-left: 8px"
  51. :options="fileformatOptions"
  52. :fieldNames="{ label: 'fileExtendName', value: 'fileExtendName', children: 'children' }"
  53. placeholder="请选择资源格式"
  54. />
  55. <a-select
  56. v-if="['0,3', '0', '3'].includes(formState.verifyStatus)"
  57. v-model:value="isVerifyStatus"
  58. placeholder="请选择资源状态"
  59. style="width: 150px; margin-left: 8px"
  60. >
  61. <a-select-option value="0">未发布</a-select-option>
  62. <a-select-option value="3">未通过</a-select-option>
  63. </a-select>
  64. <!-- <a-select
  65. v-model:value="formState.suffix"
  66. style="width: 200px; margin-left: 8px"
  67. :options="suffixTypeOptions"
  68. placeholder="请选择课件格式"
  69. /> -->
  70. <a-button type="primary" style="margin-left: 8px" @click="handleSearch">查询</a-button>
  71. <a-button style="margin-left: 8px" @click="handleReset">重置</a-button>
  72. </a-col>
  73. <a-col :span="6" style="text-align: right">
  74. <a-button
  75. type="primary"
  76. style="margin-right: 8px"
  77. v-if="formState.verifyStatus === '0,3' && !pageType"
  78. @click="batchPublish"
  79. :disabled="selectedRowKeys.length === 0"
  80. >
  81. + 批量发布
  82. </a-button>
  83. <a-button type="primary" v-if="!pageType" @click="showUploadModal">+ 上传资源</a-button>
  84. </a-col>
  85. </a-row>
  86. <!-- 表格 -->
  87. <a-table
  88. :columns="columnsPending"
  89. :data-source="dataSource"
  90. :pagination="false"
  91. :loading="loading"
  92. bordered
  93. :row-key="(record) => record.id"
  94. :row-selection="rowSelection"
  95. :scroll="{ x: 1500, y: 600 }"
  96. >
  97. <template #bodyCell="{ column, text, record }">
  98. <template
  99. v-if="
  100. ['fileName', 'collegeAllIdName', 'majorIdName', 'resourceALLTypeName', 'suffix', 'uploadTime'].includes(
  101. column.dataIndex
  102. )
  103. "
  104. >
  105. <div class="multiLine-ellipsis" :title="text">{{ text || '-' }}</div>
  106. </template>
  107. <!-- 状态列 -->
  108. <template v-if="column.key === 'verifyStatus'">
  109. <span v-if="record.verifyStatus === '0'">
  110. <a-badge status="processing" text="未发布" />
  111. </span>
  112. <span v-else-if="record.verifyStatus === 'uploaded'">
  113. <a-badge status="success" text="已上传" />
  114. </span>
  115. <span v-else-if="record.verifyStatus === '1'">
  116. <a-badge status="default" text="待审核" />
  117. </span>
  118. <span v-else-if="record.verifyStatus === '2'">
  119. <a-badge status="success" text="已发布" />
  120. </span>
  121. <span v-if="record.verifyStatus === '3'">
  122. <a-badge status="error" text="未通过" />
  123. </span>
  124. <span v-else-if="record.verifyStatus === '4'">
  125. <a-badge status="error" text="已删除" />
  126. </span>
  127. </template>
  128. <template v-if="column.dataIndex === 'fileUrl'">
  129. <!-- 动态图标 + 格式提示 -->
  130. <a-tooltip :title="`${record.suffix || '未知'}`">
  131. <component
  132. :is="fileTypeIcons[record.suffix?.toLowerCase()] || fileTypeIcons['*']"
  133. :style="{ fontSize: '24px', color: getIconColor(record.suffix) }"
  134. />
  135. </a-tooltip>
  136. </template>
  137. <!-- 个人资源操作列 -->
  138. <template v-if="column.key === 'action' && !pageType">
  139. <div class="editable-cell">
  140. <a v-if="formState.verifyStatus === '0,3'" @click="handlePublish(record)">发布</a>
  141. <a v-if="formState.verifyStatus === '4'" @click="handleRestore(record)">恢复</a>
  142. <a-divider type="vertical" />
  143. <a-dropdown>
  144. <a class="ant-dropdown-link">
  145. 更多
  146. <DownOutlined />
  147. </a>
  148. <template #overlay>
  149. <a-menu>
  150. <a-menu-item>
  151. <a href="javascript:;" @click="handleView(record)">预览</a>
  152. </a-menu-item>
  153. <a-menu-item>
  154. <a
  155. target="_blank"
  156. style="display: block; color: inherit"
  157. :href="$file.getDownloadFilePath3(record)"
  158. :download="record.fileName"
  159. >
  160. 下载
  161. </a>
  162. </a-menu-item>
  163. <a-menu-item v-if="formState.verifyStatus !== '2'">
  164. <a href="javascript:;" @click="edit(record)">编辑</a>
  165. </a-menu-item>
  166. <a-menu-item v-if="formState.verifyStatus !== '2'">
  167. <a-popconfirm title="确认删除吗?" @confirm="resourcesDelete(record)">
  168. <a href="javascript:;">删除</a>
  169. </a-popconfirm>
  170. </a-menu-item>
  171. </a-menu>
  172. </template>
  173. </a-dropdown>
  174. </div>
  175. </template>
  176. <!-- 资源管理操作列 -->
  177. <template v-if="column.key === 'action' && pageType == 'economize'">
  178. <div class="editable-cell">
  179. <a v-if="formState.verifyStatus === '1'" @click="handleAudit(record)">审核</a>
  180. <a v-if="formState.verifyStatus === '2'" @click="handlePermission(record)">权限</a>
  181. <a v-if="formState.verifyStatus === '4'" @click="handleRestore(record)">恢复</a>
  182. <a-divider type="vertical" />
  183. <a-dropdown>
  184. <a class="ant-dropdown-link">
  185. 更多
  186. <DownOutlined />
  187. </a>
  188. <template #overlay>
  189. <a-menu>
  190. <a-menu-item>
  191. <a href="javascript:;" @click="handleView(record)">预览</a>
  192. </a-menu-item>
  193. <a-menu-item>
  194. <a
  195. target="_blank"
  196. style="display: block; color: inherit"
  197. :href="$file.getDownloadFilePath3(record)"
  198. :download="record.fileName"
  199. >
  200. 下载
  201. </a>
  202. </a-menu-item>
  203. <a-menu-item v-if="formState.verifyStatus !== '1'">
  204. <a-popconfirm title="确认删除吗?" @confirm="resourcesDelete(record)">
  205. <a href="javascript:;">删除</a>
  206. </a-popconfirm>
  207. </a-menu-item>
  208. </a-menu>
  209. </template>
  210. </a-dropdown>
  211. </div>
  212. </template>
  213. </template>
  214. </a-table>
  215. <div class="dis-flex-sb margin-top">
  216. <div>
  217. <a-button @click="selectAll">选择全部</a-button>
  218. <a-button @click="invertSelection" style="margin-left: 8px">反选选择</a-button>
  219. </div>
  220. <div>
  221. <CustomPagination
  222. :total="pagination.total"
  223. :current="pagination.pageNum"
  224. :pageSize="pagination.pageSize"
  225. :showQuickJumper="true"
  226. :showSizeChanger="true"
  227. :showTotal="(total) => `共 ${total} 条数据`"
  228. @change="handlePageChange"
  229. @showSizeChange="handlePageSizeChange"
  230. />
  231. </div>
  232. </div>
  233. <!-- 权限树模态框 -->
  234. <permissionTree v-if="permissionTreeVisible" @close="permissionTreeVisible = false"></permissionTree>
  235. <!-- 审核播放模态框 -->
  236. <auditModal
  237. v-if="auditModalVisible"
  238. :recordData="publishedData"
  239. :isAudit="auditState"
  240. @confirm="auditConfirm"
  241. @close="auditModalVisible = false"
  242. ></auditModal>
  243. <!-- 资源上传模态框 -->
  244. <resourceUpload
  245. v-if="uploadModalVisible"
  246. :isState="isState"
  247. :isVerifyStatus="formState.verifyStatus"
  248. :resourcesId="editResourcesId"
  249. @close="uploadModalVisible = false"
  250. @getList="getList"
  251. ></resourceUpload>
  252. <!-- 发布模态框 -->
  253. <releaseModal v-if="releaseVisible" @close="releaseVisible = false" @confirm="releaseConfirm"></releaseModal>
  254. </a-card>
  255. </template>
  256. <script setup>
  257. import { ref, onMounted } from 'vue'
  258. import { DownOutlined } from '@ant-design/icons-vue'
  259. import releaseModal from './releaseModal.vue'
  260. import resourceUpload from './resourceUpload.vue'
  261. import resourceAuditApi from '@/api/resourceAudit.js'
  262. import permissionTree from './permissionTree.vue'
  263. import auditModal from './auditModal.vue'
  264. import CustomPagination from '@/components/customPagination.vue'
  265. import tool from '@/utils/tool'
  266. import { useRoute, useRouter } from 'vue-router'
  267. const router = useRouter()
  268. import {
  269. FileOutlined,
  270. FileImageOutlined,
  271. FilePdfOutlined,
  272. FileWordOutlined,
  273. FileExcelOutlined,
  274. FilePptOutlined,
  275. FileTextOutlined,
  276. FileZipOutlined,
  277. PlaySquareOutlined
  278. } from '@ant-design/icons-vue'
  279. const emit = defineEmits(['handleBack'])
  280. const visible = ref(false)
  281. // eslint-disable-next-line vue/no-setup-props-destructure
  282. const { pageType } = defineProps({
  283. pageType: {
  284. type: String,
  285. default: () => {}
  286. }
  287. })
  288. const fileTypeIcons = {
  289. // 图片类
  290. jpg: 'FileImageOutlined',
  291. jpeg: 'FileImageOutlined',
  292. png: 'FileImageOutlined',
  293. gif: 'FileImageOutlined',
  294. // 文档类
  295. pdf: 'FilePdfOutlined',
  296. ppt: 'FilePptOutlined',
  297. pptx: 'FilePptOutlined',
  298. doc: 'FileWordOutlined',
  299. docx: 'FileWordOutlined',
  300. xls: 'FileExcelOutlined',
  301. xlsx: 'FileExcelOutlined',
  302. txt: 'FileTextOutlined',
  303. // 视频类
  304. mp4: 'PlaySquareOutlined',
  305. mov: 'PlaySquareOutlined',
  306. // 压缩包
  307. zip: 'FileZipOutlined',
  308. rar: 'FileZipOutlined',
  309. // 默认图标
  310. '*': 'FileOutlined'
  311. }
  312. // 数据源
  313. const dataSource = ref([])
  314. //发布按钮状态
  315. const releaseVisible = ref(false)
  316. const permissionTreeVisible = ref(false) //权限树
  317. const auditModalVisible = ref(false) //播放审核
  318. const isPublishBulk = ref(false) //是否批量发布
  319. const loading = ref(false) // 列表loading
  320. const isState = ref(0) //是否是编辑 0:新增 1:编辑
  321. const isVerifyStatus = ref(null) //未发布状态 0未发布 3已驳回
  322. const editResourcesId = ref(null) //资源id
  323. // 搜索值
  324. const searchValue = ref('')
  325. //课程类型
  326. const courseTypeOptions = tool.dictList('COURSE_TYPE')
  327. const suffixTypeOptions = ref([])
  328. const pagination = reactive({
  329. pageSize: 10,
  330. pageNum: 1,
  331. total: 0
  332. })
  333. const formState = reactive({
  334. fileName: null,
  335. verifyStatus: '0,3',
  336. resourcesId: null,
  337. // majorId: null, //专业
  338. collegeId: null, //院校一级id
  339. collegeTwoId: null, //院校二级id
  340. collegeThreeId: null, //院校三级id
  341. resourceType: null, //资源类型一级
  342. resourceTwoType: null, //资源类型二级
  343. suffix: null
  344. })
  345. // 添加选择状态
  346. const majorIdName = ref([])
  347. const resourceName = ref([])
  348. const majorOptions = ref([]) //专业
  349. const selectedRowKeys = ref([])
  350. const selectedRows = ref([])
  351. const publishedData = ref([]) //当前点击数据
  352. // 行选择配置
  353. const rowSelection = computed(() => {
  354. return {
  355. selectedRowKeys: selectedRowKeys.value,
  356. onChange: (keys, rows) => {
  357. selectedRowKeys.value = keys
  358. selectedRows.value = rows
  359. },
  360. onSelectAll: (selected, selectedRows, changeRows) => {
  361. if (selected) {
  362. // 全选当前页
  363. selectedRowKeys.value = dataSource.value.map((item) => item.id)
  364. selectedRows.value = dataSource.value
  365. } else {
  366. // 取消全选
  367. selectedRowKeys.value = []
  368. selectedRows.value = []
  369. }
  370. },
  371. onSelectInvert: () => {
  372. // 反选当前页
  373. const allKeys = dataSource.value.map((item) => item.id)
  374. const newSelectedKeys = allKeys.filter((key) => !selectedRowKeys.value.includes(key))
  375. selectedRowKeys.value = newSelectedKeys
  376. selectedRows.value = dataSource.value.filter((item) => newSelectedKeys.includes(item.id))
  377. }
  378. }
  379. })
  380. // 列定义
  381. const columnsUnpublished = [
  382. {
  383. title: '编号',
  384. align: 'center',
  385. dataIndex: 'fileId',
  386. key: 'fileId'
  387. },
  388. {
  389. title: '资源名称',
  390. align: 'center',
  391. dataIndex: 'fileName',
  392. key: 'fileName'
  393. },
  394. {
  395. title: '课件格式',
  396. align: 'center',
  397. dataIndex: 'suffix',
  398. key: 'suffix'
  399. },
  400. {
  401. title: '上传时间',
  402. dataIndex: 'uploadTime',
  403. align: 'center',
  404. key: 'uploadTime'
  405. },
  406. {
  407. title: '状态',
  408. align: 'center',
  409. key: 'verifyStatus'
  410. },
  411. {
  412. title: '资源缩略图',
  413. align: 'center',
  414. dataIndex: 'fileUrl',
  415. key: 'fileUrl'
  416. },
  417. {
  418. title: '操作',
  419. align: 'center',
  420. width: 150,
  421. key: 'action'
  422. }
  423. ]
  424. const columnsPending = [
  425. {
  426. title: '编号',
  427. dataIndex: 'id',
  428. align: 'center',
  429. key: 'id'
  430. },
  431. {
  432. title: '资源名称',
  433. align: 'center',
  434. dataIndex: 'fileName',
  435. key: 'fileName'
  436. },
  437. {
  438. title: '所属院系',
  439. align: 'center',
  440. dataIndex: 'collegeAllIdName',
  441. key: 'collegeAllIdName'
  442. },
  443. // {
  444. // title: '所属课程',
  445. // align: 'center',
  446. // dataIndex: 'collegeIdName',
  447. // key: 'collegeIdName'
  448. // },
  449. // {
  450. // title: '所属专业',
  451. // align: 'center',
  452. // dataIndex: 'majorIdName',
  453. // key: 'majorIdName'
  454. // },
  455. {
  456. title: '资源类型',
  457. align: 'center',
  458. dataIndex: 'resourceALLTypeName',
  459. key: 'resourceALLTypeName'
  460. },
  461. {
  462. title: '资源格式',
  463. align: 'center',
  464. dataIndex: 'suffix',
  465. key: 'suffix'
  466. },
  467. {
  468. title: '上传时间',
  469. align: 'center',
  470. dataIndex: 'uploadTime',
  471. key: 'uploadTime'
  472. },
  473. {
  474. title: '状态',
  475. align: 'center',
  476. key: 'verifyStatus'
  477. },
  478. {
  479. title: '资源缩略图',
  480. align: 'center',
  481. dataIndex: 'fileUrl',
  482. key: 'fileUrl'
  483. },
  484. {
  485. title: '操作',
  486. align: 'center',
  487. width: 150,
  488. fixed: 'right',
  489. key: 'action'
  490. }
  491. ]
  492. const columnsPublished = [...columnsPending]
  493. const columnsRecycle = [...columnsPending]
  494. const collegeMajorOptions = ref([]) //院校下拉数据
  495. const resourceTypeOptions = ref([]) //资源类型下拉数据
  496. const fileformatOptions = ref([]) //资源格式下拉数据
  497. const currentColumns = computed(() => {
  498. switch (formState.verifyStatus) {
  499. case '0':
  500. return columnsUnpublished
  501. case '1':
  502. return columnsPending
  503. case '2':
  504. return columnsPublished
  505. case '3':
  506. return columnsPublished
  507. case '4':
  508. return columnsRecycle
  509. default:
  510. return []
  511. }
  512. })
  513. const getIconColor = (suffix) => {
  514. const type = suffix?.toLowerCase()
  515. if (['jpg', 'jpeg', 'png', 'gif'].includes(type)) return '#ff4d4f' // 图片红色
  516. if (['pdf'].includes(type)) return '#f5222d' // PDF红色
  517. if (['ppt', 'pptx'].includes(type)) return '#fa8c16' // PPT橙色
  518. if (['doc', 'docx'].includes(type)) return '#1890ff' // Word蓝色
  519. if (['xls', 'xlsx'].includes(type)) return '#52c41a' // Excel绿色
  520. return '#666' // 默认灰色
  521. }
  522. const getListData = () => {
  523. loading.value = true
  524. let params = {
  525. current: pagination.pageNum,
  526. size: pagination.pageSize,
  527. verifyStatus: isVerifyStatus.value ? isVerifyStatus.value : formState.verifyStatus,
  528. fileName: formState.fileName,
  529. resourceType: formState.resourceType,
  530. resourceTwoType: formState.resourceTwoType,
  531. suffix: formState.suffix,
  532. // majorId: formState.majorId,
  533. collegeTwoId: formState.collegeTwoId,
  534. collegeId: formState.collegeId,
  535. collegeThreeId: formState.collegeThreeId,
  536. isSelf: 0
  537. }
  538. resourceAuditApi
  539. .page(params)
  540. .then((res) => {
  541. console.log(res, '资源审核列表')
  542. dataSource.value = res.data.records
  543. pagination.total = res.data.total
  544. loading.value = false
  545. })
  546. .catch((err) => {
  547. console.log(err)
  548. dataSource.value = []
  549. pagination.total = 0
  550. loading.value = false
  551. })
  552. }
  553. const changeCollegeMajor = (value, selectedOptions) => {
  554. console.log('Selected:', value, selectedOptions)
  555. if (!value) {
  556. majorIdName.value = ''
  557. return false
  558. }
  559. majorIdName.value = selectedOptions.map((it) => it.name).join('/')
  560. formState.collegeId = value[0] || null
  561. formState.collegeTwoId = value[1] || null
  562. formState.collegeThreeId = value[2] || null
  563. if (selectedOptions.length) {
  564. // 获取选中的最后一级
  565. const lastSelected = selectedOptions[selectedOptions.length - 1]
  566. console.log(lastSelected, '最后一级id')
  567. getCollegeMajor(lastSelected.id)
  568. }
  569. }
  570. const changeCollegeResource = (value, selectedOptions) => {
  571. console.log('Selected:', value, selectedOptions)
  572. if (!value) {
  573. resourceName.value = ''
  574. formState.resourceType = undefined
  575. formState.resourceTwoType = undefined
  576. return false
  577. }
  578. resourceName.value = selectedOptions.map((it) => it.name).join('/')
  579. formState.resourceType = value[0] || undefined
  580. formState.resourceTwoType = value[1] || undefined
  581. console.log('已经修改:', formState)
  582. }
  583. const getList = () => {
  584. getListData()
  585. uploadModalVisible.value = false
  586. }
  587. //院系组织查询
  588. const getOrgTreeSelector = () => {
  589. resourceAuditApi
  590. .orgTreeSelector()
  591. .then((res) => {
  592. console.log(res.data, '获取组织树选择器')
  593. collegeMajorOptions.value = res.data
  594. })
  595. .catch((err) => {
  596. console.log(err)
  597. })
  598. }
  599. //资源类型下拉查询
  600. const getResourceTypeTree = () => {
  601. resourceAuditApi
  602. .resourceTypeTree()
  603. .then((res) => {
  604. console.log(res.data, '资源类型下拉')
  605. resourceTypeOptions.value = res.data
  606. })
  607. .catch((err) => {
  608. console.log(err)
  609. })
  610. }
  611. //资源格式下拉查询
  612. const getFileformat = () => {
  613. resourceAuditApi
  614. .fileformat()
  615. .then((res) => {
  616. console.log(res.data, '资源类型下拉')
  617. fileformatOptions.value = res.data.records
  618. })
  619. .catch((err) => {
  620. console.log(err)
  621. })
  622. }
  623. const getCollegeMajor = (id) => {
  624. resourceAuditApi
  625. .zyselect({ collegeId: id })
  626. .then((res) => {
  627. console.log(res.data, '专业下拉数据')
  628. majorOptions.value = res.data
  629. })
  630. .catch((err) => {
  631. console.log(err)
  632. })
  633. }
  634. // 方法
  635. const handleSearch = () => {
  636. console.log('Search:', searchValue.value)
  637. getListData()
  638. }
  639. const handleReset = () => {
  640. searchValue.value = null
  641. majorIdName.value = null
  642. resourceName.value = null
  643. isVerifyStatus.value = null
  644. if (formState.verifyStatus == '3' || formState.verifyStatus == '0') {
  645. formState.verifyStatus = '0,3'
  646. }
  647. formState.fileName = null
  648. formState.resourceType = null
  649. formState.resourceTwoType = null
  650. formState.suffix = null
  651. formState.collegeTwoId = null
  652. // formState.majorId = null
  653. formState.collegeId = null
  654. formState.collegeThreeId = null
  655. getListData()
  656. }
  657. const tabChange = () => {
  658. dataSource.value = []
  659. getListData()
  660. }
  661. const handleBack = () => {
  662. emit('handleBack')
  663. }
  664. //发布
  665. const handlePublish = (record) => {
  666. publishedData.value = record
  667. releaseVisible.value = true
  668. isPublishBulk.value = false
  669. }
  670. // 批量发布方法
  671. const batchPublish = () => {
  672. if (selectedRows.value.length === 0) {
  673. message.warning('请至少选择一条记录')
  674. return
  675. }
  676. isState.value = 0
  677. isPublishBulk.value = true
  678. releaseVisible.value = true
  679. }
  680. // 全选当前页数据
  681. const selectAll = () => {
  682. selectedRowKeys.value = dataSource.value.map((item) => item.id)
  683. selectedRows.value = dataSource.value
  684. }
  685. // 反选当前页数据
  686. const invertSelection = () => {
  687. const allKeys = dataSource.value.map((item) => item.id)
  688. const newSelectedKeys = allKeys.filter((key) => !selectedRowKeys.value.includes(key))
  689. selectedRowKeys.value = newSelectedKeys
  690. selectedRows.value = dataSource.value.filter((item) => newSelectedKeys.includes(item.id))
  691. }
  692. //发布确定
  693. const releaseConfirm = (obj) => {
  694. console.log(obj, selectedRows.value, '传回来的数据')
  695. releaseVisible.value = false
  696. if (isPublishBulk.value) {
  697. // const batchParams = selectedRows.value.map((item) => ({
  698. // id: item.id,
  699. // coverImage: item.coverImage,
  700. // resourceDesc: item.resourceDesc,
  701. // verifyStatus: 1
  702. // }))
  703. const params = {
  704. ids: selectedRows.value.map((item) => item.id).join(','),
  705. coverImage: obj.coverImageId,
  706. resourceDesc: obj.resourceDesc,
  707. verifyStatus: 1
  708. }
  709. console.log(params, '批量发布参数')
  710. // handleRelease(params)
  711. } else {
  712. const params = {
  713. ids: publishedData.value.id,
  714. coverImage: obj.coverImageId,
  715. resourceDesc: obj.resourceDesc,
  716. verifyStatus: 1
  717. }
  718. console.log(params, '发布参数')
  719. handleRelease(params)
  720. }
  721. }
  722. // updateStatus接口调用
  723. const handleRelease = (Params) => {
  724. resourceAuditApi
  725. .updateStatus(Params)
  726. .then((res) => {
  727. getListData()
  728. selectedRowKeys.value = []
  729. })
  730. .catch((err) => {
  731. console.error(err)
  732. })
  733. }
  734. const auditState = ref(null)
  735. const handleAudit = (record) => {
  736. // console.log('Audit:', record)
  737. // publishedData.value = record
  738. // auditState.value = true
  739. // auditModalVisible.value = true
  740. router.push({
  741. path: '/portal/resourceDetails',
  742. query: {
  743. id: record.id,
  744. state: 1,
  745. audit: 1
  746. }
  747. })
  748. }
  749. const handleView = (record) => {
  750. router.push({
  751. path: '/portal/resourceDetails',
  752. query: {
  753. id: record.id,
  754. state: 1
  755. }
  756. })
  757. // publishedData.value = record
  758. // auditState.value = false
  759. // auditModalVisible.value = true
  760. }
  761. const handleDownload = (record) => {
  762. resourceAuditApi
  763. .downloadfile({
  764. userFileId: record.fileId,
  765. shareBatchNum: record.shareBatchNum == null ? '' : record.shareBatchNum,
  766. extractionCode: record.extractionCode == null ? '' : record.extractionCode,
  767. admin: true
  768. })
  769. .then((res) => {
  770. console.log('下载成功:', res)
  771. // 创建Blob对象
  772. const url = window.URL.createObjectURL(new Blob([res]))
  773. const link = document.createElement('a')
  774. link.href = url
  775. link.download = record.fileName || `file_${record.id}.${record.suffix}`
  776. document.body.appendChild(link)
  777. link.click()
  778. window.URL.revokeObjectURL(url)
  779. document.body.removeChild(link)
  780. })
  781. .catch((err) => {
  782. console.error(err)
  783. })
  784. }
  785. const handlePermission = (record) => {
  786. console.log('Permission:', record)
  787. permissionTreeVisible.value = true
  788. }
  789. const auditConfirm = (obj) => {
  790. console.log('auditConfirm:', obj)
  791. const params = {
  792. ids: obj.id,
  793. verifyStatus: obj.auditResult
  794. }
  795. resourceAuditApi
  796. .updateStatus(params)
  797. .then((res) => {
  798. if (res.code == 200) {
  799. auditModalVisible.value = false
  800. }
  801. getListData()
  802. })
  803. .catch((err) => {
  804. console.error(err)
  805. })
  806. }
  807. const handleDelete = (record) => {
  808. console.log('Delete:', record)
  809. }
  810. const handleRestore = (record) => {
  811. const params = {
  812. ids: record.id,
  813. verifyStatus: 0
  814. }
  815. resourceAuditApi
  816. .updateStatus(params)
  817. .then((res) => {
  818. getListData()
  819. })
  820. .catch((err) => {
  821. console.error(err)
  822. })
  823. }
  824. //资源编辑
  825. const edit = (record) => {
  826. console.log('Restore:', record)
  827. uploadModalVisible.value = true
  828. isState.value = 1
  829. editResourcesId.value = record.id
  830. }
  831. //资源删除
  832. const resourcesDelete = (record) => {
  833. if (formState.verifyStatus == 4) {
  834. const params = [
  835. {
  836. id: record.id
  837. }
  838. ]
  839. resourceAuditApi
  840. .deletefile(params)
  841. .then((res) => {
  842. getListData()
  843. })
  844. .catch((err) => {
  845. console.error(err)
  846. })
  847. } else {
  848. const params = {
  849. ids: record.id,
  850. verifyStatus: 4
  851. }
  852. resourceAuditApi
  853. .updateStatus(params)
  854. .then((res) => {
  855. getListData()
  856. })
  857. .catch((err) => {
  858. console.error(err)
  859. })
  860. }
  861. }
  862. // 上传资源模态框
  863. const uploadModalVisible = ref(false)
  864. // 显示上传模态框
  865. const showUploadModal = () => {
  866. isState.value = 0
  867. uploadModalVisible.value = true
  868. }
  869. // 翻页
  870. const handlePageChange = (page) => {
  871. pagination.pageNum = page
  872. getListData()
  873. }
  874. // 每页条数
  875. const handlePageSizeChange = (pageNum, size) => {
  876. pagination.pageNum = 1
  877. pagination.pageSize = size
  878. getListData()
  879. }
  880. onMounted(() => {
  881. // if (pageType == 'economize') {
  882. // formState.verifyStatus = '1'
  883. // }
  884. // getOrgTreeSelector()
  885. // getFileformat()
  886. // getResourceTypeTree()
  887. // getListData()
  888. })
  889. const open = () => {
  890. visible.value = true
  891. if (pageType == 'economize') {
  892. formState.verifyStatus = '1'
  893. }
  894. getOrgTreeSelector()
  895. getFileformat()
  896. getResourceTypeTree()
  897. getListData()
  898. }
  899. const close = () => {
  900. visible.value = false
  901. }
  902. defineExpose( {open,close})
  903. </script>
  904. <style scoped>
  905. .editable-cell {
  906. position: relative;
  907. }
  908. .ant-dropdown-link {
  909. margin-left: 8px;
  910. }
  911. .upload-area {
  912. border: 2px dashed #3ca9f5;
  913. padding: 40px;
  914. text-align: center;
  915. }
  916. .upload-area p {
  917. margin: 10px 0;
  918. }
  919. .file-item {
  920. display: flex;
  921. align-items: center;
  922. margin: 10px 0;
  923. }
  924. .file-item .ant-progress {
  925. flex: 1;
  926. margin: 0 10px;
  927. }
  928. </style>