Blame view

src/components/spin/spin.js 1.84 KB
297648f1   梁灏   fixed #1063
1
2
3
  import Vue from 'vue';
  import Spin from './spin.vue';
  
7bafe9d9   梁灏   fixes #4453 #4480...
4
5
6
7
8
9
10
11
12
  import { transferIndex, transferIncrease } from '../../utils/transfer-queue';
  
  function handleGetIndex() {
      transferIncrease();
      return transferIndex;
  }
  
  let tIndex = handleGetIndex();
  
297648f1   梁灏   fixed #1063
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  Spin.newInstance = properties => {
      const _props = properties || {};
  
      const Instance = new Vue({
          data: Object.assign({}, _props, {
  
          }),
          render (h) {
              let vnode = '';
              if (this.render) {
                  vnode = h(Spin, {
                      props: {
                          fix: true,
                          fullscreen: true
                      }
                  }, [this.render(h)]);
              } else {
                  vnode = h(Spin, {
                      props: {
                          size: 'large',
                          fix: true,
                          fullscreen: true
                      }
                  });
              }
              return h('div', {
7bafe9d9   梁灏   fixes #4453 #4480...
39
40
41
42
                  'class': 'ivu-spin-fullscreen ivu-spin-fullscreen-wrapper',
                  'style': {
                      'z-index': 2010 + tIndex
                  }
297648f1   梁灏   fixed #1063
43
44
45
46
47
48
49
50
51
52
53
              }, [vnode]);
          }
      });
  
      const component = Instance.$mount();
      document.body.appendChild(component.$el);
      const spin = Instance.$children[0];
  
      return {
          show () {
              spin.visible = true;
7bafe9d9   梁灏   fixes #4453 #4480...
54
              tIndex = handleGetIndex();
297648f1   梁灏   fixed #1063
55
56
57
58
59
          },
          remove (cb) {
              spin.visible = false;
              setTimeout(function() {
                  spin.$parent.$destroy();
c43d1784   Carlos Alonso Turner Benites   fix: calling Spin...
60
61
62
                  if (document.getElementsByClassName('ivu-spin-fullscreen')[0] !== undefined) {
                      document.body.removeChild(document.getElementsByClassName('ivu-spin-fullscreen')[0]);
                  }
297648f1   梁灏   fixed #1063
63
64
65
66
67
68
69
                  cb();
              }, 500);
          },
          component: spin
      };
  };
  
c43d1784   Carlos Alonso Turner Benites   fix: calling Spin...
70
  export default Spin;