| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <template>
- <el-dialog
- class="cus-dialog-container fm-dialog"
- :title="title"
- :visible.sync="dialogVisible"
- :close-on-click-modal="closeOnClickModal"
- append-to-body
- center
- :width="width"
- ref="elDialog"
- :id="id"
- v-drag-dialog="true"
- :fullscreen="fullscreen"
- top="10vh"
- :style="{'--scrollbarWidth': scrollbarWidth}"
- >
- <span v-if="show">
- <slot></slot>
- </span>
- <template #footer v-if="action">
- <span class="dialog-footer" v-loading="loading"
- :element-loading-text="loadingText">
- <slot name="action">
- <el-button @click="close">{{$t('fm.actions.cancel')}}</el-button>
- <el-button type="primary" @click="submit" >{{$t('fm.actions.confirm')}}</el-button>
- </slot>
- </span>
- </template>
-
- </el-dialog>
- </template>
- <script>
- import DragDialog from '../directive/drag-dialog'
- export default {
- directives: {
- DragDialog
- },
- props: {
- visible: Boolean,
- loadingText: {
- type: String,
- default: ''
- },
- title: {
- type: String,
- default: ''
- },
- width: {
- type: String,
- default: '600px'
- },
- form: {
- type: Boolean,
- default: true
- },
- action: {
- type: Boolean,
- default: true
- },
- fullscreen: {
- type: Boolean,
- default: false
- },
- closeOnClickModal: {
- type: Boolean,
- default: false
- }
- },
- computed: {
- show () {
- if (this.form) {
- return this.showForm
- } else {
- return true
- }
- }
- },
- data () {
- return {
- loading: false,
- dialogVisible: this.visible,
- id: 'dialog_' + new Date().getTime(),
- showForm: false,
- scrollbarWidth: '6px'
- }
- },
- methods: {
- close () {
- this.dialogVisible = false
- },
- submit () {
- this.loading = true
- this.$emit('on-submit')
- },
- end () {
- this.loading = false
- }
- },
- mounted () {
- if (navigator.userAgent.indexOf("Firefox") !== -1) {
- // 当前浏览器是火狐浏览器
- this.scrollbarWidth = '17px'
- }
- if (navigator.userAgent.includes('Macintosh')) {
- // 当前操作系统为 macOS
- this.scrollbarWidth = '0px'
- }
- },
- watch: {
- dialogVisible (val) {
- if (!val) {
- this.loading = false
- this.$emit('on-close')
- setTimeout(() => {
- this.showForm = false
- }, 300)
- } else {
- this.showForm = true
- }
- },
- visible (val) {
- this.dialogVisible = val
- }
- }
- }
- </script>
- <style lang="scss">
- .cus-dialog-container{
- .el-scrollbar{
- .el-scrollbar__wrap{
- height: calc(100% + var(--scrollbarWidth));
- width: calc(100% + var(--scrollbarWidth));
- }
- }
- > .el-dialog > .el-dialog__header{
- background: rgb(230, 239, 245);
- padding: 10px;
- .el-dialog__headerbtn{
- top:10px;
- right: 10px;
- font-size: 20px;
- }
- }
- &.notitle{
- .el-dialog__header{
- padding: 0;
- }
- }
- .el-dialog--center .el-dialog__body{
- padding: 20px;
- text-align: left;
- }
- .el-dialog__footer{
- margin: 0 20px;
- // border-top: 1px dashed #ccc;
- padding: 15px 0 16px;
- text-align: center;
- position: relative;
- .dialog-footer{
- display: block;
- .circular{
- display: inline-block;
- vertical-align: middle;
- margin-right: 5px;
- width: 24px;
- height: 24px;
- }
- .el-loading-text{
- display: inline-block;
- vertical-align: middle;
- }
- .el-loading-spinner{
- margin-top: -12px;
- }
- }
- }
- }
- @media screen and (max-width: 768px) {
- .cus-dialog-container{
- .el-dialog{
- width: 100% !important;
- }
- }
- }
- </style>
|