lius
2023-06-08 c66a22e4b6bb02667a5000f2e04aeb4ef5ae44c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<template>
  <a-dropdown :trigger="['click']">
    <div class="j-vxe-ds-icons">
      <a-icon type="align-left"/>
      <a-icon type="align-right"/>
    </div>
 
    <!--    <div class="j-vxe-ds-btns">-->
    <!--      <a-button icon="caret-up" size="small" :disabled="disabledMoveUp" @click="handleRowMoveUp"/>-->
    <!--      <a-button icon="caret-down" size="small" :disabled="disabledMoveDown" @click="handleRowMoveDown"/>-->
    <!--    </div>-->
 
    <a-menu slot="overlay">
      <a-menu-item key="0" :disabled="disabledMoveUp" @click="handleRowMoveUp">向上移</a-menu-item>
      <a-menu-item key="1" :disabled="disabledMoveDown" @click="handleRowMoveDown">向下移</a-menu-item>
      <a-menu-divider/>
      <a-menu-item key="3" @click="handleRowInsertDown">插入一行</a-menu-item>
    </a-menu>
  </a-dropdown>
</template>
 
<script>
  import JVxeCellMixins from '@/components/jeecg/JVxeTable/mixins/JVxeCellMixins'
 
  export default {
    name: 'JVxeDragSortCell',
    mixins: [JVxeCellMixins],
    computed: {
      // 排序结果保存字段
      dragSortKey() {
        return this.renderOptions.dragSortKey || 'orderNum'
      },
      disabledMoveUp() {
        return this.rowIndex === 0
      },
      disabledMoveDown() {
        return this.rowIndex === (this.fullDataLength - 1)
      },
    },
    methods: {
      /** 向上移 */
      handleRowMoveUp(event) {
        // event.target.blur()
        if (!this.disabledMoveUp) {
          this.trigger('rowMoveUp', this.rowIndex)
        }
      },
      /** 向下移 */
      handleRowMoveDown(event) {
        // event.target.blur()
        if (!this.disabledMoveDown) {
          this.trigger('rowMoveDown', this.rowIndex)
        }
      },
      /** 插入一行 */
      handleRowInsertDown() {
        this.trigger('rowInsertDown', this.rowIndex)
      },
    },
    // 【组件增强】注释详见:JVxeCellMixins.js
    enhanced: {
      // 【功能开关】
      switches: {
        editRender: false
      },
    },
  }
</script>
 
<style lang="less">
  .j-vxe-ds-icons {
    position: relative;
    /*cursor: move;*/
    cursor: pointer;
    width: 14px;
    height: 100%;
    display: inline-block;
 
    .anticon-align-left,
    .anticon-align-right {
      position: absolute;
      top: 30%;
    }
 
    .anticon-align-left {
      left: 0;
    }
 
    .anticon-align-right {
      right: 0;
    }
  }
 
  .j-vxe-ds-btns {
    position: relative;
    cursor: pointer;
    width: 24px;
    height: 100%;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-content: center;
 
    .ant-btn {
      border: none;
 
      z-index: 0;
      padding: 0;
      width: 100%;
      /*height: 30%;*/
      height: 40%;
      display: block;
      border-radius: 0;
 
      &:hover {
        z-index: 1;
        /*  height: 40%;*/
 
        /*  & .anticon-caret-up,*/
        /*  & .anticon-caret-down {*/
        /*    top: 2px;*/
        /*  }*/
      }
 
      &:last-child {
        margin-top: -1px;
      }
 
      & .anticon-caret-up,
      & .anticon-caret-down {
        vertical-align: top;
        position: relative;
        top: 0;
        transition: top 0.3s;
      }
    }
  }
</style>