派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-04-16 945d71b3bc4b42e28cdca08ce7acf59e45923308
弹框组件
2个文件已删除
2个文件已修改
383 ■■■■ 已修改文件
src/components/layer/src/iframe.vue 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layer/src/layer.js 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layer/src/layer.vue 126 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layer/src/page.vue 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layer/src/iframe.vue
File was deleted
src/components/layer/src/layer.js
@@ -1,27 +1,12 @@
import layerVue from './layer.vue'
const Notification = function (Vue, globalOption = {
  msgtime: 1.5 // msg消失时间
}) {
  const NotificationConstructor = Vue.extend(layerVue)
const Layer = function (Vue) {
  const LayerVueExtend = Vue.extend(layerVue)
  const self = {}
  const defOptions = {
    type: 0, // 0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层),5msg,6prompt
    title: '信息',
    content: '',
    area: 'auto',
    offset: 'auto',
    icon: -1,
    btn: '确定',
    time: 0,
    maxmin: false, // 最大最小化
    shade: true,
    yes: '',
    cancel: '',
    tips: [0, {}], // 支持上右下左四个方向,通过1-4进行方向设定,可以设定tips: [1, '#c00']
    tipsMore: false, // 是否允许多个tips
    shadeClose: true,
    scrollbar: true, // 是否允许浏览器出现滚动条:默认是允许
    resize: false // 是否允许拉伸,默认是不允许
    btn: '确定'
  }
  self.instances = {}
  self.instancesVue = []
@@ -34,17 +19,20 @@
   * @param  {[type]} options [description]
   * @return {[type]}         [description]
   */
  self.open = function (options) {
    options = mergeJson(options, defOptions)
  self.open = function (opt) {
    /* let option = {
      type: 1,
      content: opt.content,
      area: opt.area
    } */
    var options = mergeJson(opt, defOptions)
    const id = `notification_${new Date().getTime()}_${seed++}`
    options.id = id
    options.layer = self
    const instance = new NotificationConstructor({
    options.content.content = Vue.extend(options.content.content)
    const instance = new LayerVueExtend({
      data: options
    })
    if (options.type === 1) {
      options.content.content = Vue.extend(options.content.content)
    }
    instance.id = id
    instance.vm = instance.$mount()
    self.instances[id] = {
@@ -52,6 +40,7 @@
      type: options.type
    }
    document.body.appendChild(instance.vm.$el)
    instance.init()
    self.instancesVue[id] = {
      mask: '',
      main: instance.vm,
@@ -59,28 +48,15 @@
    }
    return id
  }
  /**
   * [description]
   * @param  {[type]} options [description]
   * @return {[type]}         [description]
   */
  self.iframe = function (opt) {
    let option = {
      type: 1,
      content: opt.content,
      area: opt.area
    }
    option = mergeJson(option, opt)
    console.log(option)
    return self.open(option)
  }
  /**
   * 关闭一个弹窗
   * @param  {[type]} id [description]
   * @return {[type]}    [description]
   */
  self.close = function (id) {
    const oElm = document.getElementById(id)
    console.log(id)
    const oElm = document.getElementById(id).parentElement
    if (oElm) {
      document.body.removeChild(oElm)
      delete self.instances[id]
@@ -192,4 +168,4 @@
}
// module.exports = Notification;
export default Notification
export default Layer
src/components/layer/src/layer.vue
@@ -1,46 +1,114 @@
<template lang="html">
    <component :options="this.$data" :is="getActiveName"></component>
<template>
  <div class="public-bounced map-background" v-drag>
    <div class="public-bounced-title panel-title" ref="publicBounced">
      <span>{{title}}</span>
      <i class="el-icon-circle-close" @click="close"></i>
    </div>
    <div class="public-bounced-content" :id="id">
    </div>
  </div>
</template>
<script>
import pzpage from './page.vue'
import pziframe from './iframe.vue'
import helper from './helper/helper.js'
export default {
  data () {
    return {
      id: '',
      type: 0, // 0(alert默认)1(页面层)2(iframe层)3(loading)4(tips层),5(msg),6(prompt)
      title: '信息',
      content: '',
      area: 'auto',
      offset: 'auto',
      icon: -1,
      btn: '确定',
      time: 0,
      shade: true,
      yes: '',
      cancel: ''
      cls: {
        'vl-notify-iframe': true
      },
      id: 'vlip' + new Date().getTime()
    }
  },
  props: {
    options: {
      type: Object,
      default: function () {
        return {}
      }
    }
  },
  computed: {
    getActiveName () {
      const comps = [
        'pzpage',
        'pziframe'
      ]
      return comps[this.$data.type]
    contentStyle () {
      return {
        height: 'calc(100% - 50px)', // parseInt(this.options.area[1]) - 50 + "px",
        minHeight: '20px',
        overflow: 'auto'
      }
    }
  },
  mounted () {},
  methods: {},
  watch: {},
  components: {
    pzpage,
    pziframe
  async mounted () {
    helper.hiddenScrollBar(this.options)
  },
  methods: {
    close () {
      this.layer.close(this.id)
    },
    init () {
      const propsData = helper.deepClone(this.content.content.data) || {}
      propsData.layerid = this.id
      propsData.lydata = this.content.data
      propsData.lyoption = this.options
      const instance = new this.content.content({
        // 具体参数信息,请参考vue源码
        parent: this.content.parent,
        propsData: propsData
      })
      instance.vm = instance.$mount()
      document.getElementById(this.id).appendChild(instance.vm.$el)
    }
  }
}
</script>
<style lang="less">
<style lang="less" scoped>
  .public-bounced {
    z-index: 2000;
    position: absolute;
    top: 35%;
    left: 20%;
  .public-bounced-title {
    cursor: move;
    height: 0.1rem;
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  span {
    color: #f4f7ff;
    margin: 0 15px;
    font-size: 14px;
  }
  i {
    color: #C0C4CC;
    margin: 0 15px;
    font-size: 22px;
    cursor: pointer;
  }
  i:hover {
    color: #00fff6;
  }
  }
  .public-bounced-content {
    padding: 0.1rem;
    display: flex;
  //align-items: center;
  //justify-content: space-around;
  .public-bounced-content-left {
  //width: 4.8rem;
  }
  .public-bounced-content-right {
  //width: 3rem;
    margin-left: 0.1rem;
  }
  }
  }
</style>
src/components/layer/src/page.vue
File was deleted