2099a3b04bd86b3146d92db02ab9d8a42ddf1d0e.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 左侧文件树 -->
  4. <a-col :span="4" class="clName">
  5. <a-tree
  6. :treeData="treeData"
  7. :defaultExpandAll="defaultExpandAll"
  8. @select="this.onSelect"
  9. style="height: 500px;overflow-y: auto;"
  10. >
  11. </a-tree>
  12. </a-col>
  13. <!-- 中间面板 -->
  14. <a-col :span="2"/>
  15. <!--右侧缩略图-->
  16. <a-col :span="18">
  17. <a-spin tip="Loading..." :spinning="spinning">
  18. <div v-for="(file, key) in dataSource" :key="key">
  19. <a-row>
  20. <a-col :span="24"><p><a-divider orientation="left">{{ file.fileName }}</a-divider></p></a-col>
  21. <!-- 预览区域 -->
  22. <a-col :span="24">
  23. <template v-if="file.filePdfPath">
  24. <div style="float: left;width:104px;height:104px;margin-right: 10px;margin: 0 8px 8px 0;">
  25. <div style="width: 100%;height: 100%;position: relative;padding: 8px;" @click="pdfPreview(file.title)">
  26. <img style="width: 100%;" src="~@/assets/pdf4.jpg">
  27. </div>
  28. </div>
  29. </template>
  30. <template v-else>
  31. (暂无材料,点击"选择文件"或"扫描上传"上传文件)
  32. </template>
  33. </a-col>
  34. </a-row>
  35. </div>
  36. </a-spin>
  37. </a-col>
  38. <pdf-preview-modal ref="pdfmodal"></pdf-preview-modal >
  39. </a-card>
  40. </template>
  41. <script>
  42. import { getAction } from '@/api/manage'
  43. import { ACCESS_TOKEN } from "@/store/mutation-types"
  44. import Vue from 'vue'
  45. import PdfPreviewModal from './modules/PdfPreviewModal'
  46. const mockdata=[{
  47. "id": "1",
  48. "key": "1",
  49. "title": "实例.pdf",
  50. "fileCode": "shili",
  51. "fileName": "实例",
  52. "filePdfPath": "实例"
  53. }]
  54. export default {
  55. name: "JeecgPdfView",
  56. components:{
  57. PdfPreviewModal
  58. },
  59. data () {
  60. return {
  61. description: 'PDF预览页面',
  62. // 文件类型集
  63. treeData:[{
  64. title: '所有PDF电子档',
  65. key: '0-0',
  66. children: mockdata }],
  67. // 文件数据集
  68. dataSource: mockdata,
  69. allData:mockdata,
  70. // 上传文件集
  71. defaultExpandAll: true,
  72. // 加载中
  73. spinning:false,
  74. url: {
  75. pdfList: "/mock/api/pdfList",
  76. },
  77. }
  78. },
  79. created() {
  80. //this.loadData();
  81. },
  82. methods: {
  83. loadData (){
  84. this.spinning = false;
  85. getAction(this.url.pdfList).then((res)=>{
  86. if(res.length>0){
  87. this.allData = res;
  88. this.dataSource = res;
  89. this.treeData[0].children = res;
  90. }
  91. this.spinning = false;
  92. })
  93. },
  94. pdfPreview:function(title){
  95. const token = Vue.ls.get(ACCESS_TOKEN);
  96. this.headers = {"X-Access-Token":token}
  97. this.$refs.pdfmodal.previewFiles(title,token);
  98. },
  99. // 选择文件类型
  100. onSelect (selectedKeys, info) {
  101. this.dataSource = [];
  102. if(selectedKeys[0] === undefined || selectedKeys[0] === '0-0'){
  103. this.dataSource = this.allData;
  104. }else{
  105. this.dataSource.push(info.node._props.dataRef);
  106. }
  107. console.log("SELECT-->dataSource",this.dataSource );
  108. },
  109. // model回调
  110. modalFormOk () {
  111. this.loadData();
  112. },
  113. },
  114. }
  115. </script>
  116. <style scoped>
  117. .clName .ant-tree li span.ant-tree-switcher, .ant-tree li span.ant-tree-iconEle{width:10px}
  118. </style>