myResources.vue 22 KB

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