TechEnclosure.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="app-container">
  3. <h3 class="toolbar">
  4. <div class="tool">
  5. <el-button type="primary" plain icon="el-icon-upload2" size="mini" @click="handleUpload">一键上传</el-button>
  6. <el-button type="primary" plain icon="el-icon-download" size="mini" @click="handleDownload">批量下载</el-button>
  7. <el-button type="primary" plain icon="el-icon-delete" size="mini" @click="handleBatchDelte">批量删除</el-button>
  8. </div>
  9. </h3>
  10. <el-table v-loading="loading" :data="list" border @selection-change="handleSelectionChange" style="width: 100%" @select-all="selectAll">
  11. <el-table-column type="selection" width="55"></el-table-column>
  12. <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
  13. <el-table-column label="文件名称" prop="fileName" align="center"></el-table-column>
  14. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  15. <template slot-scope="scope">
  16. <el-button type="text" @click="handleView(scope.row)">查看</el-button>
  17. <el-button type="text" @click="handleDownload(scope.row)">下载</el-button>
  18. <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
  19. </template>
  20. </el-table-column>
  21. </el-table>
  22. <pagination
  23. v-show="total>0"
  24. :total="total"
  25. :page.sync="queryParams.pageNum"
  26. :limit.sync="queryParams.pageSize"
  27. @pagination="getList"/>
  28. <upload-enclosure ref="uploadEnclosure" v-if="enclosureVisible" @refreshData="getList()" :dataId="dataId" :attachType="'PROJECT'"></upload-enclosure>
  29. </div>
  30. </template>
  31. <script>
  32. import {getEnclosureApi,deleteEnclosureApi,getProjectInfoApi} from '@/api/enterprise/project/project'
  33. import UploadEnclosure from './UploadEnclosure'
  34. export default {
  35. components: {
  36. UploadEnclosure
  37. },
  38. data() {
  39. return {
  40. total: 0,
  41. enclosureVisible: false,
  42. list: [],
  43. id: this.$route.query.id,
  44. dataId: undefined,
  45. attachType: 'PROJECT',
  46. loading: false,
  47. selectionList: [],
  48. ids: '',
  49. queryParams: {
  50. pageNum: 1,
  51. pageSize: 10
  52. }
  53. };
  54. },
  55. created() {
  56. this.id = this.$route.query.id || undefined;
  57. this.getData()
  58. },
  59. methods: {
  60. getData() {
  61. getProjectInfoApi(this.id).then(res => {
  62. let obj = res.data.techProject || {}
  63. this.dataId = obj.id //技术资料id
  64. this.getList()
  65. })
  66. },
  67. getList() {
  68. getEnclosureApi(this.attachType,this.dataId).then(res => {
  69. if(res.code == 200) {
  70. this.list = res.data.records
  71. this.total = res.data.total
  72. }
  73. })
  74. },
  75. handleUpload() {
  76. this.enclosureVisible = true
  77. this.$nextTick(() => {
  78. this.$refs.uploadEnclosure.init()
  79. })
  80. },
  81. handleDownload() {
  82. },
  83. handleBatchDelte() {
  84. if(this.selectionList.length <=0) {
  85. this.$message.error('请选择要删除的数据');
  86. return
  87. }
  88. this.$confirm('请确认是否删除所选择的数据!', '提示').then(() => {
  89. deleteEnclosureApi(this.ids).then(res => {
  90. if(res.code == 200) {
  91. this.queryParams.pageNum = 1;
  92. this.getList();
  93. this.$modal.msgSuccess("删除成功");
  94. }
  95. })
  96. })
  97. },
  98. handleView() {
  99. },
  100. handleDelete(row) {
  101. const id = row.id;
  102. this.$confirm('是否确认删除该数据?', "警告", {
  103. confirmButtonText: "确定",
  104. cancelButtonText: "取消",
  105. type: "warning"
  106. }).then(function() {
  107. return deleteEnclosureApi(id);
  108. }).then(() => {
  109. this.queryParams.pageNum = 1;
  110. this.getList();
  111. this.$modal.msgSuccess("删除成功");
  112. })
  113. },
  114. // 取消全选
  115. selectAll(selection) {
  116. if (selection.length == 0) {
  117. let list = this.selectedList.filter(item => !this.list.some(ele => ele.id === item.id));
  118. this.selectionList = list;
  119. }
  120. },
  121. handleSelectionChange(val) {
  122. this.selectionList = val;
  123. if(this.selectionList.length > 0) {
  124. let selectionIds = []
  125. for (let i = 0, len = this.selectionList.length; i < len; i++) {
  126. selectionIds.push(this.selectionList[i].id)
  127. }
  128. this.ids = selectionIds.join(',')
  129. }else {
  130. this.ids = ''
  131. }
  132. }
  133. }
  134. };
  135. </script>
  136. </script>
  137. <style>
  138. </style>