当前位置:   article > 正文

Ant Design of Vue实现穿梭框可左右穿梭上下排序_vue穿梭框实现上下移动

vue穿梭框实现上下移动

在这里插入图片描述

<template>
  <a-card size="small" :bordered="false">
    <a-row>
      <a-button type="primary" @click="showModal">Primary</a-button>
    </a-row>
	<!--  -->
	<a-modal v-model="visible" title="Title" on-ok="handleOk" width="80%">
      <template slot="footer">
        <a-button key="back" @click="handleCancel">
          Return
        </a-button>
        <a-button key="submit" type="primary" :loading="loading" @click="handleOk">
          Submit
        </a-button>
      </template>
       <a-row type="flex">
      <a-col flex="auto">
        <a-table
        :customRow="rowClickLeft"
          :columns="leftcolumns"
          :data-source="leftdata"
          :rowKey="(record,index)=>index"
          size="small"
          :pagination="false"
          bordered
        />
      </a-col>
      <a-col flex="100px">
        <div class="transfer-all-btn">
          <a-button type="primary" :disabled="disabledright" @click="transferRight">
            <a-icon type="right" />
          </a-button>

          <a-button type="primary" :disabled="disabledleft" @click="transferLeft">
            <a-icon type="left" />
          </a-button>

          <a-button type="primary" :disabled="disabledup" @click="upLayer">
            <a-icon type="up" />
          </a-button>

          <a-button type="primary" :disabled="disableddown" @click="downLayer">
            <a-icon type="down" />
          </a-button>
        </div>
      </a-col>
      <a-col flex="auto">
        <a-table
        :customRow="rowClick"
          :columns="rightcolumns"
          :data-source="rightdata"
          :rowKey="(record,index)=>index"
          size="small"
          :pagination="false"
          bordered 
          style="height: 600px;overflow-y: scroll;"
        />
      </a-col>
    </a-row>
    </a-modal>
   
  </a-card>
</template>

<script>
export default {
  name: "newApplication",
  components: {},
  data() {
    return {
      currRowName:null,
      currRowNameFlag:null,//左侧
      selectIndex:null,
		disabledright: true,
		disabledleft: true,
		disabledup: true,
		disableddown: true,
		loading: false,
        visible: false,
      leftcolumns: [
        {
          title: "名称",
          dataIndex: "name",
        },
        {
          title: "Description",
          dataIndex: "description",
        },
      ],
      leftdata: [],
      rightcolumns: [
        {
          title: "名称",
          dataIndex: "name",
        },
        {
          title: "Description",
          dataIndex: "description",
        },
      ],
      rightdata: [
        { name: "PRODUCT", description: "PRODUCT" },
        { name: "TECHNOLOGY", description: "TECHNOLOGY" },
        { name: "FABID", description: "FABID" },
        { name: "MEASUREMENTEQUIPMENT", description: "MEASUREMENTEQUIPMENT" },
        { name: "PROCESSEQUIPMENT", description: "PROCESSEQUIPMENT" },
        { name: "TOTALSITECOUNT", description: "TOTALSITECOUNT" },
        { name: "PPID", description: "PPID" },
        { name: "AREA", description: "AREA" },
        { name: "MEASUREMENTEDCPLAN", description: "	MEASUREMENTEDCPLAN" },
        {
          name: "MEASUREMENTEQUIPMENTTYPE",
          description: "	MEASUREMENTEQUIPMENTTYPE",
        },
        { name: "MEASUREMENTRECIPE", description: "	MEASUREMENTRECIPE" },
        { name: "PROCESSEQUIPMENTTYPE", description: "	PROCESSEQUIPMENTTYPE" },
        { name: "PROCESSCHAMBER", description: "	PROCESSCHAMBER" },
        { name: "PROCESSTIME", description: "	PROCESSTIME" },
        { name: "RUNTYPE", description: "	RUNTYPE" },
        { name: "RUNCARDID", description: "	RUNCARDID" },
        { name: "PILOTFLAG", description: "	PILOTFLAG" },
        { name: "CUSTOMER", description: "	CUSTOMER" },
        { name: "PDCFLAG", description: "	PDCFLAG" },
        { name: "RETICLE", description: "	RETICLE" },
        { name: "LOTID", description: "	LOTID" },
        { name: "WAFERID", description: "	WAFERID" },
        { name: "SITEID", description: "	SITEID" },
        { name: "STEPID", description: "	STEPID" },
        { name: "ROUTEID", description: "	ROUTEID" },
        { name: "PLANID", description: "	PLANID" },
        { name: "OPERATORID", description: "	OPERATORID" },
        { name: "ISEXCLUDE", description: "	ISEXCLUDE" },
        { name: "BATCHID", description: "	BATCHID" },
        { name: "STEPSEQ", description: "	STEPSEQ" },
        { name: "STAGE", description: "	STAGE" },
        { name: "MEASUREMENTROUTE", description: "	MEASUREMENTROUTE" },
        { name: "MEASUREMENTSTEP", description: "	MEASUREMENTSTEP" },
        { name: "MEASUREMENTPLAN", description: "	MEASUREMENTPLAN	" },
        { name: "MEASUREMENTSTEPSEQ", description: "	MEASUREMENTSTEPSEQ" },
        { name: "MEASUREMENTSTAGE", description: "	MEASUREMENTSTAGE" },
        { name: "MEASUREMENTTIME", description: "	MEASUREMENTTIME" },
        { name: "X", description: "	X" },
        { name: "Y", description: "	Y" },
        { name: "WAFERTYPE", description: "	WAFERTYPE" },
      ],
    };
  },
  computed: {},
  watch: {},
  mounted(){

  },
  methods: {
    upLayer(){
        let that =this;
        let index = that.selectIndex; 
              if (index == 0) {
                //处于顶端,不能继续上移
                that.disabledup =true;
              } else {
                that.disabledup =false;
                let upDate = that.leftdata[index - 1];
                that.leftdata.splice(index - 1, 1);
                that.leftdata.splice(index, 0, upDate);
                that.selectIndex = index - 1;
                if (that.selectIndex == 0) {
                  //处于顶端,不能继续上移
                  that.disabledup =true;
                  that.disableddown = false;
                }
              }
    },
    downLayer(){
        let that =this;
        let index = that.selectIndex; 
              if (index + 1 === that.leftdata.length) {
                //处于末端端,不能继续下移
                that.disableddown = true;
              } else {
                that.disableddown = false;
                let downDate = that.leftdata[index + 1];
                that.leftdata.splice(index + 1, 1);
                that.leftdata.splice(index, 0, downDate);
                that.selectIndex = index + 1;
                console.log(that.selectIndex , that.leftdata.length)
                if (that.selectIndex == that.leftdata.length - 1) {
                  //处于顶端,不能继续上移
                  that.disableddown = true;
                  that.disabledup = false;
                }
              }
    },
    transferRight(){        
      this.rightdata.push({ name: this.currRowNameFlag, description: this.currRowNameFlag })
      const leftdata = [...this.leftdata];
      this.leftdata = leftdata.filter(item => item.name !== this.currRowNameFlag);
      
      this.disabledright = true;
    },
    transferLeft(){
      this.leftdata.push({ name: this.currRowName, description: this.currRowName })
      const rightdata = [...this.rightdata];
      this.rightdata = rightdata.filter(item => item.name !== this.currRowName);
      this.disabledleft = true;
      this.disabledup =true;
      this.disableddown = true;
    },
    rowClick(record, index) {
      return {
        style: {
          // 行背景色
          'background-color': record.name === this.currRowName ? '#56c9ff' : 'white'
        },
        on: {
          click: (event) => {
              // 记录当前点击的行标识
              this.currRowName = record.name
              this.disabledleft = false;
              this.disabledright = true;
              this.currRowNameFlag = null;
              this.disabledup =true;
              this.disableddown = true;
          },
        },
      };
    },
    rowClickLeft(record, index) {
      return {
        style: {
          // 行背景色
          'background-color': record.name === this.currRowNameFlag ? '#56c9ff' : 'white'
        },
        on: {
          click: (event) => {
              // 记录当前点击的行标识
              this.currRowNameFlag = record.name;
              this.disabledright = false;
              this.disabledleft = true;
              this.currRowName = null;

              let that =this;
              that.selectIndex = index;
              if (index == 0) {
                //处于顶端,不能继续上移
                that.disabledup =true;
              } else {
                that.disabledup =false;
              }
              if (index + 1 === that.leftdata.length) {
                //处于末端端,不能继续下移
                that.disableddown = true;
              } else {
                that.disableddown = false;
              }
          },
        },
      };
    },
	showModal() {
      this.visible = true;
    },
    handleOk(e) {
      this.loading = true;
      setTimeout(() => {
        this.visible = false;
        this.loading = false;
      }, 3000);
    },
    handleCancel(e) {
      this.visible = false;
    },
  },
  
};
</script>

<style scoped lang="less" scoped>
.transfer-all-btn {
  display: inline-block;
  margin: 0 8px;
  overflow: hidden;
  vertical-align: middle;
}
.transfer-all-btn .ant-btn {
  display: block;
  margin-bottom: 8px;
}
.transfer-all-btn .ant-btn:last-child {
  display: block;
  margin-bottom: 0px;
}
::v-deep .ant-table-body{
    color: #000;
}

::v-deep .ant-table-thead > tr > th{
    padding: 10px 5px !important;
    font-size: 14px !important;
}
::v-deep .ant-table-tbody > tr > td{
    padding: 10px 5px !important;
    font-family: Verdana, Helvetica, Arial, sans-serif !important;
    font-size: 12px !important;
    a{
        color: #0000ff;
    }
}
::v-deep .ant-table-thead > tr > th{
    padding:2px 2px !important;
    font-size: 12px !important;
}
::v-deep .ant-table-tbody > tr > td{
    padding:2px 2px !important;
    font-size: 12px !important;
}
.ant-table-tbody{
    tr{
        ::v-deep td{
            padding:2px 2px !important;
            font-size: 12px !important;
        }
    }
    
}
::v-deep .ant-table-tbody{
        > tr:hover:not(.ant-table-expanded-row) > td,.ant-table-row-hover,.ant-table-row-hover>td{
        background:none !important;
        //这里是将鼠标移入时的背景色取消掉了
        }
      }
</style>

  • 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
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/223949
推荐阅读
相关标签
  

闽ICP备14008679号