EnclosureInfo.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div class="app-container">
  3. <h3 class="toolbar">
  4. <div class="tool">
  5. <el-button type="primary" plain icon="el-icon-download" size="mini" @click="handleDownloadBatch">批量下载</el-button>
  6. </div>
  7. </h3>
  8. <el-table v-loading="loading" :data="list" border @selection-change="handleSelectionChange" style="width: 100%">
  9. <el-table-column type="selection" width="55"></el-table-column>
  10. <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
  11. <el-table-column label="文件名称" prop="fileName" align="center"></el-table-column>
  12. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  13. <template slot-scope="scope">
  14. <el-button type="text" @click="handleView(scope.row)">查看</el-button>
  15. <el-button type="text" @click="handleDownload(scope.row)">下载</el-button>
  16. <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
  17. </template>
  18. </el-table-column>
  19. </el-table>
  20. <pagination
  21. v-show="total>0"
  22. :total="total"
  23. :page.sync="queryParams.pageNum"
  24. :limit.sync="queryParams.pageSize"
  25. @pagination="getList"/>
  26. <upload-enclosure ref="uploadEnclosure" v-if="enclosureVisible" @refreshData="getList()" :dataId="dataId" :attachType="'PROJECT'"></upload-enclosure>
  27. <div class="container" style="margin-top: 20px;">
  28. <div v-show="loading" class="well loading">正在加载中,请耐心等待...</div>
  29. <div v-show="!loading" class="well" ref="output"></div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import {getEnclosureApi,deleteEnclosureApi,getProjectInfoApi,getProjectInfoCommonApi} from '@/api/enterprise/project/project'
  35. import UploadEnclosure from './UploadEnclosure'
  36. import { getExtend, readBuffer, render } from '@/utils/util';
  37. import { parse } from 'qs';
  38. import axios from 'axios'
  39. export default {
  40. components: {
  41. UploadEnclosure
  42. },
  43. props: {
  44. projectOwner: {
  45. type: String
  46. },
  47. finOwner:{
  48. type: String
  49. }
  50. },
  51. data() {
  52. return {
  53. total: 0,
  54. enclosureVisible: false,
  55. list: [],
  56. id: this.$route.query.id,
  57. dataId: undefined,
  58. attachType: 'PROJECT',
  59. loading: false,
  60. selectionList: [],
  61. ids: '',
  62. info: {},
  63. queryParams: {
  64. pageNum: 1,
  65. pageSize: 10
  66. }
  67. };
  68. },
  69. created() {
  70. this.id = this.$route.params.id || undefined;
  71. this.getData()
  72. },
  73. methods: {
  74. getData() {
  75. getProjectInfoCommonApi(this.id).then(res => {
  76. if(this.projectOwner == '1') {
  77. this.info = res.data.entProject || {}
  78. this.dataId = this.info.id
  79. }else if(this.projectOwner == '2') {
  80. this.info = res.data.techProject || {}
  81. this.dataId = this.info.id
  82. }else if(this.projectOwner == '3') {
  83. this.info = res.data.finProject || {}
  84. this.dataId = this.info.id
  85. }
  86. this.getList()
  87. })
  88. },
  89. getList() {
  90. if(this.finOwner == 'fin') {
  91. this.attachType = 'FINACIAL'
  92. }
  93. getEnclosureApi(this.attachType,this.dataId).then(res => {
  94. if(res.code == 200) {
  95. this.list = res.data.records
  96. this.total = res.data.total
  97. }
  98. })
  99. },
  100. handleDownload(row) {
  101. window.open("http://124.232.146.72:7015/api/common/attach/"+row.id)
  102. },
  103. handleDownloadBatch() {
  104. if(this.selectionList.length <=0) {
  105. this.$message.error('请选择要下载的数据');
  106. return
  107. }
  108. window.open("http://124.232.146.72:7015/api/common/attach/"+this.ids)
  109. this.getList();
  110. },
  111. handleBatchDelte() {
  112. if(this.selectionList.length <=0) {
  113. this.$message.error('请选择要删除的数据');
  114. return
  115. }
  116. this.$confirm('请确认是否删除所选择的数据!', '提示').then(() => {
  117. deleteEnclosureApi(this.ids).then(res => {
  118. if(res.code == 200) {
  119. this.queryParams.pageNum = 1;
  120. this.getList();
  121. this.$modal.msgSuccess("删除成功");
  122. }
  123. })
  124. })
  125. },
  126. // 从url加载
  127. handleView(row) {
  128. let routeUrl = this.$router.resolve({
  129. path: '/enclosurePreview',
  130. query: {url: row.url,fileName: row.fileName,id: row.id}
  131. });
  132. window.open(routeUrl.href, "_blank");
  133. },
  134. handleDelete(row) {
  135. const id = row.id;
  136. this.$confirm('是否确认删除该数据?', "警告", {
  137. confirmButtonText: "确定",
  138. cancelButtonText: "取消",
  139. type: "warning"
  140. }).then(function() {
  141. return deleteEnclosureApi(id);
  142. }).then(() => {
  143. this.queryParams.pageNum = 1;
  144. this.getList();
  145. this.$modal.msgSuccess("删除成功");
  146. })
  147. },
  148. // 取消全选
  149. // selectAll(selection) {
  150. // if (selection.length == 0) {
  151. // let list = this.selectedList.filter(item => !this.list.some(ele => ele.id === item.id));
  152. // this.selectionList = list;
  153. // }
  154. // },
  155. handleSelectionChange(val) {
  156. this.selectionList = val;
  157. if(this.selectionList.length > 0) {
  158. let selectionIds = []
  159. for (let i = 0, len = this.selectionList.length; i < len; i++) {
  160. selectionIds.push(this.selectionList[i].id)
  161. }
  162. this.ids = selectionIds.join(',')
  163. }else {
  164. this.ids = ''
  165. }
  166. }
  167. }
  168. };
  169. </script>
  170. </script>
  171. <style>
  172. </style>