Blame view

src/components/cell/cell.vue 2.57 KB
59a3b893   梁灏   add Cell componen...
1
  <template>
4258a559   梁灏   update
2
      <div :class="classes">
b216f33c   梁灏   update Cell compo...
3
          <a v-if="to" :href="linkUrl" :target="target" class="ivu-cell-link" @click="handleClickItem">
da76a284   梁灏   update Cell
4
5
              <CellItem :title="title" :label="label" :extra="extra">
                  <slot name="icon" slot="icon"></slot>
4258a559   梁灏   update
6
                  <slot slot="default"></slot>
da76a284   梁灏   update Cell
7
                  <slot name="extra" slot="extra"></slot>
4258a559   梁灏   update
8
                  <slot name="label" slot="label"></slot>
da76a284   梁灏   update Cell
9
10
              </CellItem>
          </a>
9c529885   梁灏   Cell component ad...
11
          <div class="ivu-cell-link" v-else @click="handleClickItem">
da76a284   梁灏   update Cell
12
13
              <CellItem :title="title" :label="label" :extra="extra">
                  <slot name="icon" slot="icon"></slot>
4258a559   梁灏   update
14
                  <slot slot="default"></slot>
da76a284   梁灏   update Cell
15
                  <slot name="extra" slot="extra"></slot>
4258a559   梁灏   update
16
                  <slot name="label" slot="label"></slot>
da76a284   梁灏   update Cell
17
18
19
20
              </CellItem>
          </div>
          <div class="ivu-cell-arrow" v-if="to">
              <slot name="arrow">
e94e7643   梁灏   update Cell icons
21
                  <Icon type="ios-arrow-forward"></Icon>
da76a284   梁灏   update Cell
22
23
24
              </slot>
          </div>
      </div>
59a3b893   梁灏   add Cell componen...
25
26
  </template>
  <script>
da76a284   梁灏   update Cell
27
28
      import CellItem from './cell-item.vue';
      import Icon from '../icon/icon.vue';
e77474de   梁灏   update
29
      import mixinsLink from '../../mixins/link';
da76a284   梁灏   update Cell
30
31
32
  
      const prefixCls = 'ivu-cell';
  
59a3b893   梁灏   add Cell componen...
33
      export default {
da76a284   梁灏   update Cell
34
          name: 'Cell',
9c529885   梁灏   Cell component ad...
35
          inject: ['cellGroup'],
e77474de   梁灏   update
36
          mixins: [ mixinsLink ],
da76a284   梁灏   update Cell
37
          components: { CellItem, Icon },
59a3b893   梁灏   add Cell componen...
38
          props: {
da76a284   梁灏   update Cell
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
              name: {
                  type: [String, Number]
              },
              title: {
                  type: String,
                  default: ''
              },
              label: {
                  type: String,
                  default: ''
              },
              extra: {
                  type: String,
                  default: ''
              },
              disabled: {
                  type: Boolean,
                  default: false
              },
              selected: {
                  type: Boolean,
                  default: false
da76a284   梁灏   update Cell
61
              }
59a3b893   梁灏   add Cell componen...
62
          },
da76a284   梁灏   update Cell
63
64
65
          data () {
              return {
                  prefixCls: prefixCls
77376451   梁灏   fixed #3568
66
              };
da76a284   梁灏   update Cell
67
68
69
70
71
72
73
74
75
76
77
          },
          computed: {
              classes () {
                  return [
                      `${prefixCls}`,
                      {
                          [`${prefixCls}-disabled`]: this.disabled,
                          [`${prefixCls}-selected`]: this.selected,
                          [`${prefixCls}-with-link`]: this.to
                      }
                  ];
e77474de   梁灏   update
78
              },
da76a284   梁灏   update Cell
79
          },
9c529885   梁灏   Cell component ad...
80
          methods: {
b216f33c   梁灏   update Cell compo...
81
              handleClickItem (event) {
9c529885   梁灏   Cell component ad...
82
                  this.cellGroup.handleClick(this.name);
b216f33c   梁灏   update Cell compo...
83
84
  
                  this.handleCheckClick(event);
9c529885   梁灏   Cell component ad...
85
86
              }
          }
77376451   梁灏   fixed #3568
87
      };
59a3b893   梁灏   add Cell componen...
88
  </script>