2023-05-12 17:32:51 +08:00
|
|
|
<template>
|
2023-05-19 19:17:28 +08:00
|
|
|
<a-modal v-bind="$attrs" v-model="visible" :title="title" :footer="null">
|
2023-05-12 17:32:51 +08:00
|
|
|
<slot></slot>
|
2023-05-19 19:17:28 +08:00
|
|
|
<a-space v-if="showFooter" class="operators" :size="20">
|
|
|
|
|
<a-button type="success" @click="onSave" :loading="confirmLoading">Save</a-button>
|
|
|
|
|
<a-button type="warn" @click="onCancel">Cancel</a-button>
|
|
|
|
|
</a-space>
|
2023-05-12 17:32:51 +08:00
|
|
|
</a-modal>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
value: {
|
|
|
|
|
type: Boolean
|
|
|
|
|
},
|
|
|
|
|
okHandler: {
|
|
|
|
|
type: Function
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String
|
2023-05-19 19:17:28 +08:00
|
|
|
},
|
|
|
|
|
showFooter: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true
|
2023-05-12 17:32:51 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
visible: this.value,
|
|
|
|
|
confirmLoading: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
visible(val) {
|
|
|
|
|
this.$emit('input', val)
|
|
|
|
|
},
|
|
|
|
|
value(val) {
|
|
|
|
|
this.visible = val
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async onSave() {
|
|
|
|
|
if (this.okHandler instanceof Function) {
|
|
|
|
|
try {
|
|
|
|
|
this.confirmLoading = true
|
|
|
|
|
await this.okHandler()
|
|
|
|
|
this.visible = false
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
} finally {
|
|
|
|
|
this.confirmLoading = false
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.visible = false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
this.visible = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.operators {
|
2023-05-19 19:17:28 +08:00
|
|
|
width: 100%;
|
|
|
|
|
justify-content: center;
|
2023-05-12 17:32:51 +08:00
|
|
|
.ant-btn {
|
|
|
|
|
width: 92px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|