阅行客电子档案
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.

280 lines
9.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 month ago
2 years ago
2 years ago
12 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 months ago
2 years ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div>
  3. <!-- :wrapper-closable="false" -->
  4. <el-drawer
  5. class="management-drawer"
  6. :with-header="false"
  7. :visible.sync="fileDrawer"
  8. :modal="false"
  9. :show-close="false"
  10. direction="rtl"
  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>
  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 - 364px)"
  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="85" align="right">
  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="85" align="center">
  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. <el-table-column prop="file_thumbnail" label="缩略图" min-width="60" align="center">
  53. <template slot-scope="scope">
  54. <div v-if="scope.row.file_type === 'jpg' || scope.row.file_type === 'jpeg' || scope.row.file_type === 'png' || scope.row.file_type === 'bmp'|| scope.row.file_type === 'gif'">
  55. <i class="fileIcon icon-image" />
  56. </div>
  57. <div v-else-if="scope.row.file_type === 'xlsx' || scope.row.file_type === 'xls'">
  58. <i class="fileIcon icon-excel" />
  59. </div>
  60. <div v-else-if="scope.row.file_type === 'docx' || scope.row.file_type === 'doc'">
  61. <i class="fileIcon icon-word" />
  62. </div>
  63. <div v-else-if="scope.row.file_type === 'pdf'">
  64. <i class="fileIcon icon-pdf" />
  65. </div>
  66. <div v-else-if="scope.row.file_type === 'ppt' || scope.row.file_type === 'pptx'">
  67. <i class="fileIcon icon-ppt" />
  68. </div>
  69. <div v-else-if="scope.row.file_type === 'zip' || scope.row.file_type === 'rar'">
  70. <i class="fileIcon icon-zip" />
  71. </div>
  72. <div v-else-if="scope.row.file_type === 'txt'">
  73. <i class="fileIcon icon-txt" />
  74. </div>
  75. <div v-else-if="scope.row.file_type === 'ofd'">
  76. <i class="fileIcon icon-ofd" />
  77. </div>
  78. <div v-else>
  79. <i class="fileIcon icon-other" />
  80. </div>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="create_time" label="创建时间" min-width="110" align="center" />
  84. </el-table>
  85. <!--分页组件-->
  86. <el-pagination
  87. v-if="fileData.length !== 0"
  88. :current-page="currentPage"
  89. :total="page.total"
  90. :page-size="page.size"
  91. :pager-count="5"
  92. layout="total, prev, pager, next, sizes"
  93. @size-change="handleSizeChange"
  94. @current-change="handleCurrentPage"
  95. />
  96. </div>
  97. </el-drawer>
  98. </div>
  99. </template>
  100. <script>
  101. import { manageLibraryCrud } from '../mixins/index'
  102. import { header, form } from '@crud/crud'
  103. import CollectHeader from '../module/collectHeader'
  104. import { mapGetters } from 'vuex'
  105. export default {
  106. name: 'File',
  107. components: { CollectHeader },
  108. mixins: [
  109. header(),
  110. form({}),
  111. manageLibraryCrud
  112. ],
  113. props: {
  114. selectedCategory: {
  115. type: Object,
  116. default: function() {
  117. return {}
  118. }
  119. },
  120. isRecycle: {
  121. type: Boolean,
  122. default: false
  123. },
  124. smartQuery: {
  125. type: Object,
  126. default: function() {
  127. return {}
  128. }
  129. }
  130. },
  131. inject: ['parentsData'],
  132. data() {
  133. return {
  134. defaultImg: 'this.src="' + require('@/assets/images/cover-bg.png') + '"',
  135. isTitleType: 6,
  136. fileDrawer: false,
  137. test: '',
  138. isAjNo: 0,
  139. selections: [],
  140. showCoverVisible: false,
  141. previewSrc: null,
  142. currentPage: 1
  143. }
  144. },
  145. computed: {
  146. ...mapGetters([
  147. 'baseApi'
  148. ])
  149. },
  150. watch: {
  151. selectedCategory: function(newValue, oldValue) {
  152. }
  153. },
  154. created() {
  155. },
  156. mounted() {
  157. },
  158. methods: {
  159. getFileSize(fileSize) {
  160. // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况
  161. const sizeInKB = Number(fileSize)
  162. if (isNaN(sizeInKB) || sizeInKB < 0) {
  163. return '0 KB' // 异常值默认显示0 KB
  164. }
  165. // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB)
  166. const KB = 1
  167. const MB = 1024 * KB
  168. const GB = 1024 * MB
  169. // 3. 根据大小自动选择单位并格式化
  170. if (sizeInKB >= GB) {
  171. // 大于等于1GB,显示GB(保留2位小数)
  172. return (sizeInKB / GB).toFixed(2) + ' GB'
  173. } else if (sizeInKB >= MB) {
  174. // 大于等于1MB且小于1GB,显示MB(保留2位小数)
  175. return (sizeInKB / MB).toFixed(2) + ' MB'
  176. } else if (sizeInKB < 1) {
  177. // 不足1KB,统一显示1 KB(保持你之前的需求)
  178. return '1 KB'
  179. } else {
  180. // 1KB到1MB之间,显示KB(保留2位小数)
  181. return sizeInKB + ' KB'
  182. }
  183. },
  184. getCommonData(categoryLevel, parentId, type) {
  185. this.getViewTable(categoryLevel, parentId, type)
  186. },
  187. closeDrawer() {
  188. localStorage.removeItem('currentPageSize')
  189. localStorage.removeItem('currentPage')
  190. this.fileDrawer = false
  191. if (this.selectedCategory.arrangeType === 1) {
  192. this.$parent.parentsAnjuanId = null
  193. } else {
  194. this.$parent.parentsJuanneiId = null
  195. }
  196. },
  197. rowKey(row) {
  198. return row.id
  199. },
  200. // table选中加上选中状态
  201. tableRowClassName({ row, rowIndex }) {
  202. let color = ''
  203. this.selections.forEach(item => {
  204. if (item.id === row.id) {
  205. color = 'rowStyle'
  206. }
  207. })
  208. return color
  209. },
  210. // table - 全选
  211. selectAll(val) {
  212. this.selections = val
  213. },
  214. // table - 双击查看详情
  215. tableDoubleClick(row) {
  216. // console.log('tableDoubleClick', row)
  217. // this.arcId = row.id
  218. // console.log(this.selectedCategory.isType)
  219. },
  220. // table - 当前选中得row
  221. clickRowHandler(row) {
  222. // this.parentsData.smartQuery = {
  223. // 'retention': null,
  224. // 'security_class': null,
  225. // 'doc_type': null,
  226. // 'medium_type': null,
  227. // 'archive_year': null,
  228. // 'fonds_no': null
  229. // }
  230. this.selections = this.crud.selections
  231. },
  232. // 触发单选
  233. handleCurrentChange(selection, row) {
  234. this.selections = selection
  235. },
  236. handleSizeChange(size) {
  237. this.currentPage = 1
  238. this.page.size = size
  239. this.page.page = 0
  240. localStorage.setItem('currentPageSize', size)
  241. if (this.selectedCategory.arrangeType === 1) {
  242. this.getViewTable(4, this.parentsData.parentsAnjuanId)
  243. } else {
  244. this.getViewTable(4, this.parentsData.parentsJuanneiId)
  245. }
  246. },
  247. handleCurrentPage(pageVal) {
  248. this.currentPage = pageVal
  249. this.page.page = pageVal - 1
  250. localStorage.setItem('currentPage', JSON.stringify(this.page.page))
  251. if (this.selectedCategory.arrangeType === 1) {
  252. this.getViewTable(4, this.parentsData.parentsAnjuanId)
  253. } else {
  254. this.getViewTable(4, this.parentsData.parentsJuanneiId)
  255. }
  256. },
  257. // dialog - close
  258. handleClose(done) {
  259. this.showCoverVisible = false
  260. done()
  261. },
  262. showCoverPreview(row) {
  263. this.showCoverVisible = true
  264. this.previewSrc = this.baseApi + '/downloadFile' + row.file_path
  265. }
  266. }
  267. }
  268. </script>
  269. <style lang='scss' scoped>
  270. @import "~@/assets/styles/collect-reorganizi.scss";
  271. .svg-style{
  272. width: 60px;
  273. height: 32px;
  274. }
  275. </style>