
8 changed files with 232 additions and 41 deletions
@ -1,8 +1,24 @@ |
|||||
# 忽略文件 |
# 忽略文件 |
||||
examples/ |
examples/ |
||||
|
build/ |
||||
node_modules/ |
node_modules/ |
||||
*.log |
*.map |
||||
*.md |
*.html |
||||
*.yml |
|
||||
webpack.config.js |
# 本地开发文件 |
||||
.gitignore |
.DS_Store |
||||
|
*.local |
||||
|
|
||||
|
# 日志文件 |
||||
|
npm-debug.log* |
||||
|
yarn-debug.log* |
||||
|
yarn-error.log* |
||||
|
|
||||
|
# 编辑器目录和文件 |
||||
|
.idea |
||||
|
.vscode |
||||
|
*.suo |
||||
|
*.ntvs* |
||||
|
*.njsproj |
||||
|
*.sln |
||||
|
*.sw? |
@ -1,17 +1,22 @@ |
|||||
|
// .eslintrc.js
|
||||
module.exports = { |
module.exports = { |
||||
env: { |
root: true, |
||||
browser: true, |
env: { |
||||
es2021: true |
browser: true, |
||||
}, |
node: true, |
||||
extends: [ |
es6: true |
||||
'eslint:recommended', |
}, |
||||
'plugin:vue/essential' |
extends: [ |
||||
], |
'eslint:recommended', |
||||
parserOptions: { |
'plugin:vue/essential' |
||||
ecmaVersion: 12, |
], |
||||
sourceType: 'module' |
parserOptions: { |
||||
}, |
ecmaVersion: 2018, // 改为 2018(兼容 Vue 2)
|
||||
rules: { |
sourceType: 'module', |
||||
'vue/multi-word-component-names': 'off' |
parser: 'babel-eslint' |
||||
} |
}, |
||||
|
rules: { |
||||
|
'vue/multi-word-component-names': 'off', |
||||
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off' |
||||
} |
} |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
import GuipDialog from './src/index.vue' |
||||
|
|
||||
|
GuipDialog.install = function(Vue) { |
||||
|
Vue.component(GuipDialog.name || 'GuipDialog', GuipDialog) |
||||
|
} |
||||
|
|
||||
|
export default GuipDialog |
@ -0,0 +1,131 @@ |
|||||
|
<template> |
||||
|
<el-dialog :visible.sync="dialogShow" :title="title" v-bind="$attrs" append-to-body :width="width" |
||||
|
:show-close="showCloseButton" :before-close="handleClose" :class="type == 'center' ? 'center' : 'normal'"> |
||||
|
<!-- 自定义内容 --> |
||||
|
<slot></slot> |
||||
|
<!-- 底部按钮 --> |
||||
|
<span v-if="showFooterButton" slot="footer" |
||||
|
:class="[type == 'center' ? 'dialog-footer-center' : 'dialog-footer-normal', 'flex']" |
||||
|
style="justify-content: space-between;"> |
||||
|
<GuipButton v-if="showCancelButton" @click="handleCancel" type="ignore">{{ cancelText }}</GuipButton> |
||||
|
<GuipButton type="primary" @click="handleConfirm">{{ confirmText }}</GuipButton> |
||||
|
</span> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import GuipButton from '../../GuipButton/src/index.vue'; |
||||
|
|
||||
|
export default { |
||||
|
name: 'GuipDialog', |
||||
|
props: { |
||||
|
type: { |
||||
|
type: String, |
||||
|
default: 'normal' |
||||
|
}, |
||||
|
// 控制弹框显示 |
||||
|
dialogVisible: { |
||||
|
type: Boolean, |
||||
|
default: false, |
||||
|
}, |
||||
|
// 弹框标题 |
||||
|
title: { |
||||
|
type: String, |
||||
|
default: '提示', |
||||
|
}, |
||||
|
// 弹框宽度 |
||||
|
width: { |
||||
|
type: String, |
||||
|
default: '599px', |
||||
|
}, |
||||
|
// 是否显示右上角关闭按钮 |
||||
|
showCloseButton: { |
||||
|
type: Boolean, |
||||
|
default: true, |
||||
|
}, |
||||
|
// 是否显示取消按钮 |
||||
|
showCancelButton: { |
||||
|
type: Boolean, |
||||
|
default: true, |
||||
|
}, |
||||
|
// 是否显示底部按钮 |
||||
|
showFooterButton: { |
||||
|
type: Boolean, |
||||
|
default: true, |
||||
|
}, |
||||
|
// 取消按钮文本 |
||||
|
cancelText: { |
||||
|
type: String, |
||||
|
default: '取消', |
||||
|
}, |
||||
|
// 确认按钮文本 |
||||
|
confirmText: { |
||||
|
type: String, |
||||
|
default: '确定', |
||||
|
}, |
||||
|
}, |
||||
|
components: { |
||||
|
GuipButton |
||||
|
}, |
||||
|
computed: { |
||||
|
dialogShow: { |
||||
|
get() { |
||||
|
return this.dialogVisible; |
||||
|
}, |
||||
|
set(newVal) { |
||||
|
this.$emit('dialogVisibleChange', newVal); |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
// 内部维护一个 visible 状态 |
||||
|
internalVisible: this.visible, |
||||
|
// dialogVisible:false, |
||||
|
}; |
||||
|
}, |
||||
|
watch: { |
||||
|
// // 监听 prop 的变化,同步到 internalVisible |
||||
|
// visible(newVal) { |
||||
|
// this.internalVisible = newVal; |
||||
|
// }, |
||||
|
// // 监听 internalVisible 的变化,通知父组件 |
||||
|
// internalVisible(newVal) { |
||||
|
// this.$emit('update:visible', newVal); |
||||
|
// }, |
||||
|
}, |
||||
|
methods: { |
||||
|
// 关闭弹框 |
||||
|
handleClose(done) { |
||||
|
this.$emit('close'); |
||||
|
this.internalVisible = false; // 关闭弹框 |
||||
|
if (done) { |
||||
|
done(); |
||||
|
} |
||||
|
}, |
||||
|
// 点击取消按钮 |
||||
|
handleCancel() { |
||||
|
this.$emit('cancel'); |
||||
|
this.internalVisible = false; // 关闭弹框 |
||||
|
}, |
||||
|
// 点击确认按钮 |
||||
|
handleConfirm() { |
||||
|
this.$emit('confirm'); |
||||
|
this.internalVisible = false; // 关闭弹框 |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
.el-dialog { |
||||
|
/* width: 599px; */ |
||||
|
// min-height: 344px; |
||||
|
// .el-dialog__header{ |
||||
|
// padding: 32px 32px 12px; |
||||
|
// } |
||||
|
// .el-dialog__body{ |
||||
|
// padding: 0 32px 32px; |
||||
|
// } |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue