ReportList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="report-container">
  3. <!-- <el-row :gutter="2" v-for="report,index in reportList" :key="index">
  4. <el-col :span="6">
  5. <span>{{report.name}}</span>
  6. </el-col>
  7. <el-col :span="10">
  8. <span>{{report.file}}</span>
  9. </el-col>
  10. </el-row>-->
  11. <el-table :showHeader="true" :data="reportList" style="width: 100%">
  12. <el-table-column prop="type" label="报告类型" title="报告类型">
  13. <template slot-scope="scope">
  14. <span class="badge">{{scope.row.type}}</span>
  15. </template>
  16. </el-table-column>
  17. <el-table-column prop="file" sortable label="报告文件">
  18. <template slot-scope="scope">
  19. <span v-if="scope.row.content==null || scope.row.content==''">暂无文件</span>
  20. <a :href="scope.row.file" v-if="scope.row.content!=null" target="_blank"><i
  21. class="fa fa-file-text-o"></i> {{scope.row.content}}</a>
  22. </template>
  23. </el-table-column>
  24. <el-table-column align="right" label="操作">
  25. <template slot-scope="scope">
  26. <div class="btn btn-small btn-info" @click="handleEdit(scope.$index, scope.row)">查看详情</div>
  27. <div class="btn btn-small btn-danger" @click="handleDelete(scope.$index, scope.row)">删除</div>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'report-list',
  36. props: {
  37. reports: {},
  38. projectId: '',
  39. taskId: ''
  40. },
  41. data () {
  42. return {
  43. editIndex: -1,
  44. reportList: this.reports == null ? [] : this.reports,
  45. pid: this.projectId,
  46. tid: this.taskId,
  47. }
  48. },
  49. methods: {
  50. handleEdit (index, row) {
  51. if (this.tid == null) {
  52. this.$router.push({
  53. name: 'ProjectReport',
  54. params: {
  55. reportId: row.code,
  56. projectId: this.pid
  57. }
  58. })
  59. } else {
  60. this.$router.push({
  61. name: 'TaskReport',
  62. params: {
  63. reportId: row.code,
  64. projectId: this.pid,
  65. taskId: this.tid
  66. }
  67. })
  68. }
  69. // this.editIndex = index;
  70. },
  71. handleDelete (index, row) {
  72. this.reportList.splice(index, 1)
  73. },
  74. cancelEdit (index, row) {
  75. this.editIndex = -1
  76. },
  77. handleRemove (file, fileList) {
  78. console.log(file, fileList)
  79. },
  80. handleExceed (files, fileList) {
  81. this.$message.warning(
  82. `当前限制选择 1 个文件,本次选择了 ${
  83. files.length
  84. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  85. )
  86. },
  87. beforeRemove (file, fileList) {
  88. return this.$confirm(`确定移除 ${file.name}?`)
  89. },
  90. beforeFileUpload () {
  91. }
  92. },
  93. watch: {
  94. reports () {
  95. this.reportList = this.reports
  96. },
  97. projectId () {
  98. this.pid = this.projectId
  99. },
  100. taskId () {
  101. this.tid = this.taskId
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="less" scoped>
  107. .report-container {
  108. margin: 0 30px;
  109. }
  110. .el-row {
  111. margin-bottom: 20px;
  112. }
  113. </style>