新增单个列表导入/导出功能
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<Modal :show="visible" @close="handleCancel" @after-leave="afterLeave" :closeBtn="false">
|
||||
<main :class="$style.main">{{message}}</main>
|
||||
<footer :class="$style.footer">
|
||||
<Btn :class="$style.btn" v-if="showCancel" @click="handleCancel">{{cancelBtnText}}</Btn>
|
||||
<Btn :class="$style.btn" @click="handleComfirm">{{confirmBtnText}}</Btn>
|
||||
</footer>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Modal from '@renderer/components/material/Modal'
|
||||
import Btn from '@renderer/components/material/Btn'
|
||||
export default {
|
||||
components: {
|
||||
Modal,
|
||||
Btn,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
message: '',
|
||||
showCancel: false,
|
||||
cancelButtonText: '',
|
||||
confirmButtonText: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
cancelBtnText() {
|
||||
return this.cancelButtonText || this.$t('base.cancel_button_text')
|
||||
},
|
||||
confirmBtnText() {
|
||||
return this.confirmButtonText || this.$t('base.confirm_button_text')
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
const el = this.$el
|
||||
el.parentNode.removeChild(el)
|
||||
},
|
||||
methods: {
|
||||
afterLeave(el, done) {
|
||||
this.$destroy()
|
||||
},
|
||||
handleCancel() {
|
||||
|
||||
},
|
||||
handleComfirm() {
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" module>
|
||||
|
||||
.main {
|
||||
flex: auto;
|
||||
min-height: 50px;
|
||||
padding: 15px;
|
||||
font-size: 14px;
|
||||
max-width: 320px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.footer {
|
||||
flex: none;
|
||||
padding: 0 15px 15px;
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
justify-content: flex-end;
|
||||
gap: 15px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,50 @@
|
||||
import Dialog from './Dialog'
|
||||
import i18n from '../i18n'
|
||||
import store from '@renderer/store'
|
||||
import Vue from 'vue'
|
||||
|
||||
const defaultOptions = {
|
||||
message: '',
|
||||
showCancel: false,
|
||||
cancelButtonText: '',
|
||||
confirmButtonText: '',
|
||||
}
|
||||
|
||||
const dialog = {
|
||||
install(Vue, options) {
|
||||
const DialogConstructor = Vue.extend(Dialog)
|
||||
|
||||
const dialog = function Dialog(options) {
|
||||
const { message, showCancel, cancelButtonText, confirmButtonText } =
|
||||
Object.assign({}, defaultOptions, typeof options == 'string' ? { message: options } : options || {})
|
||||
return new Promise((resolve, reject) => {
|
||||
let instance = new DialogConstructor({ i18n, store }).$mount(document.createElement('div'))
|
||||
|
||||
// 属性设置
|
||||
instance.visible = true
|
||||
instance.message = message
|
||||
instance.showCancel = showCancel
|
||||
instance.cancelButtonText = cancelButtonText
|
||||
instance.confirmButtonText = confirmButtonText
|
||||
|
||||
// 挂载
|
||||
document.getElementById('container').appendChild(instance.$el)
|
||||
|
||||
instance.handleCancel = () => {
|
||||
instance.visible = false
|
||||
resolve(false)
|
||||
}
|
||||
|
||||
instance.handleComfirm = () => {
|
||||
instance.visible = false
|
||||
resolve(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
dialog.confirm = options => dialog({ ...options, showCancel: true })
|
||||
|
||||
Vue.prototype.$dialog = dialog
|
||||
},
|
||||
}
|
||||
|
||||
Vue.use(dialog)
|
||||
@@ -1,2 +1,3 @@
|
||||
// import './axios'
|
||||
import './Dialog'
|
||||
import './Tips'
|
||||
|
||||
Reference in New Issue
Block a user