myResources.vue 20 KB

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