Commit 5644c224 authored by 智勇's avatar 智勇

全选

parent 3f033b95
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
<el-card> <el-card>
<el-button <el-button
v-for="item in ns.repos" v-for="item in ns.repos"
:key="item.domain" :key="item.appname"
:type="dependant[ns.type] && dependant[ns.type].find(sys => sys.appname === item.appname) ? 'success' : ''" :type="dependant[ns.type] && dependant[ns.type].find(sys => sys.appname === item.appname) ? 'success' : ''"
style="margin:3px" style="margin:3px"
@click="selectSystem(item, ns.type)"> @click="selectSystem(item, ns.type)">
{{ item.appname }} {{ item.appname }}
</el-button> </el-button>
</el-card> </el-card>
<el-checkbox :indeterminate="isIndeterminate[ns.type]" v-model="checkAll[ns.type]" @change="handleCheckAllChange(checkAll[ns.type],ns.type)">全选</el-checkbox>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -47,7 +48,9 @@ export default { ...@@ -47,7 +48,9 @@ export default {
dependant: {}, dependant: {},
repoNamespaces: [], repoNamespaces: [],
currentTemplate: '', currentTemplate: '',
templates: {} templates: {},
checkAll: {},
isIndeterminate: {}
} }
}, },
...@@ -64,6 +67,10 @@ export default { ...@@ -64,6 +67,10 @@ export default {
getAllRepos() { getAllRepos() {
getAppRepos().then(res => { getAppRepos().then(res => {
this.repoNamespaces = res.data this.repoNamespaces = res.data
this.repoNamespaces.forEach(item => {
this.checkAll[item.type] = false
this.isIndeterminate[item.type] = true
})
}) })
}, },
...@@ -83,6 +90,12 @@ export default { ...@@ -83,6 +90,12 @@ export default {
} }
}, },
handleCheckAllChange(val, type) {
this.$set(this.dependant, type, [])
this.isIndeterminate[type] = false
if (val) this.dependant[type] = this.repoNamespaces.filter(item => item.type === type)[0].repos.concat()
},
useTemplate() { useTemplate() {
const vm = this const vm = this
const t = this.templates.find(item => item.name === this.currentTemplate) const t = this.templates.find(item => item.name === this.currentTemplate)
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
{{ item.appname }} {{ item.appname }}
</el-button> </el-button>
</el-card> </el-card>
<el-checkbox :indeterminate="isIndeterminate[ns.type]" v-model="checkAll[ns.type]" @change="handleCheckAllChange(checkAll[ns.type],ns.type)">全选</el-checkbox>
</el-form-item> </el-form-item>
</el-form > </el-form >
<div style="float:right"> <div style="float:right">
...@@ -53,7 +54,8 @@ export default { ...@@ -53,7 +54,8 @@ export default {
currentTemplate: '', currentTemplate: '',
currentTemplateObj: {}, currentTemplateObj: {},
templates: {}, templates: {},
loading: true checkAll: {},
isIndeterminate: {}
} }
}, },
...@@ -66,7 +68,10 @@ export default { ...@@ -66,7 +68,10 @@ export default {
getAllRepos() { getAllRepos() {
getAllRepos().then(res => { getAllRepos().then(res => {
this.repoNamespaces = res.data this.repoNamespaces = res.data
this.loading = false this.repoNamespaces.forEach(item => {
this.checkAll[item.type] = false
this.isIndeterminate[item.type] = true
})
}) })
}, },
...@@ -87,6 +92,12 @@ export default { ...@@ -87,6 +92,12 @@ export default {
} }
}, },
handleCheckAllChange(val, type) {
this.$set(this.dependant, type, [])
this.isIndeterminate[type] = false
if (val) this.dependant[type] = this.repoNamespaces.filter(item => item.type === type)[0].repos.concat()
},
useTemplate() { useTemplate() {
const vm = this const vm = this
this.currentTemplateObj = this.templates.find(item => item.name === this.currentTemplate) this.currentTemplateObj = this.templates.find(item => item.name === this.currentTemplate)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment