search.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div>
  3. <el-icon size="26" @click="show = true">
  4. <Search />
  5. </el-icon>
  6. <el-dialog
  7. v-model="show"
  8. title="文件搜索"
  9. width="860"
  10. :close-on-click-modal="false"
  11. @close="closeDialog"
  12. >
  13. <div class="flex flex-center flex-col padding" style="margin-top: -20px">
  14. <div class="full-width flex flex-center">
  15. <el-input
  16. v-model="searchForm.keyword"
  17. style="width: 100%"
  18. clearable
  19. placeholder="输入关键字进行文件搜索"
  20. @clear="clearList"
  21. @keyup.enter="searchList"
  22. />
  23. <base-button class="ml-20" @click="searchList" />
  24. </div>
  25. <div
  26. v-loading="loading"
  27. class="full-width mt-20 flex flex-align-start flex-col hide-scrollbar"
  28. style="min-height: 30vh; overflow-y: auto"
  29. >
  30. <div class="full-width" v-if="resultList && resultList.length === 0">
  31. <el-empty></el-empty>
  32. </div>
  33. <div
  34. v-else
  35. class="flex flex-align-center border-bottom full-width"
  36. v-for="item in resultList"
  37. :key="item.id"
  38. @click="goFoleDetail(item)"
  39. >
  40. <img
  41. v-if="['doc', 'docx'].includes(item.suffix)"
  42. src="../../../assets/svg/folder/doc.svg"
  43. class="icon1"
  44. />
  45. <img
  46. v-else-if="['png', 'jpg', 'jpeg'].includes(item.suffix)"
  47. src="../../../assets/svg/folder/other.svg"
  48. class="icon1"
  49. />
  50. <img
  51. v-else-if="item.suffix === 'pdf'"
  52. src="../../../assets/svg/folder/pdf.svg"
  53. class="icon1"
  54. />
  55. <img
  56. v-else-if="item.suffix === 'xlsx'"
  57. src="../../../assets/svg/folder/xls.svg"
  58. class="icon1"
  59. />
  60. <span class="bold ml-10">{{ item.title }}</span>
  61. </div>
  62. </div>
  63. <div class="flex flex-align-start mt-15 border-top full-width">
  64. <span class="grey-9 mt-15"
  65. >共计查询到<span class="ml-5 mr-5 font-16 bold main-color">{{
  66. total ? total : 0
  67. }}</span
  68. >个相关文件</span
  69. >
  70. </div>
  71. </div>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script>
  76. import baseButton from '@/components/base-button.vue'
  77. export default {
  78. components: { baseButton },
  79. props: {
  80. stageId: {
  81. type: String,
  82. required: true,
  83. default: ''
  84. },
  85. folderId: {
  86. type: String,
  87. required: true,
  88. default: ''
  89. }
  90. },
  91. watch: {
  92. stageId: {
  93. handler(val) {
  94. this.searchForm.stageId = val
  95. },
  96. immediate: true
  97. },
  98. folderId: {
  99. handler(val) {
  100. this.searchForm.fileFolderId = val
  101. },
  102. immediate: true
  103. }
  104. },
  105. data() {
  106. return {
  107. loading: false,
  108. show: false,
  109. searchForm: {
  110. fileFolderId: '',
  111. keyword: '',
  112. stageId: ''
  113. },
  114. resultList: [],
  115. total: ''
  116. }
  117. },
  118. methods: {
  119. searchList() {
  120. this.loading = true
  121. setTimeout(() => {
  122. this.$api.resource.fileSearch(this.searchForm).then(res => {
  123. if (res.code === 200) {
  124. this.loading = false
  125. this.resultList = res.data
  126. this.total = res.data.length
  127. } else {
  128. this.$message.error(res.msg)
  129. }
  130. })
  131. }, 800)
  132. },
  133. clearList() {
  134. this.resultList = []
  135. this.total = 0
  136. },
  137. goFoleDetail(item) {
  138. const routeData = this.$router.resolve(
  139. '/home/file_detail?id=' + item.fileId
  140. )
  141. window.open(routeData.href, '_blank')
  142. this.show = false
  143. },
  144. closeDialog() {
  145. this.searchForm.keyword = ''
  146. this.resultList = []
  147. this.total = 0
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .icon1 {
  154. width: 50px;
  155. height: 50px;
  156. }
  157. </style>