TechEnclosure.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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" v-if="userType == 'ENT_TECH' || userType == 'ENT_ADMIN_TECH'" v-hasRole="['ENT_ADMIN_TECH','ENT_TECH']">一键上传</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" v-if="userType == 'ENT_TECH' || userType == 'ENT_ADMIN_TECH'">批量删除</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)" v-if="userType == 'ENT_TECH' || userType == 'ENT_ADMIN_TECH'">删除</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. computed: {
  56. userType() {
  57. return this.$store.state.user.userType
  58. }
  59. },
  60. created() {
  61. this.id = this.$route.query.id || undefined;
  62. this.getData()
  63. },
  64. methods: {
  65. getData() {
  66. getProjectInfoApi(this.id).then(res => {
  67. let obj = res.data.techProject || {}
  68. this.dataId = obj.id //技术资料id
  69. this.getList()
  70. })
  71. },
  72. getList() {
  73. getEnclosureApi(this.attachType,this.dataId).then(res => {
  74. if(res.code == 200) {
  75. this.list = res.data.records
  76. this.total = res.data.total
  77. }
  78. })
  79. },
  80. handleUpload() {
  81. this.enclosureVisible = true
  82. this.$nextTick(() => {
  83. this.$refs.uploadEnclosure.init()
  84. })
  85. },
  86. handleDownload() {
  87. },
  88. handleBatchDelte() {
  89. if(this.selectionList.length <=0) {
  90. this.$message.error('请选择要删除的数据');
  91. return
  92. }
  93. this.$confirm('请确认是否删除所选择的数据!', '提示').then(() => {
  94. deleteEnclosureApi(this.ids).then(res => {
  95. if(res.code == 200) {
  96. this.queryParams.pageNum = 1;
  97. this.getList();
  98. this.$modal.msgSuccess("删除成功");
  99. }
  100. })
  101. })
  102. },
  103. handleView() {
  104. },
  105. handleDelete(row) {
  106. const id = row.id;
  107. this.$confirm('是否确认删除该数据?', "警告", {
  108. confirmButtonText: "确定",
  109. cancelButtonText: "取消",
  110. type: "warning"
  111. }).then(function() {
  112. return deleteEnclosureApi(id);
  113. }).then(() => {
  114. this.queryParams.pageNum = 1;
  115. this.getList();
  116. this.$modal.msgSuccess("删除成功");
  117. })
  118. },
  119. // 取消全选
  120. selectAll(selection) {
  121. if (selection.length == 0) {
  122. let list = this.selectedList.filter(item => !this.list.some(ele => ele.id === item.id));
  123. this.selectionList = list;
  124. }
  125. },
  126. handleSelectionChange(val) {
  127. this.selectionList = val;
  128. if(this.selectionList.length > 0) {
  129. let selectionIds = []
  130. for (let i = 0, len = this.selectionList.length; i < len; i++) {
  131. selectionIds.push(this.selectionList[i].id)
  132. }
  133. this.ids = selectionIds.join(',')
  134. }else {
  135. this.ids = ''
  136. }
  137. }
  138. }
  139. };
  140. </script>
  141. </script>
  142. <style>
  143. </style>