Blame view

src/components/steps/step.vue 3.21 KB
7fa943eb   梁灏   init
1
  <template>
45b672ca   梁灏   add Steps UI
2
      <div :class="wrapClasses" :style="styles">
d6342fe1   jingsam   fixed ie bug
3
4
5
          <div :class="[prefixCls + '-tail']"><i></i></div>
          <div :class="[prefixCls + '-head']">
              <div :class="[prefixCls + '-head-inner']">
b450b555   huixisheng   update Steps
6
                  <span v-if="!icon && currentStatus != 'finish' && currentStatus != 'error'">{{ stepNumber }}</span>
7fa943eb   梁灏   init
7
8
9
                  <span v-else :class="iconClasses"></span>
              </div>
          </div>
d6342fe1   jingsam   fixed ie bug
10
11
          <div :class="[prefixCls + '-main']">
              <div :class="[prefixCls + '-title']">{{ title }}</div>
79c58804   Yang   给Steps组件增加slot支持
12
13
14
              <slot>
                  <div v-if="content" :class="[prefixCls + '-content']">{{ content }}</div>
              </slot>
7fa943eb   梁灏   init
15
16
17
18
          </div>
      </div>
  </template>
  <script>
d4cd421c   梁灏   update Steps
19
      import Emitter from '../../mixins/emitter';
7fa943eb   梁灏   init
20
21
22
23
24
25
      import { oneOf } from '../../utils/assist';
  
      const prefixCls = 'ivu-steps';
      const iconPrefixCls = 'ivu-icon';
  
      export default {
34ee7b4a   梁灏   support Tree & ad...
26
          name: 'Step',
d4cd421c   梁灏   update Steps
27
          mixins: [ Emitter ],
7fa943eb   梁灏   init
28
          props: {
b450b555   huixisheng   update Steps
29
30
31
32
33
              status: {
                  validator (value) {
                      return oneOf(value, ['wait', 'process', 'finish', 'error']);
                  }
              },
7fa943eb   梁灏   init
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
              title: {
                  type: String,
                  default: ''
              },
              content: {
                  type: String
              },
              icon: {
                  type: String
              }
          },
          data () {
              return {
                  prefixCls: prefixCls,
                  stepNumber: '',
45b672ca   梁灏   add Steps UI
49
                  nextError: false,
bd596e7a   huixisheng   support Steps
50
                  total: 1,
b450b555   huixisheng   update Steps
51
                  currentStatus: ''
b0893113   jingsam   :art: add eslint
52
              };
7fa943eb   梁灏   init
53
          },
7fa943eb   梁灏   init
54
55
56
57
          computed: {
              wrapClasses () {
                  return [
                      `${prefixCls}-item`,
b450b555   huixisheng   update Steps
58
                      `${prefixCls}-status-${this.currentStatus}`,
7fa943eb   梁灏   init
59
60
61
62
                      {
                          [`${prefixCls}-custom`]: !!this.icon,
                          [`${prefixCls}-next-error`]: this.nextError
                      }
b0893113   jingsam   :art: add eslint
63
                  ];
7fa943eb   梁灏   init
64
65
66
67
              },
              iconClasses () {
                  let icon = '';
  
b0893113   jingsam   :art: add eslint
68
                  if (this.icon) {
7fa943eb   梁灏   init
69
70
                      icon = this.icon;
                  } else {
b450b555   huixisheng   update Steps
71
                      if (this.currentStatus == 'finish') {
185df4fa   梁灏   update Steps Icon
72
                          icon = 'ios-checkmark';
b450b555   huixisheng   update Steps
73
                      } else if (this.currentStatus == 'error') {
185df4fa   梁灏   update Steps Icon
74
                          icon = 'ios-close';
7fa943eb   梁灏   init
75
76
77
78
79
80
81
82
83
                      }
                  }
  
                  return [
                      `${prefixCls}-icon`,
                      `${iconPrefixCls}`,
                      {
                          [`${iconPrefixCls}-${icon}`]: icon != ''
                      }
b0893113   jingsam   :art: add eslint
84
                  ];
45b672ca   梁灏   add Steps UI
85
86
87
88
              },
              styles () {
                  return {
                      width: `${1/this.total*100}%`
b0893113   jingsam   :art: add eslint
89
                  };
7fa943eb   梁灏   init
90
91
92
              }
          },
          watch: {
b450b555   huixisheng   update Steps
93
94
95
              status (val) {
                  this.currentStatus = val;
                  if (this.currentStatus == 'error') {
7fa943eb   梁灏   init
96
97
98
                      this.$parent.setNextError();
                  }
              }
d4cd421c   梁灏   update Steps
99
100
101
102
103
104
105
106
107
          },
          created () {
              this.currentStatus = this.status;
          },
          mounted () {
              this.dispatch('Steps', 'append');
          },
          beforeDestroy () {
              this.dispatch('Steps', 'remove');
7fa943eb   梁灏   init
108
          }
b0893113   jingsam   :art: add eslint
109
      };
d6342fe1   jingsam   fixed ie bug
110
  </script>