Blame view

src/components/cell/cell.vue 3.93 KB
59a3b893   梁灏   add Cell componen...
1
  <template>
4258a559   梁灏   update
2
      <div :class="classes">
5d6bf568   梁灏   update Cell
3
4
5
6
7
8
9
10
          <a
              v-if="to"
              :href="linkUrl"
              :target="target"
              class="ivu-cell-link"
              @click.exact="handleClickItem($event, false)"
              @click.ctrl="handleClickItem($event, true)"
              @click.meta="handleClickItem($event, true)">
da76a284   梁灏   update Cell
11
12
              <CellItem :title="title" :label="label" :extra="extra">
                  <slot name="icon" slot="icon"></slot>
4258a559   梁灏   update
13
                  <slot slot="default"></slot>
da76a284   梁灏   update Cell
14
                  <slot name="extra" slot="extra"></slot>
4258a559   梁灏   update
15
                  <slot name="label" slot="label"></slot>
da76a284   梁灏   update Cell
16
17
              </CellItem>
          </a>
9c529885   梁灏   Cell component ad...
18
          <div class="ivu-cell-link" v-else @click="handleClickItem">
da76a284   梁灏   update Cell
19
20
              <CellItem :title="title" :label="label" :extra="extra">
                  <slot name="icon" slot="icon"></slot>
4258a559   梁灏   update
21
                  <slot slot="default"></slot>
da76a284   梁灏   update Cell
22
                  <slot name="extra" slot="extra"></slot>
4258a559   梁灏   update
23
                  <slot name="label" slot="label"></slot>
da76a284   梁灏   update Cell
24
25
26
27
              </CellItem>
          </div>
          <div class="ivu-cell-arrow" v-if="to">
              <slot name="arrow">
2ef1b05f   梁灏   Cell add globl se...
28
                  <Icon :type="arrowType" :custom="customArrowType" :size="arrowSize" />
da76a284   梁灏   update Cell
29
30
31
              </slot>
          </div>
      </div>
59a3b893   梁灏   add Cell componen...
32
33
  </template>
  <script>
da76a284   梁灏   update Cell
34
35
      import CellItem from './cell-item.vue';
      import Icon from '../icon/icon.vue';
e77474de   梁灏   update
36
      import mixinsLink from '../../mixins/link';
da76a284   梁灏   update Cell
37
38
39
  
      const prefixCls = 'ivu-cell';
  
59a3b893   梁灏   add Cell componen...
40
      export default {
da76a284   梁灏   update Cell
41
          name: 'Cell',
9c529885   梁灏   Cell component ad...
42
          inject: ['cellGroup'],
e77474de   梁灏   update
43
          mixins: [ mixinsLink ],
da76a284   梁灏   update Cell
44
          components: { CellItem, Icon },
59a3b893   梁灏   add Cell componen...
45
          props: {
da76a284   梁灏   update Cell
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
              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
68
              }
59a3b893   梁灏   add Cell componen...
69
          },
da76a284   梁灏   update Cell
70
71
72
          data () {
              return {
                  prefixCls: prefixCls
77376451   梁灏   fixed #3568
73
              };
da76a284   梁灏   update Cell
74
75
76
77
78
79
80
81
82
83
84
          },
          computed: {
              classes () {
                  return [
                      `${prefixCls}`,
                      {
                          [`${prefixCls}-disabled`]: this.disabled,
                          [`${prefixCls}-selected`]: this.selected,
                          [`${prefixCls}-with-link`]: this.to
                      }
                  ];
e77474de   梁灏   update
85
              },
2ef1b05f   梁灏   Cell add globl se...
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
              // 3.4.0, global setting customArrow 有值时,arrow 赋值空
              arrowType () {
                  let type = 'ios-arrow-forward';
  
                  if (this.$IVIEW) {
                      if (this.$IVIEW.cell.customArrow) {
                          type = '';
                      } else if (this.$IVIEW.cell.arrow) {
                          type = this.$IVIEW.cell.arrow;
                      }
                  }
                  return type;
              },
              // 3.4.0, global setting
              customArrowType () {
                  let type = '';
  
                  if (this.$IVIEW) {
                      if (this.$IVIEW.cell.customArrow) {
                          type = this.$IVIEW.cell.customArrow;
                      }
                  }
                  return type;
              },
              // 3.4.0, global setting
              arrowSize () {
                  let size = '';
  
                  if (this.$IVIEW) {
                      if (this.$IVIEW.cell.arrowSize) {
                          size = this.$IVIEW.cell.arrowSize;
                      }
                  }
                  return size;
              }
da76a284   梁灏   update Cell
121
          },
9c529885   梁灏   Cell component ad...
122
          methods: {
5d6bf568   梁灏   update Cell
123
              handleClickItem (event, new_window) {
9c529885   梁灏   Cell component ad...
124
                  this.cellGroup.handleClick(this.name);
b216f33c   梁灏   update Cell compo...
125
  
5d6bf568   梁灏   update Cell
126
                  this.handleCheckClick(event, new_window);
9c529885   梁灏   Cell component ad...
127
128
              }
          }
77376451   梁灏   fixed #3568
129
      };
59a3b893   梁灏   add Cell componen...
130
  </script>