Merge branch 'v4' of github.com:jumpserver/lina into v4

This commit is contained in:
ibuler
2024-06-11 18:47:23 +08:00
2 changed files with 70 additions and 32 deletions

View File

@@ -67,7 +67,6 @@ export default {
activeMenuMap: { 0: 'ProviderPanel', 1: 'AuthPanel', 2: 'AssetPanel', 3: 'ResultPanel' }, activeMenuMap: { 0: 'ProviderPanel', 1: 'AuthPanel', 2: 'AssetPanel', 3: 'ResultPanel' },
activeMenu: 'ProviderPanel', activeMenu: 'ProviderPanel',
selected: '', selected: '',
activeMenu: 'ProviderPanel',
firstStepDesc: this.$tc('SelectPlatforms'), firstStepDesc: this.$tc('SelectPlatforms'),
active: 0, active: 0,
account: {} account: {}

View File

@@ -11,28 +11,40 @@
:title="$tc('Region')" :title="$tc('Region')"
:visible.sync="regionVisible" :visible.sync="regionVisible"
:show-cancel="false" :show-cancel="false"
width="'60'" width="60%"
@confirm="regionVisible=false" @confirm="regionVisible=false"
> >
<el-row :gutter="12"> <el-row>
<el-col v-for="r in allRegions" :key="r.id" :span="6"> <el-col>
<el-card <el-checkbox v-model="checkAll" @change="handleCheckedAllChange">
shadow="hover" {{ $t('All') }}
class="region-card" </el-checkbox>
:class="regions.indexOf(r.id) !== -1 ? 'active': ''"
:body-style="{ padding: '6px' }"
@click.native="handlerCardClick(r.id)"
>
<span>{{ r.name }}</span>
</el-card>
</el-col> </el-col>
</el-row> </el-row>
<el-checkbox-group
v-model="checkedRegion"
@change="handleCheckedRegionChange"
>
<el-row
v-for="r in allRegions"
:key="r.id"
type="flex"
>
<el-col>
<el-checkbox
:label="r.id"
:value="r.id"
>
{{ r.name }}
</el-checkbox>
</el-col>
</el-row>
</el-checkbox-group>
</Dialog> </Dialog>
</div> </div>
</template> </template>
<script> <script>
import { Dialog } from '@/components' import { Dialog } from '@/components'
import { encryptAttrsField } from '@/views/assets/Cloud/const' import { encryptAttrsField } from '@/views/assets/Cloud/const'
@@ -57,9 +69,17 @@ export default {
}, },
data() { data() {
return { return {
regionVisible: false, content: '',
checkedRegion: [],
allRegions: [], allRegions: [],
content: '' checkAll: false,
regionVisible: false,
isIndeterminate: false
}
},
watch: {
checkedRegion() {
this.updateCheckedStatus()
} }
}, },
mounted() { mounted() {
@@ -67,7 +87,7 @@ export default {
}, },
methods: { methods: {
refreshContent() { refreshContent() {
const count = this.regions.length || this.$t('SelectAll') const count = this.checkedRegion.length || this.$t('SelectAll')
this.content = `${this.$t('Modify')} [${count}]` this.content = `${this.$t('Modify')} [${count}]`
}, },
handlerLinkClick() { handlerLinkClick() {
@@ -85,34 +105,53 @@ export default {
this.$axios[method](url, data).then(resp => { this.$axios[method](url, data).then(resp => {
this.allRegions = resp?.regions this.allRegions = resp?.regions
this.regionVisible = true this.regionVisible = true
this.updateCheckedStatus()
}).catch(error => { }).catch(error => {
this.$message.error(this.$tc('CloudRegionTip' + ' ' + error)) this.$message.error(this.$tc('CloudRegionTip' + ' ' + error))
}).finally(() => { }).finally(() => {
this.refreshContent() this.refreshContent()
}) })
}, },
handlerCardClick(regionId) { handleCheckedAllChange(val) {
const index = this.regions.indexOf(regionId) this.checkedRegion = val ? this.allRegions.map(region => region.id) : []
if (index !== -1) { this.isIndeterminate = false
this.regions.splice(index, 1) },
} else { handleCheckedRegionChange(value) {
this.regions.push(regionId) const checkedCount = value.length
} this.checkAll = checkedCount === this.allRegions.length
this.$emit('input', this.regions) this.isIndeterminate = checkedCount > 0 && checkedCount < this.allRegions.length
const checkedRegion = this.allRegions.filter(item => value.includes(item.id))
this.$emit('input', checkedRegion)
this.refreshContent() this.refreshContent()
},
updateCheckedStatus() {
const checkedCount = this.checkedRegion.length
this.checkAll = checkedCount === this.allRegions.length
this.isIndeterminate = checkedCount > 0 && checkedCount < this.allRegions.length
} }
} }
} }
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
.region-card { .el-checkbox {
font-size: 12px; margin-bottom: 10px;
text-align: center;
margin-bottom: 6px;
} }
.el-card.active {
color: var(--color-primary); .el-checkbox-group {
border: 1px solid; display: flex;
flex-wrap: wrap;
::v-deep .el-col {
.el-checkbox {
display: flex;
align-items: center;
width: 250px;
height: 25px;
}
}
} }
</style> </style>