|
@@ -155,6 +155,15 @@
|
155
|
155
|
|
156
|
156
|
<script>
|
157
|
157
|
import api from "@/api/homepage/search.js";
|
|
158
|
+const resourceTypeMap = {
|
|
159
|
+ first: 'theme',
|
|
160
|
+ second: 'specialSubject',
|
|
161
|
+ third: 'index',
|
|
162
|
+ fourth: 'service'
|
|
163
|
+}
|
|
164
|
+const tabNames = {
|
|
165
|
+ first: '主题库', second: '专题库',third: '指标', fourth: '服务'
|
|
166
|
+}
|
158
|
167
|
export default {
|
159
|
168
|
data() {
|
160
|
169
|
return {
|
|
@@ -202,24 +211,22 @@ export default {
|
202
|
211
|
this.getSearchData()
|
203
|
212
|
},
|
204
|
213
|
jumpToDetailPage(id) {
|
205
|
|
- const resourceTypeMap = {
|
|
214
|
+ const resourceTypeMapA = {
|
206
|
215
|
first: 'theme',
|
207
|
216
|
second: 'special',
|
208
|
217
|
third: 'target',
|
209
|
218
|
fourth: this.serviceType === 'API' ? 'api' : 'message'
|
210
|
219
|
}
|
211
|
|
- let type = resourceTypeMap[this.activeName]
|
|
220
|
+ let type = resourceTypeMapA[this.activeName]
|
212
|
221
|
this.$router.push({
|
213
|
222
|
name: "entityDetail",
|
214
|
223
|
path: "/entityDetail",
|
215
|
|
- query: {
|
216
|
|
- id: id,
|
217
|
|
- type
|
218
|
|
- }
|
|
224
|
+ query: {id: id, type}
|
219
|
225
|
});
|
220
|
226
|
},
|
221
|
227
|
handleSearch() {
|
222
|
|
- this.getSearchData()
|
|
228
|
+ this.initData()
|
|
229
|
+ this.getMenu()
|
223
|
230
|
},
|
224
|
231
|
getCardClass() {
|
225
|
232
|
let ret = 'entity-card'
|
|
@@ -239,12 +246,6 @@ export default {
|
239
|
246
|
this.cancelCollect([id])
|
240
|
247
|
},
|
241
|
248
|
cancelCollect(ids) {
|
242
|
|
- const resourceTypeMap = {
|
243
|
|
- first: 'theme',
|
244
|
|
- second: 'specialSubject',
|
245
|
|
- third: 'index',
|
246
|
|
- fourth: 'service'
|
247
|
|
- }
|
248
|
249
|
const params = {resourceType: resourceTypeMap[this.activeName], resourceIds: ids,}
|
249
|
250
|
api.deleteCollect(params).then(res => {
|
250
|
251
|
if (res.success) {
|
|
@@ -272,14 +273,10 @@ export default {
|
272
|
273
|
handleUp() {
|
273
|
274
|
console.log('up')
|
274
|
275
|
},
|
275
|
|
- // 初始化tablist 数据,并请求每个tab项的总数
|
|
276
|
+ // 1.初始化tablist 数据,2.请求每个tab项包含数据的总数, 3.请求右侧列表数据
|
276
|
277
|
initData() {
|
277
|
|
- let tabList = [
|
278
|
|
- {name: '主题库',id: 'first'},
|
279
|
|
- {name: '专题库',id: 'second'},
|
280
|
|
- {name: '指标',id: 'third'},
|
281
|
|
- {name: '服务',id: 'fourth'}
|
282
|
|
- ]
|
|
278
|
+ let tabList = [{name: '主题库',id: 'first'}, {name: '专题库',id: 'second'},
|
|
279
|
+ {name: '指标',id: 'third'}, {name: '服务',id: 'fourth'}]
|
283
|
280
|
if (this.$route.query.pageType === 'theme') {
|
284
|
281
|
tabList = [{ name: '主题库', id: 'first' }]
|
285
|
282
|
this.activeName = 'first'
|
|
@@ -302,17 +299,10 @@ export default {
|
302
|
299
|
}
|
303
|
300
|
this.tabList = tabList
|
304
|
301
|
if (this.pageType === 'all') {
|
305
|
|
- api.esItemDataNum({resourceType: 'theme', shelvesType: '1'}).then(res => {
|
306
|
|
- this.tabList[0].name = `主题库(${res.data})`
|
307
|
|
- })
|
308
|
|
- api.esItemDataNum({resourceType: 'specialSubject', shelvesType: '1'}).then(res => {
|
309
|
|
- this.tabList[1].name = `专题库(${res.data})`
|
310
|
|
- })
|
311
|
|
- api.esItemDataNum({resourceType: 'index', shelvesType: '1'}).then(res => {
|
312
|
|
- this.tabList[2].name = `指标(${res.data})`
|
313
|
|
- })
|
314
|
|
- api.esItemDataNum({resourceType: 'service', shelvesType: '1'}).then(res => {
|
315
|
|
- this.tabList[3].name = `服务(${res.data})`
|
|
302
|
+ this.tabList.map((item, index) => {
|
|
303
|
+ api.esItemDataNum({resourceType: resourceTypeMap[item.id], shelvesType: '1', menuId: this.menuId, keyword: this.searchWords}).then(res => {
|
|
304
|
+ this.tabList[index].name = `${tabNames[item.id]}(${res.data})`
|
|
305
|
+ })
|
316
|
306
|
})
|
317
|
307
|
}
|
318
|
308
|
if (this.pageType === 'collect') {
|
|
@@ -321,30 +311,15 @@ export default {
|
321
|
311
|
this.getSearchData()
|
322
|
312
|
},
|
323
|
313
|
getCollectTabTotal() {
|
324
|
|
- api.collectMenuDataNum({resourceType: 'theme'}).then(res => {
|
325
|
|
- this.tabList[0].name = `主题库(${res.data})`
|
326
|
|
- })
|
327
|
|
- api.collectMenuDataNum({resourceType: 'specialSubject'}).then(res => {
|
328
|
|
- this.tabList[1].name = `专题库(${res.data})`
|
329
|
|
- })
|
330
|
|
- api.collectMenuDataNum({resourceType: 'index'}).then(res => {
|
331
|
|
- this.tabList[2].name = `指标(${res.data})`
|
332
|
|
- })
|
333
|
|
- api.collectMenuDataNum({resourceType: 'service'}).then(res => {
|
334
|
|
- this.tabList[3].name = `服务(${res.data})`
|
|
314
|
+ this.tabList.map((item, index) => {
|
|
315
|
+ api.collectMenuDataNum({resourceType: resourceTypeMap[item.id], menuId: this.menuId, resourceName: this.searchWords}).then(res => {
|
|
316
|
+ this.tabList[index].name = `${tabNames[item.id]}(${res.data})`
|
|
317
|
+ })
|
335
|
318
|
})
|
336
|
319
|
},
|
|
320
|
+ // 获取树形列表数据,并在tab选项为服务时请求所有树形数据项对应包含的数据条数
|
337
|
321
|
getMenu() {
|
338
|
|
- const params = {resourceType: 'theme'}
|
339
|
|
- if (this.activeName === 'second') {
|
340
|
|
- params.resourceType = 'specialSubject'
|
341
|
|
- }
|
342
|
|
- if (this.activeName === 'third') {
|
343
|
|
- params.resourceType = 'index'
|
344
|
|
- }
|
345
|
|
- if (this.activeName === 'fourth') {
|
346
|
|
- params.resourceType = 'service'
|
347
|
|
- }
|
|
322
|
+ const params = {resourceType: resourceTypeMap[this.activeName]}
|
348
|
323
|
api.menuInfo(params).then(res => {
|
349
|
324
|
if (res.success) {
|
350
|
325
|
this.data = res.data
|
|
@@ -361,21 +336,18 @@ export default {
|
361
|
336
|
this.getSearchData()
|
362
|
337
|
},
|
363
|
338
|
getSearchData() {
|
|
339
|
+ const resourceTypeMapB = {
|
|
340
|
+ first: 'theme',
|
|
341
|
+ second: 'specialSubject',
|
|
342
|
+ third: 'index',
|
|
343
|
+ fourth: this.serviceType === 'API' ? 'api' : 'mqs'
|
|
344
|
+ }
|
364
|
345
|
const params = {
|
365
|
|
- resourceType: 'theme', pageNum: this.currentPage,
|
|
346
|
+ resourceType: resourceTypeMapB[this.activeName], pageNum: this.currentPage,
|
366
|
347
|
pageSize: this.pageSize, menuId: this.menuId,
|
367
|
348
|
keyword: this.searchWords,
|
368
|
349
|
shelvesType: '1'
|
369
|
350
|
}
|
370
|
|
- if (this.activeName === 'second') {
|
371
|
|
- params.resourceType = 'specialSubject'
|
372
|
|
- }
|
373
|
|
- if (this.activeName === 'third') {
|
374
|
|
- params.resourceType = 'index'
|
375
|
|
- }
|
376
|
|
- if (this.activeName === 'fourth') {
|
377
|
|
- params.resourceType = this.serviceType === 'API' ? 'api' : 'mqs'
|
378
|
|
- }
|
379
|
351
|
if (this.pageType === 'collect') {
|
380
|
352
|
params.shelvesType = undefined
|
381
|
353
|
params.keyword = undefined
|
|
@@ -414,12 +386,14 @@ export default {
|
414
|
386
|
}
|
415
|
387
|
},
|
416
|
388
|
getServiceStatNum() {
|
417
|
|
- let params = {resourceType: 'api', shelvesType: '1'}
|
|
389
|
+ let params = {resourceType: 'api', shelvesType: '1', menuId: this.menuId, keyword: this.searchWords}
|
418
|
390
|
if (this.serviceType === 'MQ') {
|
419
|
391
|
params.resourceType = 'mqs'
|
420
|
392
|
}
|
421
|
393
|
if (this.pageType === 'collect') {
|
422
|
394
|
params.shelvesType = undefined
|
|
395
|
+ params.keyword = undefined
|
|
396
|
+ params.resourceName = this.searchWords
|
423
|
397
|
api.collectMenuStatNum(params).then(res => {
|
424
|
398
|
this.handleMenuStatNumRes(res)
|
425
|
399
|
})
|
|
@@ -448,22 +422,22 @@ export default {
|
448
|
422
|
this.currentPage = 1
|
449
|
423
|
},
|
450
|
424
|
getThemeTotal() {
|
451
|
|
- api.esItemDataNum({resourceType: 'theme', shelvesType: '1'}).then(res => {
|
|
425
|
+ api.esItemDataNum({resourceType: 'theme', shelvesType: '1', menuId: this.menuId, keyword: this.searchWords}).then(res => {
|
452
|
426
|
this.tabList[0].name = `主题库(${res.data})`
|
453
|
427
|
})
|
454
|
428
|
},
|
455
|
429
|
getSpecialTotal() {
|
456
|
|
- api.esItemDataNum({resourceType: 'specialSubject', shelvesType: '1'}).then(res => {
|
|
430
|
+ api.esItemDataNum({resourceType: 'specialSubject', shelvesType: '1', menuId: this.menuId, keyword: this.searchWords}).then(res => {
|
457
|
431
|
this.tabList[0].name = `专题库(${res.data})`
|
458
|
432
|
})
|
459
|
433
|
},
|
460
|
434
|
getIndexTotal() {
|
461
|
|
- api.esItemDataNum({resourceType: 'index', shelvesType: '1'}).then(res => {
|
|
435
|
+ api.esItemDataNum({resourceType: 'index', shelvesType: '1', menuId: this.menuId, keyword: this.searchWords}).then(res => {
|
462
|
436
|
this.tabList[0].name = `指标(${res.data})`
|
463
|
437
|
})
|
464
|
438
|
},
|
465
|
439
|
getServiceTotal() {
|
466
|
|
- api.esItemDataNum({resourceType: 'service', shelvesType: '1'}).then(res => {
|
|
440
|
+ api.esItemDataNum({resourceType: 'service', shelvesType: '1', menuId: this.menuId, keyword: this.searchWords}).then(res => {
|
467
|
441
|
this.tabList[0].name = `服务(${res.data})`
|
468
|
442
|
})
|
469
|
443
|
}
|