Blame view

src/components/steps/step.vue 2.92 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
12
          <div :class="[prefixCls + '-main']">
              <div :class="[prefixCls + '-title']">{{ title }}</div>
              <div v-if="content" :class="[prefixCls + '-content']">{{ content }}</div>
7fa943eb   梁灏   init
13
14
15
16
17
18
19
20
21
22
23
          </div>
      </div>
  </template>
  <script>
      import { oneOf } from '../../utils/assist';
  
      const prefixCls = 'ivu-steps';
      const iconPrefixCls = 'ivu-icon';
  
      export default {
          props: {
b450b555   huixisheng   update Steps
24
25
26
27
28
              status: {
                  validator (value) {
                      return oneOf(value, ['wait', 'process', 'finish', 'error']);
                  }
              },
7fa943eb   梁灏   init
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
              title: {
                  type: String,
                  default: ''
              },
              content: {
                  type: String
              },
              icon: {
                  type: String
              }
          },
          data () {
              return {
                  prefixCls: prefixCls,
                  stepNumber: '',
45b672ca   梁灏   add Steps UI
44
                  nextError: false,
bd596e7a   huixisheng   support Steps
45
                  total: 1,
b450b555   huixisheng   update Steps
46
                  currentStatus: ''
b0893113   jingsam   :art: add eslint
47
              };
7fa943eb   梁灏   init
48
          },
b450b555   huixisheng   update Steps
49
50
51
          created () {
              this.currentStatus = this.status;
          },
7fa943eb   梁灏   init
52
53
54
55
          computed: {
              wrapClasses () {
                  return [
                      `${prefixCls}-item`,
b450b555   huixisheng   update Steps
56
                      `${prefixCls}-status-${this.currentStatus}`,
7fa943eb   梁灏   init
57
58
59
60
                      {
                          [`${prefixCls}-custom`]: !!this.icon,
                          [`${prefixCls}-next-error`]: this.nextError
                      }
b0893113   jingsam   :art: add eslint
61
                  ];
7fa943eb   梁灏   init
62
63
64
65
              },
              iconClasses () {
                  let icon = '';
  
b0893113   jingsam   :art: add eslint
66
                  if (this.icon) {
7fa943eb   梁灏   init
67
68
                      icon = this.icon;
                  } else {
b450b555   huixisheng   update Steps
69
                      if (this.currentStatus == 'finish') {
7fa943eb   梁灏   init
70
                          icon = 'ios-checkmark-empty';
b450b555   huixisheng   update Steps
71
                      } else if (this.currentStatus == 'error') {
7fa943eb   梁灏   init
72
73
74
75
76
77
78
79
80
81
                          icon = 'ios-close-empty';
                      }
                  }
  
                  return [
                      `${prefixCls}-icon`,
                      `${iconPrefixCls}`,
                      {
                          [`${iconPrefixCls}-${icon}`]: icon != ''
                      }
b0893113   jingsam   :art: add eslint
82
                  ];
45b672ca   梁灏   add Steps UI
83
84
85
86
              },
              styles () {
                  return {
                      width: `${1/this.total*100}%`
b0893113   jingsam   :art: add eslint
87
                  };
7fa943eb   梁灏   init
88
89
90
              }
          },
          watch: {
b450b555   huixisheng   update Steps
91
92
93
              status (val) {
                  this.currentStatus = val;
                  if (this.currentStatus == 'error') {
7fa943eb   梁灏   init
94
95
96
97
                      this.$parent.setNextError();
                  }
              }
          }
b0893113   jingsam   :art: add eslint
98
      };
d6342fe1   jingsam   fixed ie bug
99
  </script>