scorpio 2 năm trước cách đây
mục cha
commit
d64ac7ed51
1 tập tin đã thay đổi với 47 bổ sung11 xóa
  1. 47 11
      src/layout/top.vue

+ 47 - 11
src/layout/top.vue

@@ -73,27 +73,36 @@
                 @keydown="searchTotal"
             >
             </el-input>
-            <el-button type='primary' class='ml-20' @click='searchTotal'>搜 索</el-button>
+            <el-button type='primary' class='ml-20' @click='searchTotal(1)'>搜 索</el-button>
           </div>
         </div>
-        <div  v-if="isAll === 1" class="flex flex-center mt-15">
-          <div  v-for="(item,index) in type" :key='item.key' class="flex flex-center tab">
+<!--        结果展示-->
+        <div  v-if="isAll === 1" class="flex flex-justify-center flex-align-start mt-15">
+          <div  v-for="(item,index) in type" :key='item.key' class="flex flex-center tab" @click="change(index,item.key)">
             <el-badge :value='item.count' :hidden='item.count === 0'>
-              <div :class="active === index ? 'tab-active' : ''" class="pointer"
-                   @click="change(index,item.key)">{{item.value }}
+              <div :class="active === index ? 'tab-active' : ''" class="pointer">{{item.value }}
               </div>
             </el-badge>
           </div>
         </div>
         <el-empty v-if="data && data.length === 0" description='暂无数据'/>
-        <div v-else class="mt-10" v-for="sub in data" :key='sub.id' style="margin-left: 34px;">
-          <span>{{ sub.title }}</span>
+        <div v-else style='min-height: 300px'>
+          <div  class="mt-10 border-bottom padding flex flex-center flex-justify-between" v-for="sub in data" :key='sub.id'>
+            <span v-if='params.searchType === "project" '>{{ sub.projectName }}</span>
+            <span v-else>{{ sub.title }}</span>
+            <el-button text type='primary' @click='detail(sub)'>详情</el-button>
+          </div>
         </div>
         <div class="full-width mt-10 flex flex-justify-end">
           <el-pagination small layout="prev, pager, next" :total="total"/>
         </div>
       </div>
     </el-dialog>
+    <el-image-viewer
+        v-if='showImage'
+        :url-list="imgList"
+        @close='showImage = false'
+    />
   </div>
 </template>
 
@@ -112,6 +121,8 @@ export default {
   },
   data () {
     return {
+      showImage: false,
+      imgList: [],
       show: false,
       keywords: '',
       active: 0,
@@ -141,8 +152,9 @@ export default {
       },
       data: [],
       total: '',
-      isAll: 0,
-      filterTypeName: '全部'
+      isAll: 1,
+      filterTypeName: '全部',
+      resultCount: 0
     }
   },
   created () {
@@ -177,7 +189,7 @@ export default {
         this.isAll = 0
         this.params.searchType = 'project'
         this.searchTotal()
-      } else if (res === '文') {
+      } else if (res === '文') {
         this.filterTypeName = res
         this.isAll = 0
         this.params.searchType = 'file'
@@ -212,7 +224,7 @@ export default {
       }
     },
     searchTotal (res) {
-      if (res.key === 'Enter') {
+      if (res.key === 'Enter' || res === 1) {
         this.getTotal()
         this.$api.project.totalSearch(this.params).then(res => {
           if (res.code === 200) {
@@ -223,13 +235,37 @@ export default {
       }
     },
     getTotal () {
+      this.resultCount = 0
       this.$api.project.total({ keyword: this.params.keyword }).then(res => {
         if (res.code === 200) {
           this.type[0].count = res.data.projectTotal
           this.type[1].count = res.data.fileTotal
           this.type[2].count = res.data.pictureTotal
+          this.type.forEach(sub => {
+            this.resultCount = this.resultCount + sub.count
+          })
         }
       })
+    },
+    detail (res) {
+      if (this.params.searchType === 'project') {
+        this.$api.project.projectInfo(res.projectId).then(res => {
+          if (res.code === 200) {
+            console.log(res)
+            this.$router.push({
+              path: '/home/details',
+              query: { id: res.data.id, type: '0', ownerId: res.data.createUser }
+            })
+          }
+        })
+        this.show = false
+      } else if (this.params.searchType === 'file') {
+        const routeData = this.$router.resolve({ path: '/home/file_detail', query: { id: res.fileId.replace('fileid-', '') } })
+        window.open(routeData.href, '_blank')
+      } else if (this.params.searchType === 'picture') {
+        this.imgList = [res.url]
+        this.showImage = true
+      }
     }
   }
 }