myResources.vue 22 KB

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