Skip to content

Commit

Permalink
improvement: 数据统计页面拉取所有业务 TencentBlueKing#119 (TencentBlueKing#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
luofann authored and pagezz-canway committed Apr 14, 2019
1 parent 9c23557 commit 69e558d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 35 deletions.
7 changes: 5 additions & 2 deletions pipeline/blueflow/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ const api = {
/**
* 获取当前用户有权限业务
*/
getBizList () {
getBizList (isAll) {
const prefixUrl = this.getPrefix('business')
const opts = {
method: 'GET',
url: prefixUrl
url: prefixUrl,
params: {
all: isAll
}
}
return request(opts)
},
Expand Down
12 changes: 6 additions & 6 deletions pipeline/blueflow/src/pages/statistics/Appmaker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<div class="content-wrap-select">
<label class="content-detail-label">{{i18n.choiceBusiness}}</label>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -292,16 +292,16 @@ export default {
},
computed: {
...mapState({
bizList: state => state.bizList,
allBusinessList: state => state.allBusinessList,
categorys: state => state.categorys,
site_url: state => state.site_url
}),
businessList () {
if (this.bizList.length === 0) {
this.getBizList()
if (this.allBusinessList.length === 0) {
this.getBizList(1)
}
const list = tools.deepClone(this.bizList)
list.unshift({cc_id: 'all', cc_name: i18n.choiceAllBusiness})
const list = tools.deepClone(this.allBusinessList)
list.unshift({cc_id: undefined, cc_name: i18n.choiceAllBusiness})
return list
},
categoryList () {
Expand Down
16 changes: 8 additions & 8 deletions pipeline/blueflow/src/pages/statistics/Atom/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<div class="content-wrap-select">
<label class="content-detail-label">{{i18n.choiceBusiness}}</label>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -141,7 +141,7 @@
<div class="content-wrap-select">
<label class="content-detail-label">{{i18n.choiceBusiness}}</label>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -217,7 +217,7 @@
<div class="content-wrap-select">
<label class="content-detail-label">{{i18n.choiceBusiness}}</label>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -515,16 +515,16 @@ export default {
},
computed: {
...mapState({
bizList: state => state.bizList,
allBusinessList: state => state.allBusinessList,
categorys: state => state.categorys,
site_url: state => state.site_url
}),
businessList () {
if (this.bizList.length === 0) {
this.getBizList()
if (this.allBusinessList.length === 0) {
this.getBizList(1)
}
const list = tools.deepClone(this.bizList)
list.unshift({cc_id: 'all', cc_name: i18n.choiceAllBusiness})
const list = tools.deepClone(this.allBusinessList)
list.unshift({cc_id: undefined, cc_name: i18n.choiceAllBusiness})
return list
},
componentsList () {
Expand Down
15 changes: 7 additions & 8 deletions pipeline/blueflow/src/pages/statistics/Instance/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<div class="content-wrap-select">
<label class="content-detail-label">{{i18n.choiceBusiness}}</label>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -221,7 +221,7 @@
<div class="content-wrap-select">
<label class="content-detail-label">{{i18n.choiceBusiness}}</label>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -467,17 +467,16 @@ export default {
},
computed: {
...mapState({
bizList: state => state.bizList,
instanceList: state => state.bizList,
allBusinessList: state => state.allBusinessList,
categorys: state => state.categorys,
site_url: state => state.site_url
}),
businessList () {
if (this.bizList.length === 0) {
this.getBizList()
if (this.allBusinessList.length === 0) {
this.getBizList(1)
}
const list = tools.deepClone(this.bizList)
list.unshift({cc_id: 'all', cc_name: i18n.choiceAllBusiness})
const list = tools.deepClone(this.allBusinessList)
list.unshift({cc_id: undefined, cc_name: i18n.choiceAllBusiness})
return list
},
categoryList () {
Expand Down
14 changes: 7 additions & 7 deletions pipeline/blueflow/src/pages/statistics/Template/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<div class="content-wrap-select">
<span class="content-detail-label">{{i18n.choiceBusiness}}</span>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -156,7 +156,7 @@
<div class="content-wrap-select">
<label class="content-detail-label">{{i18n.choiceBusiness}}</label>
<bk-selector
:list="bizList"
:list="allBusinessList"
:display-key="'cc_name'"
:setting-name="'cc_id'"
:search-key="'cc_name'"
Expand Down Expand Up @@ -385,16 +385,16 @@ export default {
},
computed: {
...mapState({
bizList: state => state.bizList,
allBusinessList: state => state.allBusinessList,
categorys: state => state.categorys,
site_url: state => state.site_url
}),
businessList () {
if (this.bizList.length === 0) {
this.getBizList()
if (this.allBusinessList.length === 0) {
this.getBizList(1)
}
const list = tools.deepClone(this.bizList)
list.unshift({cc_id: 'all', cc_name: gettext('全部业务')})
const list = tools.deepClone(this.allBusinessList)
list.unshift({cc_id: undefined, cc_name: gettext('全部业务')})
return list
},
categoryList () {
Expand Down
16 changes: 12 additions & 4 deletions pipeline/blueflow/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const store = new Vuex.Store({
isSuperUser: window.IS_SUPERUSER === 1,
v1_import_flag: window.IMPORT_V1_FLAG,
rsa_pub_key: window.RSA_PUB_KEY,
businessTimezone: window.BUSINESS_TIMEZONE
businessTimezone: window.BUSINESS_TIMEZONE,
allBusinessList: []
},
mutations: {
setAppId (state, id) {
Expand Down Expand Up @@ -81,12 +82,19 @@ const store = new Vuex.Store({
},
setBusinessTimezone (state, data) {
state.businessTimezone = data
},
setAllBusinessList (state, data) {
state.allBusinessList = data
}
},
actions: {
getBizList ({commit}) {
api.getBizList().then(response => {
commit('setBizList', response.data.objects)
getBizList ({commit}, isAll) {
api.getBizList(isAll).then(response => {
if (isAll) {
commit('setAllBusinessList', response.data.objects)
} else {
commit('setBizList', response.data.objects)
}
})
},
changeDefaultBiz ({commit}, ccId) {
Expand Down

0 comments on commit 69e558d

Please sign in to comment.