Browse Source

前台收藏搜索页接口联调、后台搜索页接口联调

chaihaorui 1 year ago
parent
commit
76f7ad676e

+ 18 - 2
src/api/homepage/search.js

@@ -1,4 +1,4 @@
1
-// 前台
1
+// 前台搜索
2 2
 import axios from "@/util/ajax";
3 3
 
4 4
 export default {
@@ -9,5 +9,21 @@ export default {
9 9
     // 获取查询数据列表
10 10
     searchData(params) {
11 11
         return axios.get('/resourceDirectory/searchEsData', { params });
12
-    }
12
+    },
13
+    // 搜索服务各目录下数据量
14
+    menuStatNum(params) {
15
+        return axios.get('/resourceDirectory/searchEsMenuStatisticsNum', { params });
16
+    },
17
+    // 取消收藏
18
+    deleteCollect(params) {
19
+        return axios.post('/resourceDirectory/deleteCollect', params);
20
+    },
21
+    // 收藏列表查询
22
+    collectList(params) {
23
+        return axios.get('/resourceDirectory/collectList', { params });
24
+    },
25
+    //收藏服务各目录下数据量
26
+    collectMenuStatNum(params) {
27
+        return axios.get('/resourceDirectory/collectMenuStatisticsNum', { params });
28
+    },
13 29
 }

+ 13 - 0
src/api/index/search.js

@@ -0,0 +1,13 @@
1
+// 后台搜索页
2
+import axios from "@/util/ajax";
3
+
4
+export default {
5
+    // 批量上架
6
+    batchUpShelves(params) {
7
+        return axios.post('/resourceDirectory/batchUpShelves', params);
8
+    },
9
+    // 批量下架
10
+    batchDownShelves(params) {
11
+        return axios.post('/resourceDirectory/batchDownShelves', params);
12
+    }
13
+}

+ 136 - 33
src/pages/homepage/components/searchPage.vue

@@ -9,7 +9,7 @@
9 9
       </el-input>
10 10
     </div>
11 11
     <el-tabs class="bottom-card" v-model="activeName" @tab-click="handleClick">
12
-      <el-tab-pane :key="item.id" v-for="item in initTabList()" :label="item.name" :name="item.id">
12
+      <el-tab-pane :key="item.id" v-for="item in tabList" :label="item.name" :name="item.id">
13 13
         <div class="flex">
14 14
           <div class="tree-wrap">
15 15
             <el-button-group v-if="activeName === 'fourth'">
@@ -33,7 +33,7 @@
33 33
                   实体名称:{{item.logicTbName}}
34 34
                 </p>
35 35
                 <div class="right">
36
-                  <img v-if="item.isCollect" src="../../../assets/image/u9765.svg" alt="">
36
+                  <img v-if="pageType === 'collect'" src="../../../assets/image/u9765.svg" alt="">
37 37
                 </div>
38 38
               </div>
39 39
               <el-row v-if="activeName === 'first' || activeName === 'second'" style="color: rgb(91,91,91);line-height: 40px;">
@@ -48,13 +48,18 @@
48 48
                 </el-col>
49 49
               </el-row>
50 50
               <!-- 指标编码块 -->
51
-              <p v-if="activeName === 'third'" class="title">
52
-                <span  @click.stop="">
53
-                  <el-checkbox v-if="pageType === 'collect'" class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
54
-                </span>
55
-                <img src="../../../assets/image/u652.svg" alt="">
56
-                指标名称:{{item.name}}
57
-              </p>
51
+              <div v-if="activeName === 'third'" class="title title-block clearfix">
52
+                <p class="left">
53
+                  <span  @click.stop="">
54
+                    <el-checkbox v-if="pageType === 'collect'" class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
55
+                  </span>
56
+                  <img src="../../../assets/image/u652.svg" alt="">
57
+                  指标名称:{{item.name}}
58
+                </p>
59
+                <div class="right">
60
+                  <img v-if="pageType === 'collect'" src="../../../assets/image/u9765.svg" alt="">
61
+                </div>
62
+              </div>
58 63
               <el-row v-if="activeName === 'third'" style="color: rgb(91,91,91);line-height: 40px;">
59 64
                 <el-col :span="12">
60 65
                   所属目录:{{item.l1}}
@@ -74,17 +79,22 @@
74 79
                 </el-col>
75 80
               </el-row>
76 81
               <!-- 服务块 -->
77
-              <p v-if="activeName === 'fourth'" class="title">
78
-                <span  @click.stop="">
79
-                  <el-checkbox v-if="pageType === 'collect'"  class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
80
-                </span>
81
-                <img src="../../../assets/image/u652.svg" alt="">
82
-                <span v-if="serviceType === 'API'">序号:{{item.id}}</span>
83
-                <span v-if="serviceType === 'MQ'">Topic名称:{{item.name}}</span>
84
-              </p>
82
+              <div v-if="activeName === 'fourth'" class="title title-block clearfix">
83
+                <p class="left">
84
+                  <span  @click.stop="">
85
+                    <el-checkbox v-if="pageType === 'collect'"  class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
86
+                  </span>
87
+                  <img src="../../../assets/image/u652.svg" alt="">
88
+                  <span v-if="serviceType === 'API'">序号:{{item.id}}</span>
89
+                  <span v-if="serviceType === 'MQ'">Topic名称:{{item.name}}</span>
90
+                </p>
91
+                <div class="right">
92
+                  <img v-if="pageType === 'collect'" src="../../../assets/image/u9765.svg" alt="">
93
+                </div>
94
+              </div>
85 95
               <el-row v-if="activeName === 'fourth'" style="color: rgb(91,91,91);line-height: 40px;">
86 96
                 <el-col v-if="serviceType === 'API'" :span="12">
87
-                  API名称:{{item.NAME}}
97
+                  API名称:{{item.name}}
88 98
                 </el-col>
89 99
                 <el-col v-if="serviceType === 'MQ'" :span="12">
90 100
                   集成应用:{{item.appName}}
@@ -155,25 +165,27 @@ export default {
155 165
       total: 0,
156 166
       serviceType: 'API', // API-API服务,MQ-消息队列
157 167
       pageType: this.$route.query.pageType || 'all', // all-全量搜索,theme-只有主题库搜索,topic-只有专题库搜索,index-只有指标搜索,service-只有服务搜索,collect-我的收藏全量搜索
158
-      menuId: undefined
168
+      menuId: undefined,
169
+      tabList: [],
170
+      selectIds: []
159 171
     };
160 172
   },
161 173
   created() {},
162 174
   mounted() {
163 175
     document.documentElement.scrollTop = 0;
176
+    this.initTabList()
164 177
     this.getMenu()
165 178
     this.getSearchData()
166 179
   },
167 180
   methods: {
168 181
     handleClick(tab, event) {
169 182
       this.activeName = tab.name;
170
-      this.menuId = undefined
171
-      this.currentPage = 1
183
+      this.resetValue()
172 184
       this.getMenu()
173 185
       this.getSearchData()
174 186
     },
175 187
     handleNodeClick(data) {
176
-      console.log(data);
188
+      // console.log(data);
177 189
       this.menuId = data.id
178 190
       this.getSearchData()
179 191
     },
@@ -219,10 +231,34 @@ export default {
219 231
     },
220 232
     // 批量取消收藏
221 233
     batchCancelCollect() {
222
-
234
+      const params = {resourceType: 'theme', resourceIds: this.selectIds,}
235
+      if (this.activeName === 'second') {
236
+        params.resourceType = 'specialSubject'
237
+      }
238
+      if (this.activeName === 'third') {
239
+        params.resourceType = 'index'
240
+      }
241
+      if (this.activeName === 'fourth') {
242
+        params.resourceType = 'service'
243
+      }
244
+      api.deleteCollect(params).then(res => {
245
+        if (res.success) {
246
+          this.$message({
247
+            message: '取消成功!',
248
+            type: 'success'
249
+          })
250
+          this.selectIds = []
251
+          this.getSearchData()
252
+        }
253
+      })
223 254
     },
224 255
     checkboxChange(e, id) {
225
-      console.log('e', e, 'id', id)
256
+      if (e) {
257
+        this.selectIds.push(id)
258
+      } else {
259
+        this.selectIds = this.selectIds.filter(item => item !== id)
260
+      }
261
+      console.log('selectIds', this.selectIds)
226 262
     },
227 263
     handleDown() {
228 264
       console.log('down')
@@ -253,7 +289,7 @@ export default {
253 289
         tabList = [{ name: '服务',id: 'fourth',num: 0 }]
254 290
         this.activeName = 'fourth'
255 291
       }
256
-      return tabList
292
+      this.tabList = tabList
257 293
     },
258 294
     getMenu() {
259 295
       const params = {resourceType: 'theme'}
@@ -271,11 +307,13 @@ export default {
271 307
           this.data = res.data
272 308
         }
273 309
       })
310
+      if (this.activeName === 'fourth') {
311
+        this.getServiceStatNum()
312
+      }
274 313
     },
275 314
     serviceBtnClick(key) {
276 315
       this.serviceType = key
277
-      this.menuId = undefined
278
-      this.currentPage = 1
316
+      this.resetValue()
279 317
       this.getMenu()
280 318
       this.getSearchData()
281 319
     },
@@ -283,7 +321,8 @@ export default {
283 321
       const params = {
284 322
         resourceType: 'theme', pageNum: this.currentPage, 
285 323
         pageSize: this.pageSize, menuId: this.menuId,
286
-        keyword: this.searchWords
324
+        keyword: this.searchWords,
325
+        shelvesType: '1'
287 326
       }
288 327
       if (this.$route.query.pageType === 'topic' || this.activeName === 'second') {
289 328
         params.resourceType = 'specialSubject'
@@ -294,12 +333,76 @@ export default {
294 333
       if (this.$route.query.pageType === 'service' || this.activeName === 'fourth') {
295 334
         params.resourceType = this.serviceType === 'API' ? 'api' : 'mqs'
296 335
       }
297
-      api.searchData(params).then(res => {
298
-        if(res.success) {
299
-          this.total = res.data.total
300
-          this.list = res.data.records
336
+      if (this.pageType === 'collect') {
337
+        params.shelvesType = undefined
338
+        params.keyword = undefined
339
+        params.resourceName = this.searchWords
340
+        api.collectList(params).then(res => {
341
+          if(res.success) {
342
+            this.total = res.data.total
343
+            this.list = []
344
+            res.data.records.map((item, index) => {
345
+              const newItem = {...item}
346
+              if (this.selectIds.indexOf(item.id) !== -1) {
347
+                newItem.checked = true
348
+              } else {
349
+                newItem.checked = false
350
+              }
351
+              this.list.push(newItem)
352
+            })
353
+          }
354
+        })
355
+      } else {
356
+        api.searchData(params).then(res => {
357
+          if(res.success) {
358
+            this.total = res.data.total
359
+            this.list = []
360
+            res.data.records.map((item, index) => {
361
+              const newItem = {...item}
362
+              if (this.selectIds.indexOf(item.id) !== -1) {
363
+                newItem.checked = true
364
+              } else {
365
+                newItem.checked = false
366
+              }
367
+              this.list.push(newItem)
368
+            })
369
+          }
370
+        })
371
+      }
372
+    },
373
+    getServiceStatNum() {
374
+      let params = {resourceType: 'api', shelvesType: '1'}
375
+      if (this.serviceType === 'MQ') {
376
+        params.resourceType = 'mqs'
377
+      }
378
+      if (this.pageType === 'collect') {
379
+        params.shelvesType = undefined
380
+        api.collectMenuStatNum(params).then(res => {
381
+          this.handleMenuStatNumRes(res)
382
+        })
383
+      } else {
384
+        api.menuStatNum(params).then(res => {
385
+          this.handleMenuStatNumRes(res)
386
+        })
387
+      }
388
+    },
389
+    handleMenuStatNumRes(res) {
390
+      if (res.success) {
391
+          this.data.map((item, index) => {
392
+            const findObj = res.data.find(fItem => fItem.menuId === item.id)
393
+            if (findObj) {
394
+              item.name = `${item.name}(${findObj.num})`
395
+            } else {
396
+              item.name = `${item.name}(0)`
397
+            }
398
+          })
399
+          // console.log('this.data', this.data)
301 400
         }
302
-      })
401
+    },
402
+    resetValue() {
403
+      this.selectIds = []
404
+      this.menuId = undefined
405
+      this.currentPage = 1
303 406
     }
304 407
   }
305 408
 };

+ 242 - 160
src/pages/index/components/searchPage.vue

@@ -13,8 +13,8 @@
13 13
         <div class="flex">
14 14
           <div class="tree-wrap">
15 15
             <el-button-group v-if="activeName === 'fourth'">
16
-              <el-button :type="serviceType === 'API' ? 'primary' : ''" @click="serviceType = 'API'" size="small">API服务</el-button>
17
-              <el-button :type="serviceType === 'MQ' ? 'primary' : ''" @click="serviceType = 'MQ'" size="small">消息队列</el-button>
16
+              <el-button :type="serviceType === 'API' ? 'primary' : ''" @click="() => serviceBtnClick('API')" size="small">API服务</el-button>
17
+              <el-button :type="serviceType === 'MQ' ? 'primary' : ''" @click="() => serviceBtnClick('MQ')" size="small">消息队列</el-button>
18 18
             </el-button-group>
19 19
             <div>{{item.name}}</div>
20 20
             <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
@@ -24,7 +24,8 @@
24 24
               <el-button :type="'primary'" @click="batchListing" size="small">批量上架</el-button>
25 25
               <el-button :type="'primary'" @click="batchOffShelf" size="small">批量下架</el-button>
26 26
             </div>
27
-            <div :class="getCardClass()" v-for="(item, idx) in list" :key="idx" @click="jumpToDetailPage(item.id)">
27
+            <div v-if="list.length === 0" class="empty-block">暂无数据</div>
28
+            <div v-else :class="getCardClass()" v-for="(item, idx) in list" :key="idx" @click="jumpToDetailPage(item.id)">
28 29
               <!-- 主题库和专题库块 -->
29 30
               <div v-if="activeName === 'first' || activeName === 'second'" class="title title-block clearfix">
30 31
                 <p class="left">
@@ -35,22 +36,22 @@
35 36
                   实体名称:{{item.logicTbName}}
36 37
                 </p>
37 38
                 <div class="right">
38
-                  <span v-if="item.isListing" class="right-item">
39
+                  <span v-if="item.shelvesType" class="right-item">
39 40
                     <img src="../../../assets/image/u1723.png" alt="">
40 41
                     已上架
41 42
                   </span>
42 43
                   <span @click.stop="">
43
-                    <span v-if="!item.isListing" class="active right-item"  @click="handleUp(item.id)">
44
+                    <span v-if="!item.shelvesType" class="active right-item"  @click="handleUp(item.id)">
44 45
                       <img src="../../../assets/image/u1723.png" alt="">
45 46
                       上架
46 47
                     </span>
47 48
                   </span>
48
-                  <span v-if="!item.isListing"  class="right-item">
49
+                  <span v-if="!item.shelvesType"  class="right-item">
49 50
                     <img src="../../../assets/image/u1720.png" alt="">
50 51
                     已下架
51 52
                   </span>
52 53
                   <span @click.stop="">
53
-                    <span v-if="item.isListing" class="active right-item" @click="handleDown(item.id)">
54
+                    <span v-if="item.shelvesType" class="active right-item" @click="handleDown(item.id)">
54 55
                       <img src="../../../assets/image/u1720.png" alt="">
55 56
                       下架
56 57
                     </span>
@@ -58,27 +59,51 @@
58 59
                 </div>
59 60
               </div>
60 61
               <el-row v-if="activeName === 'first' || activeName === 'second'" style="color: rgb(91,91,91);line-height: 40px;">
61
-                <el-col :span="12">
62
+                <el-col :span="12" class="text-overflow" :title="item.tbName">
62 63
                   英文名称:{{item.tbName}}
63 64
                 </el-col>
64 65
                 <el-col :span="12">
65 66
                   更新时间:{{item.updateTime}}
66 67
                 </el-col>
67 68
                 <el-col :span="12">
68
-                  所属主题:{{item.topic}}
69
+                  所属主题:{{item.l1}}
69 70
                 </el-col>
70 71
               </el-row>
71 72
               <!-- 指标编码块 -->
72
-              <p v-if="activeName === 'third'" class="title">
73
-                <span  @click.stop="">
74
-                  <el-checkbox class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
75
-                </span>
76
-                <img src="../../../assets/image/u652.svg" alt="">
77
-                指标名称:{{item.logicTbName}}
78
-              </p>
73
+              <div v-if="activeName === 'third'" class="title title-block clearfix">
74
+                <p class="left">
75
+                  <span  @click.stop="">
76
+                    <el-checkbox class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
77
+                  </span>
78
+                  <img src="../../../assets/image/u652.svg" alt="">
79
+                  指标名称:{{item.name}}
80
+                </p>
81
+                <div class="right">
82
+                  <span v-if="item.shelvesType" class="right-item">
83
+                    <img src="../../../assets/image/u1723.png" alt="">
84
+                    已上架
85
+                  </span>
86
+                  <span @click.stop="">
87
+                    <span v-if="!item.shelvesType" class="active right-item"  @click="handleUp(item.id)">
88
+                      <img src="../../../assets/image/u1723.png" alt="">
89
+                      上架
90
+                    </span>
91
+                  </span>
92
+                  <span v-if="!item.shelvesType"  class="right-item">
93
+                    <img src="../../../assets/image/u1720.png" alt="">
94
+                    已下架
95
+                  </span>
96
+                  <span @click.stop="">
97
+                    <span v-if="item.shelvesType" class="active right-item" @click="handleDown(item.id)">
98
+                      <img src="../../../assets/image/u1720.png" alt="">
99
+                      下架
100
+                    </span>
101
+                  </span>
102
+                </div>
103
+              </div>
79 104
               <el-row v-if="activeName === 'third'" style="color: rgb(91,91,91);line-height: 40px;">
80 105
                 <el-col :span="12">
81
-                  所属目录:{{item.tbName}}
106
+                  所属目录:{{item.l1}}
82 107
                 </el-col>
83 108
                 <el-col :span="12">
84 109
                   更新时间:{{item.updateTime}}
@@ -86,49 +111,81 @@
86 111
               </el-row>
87 112
               <el-row v-if="activeName === 'third'" style="color: rgb(91,91,91);line-height: 40px;">
88 113
                 <el-col :span="12">
89
-                  所属部门:{{item.depart}}
114
+                  所属部门:{{item.ownerDepartment}}
90 115
                 </el-col>
91 116
               </el-row>
92 117
               <el-row v-if="activeName === 'third'" style="color: rgb(91,91,91);line-height: 40px;">
93 118
                 <el-col :span="12">
94
-                  指标编码:{{item.indexCode}}
119
+                  指标编码:{{item.code}}
95 120
                 </el-col>
96 121
               </el-row>
97 122
               <!-- 服务块 -->
98
-              <p v-if="activeName === 'fourth'" class="title">
99
-                <span  @click.stop="">
100
-                  <el-checkbox class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
101
-                </span>
102
-                <img src="../../../assets/image/u652.svg" alt="">
103
-                {{ serviceType === 'API' ? '序号:' : 'Topic名称:'}}{{item.logicTbName}}
104
-              </p>
123
+              <div v-if="activeName === 'fourth'" class="title title-block clearfix">
124
+                <p class="left">
125
+                  <span  @click.stop="">
126
+                    <el-checkbox  class="checkbox" v-model="item.checked" @click.stop="" @change="(e) => checkboxChange(e, item.id)"></el-checkbox>
127
+                  </span>
128
+                  <img src="../../../assets/image/u652.svg" alt="">
129
+                  <span v-if="serviceType === 'API'">序号:{{item.id}}</span>
130
+                  <span v-if="serviceType === 'MQ'">Topic名称:{{item.name}}</span>
131
+                </p>
132
+                <div class="right">
133
+                  <span v-if="item.shelvesType" class="right-item">
134
+                    <img src="../../../assets/image/u1723.png" alt="">
135
+                    已上架
136
+                  </span>
137
+                  <span @click.stop="">
138
+                    <span v-if="!item.shelvesType" class="active right-item"  @click="handleUp(item.id)">
139
+                      <img src="../../../assets/image/u1723.png" alt="">
140
+                      上架
141
+                    </span>
142
+                  </span>
143
+                  <span v-if="!item.shelvesType"  class="right-item">
144
+                    <img src="../../../assets/image/u1720.png" alt="">
145
+                    已下架
146
+                  </span>
147
+                  <span @click.stop="">
148
+                    <span v-if="item.shelvesType" class="active right-item" @click="handleDown(item.id)">
149
+                      <img src="../../../assets/image/u1720.png" alt="">
150
+                      下架
151
+                    </span>
152
+                  </span>
153
+                </div>
154
+              </div>
105 155
               <el-row v-if="activeName === 'fourth'" style="color: rgb(91,91,91);line-height: 40px;">
106
-                <el-col :span="12">
107
-                  {{ serviceType === 'API' ? 'API名称:' : '集成应用:'}}{{item.tbName}}
156
+                <el-col v-if="serviceType === 'API'" :span="12">
157
+                  API名称:{{item.NAME}}
108 158
                 </el-col>
109
-                <el-col :span="12">
110
-                  {{ serviceType === 'API' ? '更新时间:' : '提供部门:'}}{{item.updateTime}}
159
+                <el-col v-if="serviceType === 'MQ'" :span="12">
160
+                  集成应用:{{item.appName}}
111 161
                 </el-col>
112
-              </el-row>
113
-              <el-row v-if="activeName === 'fourth'" style="color: rgb(91,91,91);line-height: 40px;">
114
-                <el-col :span="12">
115
-                  {{ serviceType === 'API' ? 'API描述:' : 'topic分区数:'}}{{item.apiDesc}}
162
+                <el-col v-if="serviceType === 'API'" :span="12">
163
+                  更新时间:{{item.updateTime}}
116 164
                 </el-col>
117
-                <el-col :span="12">
118
-                  {{ serviceType === 'API' ? '提供部门:' : '使用部门:'}}{{item.depart}}
165
+                <el-col v-if="serviceType === 'MQ'" :span="12">
166
+                  topic分区数:{{item.partitions}}
119 167
                 </el-col>
120 168
               </el-row>
121 169
               <el-row v-if="activeName === 'fourth'" style="color: rgb(91,91,91);line-height: 40px;">
122
-                <el-col :span="12">
123
-                  {{ serviceType === 'API' ? '服务归属系统名称:' : '副本数:'}}{{item.sysName}}
170
+                <el-col v-if="serviceType === 'API'" :span="12">
171
+                  API描述:{{item.remark}}
124 172
                 </el-col>
125
-                <el-col :span="12">
126
-                  {{ serviceType === 'API' ? '使用部门:' : '老化时间(小时):'}}{{item.useDepart}}
173
+                <el-col v-if="serviceType === 'MQ'" :span="12">
174
+                  老化时间(小时):{{item.retentionTime}}
175
+                </el-col>
176
+                <el-col v-if="serviceType === 'API'" :span="12">
177
+                  使用系统:{{item.apiBindedAppNames}}
178
+                </el-col>
179
+                <el-col v-if="serviceType === 'MQ'" :span="12">
180
+                  副本数:{{item.replication}}
127 181
                 </el-col>
128 182
               </el-row>
129
-              <el-row v-if="activeName === 'fourth' && serviceType === 'MQ'" style="color: rgb(91,91,91);line-height: 40px;">
130
-                <el-col :span="12">
131
-                  描述:{{item.desc}}
183
+              <el-row v-if="activeName === 'fourth'" style="color: rgb(91,91,91);line-height: 40px;">
184
+                <el-col v-if="serviceType === 'API'" :span="12">
185
+                  服务归属系统名称:{{item.romaAppName}}
186
+                </el-col>
187
+                <el-col v-if="serviceType === 'MQ'" :span="12">
188
+                  描述:{{item.description}}
132 189
                 </el-col>
133 190
               </el-row>
134 191
             </div>
@@ -150,6 +207,8 @@
150 207
 </template>
151 208
 
152 209
 <script>
210
+import api from "@/api/homepage/search.js";
211
+import backApi from "@/api/index/search.js";
153 212
 export default {
154 213
   data() {
155 214
     return {
@@ -174,140 +233,45 @@ export default {
174 233
           id: 'fourth',
175 234
           num: 0}
176 235
       ],
177
-      data: [{
178
-        label: '一级 1',
179
-        children: [{
180
-          label: '二级 1-1',
181
-          children: [{
182
-            label: '三级 1-1-1'
183
-          }]
184
-        }]
185
-      }, {
186
-        label: '一级 2',
187
-        children: [{
188
-          label: '二级 2-1',
189
-          children: [{
190
-            label: '三级 2-1-1'
191
-          }]
192
-        }, {
193
-          label: '二级 2-2',
194
-          children: [{
195
-            label: '三级 2-2-1'
196
-          }]
197
-        }]
198
-      }, {
199
-        label: '一级 3',
200
-        children: [{
201
-          label: '二级 3-1',
202
-          children: [{
203
-            label: '三级 3-1-1'
204
-          }]
205
-        }, {
206
-          label: '二级 3-2',
207
-          children: [{
208
-            label: '三级 3-2-1'
209
-          }]
210
-        }]
211
-      }],
236
+      data: [],
212 237
       defaultProps: {
213
-        children: 'children',
214
-        label: 'label'
238
+        children: 'childrens',
239
+        label: 'name'
215 240
       },
216
-      list: [
217
-        {
218
-          id: '111',
219
-          logicTbName: '周期性维护计划注销信息',
220
-          tbName: 'periodic_maintenance_plan_cancel',
221
-          updateTime: '2022-07-06 09:23:44',
222
-          topic: '人力资源管理',
223
-          indexCode: 'ZB001080',
224
-          depart: 'sunpu',
225
-          apiDesc: 'degegwgwgwg',
226
-          useDepart: '部门XXX',
227
-          sysName: 'app-tfs',
228
-          desc: '暂无',
229
-          isListing: true
230
-        },
231
-        {
232
-          id: '222',
233
-          logicTbName: '周期性维护计划注销信息',
234
-          tbName: 'periodic_maintenance_plan_cancel',
235
-          updateTime: '2022-07-06 09:23:44',
236
-          topic: '人力资源管理',
237
-          indexCode: 'ZB001080',
238
-          depart: 'sunpu',
239
-          apiDesc: 'degegwgwgwg',
240
-          useDepart: '部门XXX',
241
-          sysName: 'app-tfs',
242
-          desc: '暂无',
243
-          isListing: false
244
-        },
245
-        {
246
-          id: '333',
247
-          logicTbName: '周期性维护计划注销信息',
248
-          tbName: 'periodic_maintenance_plan_cancel',
249
-          updateTime: '2022-07-06 09:23:44',
250
-          topic: '人力资源管理',
251
-          indexCode: 'ZB001080',
252
-          depart: 'sunpu',
253
-          apiDesc: 'degegwgwgwg',
254
-          useDepart: '部门XXX',
255
-          sysName: 'app-tfs',
256
-          desc: '暂无',
257
-          isListing: true
258
-        },
259
-        {
260
-          id: '444',
261
-          logicTbName: '周期性维护计划注销信息',
262
-          tbName: 'periodic_maintenance_plan_cancel',
263
-          updateTime: '2022-07-06 09:23:44',
264
-          topic: '人力资源管理',
265
-          indexCode: 'ZB001080',
266
-          depart: 'sunpu',
267
-          apiDesc: 'degegwgwgwg',
268
-          useDepart: '部门XXX',
269
-          sysName: 'app-tfs',
270
-          desc: '暂无',
271
-          isListing: true
272
-        },
273
-        {
274
-          id: '555',
275
-          logicTbName: '周期性维护计划注销信息',
276
-          tbName: 'periodic_maintenance_plan_cancel',
277
-          updateTime: '2022-07-06 09:23:44',
278
-          topic: '人力资源管理',
279
-          indexCode: 'ZB001080',
280
-          depart: 'sunpu',
281
-          apiDesc: 'degegwgwgwg',
282
-          useDepart: '部门XXX',
283
-          sysName: 'app-tfs',
284
-          desc: '暂无',
285
-          isListing: true
286
-        },
287
-      ],
241
+      list: [],
288 242
       currentPage: 1,
289 243
       pageSize: 5,
290
-      total: 1000,
244
+      total: 0,
291 245
       serviceType: 'API', // API-API服务,MQ-消息队列
292 246
       pageType: this.$route.query.pageType || 'all', // all-全量搜索,theme-只有主题库搜索,topic-只有专题库搜索,index-只有指标搜索,service-只有服务搜索,background-后台管理搜索
247
+      menuId: undefined,
248
+      selectIds: []
293 249
     };
294 250
   },
295 251
   created() {},
296 252
   mounted() {
297 253
     document.documentElement.scrollTop = 0;
254
+    this.getMenu()
255
+    this.getSearchData()
298 256
   },
299 257
   methods: {
300 258
     handleClick(tab, event) {
301 259
       this.activeName = tab.name;
260
+      this.resetValue()
261
+      this.getMenu()
262
+      this.getSearchData()
302 263
     },
303 264
     handleNodeClick(data) {
304
-      console.log(data);
265
+      // console.log(data);
266
+      this.menuId = data.id
267
+      this.getSearchData()
305 268
     },
306 269
     handleSizeChange(val) {
307 270
       console.log(`每页 ${val} 条`);
308 271
     },
309 272
     handleCurrentChange(val) {
310 273
       console.log(`当前页: ${val}`);
274
+      this.getSearchData()
311 275
     },
312 276
     jumpToDetailPage(id) {
313 277
       let type = 'theme'
@@ -330,7 +294,7 @@ export default {
330 294
       });
331 295
     },
332 296
     handleSearch() {
333
-      
297
+      this.getSearchData()
334 298
     },
335 299
     getCardClass() {
336 300
       let ret = 'entity-card'
@@ -342,18 +306,136 @@ export default {
342 306
       }
343 307
       return ret
344 308
     },
345
-    // 批量上架
346
-    batchListing() {},
347
-    // 批量下架
348
-    batchOffShelf() {},
349 309
     checkboxChange(e, id) {
350
-      console.log('e', e, 'id', id)
310
+      if (e) {
311
+        this.selectIds.push(id)
312
+      } else {
313
+        this.selectIds = this.selectIds.filter(item => item !== id)
314
+      }
315
+      console.log('selectIds', this.selectIds)
351 316
     },
352 317
     handleDown() {
353 318
       console.log('down')
354 319
     },
355 320
     handleUp() {
356 321
       console.log('up')
322
+    },
323
+    getMenu() {
324
+      const params = {resourceType: 'theme'}
325
+      if (this.$route.query.pageType === 'topic' || this.activeName === 'second') {
326
+        params.resourceType = 'specialSubject'
327
+      }
328
+      if (this.$route.query.pageType === 'index' || this.activeName === 'third') {
329
+        params.resourceType = 'index'
330
+      }
331
+      if (this.$route.query.pageType === 'service' || this.activeName === 'fourth') {
332
+        params.resourceType = 'service'
333
+      }
334
+      api.menuInfo(params).then(res => {
335
+        if (res.success) {
336
+          this.data = res.data
337
+        }
338
+      })
339
+      if (this.activeName === 'fourth') {
340
+        this.getServiceStatNum()
341
+      }
342
+    },
343
+    serviceBtnClick(key) {
344
+      this.serviceType = key
345
+      this.resetValue()
346
+      this.getMenu()
347
+      this.getSearchData()
348
+    },
349
+    getSearchData() {
350
+      const params = {
351
+        resourceType: 'theme', pageNum: this.currentPage, 
352
+        pageSize: this.pageSize, menuId: this.menuId,
353
+        keyword: this.searchWords
354
+      }
355
+      if (this.$route.query.pageType === 'topic' || this.activeName === 'second') {
356
+        params.resourceType = 'specialSubject'
357
+      }
358
+      if (this.$route.query.pageType === 'index' || this.activeName === 'third') {
359
+        params.resourceType = 'index'
360
+      }
361
+      if (this.$route.query.pageType === 'service' || this.activeName === 'fourth') {
362
+        params.resourceType = this.serviceType === 'API' ? 'api' : 'mqs'
363
+      }
364
+      api.searchData(params).then(res => {
365
+        if(res.success) {
366
+          this.total = res.data.total
367
+          this.list = []
368
+          res.data.records.map((item, index) => {
369
+            const newItem = {...item}
370
+            if (this.selectIds.indexOf(item.id) !== -1) {
371
+              newItem.checked = true
372
+            } else {
373
+              newItem.checked = false
374
+            }
375
+            this.list.push(newItem)
376
+          })
377
+          console.log('list', this.list)
378
+        }
379
+      })
380
+    },
381
+    getServiceStatNum() {
382
+      let params = {resourceType: 'api'}
383
+      if (this.serviceType === 'MQ') {
384
+        params.resourceType = 'mqs'
385
+      }
386
+      api.menuStatNum(params).then(res => {
387
+        if (res.success) {
388
+          this.data.map((item, index) => {
389
+            const findObj = res.data.find(fItem => fItem.menuId === item.id)
390
+            if (findObj) {
391
+              item.name = `${item.name}(${findObj.docCount})`
392
+            } else {
393
+              item.name = `${item.name}(0)`
394
+            }
395
+          })
396
+          // console.log('this.data', this.data)
397
+        }
398
+      })
399
+    },
400
+    getListingParam() {
401
+      const params = {resourceType: 'theme', resourceIds: this.selectIds,}
402
+      if (this.activeName === 'second') {
403
+        params.resourceType = 'specialSubject'
404
+      }
405
+      if (this.activeName === 'third') {
406
+        params.resourceType = 'index'
407
+      }
408
+      if (this.activeName === 'fourth') {
409
+        params.resourceType = 'service'
410
+      }
411
+      return params
412
+    },
413
+    // 批量上架
414
+    batchListing() {
415
+      const params = this.getListingParam()
416
+      backApi.batchUpShelves(params).then(res => {
417
+        if (res.success) {
418
+          this.$message({ type: 'success', message: '上架成功!' })
419
+          this.selectIds = []
420
+          this.getSearchData()
421
+        }
422
+      })
423
+    },
424
+    // 批量下架
425
+    batchOffShelf() {
426
+      const params = this.getListingParam()
427
+      backApi.batchDownShelves(params).then(res => {
428
+        if (res.success) {
429
+          this.$message({ type: 'success', message: '下架成功!' })
430
+          this.selectIds = []
431
+          this.getSearchData()
432
+        }
433
+      })
434
+    },
435
+    resetValue() {
436
+      this.selectIds = []
437
+      this.menuId = undefined
438
+      this.currentPage = 1
357 439
     }
358 440
   }
359 441
 };