Blame view

src/components/table/table-tr.vue 1.55 KB
e40c5352   Aresn   fixed #1195
1
  <template>
7f035c37   Aresn   change api name
2
3
      <tr :class="rowClasses(row._index)" :draggable="draggable" @dragstart="onDrag($event,row._index)" @drop="onDrop($event,row._index)" @dragover="allowDrop($event)" v-if="draggable"><slot></slot></tr>
      <tr :class="rowClasses(row._index)" v-else><slot></slot></tr>
e40c5352   Aresn   fixed #1195
4
5
6
7
8
  </template>
  <script>
      export default {
          props: {
              row: Object,
7e8e6ef8   forfire   add dragdrop for tr
9
              prefixCls: String,
7f035c37   Aresn   change api name
10
              draggable: Boolean
e40c5352   Aresn   fixed #1195
11
12
13
14
15
16
17
          },
          computed: {
              objData () {
                  return this.$parent.objData;
              }
          },
          methods: {
958faf1d   梁灏   release 3.3.3
18
19
              onDrag (e,index) {
                  e.dataTransfer.setData('index',index);
7e8e6ef8   forfire   add dragdrop for tr
20
              },
7f035c37   Aresn   change api name
21
              onDrop (e,index) {
958faf1d   梁灏   release 3.3.3
22
                  const dragIndex = e.dataTransfer.getData('index');
7e8e6ef8   forfire   add dragdrop for tr
23
24
25
                  this.$parent.$parent.dragAndDrop(dragIndex,index);
                  e.preventDefault();
              },
7f035c37   Aresn   change api name
26
              allowDrop (e) {
7e8e6ef8   forfire   add dragdrop for tr
27
28
                  e.preventDefault();
              },
e40c5352   Aresn   fixed #1195
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
              rowClasses (_index) {
                  return [
                      `${this.prefixCls}-row`,
                      this.rowClsName(_index),
                      {
                          [`${this.prefixCls}-row-highlight`]: this.objData[_index] && this.objData[_index]._isHighlight,
                          [`${this.prefixCls}-row-hover`]: this.objData[_index] && this.objData[_index]._isHover
                      }
                  ];
              },
              rowClsName (_index) {
                  return this.$parent.$parent.rowClassName(this.objData[_index], _index);
              },
          }
      };
7f035c37   Aresn   change api name
44
  </script>