Skip to content

Commit

Permalink
perf: add button loading status (jumpserver#4287)
Browse files Browse the repository at this point in the history
* perf: add button loading status

* perf: add button loading status

---------

Co-authored-by: zhaojisen <[email protected]>
  • Loading branch information
fit2bot and ZhaoJiSen authored Aug 8, 2024
1 parent 40bf040 commit 9e0c623
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/components/Apps/AssetSelect/dialog.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<Dialog
ref="customDialog"
:close-on-click-modal="false"
:title="$tc('assets.Assets')"
custom-class="asset-select-dialog"
Expand All @@ -21,6 +22,7 @@
:tree-setting="treeSetting"
class="tree-table"
v-bind="$attrs"
@loaded="handleTableLoaded"
/>
</Dialog>
</template>
Expand Down Expand Up @@ -143,6 +145,9 @@ export default {
if (selectValueIndex > -1) {
this.rowSelected.splice(selectValueIndex, 1)
}
},
handleTableLoaded() {
this.$refs.customDialog.loaded()
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/components/Apps/AssetSelect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<script>
import Select2 from '@/components/Form/FormFields/Select2.vue'
import AssetSelectDialog from './dialog.vue'
import { b } from 'css-color-function/lib/adjusters'
export default {
componentName: 'AssetSelect',
Expand Down Expand Up @@ -81,7 +80,6 @@ export default {
}
},
methods: {
b,
handleFocus() {
this.$refs.select2.selectRef.blur()
this.dialogVisible = true
Expand Down
15 changes: 12 additions & 3 deletions src/components/Dialog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
v-bind="$attrs"
v-on="$listeners"
>
<slot />
<div v-loading="!isLoaded">
<slot />
</div>
<div slot="footer" class="dialog-footer">
<slot name="footer">
<el-button v-if="showCancel && showButtons" @click="onCancel">{{ cancelTitle }}</el-button>
<el-button v-if="showConfirm && showButtons" :loading="loadingStatus" type="primary" @click="onConfirm">
<el-button v-if="showConfirm && showButtons" :disabled="!isLoaded" type="primary" @click="onConfirm">
{{ confirmTitle }}
</el-button>
</slot>
Expand Down Expand Up @@ -71,14 +73,21 @@ export default {
}
},
data() {
return {}
return {
isLoaded: false
}
},
computed: {
iWidth() {
return this.$store.getters.isMobile ? '1000px' : this.width
}
},
mounted() {
},
methods: {
loaded() {
this.isLoaded = true
},
onCancel() {
this.$emit('cancel')
},
Expand Down
11 changes: 6 additions & 5 deletions src/components/Form/FormFields/TransferSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
/>
<Dialog
v-if="showTransfer"
ref="customDialog"
:close-on-click-modal="false"
:title="label"
:visible.sync="showTransfer"
class="the-dialog"
width="730px"
@cancel="handleTransCancel"
@confirm="handleTransConfirm"
v-on="$listeners"
>
<krryPaging v-if="selectInitialized" ref="pageTransfer" class="transfer" v-bind="pagingTransfer" />
<krryPaging v-if="selectInitialized" ref="pageTransfer" class="transfer" v-bind="pagingTransfer" @loaded="handleLoaded" />
</Dialog>
</div>
</template>
Expand Down Expand Up @@ -162,11 +164,10 @@ export default {
this.select2.options = options
this.emit(options.map(item => item.value))
this.showTransfer = false
},
handleLoaded() {
this.$refs.customDialog.loaded()
}
}
}
</script>

<style scoped>
</style>
2 changes: 2 additions & 0 deletions src/components/Libs/Krry/paging/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ export default {
ele => !checkDataId.includes(ele.id)
)
}
this.$emit('loaded')
},
searchWord(keyword, titleId) {
// 过滤掉数据,保留搜索的数据
Expand Down
3 changes: 3 additions & 0 deletions src/components/Table/DataTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script>
import { default as ElDatableTable } from './compenents/el-data-table'
import { mapGetters } from 'vuex'
import { eventBus } from '@/utils/const'
export default {
name: 'DataTable',
Expand Down Expand Up @@ -153,6 +154,8 @@ export default {
this.toggleRowSelection(row, true)
}
}
eventBus.$emit('loaded')
},
handleSizeChange(val) {
localStorage.setItem('paginationSize', val)
Expand Down

0 comments on commit 9e0c623

Please sign in to comment.