阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

361 lines
13 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
3 years ago
3 years ago
3 years ago
11 months ago
4 weeks ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
11 months ago
3 years ago
3 years ago
3 years ago
5 months ago
3 years ago
3 years ago
11 months ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
5 months ago
3 years ago
5 months ago
11 months ago
4 weeks ago
11 months ago
4 weeks ago
11 months ago
4 weeks ago
11 months ago
4 weeks ago
11 months ago
3 years ago
3 years ago
11 months ago
  1. <template>
  2. <div>
  3. <!-- :wrapper-closable="false" -->
  4. <el-drawer
  5. :with-header="false"
  6. :visible.sync="fileDrawer"
  7. :modal="false"
  8. :show-close="false"
  9. direction="rtl"
  10. :class="((selectedCategory.arrangeType === 2 && isAjNo === 0) || (selectedCategory.arrangeType === 3 && isAjNo === 1)) ? 'drawer2-modal' : (isAjNo === 1) ? 'drawer1-modal' : (selectedCategory.arrangeType === 1) ? 'drawer1-modal' : 'drawer3-modal'"
  11. :size="((selectedCategory.arrangeType === 2 && isAjNo === 0) || (selectedCategory.arrangeType === 3 && isAjNo === 1)) ? '80%' : (isAjNo === 1) ? '90%' : (selectedCategory.arrangeType === 1) ? '90%' : '70%'"
  12. >
  13. <CollectHeader ref="collectHeaderRef" :is-title-type="isTitleType" :selected-category="selectedCategory" :selections="selections" :test="test" :is-recycle="isRecycle" />
  14. <span class="closed-btn" @click="closeDrawer" />
  15. <div class="collect-table">
  16. <el-table
  17. ref="table"
  18. v-loading="crud.loading || getTableDisplayFieldsLoading"
  19. class="archives-table"
  20. :data="fileData"
  21. highlight-current-row
  22. style="width: 100%;"
  23. height="calc(100vh - 418px)"
  24. :row-class-name="tableRowClassName"
  25. :row-key="rowKey"
  26. @select-all="selectAll"
  27. @selection-change="crud.selectionChangeHandler"
  28. @row-click="clickRowHandler"
  29. @cell-dblclick="tableDoubleClick"
  30. @select="handleCurrentChange"
  31. >
  32. <el-table-column type="selection" width="55" :reserve-selection="true" align="center" />
  33. <el-table-column label="序号" width="55" align="center" show-overflow-tooltip>
  34. <template slot-scope="scope">
  35. <span>{{ page.page * page.size + scope.$index + 1 }}</span>
  36. </template>
  37. </el-table-column>
  38. <!-- <el-table-column type="index" label="序号" width="55" align="center" /> -->
  39. <el-table-column prop="file_name" label="原文名称" show-overflow-tooltip min-width="140" />
  40. <el-table-column prop="file_type" label="格式" min-width="60" align="center" />
  41. <el-table-column prop="file_size" label="大小" min-width="80" align="right" show-overflow-tooltip>
  42. <template slot-scope="scope">
  43. {{ getFileSize(scope.row.file_size) }}
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="file_dpi" label="尺寸" min-width="100" align="center" show-overflow-tooltip>
  47. <template slot-scope="scope">
  48. <div v-if="!scope.row.file_dpi || scope.row.file_dpi === 'null'"> - </div>
  49. <div v-else> {{ scope.row.file_dpi }} </div>
  50. </template>
  51. </el-table-column>
  52. <!-- @click="showCoverPreview(scope.row)" -->
  53. <el-table-column prop="file_thumbnail" label="缩略图" min-width="60" align="center">
  54. <template slot-scope="scope">
  55. <div :class="getFileIconClass(scope.row.file_type)">
  56. <i class="fileIcon" :class="getFileIconClass(scope.row.file_type)" />
  57. </div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column prop="create_time" label="创建时间" min-width="120" align="center" />
  61. <!-- && !recycleMain.isRecycle -->
  62. <el-table-column v-if=" !parentsData.isRecycle" label="操作" min-width="80" align="center">
  63. <template slot-scope="scope">
  64. <div class="handle-btn">
  65. <el-button class="iconfont icon-sulan" @click="toPreview(scope.row)" />
  66. <el-button class="iconfont icon-xiazai" @click="downloadFile(scope.row)" />
  67. <!-- <el-button class="iconfont icon-dayin" /> -->
  68. </div>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <!--分页组件-->
  73. <el-pagination
  74. v-if="fileData.length !== 0"
  75. :current-page="currentPage"
  76. :total="page.total"
  77. :page-size="page.size"
  78. :pager-count="5"
  79. layout="total, prev, pager, next, sizes"
  80. @size-change="handleSizeChange"
  81. @current-change="handleCurrentPage"
  82. />
  83. </div>
  84. </el-drawer>
  85. <!-- 点击缩略图看大图 -->
  86. <el-dialog class="preview-dialog" :append-to-body="true" :close-on-click-modal="false" :before-close="handleClose" :visible="showCoverVisible" title="查看大图">
  87. <span class="dialog-right-top" />
  88. <span class="dialog-left-bottom" />
  89. <div class="setting-dialog" style="max-height:calc(100vh - 230px); overflow:auto;">
  90. <img style="max-width:100%; object-fit: contain;" :src="previewSrc" :onerror="defaultImg">
  91. </div>
  92. </el-dialog>
  93. <div v-if="fileDrawer" :class="['mask-modal',((selectedCategory.arrangeType === 2 && isAjNo === 0) || (selectedCategory.arrangeType === 3 && isAjNo === 1)) ? 'level2-modal' : (isAjNo === 1) ? 'level1-modal' : (selectedCategory.arrangeType === 1) ? 'level1-modal' : 'level3-modal']" @click="closeDrawer" />
  94. </div>
  95. </template>
  96. <script>
  97. import { collectionLibraryCrud } from '../mixins/index'
  98. import { header, form } from '@crud/crud'
  99. import CollectHeader from '../module/collectHeader'
  100. import { mapGetters } from 'vuex'
  101. import { downloadFile } from '@/utils/index'
  102. import { getToken } from '@/utils/auth'
  103. export default {
  104. name: 'File',
  105. components: { CollectHeader },
  106. mixins: [
  107. header(),
  108. form({}),
  109. collectionLibraryCrud
  110. ],
  111. props: {
  112. selectedCategory: {
  113. type: Object,
  114. default: function() {
  115. return {}
  116. }
  117. },
  118. isRecycle: {
  119. type: Boolean,
  120. default: false
  121. },
  122. smartQuery: {
  123. type: Object,
  124. default: function() {
  125. return {}
  126. }
  127. }
  128. },
  129. inject: ['parentsData'],
  130. data() {
  131. return {
  132. defaultImg: 'this.src="' + require('@/assets/images/cover-bg.png') + '"',
  133. isTitleType: 6,
  134. fileDrawer: false,
  135. test: '',
  136. isAjNo: 0,
  137. selections: [],
  138. showCoverVisible: false,
  139. previewSrc: null,
  140. currentPage: 1,
  141. parentInfo: null
  142. }
  143. },
  144. computed: {
  145. ...mapGetters([
  146. 'baseApi'
  147. ])
  148. },
  149. watch: {
  150. selectedCategory: function(newValue, oldValue) {
  151. }
  152. },
  153. created() {
  154. },
  155. mounted() {
  156. },
  157. methods: {
  158. getFileIconClass(fileType) {
  159. if (!fileType) return 'icon-other'
  160. const lowerFileType = fileType.toLowerCase()
  161. switch (lowerFileType) {
  162. case 'jpg':
  163. case 'jpeg':
  164. case 'png':
  165. case 'bmp':
  166. case 'gif':
  167. return 'icon-image'
  168. case 'xlsx':
  169. case 'xls':
  170. return 'icon-excel'
  171. case 'docx':
  172. case 'doc':
  173. return 'icon-word'
  174. case 'pdf':
  175. return 'icon-pdf'
  176. case 'ppt':
  177. case 'pptx':
  178. return 'icon-ppt'
  179. case 'zip':
  180. case 'rar':
  181. return 'icon-zip'
  182. case 'txt':
  183. return 'icon-txt'
  184. case 'ofd':
  185. return 'icon-ofd'
  186. // 其他未匹配的文件类型
  187. default:
  188. return 'icon-other'
  189. }
  190. },
  191. getFileSize(fileSize) {
  192. // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况
  193. const sizeInKB = Number(fileSize)
  194. if (isNaN(sizeInKB) || sizeInKB < 0) {
  195. return '0 KB' // 异常值默认显示0 KB
  196. }
  197. // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB)
  198. const KB = 1
  199. const MB = 1024 * KB
  200. const GB = 1024 * MB
  201. // 3. 根据大小自动选择单位并格式化
  202. if (sizeInKB >= GB) {
  203. // 大于等于1GB,显示GB(保留2位小数)
  204. return (sizeInKB / GB).toFixed(2) + ' GB'
  205. } else if (sizeInKB >= MB) {
  206. // 大于等于1MB且小于1GB,显示MB(保留2位小数)
  207. return (sizeInKB / MB).toFixed(2) + ' MB'
  208. } else if (sizeInKB < 1) {
  209. // 不足1KB,统一显示1 KB(保持你之前的需求)
  210. return '1 KB'
  211. } else {
  212. // 1KB到1MB之间,显示KB(保留2位小数)
  213. return sizeInKB + ' KB'
  214. }
  215. },
  216. getCommonData(categoryLevel, parentId, type) {
  217. this.getViewTable(categoryLevel, parentId, type)
  218. },
  219. closeDrawer() {
  220. console.log('关闭文件annnn')
  221. localStorage.removeItem('currentPageSize')
  222. localStorage.removeItem('currentPage')
  223. this.fileDrawer = false
  224. if (this.selectedCategory.arrangeType === 1) {
  225. this.$parent.parentsAnjuanId = null
  226. } else {
  227. this.$parent.parentsJuanneiId = null
  228. }
  229. },
  230. rowKey(row) {
  231. return row.id
  232. },
  233. // table选中加上选中状态
  234. tableRowClassName({ row, rowIndex }) {
  235. let color = ''
  236. this.selections.forEach(item => {
  237. if (item.id === row.id) {
  238. color = 'rowStyle'
  239. }
  240. })
  241. return color
  242. },
  243. // table - 全选
  244. selectAll(val) {
  245. this.selections = val
  246. },
  247. // table - 双击查看详情
  248. tableDoubleClick(row) {
  249. },
  250. // table - 当前选中得row
  251. clickRowHandler(row) {
  252. // this.parentsData.smartQuery = {
  253. // 'retention': null,
  254. // 'security_class': null,
  255. // 'doc_type': null,
  256. // 'medium_type': null,
  257. // 'archive_year': null,
  258. // 'fonds_no': null
  259. // }
  260. this.selections = this.crud.selections
  261. },
  262. // 触发单选
  263. handleCurrentChange(selection, row) {
  264. this.selections = selection
  265. },
  266. handleSizeChange(size) {
  267. this.currentPage = 1
  268. this.page.size = size
  269. this.page.page = 0
  270. localStorage.setItem('currentPageSize', size)
  271. if (this.selectedCategory.arrangeType === 1) {
  272. this.getViewTable(4, this.parentsData.parentsAnjuanId)
  273. } else {
  274. this.getViewTable(4, this.parentsData.parentsJuanneiId)
  275. }
  276. },
  277. handleCurrentPage(pageVal) {
  278. this.currentPage = pageVal
  279. this.page.page = pageVal - 1
  280. localStorage.setItem('currentPage', JSON.stringify(this.page.page))
  281. if (this.selectedCategory.arrangeType === 1) {
  282. this.getViewTable(4, this.parentsData.parentsAnjuanId)
  283. } else {
  284. this.getViewTable(4, this.parentsData.parentsJuanneiId)
  285. }
  286. },
  287. // dialog - close
  288. handleClose(done) {
  289. this.showCoverVisible = false
  290. done()
  291. },
  292. showCoverPreview(row) {
  293. this.showCoverVisible = true
  294. this.previewSrc = this.baseApi + '/downloadFile' + row.file_path
  295. },
  296. toPreview(row) {
  297. console.log('row', row)
  298. console.log('selectedCategory', row)
  299. console.log('parentsData', this.parentsData)
  300. if (this.selectedCategory.arrangeType === 1) {
  301. this.parentInfo = this.parentsData.parentsAnjuanRow
  302. } else {
  303. this.parentInfo = this.parentsData.parentsJuanneiRow
  304. }
  305. console.log('this.parentInfo', this.parentInfo)
  306. const routeData = this.$router.resolve({
  307. path: '/preview',
  308. query: {
  309. 'archiveNo': this.parentInfo.archive_no
  310. }})
  311. window.open(routeData.href, '_blank')
  312. if (localStorage.getItem('documentId')) {
  313. localStorage.removeItem('documentId')
  314. }
  315. localStorage.setItem('fileParentInfo', JSON.stringify(this.parentInfo))
  316. localStorage.setItem('fileTables', JSON.stringify(this.fileData))
  317. localStorage.setItem('fileCurrent', JSON.stringify(row))
  318. },
  319. // 下载附件
  320. // downloadFile(row) {
  321. // const url = this.baseApi + '/downloadFile' + row.file_path
  322. // fetch(url).then(res => res.blob()).then(blob => {
  323. // downloadFile(blob, row.file_name.split('.')[0], row.file_type)
  324. // }).catch(() => {
  325. // this.$message({ message: '下载文件失败!', type: 'error', offset: 8 })
  326. // })
  327. // }
  328. downloadFile(row) {
  329. const url = this.baseApi + '/api/minioUpload/getFile?filePath=' + row.file_path + '&bucketType=2'
  330. const fetchOptions = {
  331. method: 'GET',
  332. headers: {
  333. 'Authorization': getToken()
  334. }
  335. }
  336. fetch(url, fetchOptions).then(res => res.blob()).then(blob => {
  337. downloadFile(blob, row.file_name.split('.')[0], row.file_type)
  338. this.downloading = false
  339. }).catch(() => {
  340. this.$message({ message: '下载文件失败', type: 'error', offset: 8 })
  341. this.downloading = false
  342. })
  343. }
  344. }
  345. }
  346. </script>
  347. <style lang='scss' scoped>
  348. @import "~@/assets/styles/collect-reorganizi.scss";
  349. .svg-style{
  350. width: 60px;
  351. height: 32px;
  352. }
  353. </style>